]> git.llucax.com Git - software/blitiri.git/commitdiff
Make using local links in posts easier
authorLeandro Lucarella <llucax@gmail.com>
Tue, 1 Jun 2010 00:19:47 +0000 (21:19 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Sun, 8 Aug 2010 05:12:39 +0000 (02:12 -0300)
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.

blitiri.cgi

index 0ffc81a6ac40851dbc1944aa90794c33f413f1bb..781659958e0539d84d361998cfbf0e464df373f0 100755 (executable)
@@ -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 {