From: Leandro Lucarella Date: Tue, 1 Jun 2010 00:19:47 +0000 (-0300) Subject: Make using local links in posts easier X-Git-Url: https://git.llucax.com/software/blitiri.git/commitdiff_plain/7fdcb7965e9fc9b5e7133d72f0bcf64631af43dc Make using local links in posts easier A special string token (##POST_URL##) is recognized in post bodies and replaced with the path to the post (URL-wise) in the rendered HTML. This makes easier to have local resorces and makes links or use them as image sources in posts. --- diff --git a/blitiri.cgi b/blitiri.cgi index 0ffc81a..7816599 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -925,7 +925,10 @@ class Article (object): self.loaded = True def to_html(self): - return rst_to_html(self.raw_content) + dirname = os.path.dirname + post_url = '/'.join(dirname(full_url), data_path, dirname(self.path)) + rst = self.raw_content.replace('##POST_URL##', post_url) + return rst_to_html(rst) def to_vars(self): return {