]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Show tags in the blog index.
authorOleg Broytman <phd@phdru.name>
Wed, 8 Mar 2006 20:48:52 +0000 (20:48 +0000)
committerOleg Broytman <phd@phdru.name>
Wed, 8 Mar 2006 20:48:52 +0000 (20:48 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@22 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

reindex_blog.py

index 4451baa740e25f20b60be92b3699fc69e4ca2413..45faac2fdb7908e9b383d6f1c454ca02f500b9ee 100755 (executable)
@@ -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('''
 <hr>
 
-<p class="years">
+<p class="noindent"><a href="tags/">Теги</a>:
+''')
+      first_tag = True
+      for count, tag, links in all_tags:
+         if first_tag:
+            first_tag = False
+         else:
+            new_text.append(' - ')
+         new_text.append("""<a href="tags/%s.html">%s (%d)</a>""" % (tag, tag, count))
+      new_text.append('''
+</p>
 ''')
+
+      new_text.append('''
+<p class="noindent">По годам:
+''')
+      first_year = True
       for year in sorted(years.keys()):
          if first_year:
             first_year = False
@@ -283,11 +297,12 @@ for year in sorted(years.keys()):
          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