commit 4a662eab79c964eac6ba4f6d0a6624d16553161e
parent f4ca708425afd73ab24dd08a8fd668f3e4956828
Author: Dan Callaghan <djc@djc.id.au>
Date: Tue, 2 Sep 2008 10:33:28 +1000
abolished categories
Diffstat:
4 files changed, 3 insertions(+), 59 deletions(-)
diff --git a/app.py b/app.py
@@ -19,7 +19,6 @@ class BlogApplication(RegexApplication):
urls = [(r'^$', 'index'),
(r'^feed$', 'feed'),
- (r'^\+categories/(.+)$', 'category'),
(r'^\+tags/(.+)$', 'tag'),
(r'^([^+/][^/]*)/?$', 'post')]
charset = 'utf-8'
@@ -35,7 +34,6 @@ class BlogApplication(RegexApplication):
if format == 'html':
rendered = template_loader.load('multiple.xml').generate(
title=None,
- all_categories=self.entries.categories(),
sorted_entries=sorted_entries,
offset=offset,
).render('xhtml')
@@ -54,29 +52,12 @@ class BlogApplication(RegexApplication):
try:
entry = self.entries[id]
rendered = template_loader.load('single.xml').generate(
- all_categories=self.entries.categories(),
entry=entry
).render('xhtml')
return HttpResponse(rendered, [('Content-Type', 'text/html')], 200)
except blog.EntryNotFoundError:
raise PageNotFound()
- def category(self, category):
- category = category.decode(self.charset)
- categories = self.entries.by_category()
- if category not in categories:
- raise PageNotFound()
- offset = int(self.request.args.get('offset', 0))
- entries = categories[category]
- sorted_entries = sorted(entries, key=lambda e: e.publication_date, reverse=True)[offset:offset + config.ENTRIES_PER_PAGE]
- rendered = template_loader.load('multiple.xml').generate(
- title=u'%s category' % category,
- all_categories=self.entries.categories(),
- sorted_entries=sorted_entries,
- offset=offset
- ).render('xhtml')
- return HttpResponse(rendered, [('Content-Type', 'text/html')], 200)
-
def tag(self, tag):
tag = tag.decode(self.charset)
by_tag = self.entries.by_tag()
@@ -87,7 +68,6 @@ class BlogApplication(RegexApplication):
sorted_entries = sorted(entries, key=lambda e: e.publication_date, reverse=True)[offset:offset + config.ENTRIES_PER_PAGE]
rendered = template_loader.load('multiple.xml').generate(
title=u'“%s” tag' % tag,
- all_categories=self.entries.categories(),
sorted_entries=sorted_entries,
offset=offset
).render('xhtml')
diff --git a/blog.py b/blog.py
@@ -63,25 +63,6 @@ class Entries(object):
for d in yaml.load_all(open(self.readinglog_file, 'r')))
)
- def by_category(self):
- """
- Returns a dict of (category -> set of entries).
- """
- d = {}
- for entry in self:
- for category in entry.categories:
- d.setdefault(category, set()).add(entry)
- return d
-
- def categories(self):
- """
- Returns a frequency-ordered list of categories.
- """
- by_category = self.by_category()
- return sorted(by_category.iterkeys(),
- key=lambda c: len(by_category[c]),
- reverse=True)
-
def by_tag(self):
d = {}
for entry in self:
@@ -109,11 +90,6 @@ class Entry(object):
self.metadata = cleanup_metadata(md.Meta)
self.title = self.metadata['title']
- raw_cats = self.metadata.get('categories', '').strip()
- if raw_cats:
- self.categories = frozenset(cat.strip() for cat in raw_cats.split(','))
- else:
- self.categories = frozenset()
raw_tags = self.metadata.get('tags', '').strip()
if raw_tags:
self.tags = frozenset(tag.strip() for tag in raw_tags.split(','))
@@ -148,7 +124,6 @@ class ReadingLogEntry(object):
self.publication_date = self.modified_date = self.date = yaml_dict['Date']
self.url = yaml_dict.get('URL', None)
self.rating = yaml_dict.get('Rating', None)
- self.categories = frozenset([u'Reading'])
self.tags = frozenset()
self._guid = yaml_dict.get('GUID', None)
diff --git a/templates/_commonwrapper.xml b/templates/_commonwrapper.xml
@@ -35,12 +35,6 @@ import config
<li><a rel="alternate" type="application/atom+xml" href="${config.REL_BASE}/?format=atom" title="Atom feed for posts">Atom posts</a></li>
</ul>
</li>
- <li class="categories">
- <h2>Categories</h2>
- <ul>
- <li py:for="category in all_categories" class="cat-item"><a href="${config.REL_BASE}/+categories/${category}">${category}</a></li>
- </ul>
- </li>
<li id="archives">
<h2>Archives</h2>
XXX TODO
diff --git a/templates/_entry.xml b/templates/_entry.xml
@@ -5,18 +5,16 @@
py:def="show_entry(entry, show_comments=True)">
<?python
+import blog
from viewutils import mini_markdown, tag_list, category_list
?>
-<div class="entry" py:if="'Reading' not in entry.categories">
+<div class="entry" py:if="isinstance(entry, blog.Entry)">
<h3 class="entrytitle" id="post-${entry.id}"><a href="${config.REL_BASE}/${entry.id}" rel="bookmark">${mini_markdown(entry.title)}</a></h3>
<div class="entrymeta">
Posted ${entry.publication_date.strftime(str('%-1d %B %Y at %H:%M'))}
- <py:if test="entry.categories">
- in ${category_list(entry.categories)}
- </py:if>
<py:if test="not show_comments and entry.has_comments()">
·
<a href="${config.REL_BASE}/${entry.id}#comments">
@@ -41,7 +39,7 @@ from viewutils import mini_markdown, tag_list, category_list
<img src="${config.REL_BASE}/static/images/halfstar.png" alt="[half-star]" py:if="rating > int(rating)" />
</span>
-<div class="entry readinglog" py:if="'Reading' in entry.categories">
+<div class="entry readinglog" py:if="isinstance(entry, blog.ReadingLogEntry)">
<h3 class="entrytitle" id="post-${entry.id}">
<a py:strip="not entry.url" href="${entry.url}">${mini_markdown(entry.title)}</a>
<py:if test="entry.author">
@@ -50,9 +48,6 @@ from viewutils import mini_markdown, tag_list, category_list
</h3>
<div class="entrymeta">
Posted ${entry.publication_date.strftime(str('%-1d %B %Y'))}
- <py:if test="entry.categories">
- in <a py:for="category in entry.categories" href="${config.REL_BASE}/+categories/${category}">${category}</a>
- </py:if>
<py:if test="entry.rating">
· ${stars(entry.rating)}
</py:if>