summaryrefslogtreecommitdiff
path: root/app/jrnl/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2016-11-12 16:24:34 -0500
committerluxagraf <sng@luxagraf.net>2016-11-12 16:24:34 -0500
commit879fbe18d39fef0021c133f59523d3e050be5c73 (patch)
treedfd9203e66c9df5b82da74bbcf97dc4424e3812e /app/jrnl/models.py
parente1bea8c116e7d70eabecf1346f6428c13dbad3e0 (diff)
added some more image layout styles
Diffstat (limited to 'app/jrnl/models.py')
-rw-r--r--app/jrnl/models.py38
1 files changed, 6 insertions, 32 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py
index 340b718..20d753f 100644
--- a/app/jrnl/models.py
+++ b/app/jrnl/models.py
@@ -20,6 +20,9 @@ from bs4 import BeautifulSoup
from photos.models import PhotoGallery, LuxImage
from locations.models import Location
+from utils.widgets import parse_image
+from utils.widgets import markdown_to_html
+
def get_upload_path(self, filename):
return "images/post-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
@@ -34,36 +37,6 @@ def image_url_replace(s):
return s
-def parse_image(s):
- soup = BeautifulSoup(s.group(), "lxml")
- for img in soup.find_all('img'):
- src = img['src'].split("images/")[1]
- i = LuxImage.objects.get(image__icontains=src)
- cl = img['class']
- caption = False
- exif = False
- cluster_class = None
- if len(cl) > 1:
- css_class = cl[0]
- if css_class == 'cluster':
- cluster_class = cl[1]
- if cl[1] == 'caption':
- caption = True
- if cl[1] == 'exif':
- exif = True
- if 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]
- c = Context({'image': i, 'caption': caption, 'exif': exif, 'cluster_class': cluster_class})
- return render_to_string("lib/img_%s.html" % css_class, c)
-
-
def render_images(s):
s = re.sub('<img(.*)/>', parse_image, s)
return s
@@ -187,10 +160,11 @@ class Entry(models.Model):
if self.pk:
if self.pk >= 167:
md = render_images(self.body_markdown)
+ self.body_html = markdown_to_html(md)
else:
md = image_url_replace(self.body_markdown)
- self.body_html = markdown.markdown(md, extensions=['extra'], safe_mode=False)
- self.dek == markdown.markdown(self.dek, safe_mode=False)
+ self.body_html = markdown.markdown(md, extensions=['extra'], safe_mode=False)
+ self.dek = markdown_to_html(self.dek)
try:
self.location = Location.objects.filter(geometry__contains=self.point).get()
except Location.DoesNotExist: