constance

Scripts for generating (an earlier obsolete version of) my personal web site
git clone https://code.djc.id.au/git/constance/
commit 1e2ed739177e4d0524ad6ca94f2078d825989648
parent 584924028e8dee85f5b9701c629feb2a4e319870
Author: Dan Callaghan <djc@djc.id.au>
Date:   Sun, 15 Aug 2010 14:39:08 +1000

embed language from blog posts

Diffstat:
Mblog.py | 1+
Mtemplates/blog/entry.atom | 3++-
Mtemplates/blog/entry.html | 2+-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/blog.py b/blog.py
@@ -47,6 +47,7 @@ class BlogEntry(object):
         self.modified_date = datetime.fromtimestamp(os.path.getmtime(content_filename))
         self.publication_date = self.metadata.get('publication-date', None) or self.modified_date
         self.guid = self.metadata['guid']
+        self.language = self.metadata.get('language', None)
 
     def generate_atom(self):
         return template_loader.load('entry.atom').generate(item=self)
diff --git a/templates/blog/entry.atom b/templates/blog/entry.atom
@@ -1,6 +1,7 @@
 <entry xmlns="http://www.w3.org/2005/Atom"
        xmlns:py="http://genshi.edgewall.org/"
-       xmlns:xi="http://www.w3.org/2001/XInclude">
+       xmlns:xi="http://www.w3.org/2001/XInclude"
+       py:attrs="(item.language is not None) and {'xml:lang': item.language} or {}">
 
 <?python
 import urllib
diff --git a/templates/blog/entry.html b/templates/blog/entry.html
@@ -11,7 +11,7 @@ from viewutils import tag_list
     <meta name="DC.date" content="${item.publication_date.strftime(str('%Y-%m-%d'))}" />
 </head>
 <body>
-    <div class="item blog-entry">
+    <div class="item blog-entry" py:attrs="(item.language is not None) and {'lang': item.language} or {}">
 
         <h1 class="entry-title"><a href="http://www.djc.id.au/blog/${item.id}" rel="bookmark">${item.title}</a></h1>