Commits

Fredrik Håård committed 80646e4

genshi prototype

  • Participants
  • Parent commits 6fc6880
  • Branches genshi

Comments (0)

Files changed (2)

 CHANGES
 =======
 
+
 0.6 (unreleased)
 ----------------
 
 # -*- encoding: utf-8 -*-
-from string import Template
 from datetime import datetime, timedelta
 from time import time, mktime
 import os, os.path, shutil, re
 from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
 import codecs
 import argparse
-import proton.template
+from string import Template
+from genshi.template import TemplateLoader
+from genshi.core import Markup
+
 
 class Config(object):
     def __init__(self, path, defaults):
 
     templates_path = os.path.join(os.path.dirname(__file__), 'templates')
     templates = Templates(templates_path)
+    loader = TemplateLoader(
+        os.path.join(os.path.dirname(__file__), 'templates'),
+        auto_reload=True
+        )
 
     page_tpl = templates.get('pagetemplate.html')
     blaag_tpl = templates.get('blaag_template.html')
     #            links=links, 
     #            footer=footer,
     #            main="\n".join(main))
+    template = loader.load("page_template.xhtml")
+    get_custom(
+        config.get('content','custom_path'), 
+        'footer')
+    articles = []
 
-    ptl = proton.template.Templates(templates_path)['pagetemplate.html']
-    for i in 0, 1:
-        ptl.setelement(u'title', parts['title'], i)
+    class Article(object): pass
+
+    for parts in data:
+        article = Article()
+        article.article_id = identifier(parts)
+        article.body = Markup(parts['html_body'])
+        article.timestamp = parts['created']
+        article.comment_thread_link = get_absolute_url(parts)
+        article.article_url = get_absolute_url(parts)
+        article.article_title = parts['title']
+        articles.append(article)
+
+    stream = template.generate(articles = articles, footer=Markup(footer), **defaults)
+    content = stream.render('html', doctype='html')
+
 
     #Write main page
     with open(os.path.join(html_path, "index.html"), "w") as target:
-        target.write(str(ptl))
+        target.write(content)
+
     #Write rss
-
     description = config.get('content', 'description')
     
     for name in FEEDS: