1 ################################################################################
4 ## Writes out yearly, monthly, and daily archives.
5 ## Each archive is navigable to the next and previous archive
6 ## in which posts were made.
7 ################################################################################
11 from blogofile.cache import bf
14 blog = bf.config.controllers.blog
18 write_monthly_archives()
21 def sort_into_archives():
22 #This is run in 0.initial.py
23 for post in blog.posts:
24 link = post.date.strftime("archive/%Y/%m")
26 blog.archived_posts[link].append(post)
28 blog.archived_posts[link] = [post]
29 for archive, posts in sorted(
30 blog.archived_posts.items(), key=operator.itemgetter(0), reverse=True):
31 name = posts[0].date.strftime("%B %Y")
32 blog.archive_links.append((archive, name, len(posts)))
35 def write_monthly_archives():
36 for link, posts in blog.archived_posts.items():
37 name = posts[0].date.strftime("%B %Y")
38 chronological.write_blog_chron(posts, root=link)