X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=reindex_blog.py;h=c2a87c603062d38d493ed1bef8031b88413ff47a;hb=af2e193af1a1a95983839beb0fad3d76ab96e4c6;hp=197c1c6956db3b3972f1a41a01791b607a3fc1b8;hpb=de7b8fd4faef91c9cb69be86e18697752ef89fe5;p=phdru.name%2Fphdru.name.git diff --git a/reindex_blog.py b/reindex_blog.py index 197c1c6..c2a87c6 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -2,9 +2,10 @@ # -*- coding: koi8-r -*- __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006-2013 PhiloSoft Design" +__copyright__ = "Copyright (C) 2006-2017 PhiloSoft Design" import sys, os +from Cheetah.compat import string_type blog_data_root = sys.argv[1] blog_root = sys.argv[2] @@ -54,7 +55,7 @@ for dirpath, dirs, files in os.walk(blog_root): lead = template.Lead.decode('utf-8').encode('koi8-r') tags = template.Tag - if isinstance(tags, basestring): + if isinstance(tags, string_type): tags = (tags,) tags = [tag.decode('utf-8').encode('koi8-r') for tag in tags] @@ -264,13 +265,20 @@ def write_template(level, year, month, day, titles, tags=None): new_text.append('''

ðÏ ÇÏÄÁÍ: ''') + + year_counts = {} + for year, month, day, file, title, lead in all_titles: + year_counts[year] = 0 + for year, month, day, file, title, lead in all_titles: + year_counts[year] += 1 + first_year = True for year in years: if first_year: first_year = False else: new_text.append(' - ') - new_text.append('%s' % (year, year)) + new_text.append('%s (%d)' % (year, year, year_counts[str(year)])) new_text.append('''

''') @@ -345,7 +353,29 @@ new_text = ["""\ #def body_html

ôÅÇÉ

-

+

+æÏÒÍÁ ÐÏÉÓËÁ ÐÏÚ×ÏÌÑÅÔ ÉÓËÁÔØ ÓÏÏÂÝÅÎÉÑ × ÂÌÏÇÅ, ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÅ ×ÙÒÁÖÅÎÉÀ. +óÉÎÔÁËÓÉÓ ×ÙÒÁÖÅÎÉÑ:

+ +

+ðÒÉÍÅÒÙ ×ÙÒÁÖÅÎÉÊ: linux - ÐÒÏÉÚÏÊÄ£Ô ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÅ +ÎÁ ÓÔÒÁÎÉÃÕ linux.html; linux&!audio - ÉÓËÁÔØ ÚÁÐÉÓÉ × ËÏÔÏÒÙÈ ÅÓÔØ ÔÅÇ +linux É ÎÅÔ ÔÅÇÁ audio; linux and not audio - ÔÏ ÖÅ ÓÁÍÏÅ. +

+ +
+
+ + +
+
+
"""] @@ -398,7 +428,6 @@ for i, (count, tag, links) in enumerate(all_tags): #def body_html

%s

-

-

#end def $phd_site.respond(self) """) @@ -423,7 +451,6 @@ $phd_site.respond(self) new_text.append("""\
-

#end def $phd_site.respond(self) """) @@ -537,7 +564,6 @@ for item in tuple(reversed(all_titles_tags))[:10]: item.categoryList = tags body = bodies[(year, month, day, file)] body = absolute_urls(body, baseURL + url_path) - body = body.decode('koi8-r').encode('utf-8') item.body = body item.excerpt = get_first_p(body)