X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=reindex_blog.py;h=197c1c6956db3b3972f1a41a01791b607a3fc1b8;hb=28d23cff98bdf9d9ae59b99581b48da5b6bfb3ab;hp=6b7af352f8d582410fec70f4bd6cebfcb57fec15;hpb=91da0eaa057dff4d082d67f9ad655c1d9d7daa75;p=phdru.name%2Fphdru.name.git diff --git a/reindex_blog.py b/reindex_blog.py index 6b7af35..197c1c6 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -1,12 +1,8 @@ #! /usr/bin/env python # -*- coding: koi8-r -*- -__version__ = "$Revision$"[11:-2] -__revision__ = "$Id$"[5:-2] -__date__ = "$Date$"[7:-2] __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006-2011 PhiloSoft Design" - +__copyright__ = "Copyright (C) 2006-2013 PhiloSoft Design" import sys, os @@ -53,13 +49,14 @@ for dirpath, dirs, files in os.walk(blog_root): continue fullpath = os.path.join(dirpath, file) template = Template(file=fullpath) - title_parts = template.Title.split() + title_parts = template.Title.decode('utf-8').encode('koi8-r').split() title = ' '.join(title_parts[6:]) - lead = template.Lead + lead = template.Lead.decode('utf-8').encode('koi8-r') tags = template.Tag if isinstance(tags, basestring): tags = (tags,) + tags = [tag.decode('utf-8').encode('koi8-r') for tag in tags] if title: key = year, month, day = tuple(dirpath[len(blog_root):].split(os.sep)[1:]) @@ -83,7 +80,10 @@ for dirpath, dirs, files in os.walk(blog_root): file = file[:-len("tmpl")] + "html" key = (year, month, day, file) - bodies[key] = template.body() + body = template.body() + if isinstance(body, unicode): + body = body.encode('koi8-r') + bodies[key] = body # Need to save the blog? if blog <> old_blog: @@ -181,7 +181,7 @@ def write_template(level, year, month, day, titles, tags=None): if len(titles) == 1: new_text.append("""\ -#attr $refresh = "0; URL=%s" +#attr $Refresh = "0; URL=%s" """ % titles[0][3]) new_text.append("""\ @@ -484,6 +484,19 @@ class AbsURLHTMLParser(_HTMLParser): def end_a(self): self.accumulator += '' + def start_img(self, attrs): + self.accumulator += '