]> 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 5c14d4693590138f44db0fe794b8f95ca8339e39..0ba0804d4c1d458628744a4c9d8ba5f6c2781744 100755 (executable)
@@ -334,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
@@ -352,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):