X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=phd.py;h=0a6a4e54de9415790155401a26dba3a57c95496f;hb=HEAD;hp=7954e70bc8c8525338df55dd40e85a16a9b7729c;hpb=e1630324d6e4e0c83d68f59bc87a222f89874a2e;p=phdru.name%2Fphdru.name.git diff --git a/phd.py b/phd.py index 7954e70..5b90ae6 100644 --- 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

\n

\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)