commit 8d48734ca6a00fc567c673c28b65492d4ca0b3a0
parent 56f0e9796202b275d9a7f5bfd2c8d73cc38c2dac
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 16 Jun 2013 17:17:39 +1000
cleaned up and simplified templates; HTML5 output
Diffstat:
8 files changed, 65 insertions(+), 59 deletions(-)
diff --git a/constance.py b/constance.py
@@ -22,6 +22,10 @@ import homepage
def output(filename, content):
assert isinstance(content, str)
+
+ # XXX ugh, nasty
+ content = re.sub(r'<!DOCTYPE html.*>', '<!DOCTYPE html>', content)
+
if os.path.exists(filename):
existing = open(filename, 'r').read()
if content == existing:
diff --git a/homepage.py b/homepage.py
@@ -19,7 +19,7 @@ def generate(dir, xslt, blog_entries, reading_entries, config):
rendered = template.generate(blog_entries=blog_entries,
reading_entries=reading_entries,
config=config).render('xhtml')
- transformed = str(xslt(lxml.etree.fromstring(rendered)))
+ transformed = str(xslt(lxml.etree.fromstring(rendered), homepage='1'))
constance.output(os.path.join(dir, 'index.html'), transformed)
# firehose
diff --git a/templates/blog/entry.html b/templates/blog/entry.html
@@ -7,24 +7,25 @@ from viewutils import tag_list
?>
<head>
- <title>${item.title.striptags()} - ${config.get('blog', 'title')}</title>
- <meta name="DC.date" content="${item.publication_date.strftime(str('%Y-%m-%d'))}" />
+ <title>${item.title.striptags()} · ${config.get('blog', 'title')}</title>
+ <meta name="dcterms.issued" content="${item.publication_date.strftime(str('%Y-%m-%d'))}" />
</head>
<body>
- <div class="item blog-entry" py:attrs="(item.language is not None) and {'lang': item.language} or {}">
+ <article class="item blog-entry" py:attrs="(item.language is not None) and {'lang': item.language} or {}">
- <h1 class="entry-title"><a href="${config.get('global', 'url_base')}blog/${item.id}" rel="bookmark">${item.title}</a></h1>
-
- <div class="date published">${item.publication_date.strftime(str('%-1d %b %Y'))}</div>
-
- <div py:if="item.tags" class="tags">
- tagged: ${tag_list(item.tags)}
- </div>
+ <h1 class="entry-title">${item.title} <a href="${config.get('global', 'url_base')}blog/${item.id}" rel="bookmark" class="icon icon-link"></a></h1>
<div class="entry-content">
${item.body}
</div>
+ <p class="meta">
+ Originally published <time datetime="${item.publication_date.strftime(str('%Y-%m-%d %H:%M:%S%Z'))}" pubdate="">${item.publication_date.strftime(str('%-1d %B %Y'))}</time>.
+ <py:if test="item.tags">
+ Tagged: ${tag_list(item.tags)}.
+ </py:if>
+ </p>
+
<py:if test="config.get('disqus', 'site')">
<div id="disqus_thread"></div>
<script type="text/javascript">
@@ -37,6 +38,6 @@ from viewutils import tag_list
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=${config.get('disqus', 'site')}">comments powered by Disqus.</a></noscript>
</py:if>
- </div>
+ </article>
</body>
</html>
diff --git a/templates/blog/index.html b/templates/blog/index.html
@@ -13,16 +13,18 @@ from viewutils import markdown, mini_markdown, tag_list
</head>
<body>
-
+<section>
<h1>${config.get('blog', 'title')}</h1>
<py:for each="year, items in groupby(sorted(items, key=lambda e: e.publication_date, reverse=True), key=lambda e: e.publication_date.year)">
<h2>${year}</h2>
- <div class="item blog-entry-stub" py:for="item in items">
- <h3 class="entry-title"><a href="${item.id}">${item.title}</a></h3>
- <div class="date published">${item.publication_date.strftime(str('%-1d %b %Y'))}</div>
- </div>
+ <ul class="blog-index">
+ <li py:for="item in items">
+ <a href="${item.id}">${item.title}</a>
+ <time datetime="${item.publication_date.strftime(str('%Y-%m-%d %H:%M:%S%Z'))}">${item.publication_date.strftime(str('%-1d %B'))}</time>
+ </li>
+ </ul>
</py:for>
-
+</section>
</body>
</html>
diff --git a/templates/homepage/index.html b/templates/homepage/index.html
@@ -25,25 +25,32 @@ from viewutils import markdown, mini_markdown, tag_list
<body>
<py:if test="len(blog_entries) != 0">
- <h1>Recent blog entries</h1>
- <div class="item blog-entry-stub" py:for="item in sorted(blog_entries, key=lambda e: e.publication_date, reverse=True)[:4]">
- <h3 class="entry-title"><a href="blog/${item.id}">${item.title}</a></h3>
- <div class="date published">${item.publication_date.strftime(str('%-1d %b %Y'))}</div>
- <div py:if="item.tags" class="tags">tagged: ${tag_list(item.tags)}</div>
- </div>
- <p><a href="blog/">older entries…</a></p>
+ <section>
+ <h1>Recent blog entries</h1>
+ <ul class="blog-index">
+ <li py:for="item in sorted(blog_entries, key=lambda e: e.publication_date, reverse=True)[:4]">
+ <a href="blog/${item.id}">${item.title}</a>
+ <time datetime="${item.publication_date.strftime(str('%Y-%m-%d %H:%M:%S%Z'))}">${item.publication_date.strftime(str('%-1d %B %Y'))}</time>
+ </li>
+ </ul>
+ <p class="more"><a href="blog/">older entries…</a></p>
+ </section>
</py:if>
<py:if test="len(reading_entries) != 0">
- <h1>Recent reading</h1>
- <div class="item reading-log-entry-stub" py:for="item in sorted((e for e in reading_entries if e.isbn), key=lambda e: e.publication_date, reverse=True)[:6]">
- <a py:strip="not item.url" href="${item.url}">
- <img py:if="item.isbn" class="cover"
- src="/covers/isbn/${item.isbn}/thumbnail"
- alt="${item.title.striptags()}" />
- </a>
- </div>
- <p><a href="reading">older entries…</a></p>
+ <section>
+ <h1>Recent reading</h1>
+ <ul class="reading-index">
+ <li py:for="item in sorted((e for e in reading_entries if e.isbn), key=lambda e: e.publication_date, reverse=True)[:6]">
+ <a py:strip="not item.url" href="${item.url}">
+ <img py:if="item.isbn" class="cover"
+ src="/covers/isbn/${item.isbn}/thumbnail"
+ alt="${item.title.striptags()}" />
+ </a>
+ </li>
+ </ul>
+ <p class="more"><a href="reading">older entries…</a></p>
+ </section>
</py:if>
</body>
diff --git a/templates/reading/reading.html b/templates/reading/reading.html
@@ -16,32 +16,23 @@ from viewutils import markdown, mini_markdown, tag_list, idify
</head>
<body>
-
+<section>
<h1>${config.get('reading', 'title')}</h1>
<py:for each="item in sorted(items, key=lambda e: e.publication_date, reverse=True)">
- <div class="item reading-log-entry">
-
+ <div class="item reading-log-entry" id="${idify(item.title.striptags())}">
<img py:if="item.isbn" class="cover"
src="/covers/isbn/${item.isbn}/thumbnail"
alt="Cover image for ${item.title.striptags()}" />
-
- <h3 id="${idify(item.title.striptags())}">
- <a py:strip="not item.url" href="${item.url}">${item.title}</a>
+ <div>
+ <span class="title"><a py:strip="not item.url" href="${item.url}">${item.title}</a></span>
<span py:if="item.author" class="author">by ${item.author}</span>
- </h3>
-
- <div class="date published">
- ${item.publication_date.strftime(str('%-1d %b %Y'))}
+ <time datetime="${item.publication_date.strftime(str('%Y-%m-%d %H:%M:%S%Z'))}">${item.publication_date.strftime(str('%-1d %B %Y'))}</time>
+ <span py:if="item.rating" class="rating">${stars(item.rating)}</span>
</div>
-
- <div py:if="item.rating" class="rating">
- ${stars(item.rating)}
- </div>
-
</div>
</py:for>
-
+</section>
</body>
</html>
diff --git a/templates/tags/index.html b/templates/tags/index.html
@@ -4,10 +4,9 @@
<head>
<title>Tag cloud</title>
- <link rel="stylesheet" type="text/css" href="../style/tag_cloud.css" />
</head>
<body>
-
+<section>
<h1>Tag cloud</h1>
<ol id="tagcloud">
@@ -16,6 +15,6 @@
<span class="frequency">(used ${freq} times)</span>
</li>
</ol>
-
+</section>
</body>
</html>
diff --git a/templates/tags/tag.html b/templates/tags/tag.html
@@ -12,13 +12,15 @@ from viewutils import markdown, mini_markdown, tag_list
</head>
<body>
-
+<section>
<h1>“${tag}” tag</h1>
- <div class="item blog-entry-stub" py:for="item in sorted(items, key=lambda e: e.publication_date, reverse=True)">
- <h3 class="entry-title"><a href="../blog/${item.id}">${item.title}</a></h3>
- <div class="date published">${item.publication_date.strftime(str('%-1d %b %Y'))}</div>
- </div>
-
+ <ul class="blog-index">
+ <li py:for="item in sorted(items, key=lambda e: e.publication_date, reverse=True)">
+ <a href="../blog/${item.id}">${item.title}</a>
+ <time datetime="${item.publication_date.strftime(str('%Y-%m-%d %H:%M:%S%Z'))}">${item.publication_date.strftime(str('%-1d %B %Y'))}</time>
+ </li>
+ </ul>
+</section>
</body>
</html>