]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - reindex_blog.py
First/prev/next/last links in dotfiles and blog tags.
[phdru.name/phdru.name.git] / reindex_blog.py
index a57f1d2e5db28e9225889729f603ae872af7de52..0ba0804d4c1d458628744a4c9d8ba5f6c2781744 100755 (executable)
@@ -167,11 +167,6 @@ def write_template(level, year, month, day, titles, tags=None):
       iday = int(day)
       imonth = int(month)
 
-      new_text.append("""\
-#attr $Next = "%s"
-""" % titles[0][3])
-
-
       if len(titles) == 1:
          new_text.append("""\
 #attr $refresh = "0; URL=%s"
@@ -339,17 +334,49 @@ new_text = ["""\
 <dl>
 """]
 
-for count, tag, links in all_tags:
+for i, (count, tag, links) in enumerate(all_tags):
    new_text.append("""\
    <dt><a href="%s.html">%s (%d)</a></dt>
 """ % (tag, tag, count))
 
+   first = all_tags[0][1]
+   if i == 0:
+      prev = None
+   else:
+      prev = all_tags[i-1][1]
+   if i >= len(all_tags)-1:
+      next = None
+   else:
+      next = all_tags[i+1][1]
+   last = all_tags[-1][1]
+
    tag_text = ["""\
 ## THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
 #extends phd_pp_ru
 #implements respond
 #attr $Title = "Oleg Broytman's blog: tag %s"
 #attr $Description = "Broytman Russian Blog Tag %s Index Document"
+""" % (tag, tag)]
+
+   tag_text.append("""\
+#attr $First = "%s"
+""" % first)
+
+   if prev:
+      tag_text.append("""\
+#attr $Prev = "%s"
+""" % prev)
+
+   if next:
+      tag_text.append("""\
+#attr $Next = "%s"
+""" % next)
+
+   tag_text.append("""\
+#attr $Last = "%s"
+""" % last)
+
+   tag_text.append("""\
 #attr $Copyright = 2006
 ##
 #def body_html
@@ -357,7 +384,7 @@ for count, tag, links in all_tags:
 
 <p class="head">
 <ul>
-""" % (tag, tag, tag)]
+""" % tag)
 
    count = 0
    for year, month, day, filename, title, lead in reversed(links):