X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=reindex_blog.py;h=45faac2fdb7908e9b383d6f1c454ca02f500b9ee;hb=8ce78a8642808290ff30125c76b07279f117b998;hp=f554bc32a85323a737036999eb563007ef9f688f;hpb=338269ecdb539e349db2e0237dbefc70906320e2;p=phdru.name%2Fphdru.name.git diff --git a/reindex_blog.py b/reindex_blog.py index f554bc3..45faac2 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -116,7 +116,7 @@ def write_if_changed(filename, new_text): outfile.close() -def write_template(level, year, month, day, titles): +def write_template(level, year, month, day, titles, tags=None): path = [] if level >= 1: path.append(year) @@ -231,12 +231,26 @@ def write_template(level, year, month, day, titles): years = {} for year, month, day, file, title, lead in save_titles: years[year] = True - first_year = True new_text.append('''
-

+

ôÅÇÉ: +''') + first_tag = True + for count, tag, links in all_tags: + if first_tag: + first_tag = False + else: + new_text.append(' - ') + new_text.append("""%s (%d)""" % (tag, tag, count)) + new_text.append(''' +

+''') + + new_text.append(''' +

ðÏ ÇÏÄÁÍ: ''') + first_year = True for year in sorted(years.keys()): if first_year: first_year = False @@ -279,15 +293,16 @@ for year in sorted(years.keys()): tag_links = all_tags[tag] else: tag_links = all_tags[tag] = [] - tag_links.append('/'.join(("..", year, month, day, file))) + tag_links.append(value) write_template(3, year, month, day, day_titles) write_template(2, year, month, day, month_titles) write_template(1, year, month, day, year_titles) -write_template(0, year, month, day, all_titles[-20:]) all_tags = [(len(links), tag, links) for (tag, links) in all_tags.items()] all_tags.sort() +write_template(0, year, month, day, all_titles[-20:], all_tags) + new_text = ["""\ ## THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. #extends phd_pp_ru @@ -298,11 +313,14 @@ new_text = ["""\ ## #def body_html

ôÅÇÉ

+ +

+

"""] for count, tag, links in all_tags: - new_text.append(""" -

%s (%d)

+ new_text.append("""\ +
%s (%d)
""" % (tag, tag, count)) tag_text = ["""\ @@ -315,21 +333,37 @@ for count, tag, links in all_tags: ## #def body_html

%s

+ +

+

+

#end def $phd_pp_ru.respond(self) """) write_if_changed(os.path.join("tags", tag+".tmpl"), ''.join(tag_text)) new_text.append("""\ +
+

#end def $phd_pp_ru.respond(self) """)