]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - phd.py
Fix(blog): Fix tag encoding
[phdru.name/phdru.name.git] / phd.py
diff --git a/phd.py b/phd.py
index 7954e70bc8c8525338df55dd40e85a16a9b7729c..5b90ae6c747ec5ee73578a4095e0b97a657a6c7c 100644 (file)
--- a/phd.py
+++ b/phd.py
@@ -1,10 +1,9 @@
 import os, re, time
-try:
-    from urllib import quote as url_quote
-except ImportError:
-    from urllib.parse import quote as url_quote
+from urllib.parse import quote as url_quote
+
 from Cheetah.Template import Template
 from Cheetah.compat import PY2
+
 from blog_db import load_blog
 
 
@@ -31,7 +30,7 @@ class phd(Template):
         if dirs_to_root:
             root = "../"*dirs_to_root
         else:
-            root = ''
+            root = './'
         self.root = root
         path = '/'.join(directories) + '/' + \
             self._fileBaseName.replace(".tmpl", ".html")
@@ -63,8 +62,6 @@ class phd(Template):
 
         new_paras = []
         for p in paragraphs:
-            if PY2 and not isinstance(p, bytes):
-                p = p.encode('utf-8')
             parts = p.split("\n  ")
             parts[0] = parts[0].strip()
             new_paras.append('\n</p>\n<p>\n'.join(parts))
@@ -95,8 +92,6 @@ class phd(Template):
         for part in (title, subtitle, body):
             if not part:
                 continue
-            if PY2 and not isinstance(part, bytes):
-                part = part.encode('utf-8')
             parts.append(part)
         return "\n\n".join(parts)
 
@@ -111,7 +106,7 @@ class phd(Template):
         # blog post is ['', 'Russian', 'blog', year, month, day, filename]
         if len(dirs) != 7:  # Not a blog post
             return None, None, None, None
-        ymd = tuple(dirs[3:-1])
+        ymd = tuple(dirs[3:6])
         filename = self._fileBaseName
 
         prev_key = prev_blog_post = current_key = current_blog_post = \
@@ -166,13 +161,9 @@ class phd(Template):
             % quote_string(query)
 
     def lurkmoar(self, query):
-        return "https://lurkmore.to/%s" % quote_string(
+        return "http://lurklurk.com/%s" % quote_string(
             query.replace(' ', '_'), ext_safe=',')
 
 
 def quote_string(s, to_encoding="utf-8", ext_safe=''):
-    if isinstance(s, bytes):
-        s = s.decode("utf-8")
-        if PY2:
-            s = s.encode(to_encoding)
     return url_quote(s, '/' + ext_safe)