]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - phd_pp.py
Adapted to Cheetah 2.0.
[phdru.name/phdru.name.git] / phd_pp.py
index 08b6bf6573a8f8ef29042196809480d7fac226d6..1352b18a61b78d9c3a49faa3a68e5bf491a48406 100644 (file)
--- a/phd_pp.py
+++ b/phd_pp.py
@@ -6,7 +6,7 @@ from Cheetah.Template import Template
 
 urlchars         = r'[A-Za-z0-9/:@_%~#=&\.\-\?\+\$,]+'
 urlendchar       = r'[A-Za-z0-9/]'
-url              = r'["=]?((about|gopher|http|https|ftp|mailto|file):%s)' % \
+url              = r'["=]?((about|file|ftp|gopher|http|https|mailto|news|telnet):%s)' % \
                    (urlchars+urlendchar)
 
 def _url2href(match):
@@ -18,6 +18,8 @@ full_dirs = len(os.getcwd().split('/')) + 1
 
 class phd_pp(Template):
    def __init__(self, *args, **kw):
+      if not hasattr(self, "_fileBaseName"):
+         self._fileDirName, self._fileBaseName = os.path.split(os.path.abspath(self._CHEETAH_src))
       Template.__init__(self, *args, **kw)
       directories = self._fileDirName.split('/')[full_dirs:] # remove directories up to "./files"
       dirs_to_root = len(directories)
@@ -84,3 +86,8 @@ class phd_pp(Template):
       body = parts["body"].encode(encoding)
       parts = [part for part in (title, subtitle, body) if part]
       return "\n\n".join(parts)
+
+   def img_thumbnail_800_1024(self, img_name):
+      return """\
+<img src="%(img_name)s-thumbnail.jpg" alt="%(img_name)s-thumbnail.jpg" /><br />
+<a href="%(img_name)s-800x600.jpg">800x600</a>, <a href="%(img_name)s-1024x800.jpg">1024x800</a>""" % {"img_name": img_name}