import sys, os
-from glob import glob
try:
import cPickle as pickle
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]
else:
days = months[month] = []
- days.append(day)
+ if day not in days: days.append(day)
# Need to save the blog?
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)