diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/blog/models.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/blog/models.py b/apps/blog/models.py index 7b01eb7..1026dc0 100644 --- a/apps/blog/models.py +++ b/apps/blog/models.py @@ -19,6 +19,10 @@ def get_upload_path(self, filename): def get_tn_path(self, filename): return "images/post-thumbnail/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) +def image_url_replace(str): + str = str.replace('[[base_url]]', settings.IMAGES_URL) + #print str + return str def markdown_processor(md): processed = markdown.markdown(md, ['footnotes'],safe_mode = False).split('<break>') @@ -111,15 +115,16 @@ class Entry(models.Model): return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date def get_thumbnail_url(self): - image_dir, img = self.thumbnail.url.split('post-thumbs/')[1].split('/') - return '%spost-thumbs/%s/%s' %(settings.IMAGES_URL, image_dir, img) + image_dir, img = self.thumbnail.url.split('post-thumbnail/')[1].split('/') + return '%spost-thumbnail/%s/%s' %(settings.IMAGES_URL, image_dir, img) def get_image_url(self): image_dir, img = self.image.url.split('post-images/')[1].split('/') return '%spost-images/%s/%s' %(settings.IMAGES_URL, image_dir, img) def save(self): - html,lede = markdown_processor(self.body_markdown) + md = image_url_replace(self.body_markdown) + html,lede = markdown_processor(md) self.body_html = html self.lede = lede self.dek == markdown.markdown(self.dek, safe_mode = False) |