From d0be352d2338108429969dbb31323925cf0adb47 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 15 Feb 2019 21:07:59 -0600 Subject: fixed a bug in jrnl archives location data --- app/utils/util.py | 98 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 47 deletions(-) (limited to 'app/utils/util.py') diff --git a/app/utils/util.py b/app/utils/util.py index 6d20a54..1779baa 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -53,55 +53,59 @@ def extract_main_image(markdown): def parse_image(s): soup = BeautifulSoup(s.group(), "lxml") for img in soup.find_all('img'): - cl = img['class'] - if cl[0] == 'postpic' or cl[0] == 'postpicright': - s = str(img).replace('[[base_url]]', settings.IMAGES_URL) - return s - else: - try: - image_id = img['id'].split("image-")[1] - i = apps.get_model('photos', 'LuxImage').objects.get(pk=image_id) - caption = False - exif = False - cluster_class = None - is_cluster = False - extra = None - if cl[0] == 'cluster': - css_class = cl[0] - is_cluster = True - cluster_class = cl[1] - try: - if cl[2] == 'caption': + try: + cl = img['class'] + if cl[0] == 'postpic' or cl[0] == 'postpicright': + s = str(img).replace('[[base_url]]', settings.IMAGES_URL) + return s + else: + try: + image_id = img['id'].split("image-")[1] + i = apps.get_model('photos', 'LuxImage').objects.get(pk=image_id) + caption = False + exif = False + cluster_class = None + is_cluster = False + extra = None + if cl[0] == 'cluster': + css_class = cl[0] + is_cluster = True + cluster_class = cl[1] + try: + if cl[2] == 'caption': + caption = True + elif cl[2] == 'exif': + exif = True + else: + extra = cl[2] + + if len(cl) > 3: + if cl[3] == 'exif': + exif = True + except: + pass + elif cl[0] != 'cluster' and len(cl) > 1: + css_class = cl[0] + if cl[1] == 'caption': caption = True - elif cl[2] == 'exif': + if cl[1] == 'exif': exif = True - else: - extra = cl[2] - - if len(cl) > 3: - if cl[3] == 'exif': - exif = True - except: - pass - elif cl[0] != 'cluster' and len(cl) > 1: - css_class = cl[0] - if cl[1] == 'caption': - caption = True - if cl[1] == 'exif': - exif = True - elif cl[0] != 'cluster' and len(cl) > 2: - css_class = cl[0] - if cl[1] == 'caption': - caption = True - if cl[2] == 'exif': - exif = True - print('caption'+str(caption)) - else: - css_class = cl[0] - return render_to_string("lib/img_%s.html" % css_class, {'image': i, 'caption': caption, 'exif': exif, 'is_cluster': is_cluster, 'cluster_class': cluster_class, 'extra': extra}) - except KeyError: - ''' regular inline image, not a luximage ''' - return str(img) + elif cl[0] != 'cluster' and len(cl) > 2: + css_class = cl[0] + if cl[1] == 'caption': + caption = True + if cl[2] == 'exif': + exif = True + print('caption'+str(caption)) + else: + css_class = cl[0] + return render_to_string("lib/img_%s.html" % css_class, {'image': i, 'caption': caption, 'exif': exif, 'is_cluster': is_cluster, 'cluster_class': cluster_class, 'extra': extra}) + except KeyError: + ''' regular inline image, not a luximage ''' + return str(img) + except KeyError: + ''' regular inline image, not a luximage ''' + return str(img) def render_images(s): -- cgit v1.2.3-70-g09d2