@@ 18,8 18,8 @@ class TemplateConfig(configuration.Confi
self._jenv = None
def templateloader(self):
- p = '/home/john/projects/newgenerator/skins/default'
- loader = jinja2.FileSystemLoader(p)
+ tpath = self.templates()
+ loader = jinja2.FileSystemLoader(tpath)
return loader
def templateenv(self):
@@ 28,7 28,7 @@ class TemplateConfig(configuration.Confi
return self._jenv
def besticon(self, tags):
- for tag, icon in self.icontags().iteritems():
+ for tag, icon in self.tagicons().iteritems():
if tag in tags:
return (tag, icon)
return None
@@ 1,3 1,8 @@
+"""Muyhomepage configuration
+"""
+
+import os
+import vanity.configreader
from muyhomepage2.pagehandlers.standard import StandardHandler
from muyhomepage2.pagehandlers.tagsummary import TagSummaryHandler
@@ 22,18 27,30 @@ class Config(object):
def __init__(self, filename):
self._filename = filename
+ self.reader = vanity.configreader.ConfigReader()
+ self.reader.read(filename, require=True)
+
+ def _get(self, section, name, default=None):
+ return self.reader.get(section, name, default)
+
+ def _list(self, section):
+ return list(self.reader.items(section))
+
def root(self):
- return '.'
+ return self._get('build', 'root', '.')
def destination(self):
- return '/home/john/www/cruft/'
+ return self._get('build', 'destination', '.html')
+
+ def templates(self):
+ return self._get('build', 'templates', '.templates')
def page_cache(self):
- return '/tmp/garbage/.pcache'
+ return self._get('build', 'cache.pages', '.pagecache')
def tag_cache(self):
- return '/tmp/garbage/.tcache'
+ return self._get('build', 'cache.tags', '.tagcache')
def handlers(self):
"""Return the handlers registry
@@ 47,23 64,25 @@ class Config(object):
return ['tagsummary', 'tagglobal', 'atom', 'rss2', 'blog']
def blog_count(self):
- return 10
+ blog = self._get('site', 'blogcount', '10')
+ return int(blog)
def feed_count(self):
- return 20
+ feed = self._get('site', 'feedcount', '20')
+ return int(feed)
- def icontags(self):
- return {'Technology': '/~john/cruft/static/tagicon-tech.png'}
+ def tagicons(self):
+ return dict(self._list('tagicons'))
def base_url(self):
- return 'http://karnak.nile/~john/cruft'
+ return self._get('site', 'baseurl', '/')
def site_author(self):
- return 'John Mulligan'
+ return self._get('site', 'author', 'John Doe')
def site_atom_id(self):
- return 'tag:asynchrono.us,2006-01-02:birch-street-computing'
+ return self._get('site', 'feed_id', 'tag:my-site,2009-01-01:default')
def atom_id_base(self):
- return 'tag:asynchrono.us'
+ return self._get('site', 'id_base', 'tag:my-site')