commit 3bd246676fa0b278ea9acd3943fa96846bdbeb56
parent 3dceddaca7a67502e90b4f5c5d4d04648ceb17cd
Author: Dan Callaghan <djc@djc.id.au>
Date: Sat, 7 Jun 2008 23:34:19 +1000
a single template for all pages showing multiple entries
committer: Dan Callaghan <djc@djc.id.au>
--HG--
extra : convert_revision : fa4ca8a14435a5e8536a0e1f2c7d0d0d97c8155e
Diffstat:
5 files changed, 30 insertions(+), 65 deletions(-)
diff --git a/app.py b/app.py
@@ -1,3 +1,6 @@
+
+# vim:encoding=utf-8
+
import os
from genshi.template import TemplateLoader
from colubrid import RegexApplication, HttpResponse, execute
@@ -29,7 +32,8 @@ class BlogApplication(RegexApplication):
self.entries = blog.Entries(ENTRIES_DIR, READINGLOG_FILE)
def index(self):
- rendered = template_loader.load('index.xml').generate(
+ rendered = template_loader.load('multiple.xml').generate(
+ title=None,
all_categories=self.entries.categories(),
entries=self.entries
).render('xhtml')
@@ -53,9 +57,9 @@ class BlogApplication(RegexApplication):
if category not in categories:
raise PageNotFound()
entries = categories[category]
- rendered = template_loader.load('category.xml').generate(
+ rendered = template_loader.load('multiple.xml').generate(
+ title=u'%s category' % category,
all_categories=self.entries.categories(),
- category=category,
entries=entries
).render('xhtml')
return HttpResponse(rendered, [('Content-Type', 'text/html')], 200)
@@ -66,9 +70,9 @@ class BlogApplication(RegexApplication):
if tag not in by_tag:
raise PageNotFound()
entries = by_tag[tag]
- rendered = template_loader.load('tag.xml').generate(
+ rendered = template_loader.load('multiple.xml').generate(
+ title=u'“%s” tag' % tag,
all_categories=self.entries.categories(),
- tag=tag,
entries=entries
).render('xhtml')
return HttpResponse(rendered, [('Content-Type', 'text/html')], 200)
diff --git a/templates/category.xml b/templates/category.xml
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:py="http://genshi.edgewall.org/"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- lang="en-AU">
-<xi:include href="_commonwrapper.xml" />
-<xi:include href="_entry.xml" />
-
-<head>
- <title>${category} category</title>
-</head>
-<body>
-
-<h2 class="archives">Archive for the ${category} category</h2>
-
-<py:for each="entry in sorted(entries, key=lambda e: e.publication_date, reverse=True)[:20]">
- ${show_entry(entry, show_comments=False)}
-</py:for>
-
-</body>
-</html>
diff --git a/templates/index.xml b/templates/index.xml
@@ -1,18 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:py="http://genshi.edgewall.org/"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- lang="en-AU">
-<xi:include href="_commonwrapper.xml" />
-<xi:include href="_entry.xml" />
-
-<head>
-</head>
-<body>
-
-<py:for each="entry in sorted(entries, key=lambda e: e.publication_date, reverse=True)[:20]">
- ${show_entry(entry, show_comments=False)}
-</py:for>
-
-</body>
-</html>
diff --git a/templates/multiple.xml b/templates/multiple.xml
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ lang="en-AU">
+<xi:include href="_commonwrapper.xml" />
+<xi:include href="_entry.xml" />
+
+<head>
+ <title py:if="title">${title}</title>
+</head>
+<body>
+
+<h2 class="archives" py:if="title">Archive for the ${title}</h2>
+
+<py:for each="entry in sorted(entries, key=lambda e: e.publication_date, reverse=True)[:20]">
+ ${show_entry(entry, show_comments=False)}
+</py:for>
+
+</body>
+</html>
diff --git a/templates/tag.xml b/templates/tag.xml
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:py="http://genshi.edgewall.org/"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- lang="en-AU">
-<xi:include href="_commonwrapper.xml" />
-<xi:include href="_entry.xml" />
-
-<head>
- <title>“${tag}” tag</title>
-</head>
-<body>
-
-<h2 class="archives">Archive for the “${tag}” tag</h2>
-
-<py:for each="entry in sorted(entries, key=lambda e: e.publication_date, reverse=True)[:20]">
- ${show_entry(entry, show_comments=False)}
-</py:for>
-
-</body>
-</html>