Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
Created November 29, 2009 06:42
Show Gist options
  • Save EnigmaCurry/244821 to your computer and use it in GitHub Desktop.
Save EnigmaCurry/244821 to your computer and use it in GitHub Desktop.
A single page indexing all the categories and posts
<%inherit file="_templates/site.mako" />
<%
# Generate a map of categories to posts
category_post_map = {}
for p in bf.posts:
for c in p.categories:
try:
category_post_map[c.name].add(p)
except KeyError:
category_post_map[c.name] = set([p])
%>
<ul>
% for category, posts in category_post_map.items():
<li>${category}
<ul>
% for post in posts:
<li><a href="${post.permalink}">${post.title}</a></li>
% endfor
</ul>
</li>
% endfor
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment