X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=reindex_blog.py;h=fd82c1839111ae59ddcd7a7e86eace33d7b9a715;hb=c6eb1e00be821ab12e0edaa622e75eff1ec8abd2;hp=92a02272ea79c60a9f79b0ae21fe8733d6fa47f2;hpb=6d775fb85dad6e10928e0e418645124a804a4275;p=phdru.name%2Fphdru.name.git diff --git a/reindex_blog.py b/reindex_blog.py index 92a0227..fd82c18 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -5,7 +5,7 @@ __version__ = "$Revision$"[11:-2] __revision__ = "$Id$"[5:-2] __date__ = "$Date$"[7:-2] __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006 PhiloSoft Design" +__copyright__ = "Copyright (C) 2006-2010 PhiloSoft Design" import sys, os @@ -39,6 +39,11 @@ else: blog = {} years = {} +# excerpts nd bodies are dictionaries mapping file => excerpt/body + +excerpts = {} +bodies = {} + # Walk the directory recursively for dirpath, dirs, files in os.walk(blog_root): d = os.path.basename(dirpath) @@ -77,6 +82,10 @@ for dirpath, dirs, files in os.walk(blog_root): if day not in days: days.append(day) + file = file[:-len("tmpl")] + "html" + key = (year, month, day, file) + excerpts[key] = template.get_first_p() + bodies[key] = template.Body # Need to save the blog? if blog <> old_blog: @@ -130,8 +139,12 @@ def write_template(level, year, month, day, titles, tags=None): #attr $Title = "Oleg Broytman's blog" #attr $Description = "Broytman Russian Blog Index Document" #attr $Copyright = %(cyear)s -#attr $alternates = (("application/atom+xml", "News [Atom 1.0]", "atom_10.xml"), - ("application/rss+xml", "News [RSS 2.0]", "rss_20.xml") +#attr $alternates = (("îÏ×ÏÓÔÉ [Atom 1.0] ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ", "application/atom+xml", "atom_10_titles.xml"), + ("îÏ×ÏÓÔÉ [Atom 1.0]", "application/atom+xml", "atom_10.xml"), + ("îÏ×ÏÓÔÉ [Atom 1.0] ÐÏÌÎÙÅ ÔÅËÓÔÙ", "application/atom+xml", "atom_10_full.xml"), + ("îÏ×ÏÓÔÉ [RSS 2.0] ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ", "application/rss+xml", "rss_20_titles.xml"), + ("îÏ×ÏÓÔÉ [RSS 2.0]", "application/rss+xml", "rss_20.xml"), + ("îÏ×ÏÓÔÉ [RSS 2.0] ÐÏÌÎÙÅ ÔÅËÓÔÙ", "application/rss+xml", "rss_20_full.xml"), ) ## #def body_html @@ -167,11 +180,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" @@ -227,8 +235,14 @@ def write_template(level, year, month, day, titles, tags=None):

îÏ×ÏÓÔÅ×ÁÑ ÌÅÎÔÁ × ÆÏÒÍÁÔÁÈ -Atom 1.0 RSS 2.0 . + +Atom 1.0 ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ / +Atom 1.0 / +Atom 1.0 ÐÏÌÎÙÅ ÔÅËÓÔÙ +RSS 2.0 ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ / +RSS 2.0 / +RSS 2.0 ÐÏÌÎÙÅ ÔÅËÓÔÙ.

""") @@ -339,17 +353,49 @@ new_text = ["""\
"""] -for count, tag, links in all_tags: +for i, (count, tag, links) in enumerate(all_tags): new_text.append("""\
%s (%d)
""" % (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 +403,7 @@ for count, tag, links in all_tags: