]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Allow a few blog entries for one day.
authorOleg Broytman <phd@phdru.name>
Fri, 3 Mar 2006 17:24:47 +0000 (17:24 +0000)
committerOleg Broytman <phd@phdru.name>
Fri, 3 Mar 2006 17:24:47 +0000 (17:24 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@12 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

reindex_blog.py

index 7e39798b506783c286ce12ed7acfe74f58d57816..c4d9be3358e6904ef9256879b0174efb9fcf729c 100755 (executable)
@@ -9,7 +9,6 @@ __copyright__ = "Copyright (C) 2006 PhiloSoft Design"
 
 
 import sys, os
-from glob import glob
 
 try:
    import cPickle as pickle
@@ -48,8 +47,12 @@ for dirpath, dirs, files in os.walk(os.curdir):
       lead = getattr(template, "Lead", None)
 
       if title:
-         year, month, day = dirpath.split(os.sep)[1:]
-         blog[year, month, day] = (os.path.basename(file), title, lead)
+         key = year, month, day = tuple(dirpath.split(os.sep)[1:])
+         if key in blog:
+            days = blog[key]
+         else:
+            days = blog[key] = []
+         days.append((file, title, lead))
 
          if year in years:
             months = years[year]
@@ -61,7 +64,7 @@ for dirpath, dirs, files in os.walk(os.curdir):
          else:
             days = months[month] = []
 
-         days.append(day)
+         if day not in days: days.append(day)
 
 
 # Need to save the blog?
@@ -237,16 +240,16 @@ for year in sorted(years.keys()):
    months = years[year]
    for month in sorted(months.keys()):
       month_titles = []
-      for day in months[month]:
+      for day in sorted(months[month]):
          day_titles = []
          key = year, month, day
          if key in blog:
-            tmpl, title, lead = blog[key]
-            if tmpl.endswith(".tmpl"): tmpl = tmpl[:-len("tmpl")] + "html"
-            all_titles.append((key, tmpl, title, lead))
-            year_titles.append((key, tmpl, title, lead))
-            month_titles.append((key, tmpl, title, lead))
-            day_titles.append((key, tmpl, title, lead))
+            for tmpl, title, lead in blog[key]:
+               if tmpl.endswith(".tmpl"): tmpl = tmpl[:-len("tmpl")] + "html"
+               all_titles.append((key, tmpl, title, lead))
+               year_titles.append((key, tmpl, title, lead))
+               month_titles.append((key, tmpl, title, lead))
+               day_titles.append((key, tmpl, title, lead))
          write_template(year, month, day, day_titles)
       write_template(year, month, '', month_titles)
    write_template(year, '', '', year_titles)