From: Oleg Broytman Date: Fri, 3 Mar 2006 17:24:47 +0000 (+0000) Subject: Allow a few blog entries for one day. X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=192efe0dee2d6a52978cb3db046949532e7678e1;p=phdru.name%2Fphdru.name.git Allow a few blog entries for one day. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@12 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- diff --git a/reindex_blog.py b/reindex_blog.py index 7e39798..c4d9be3 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -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)