From 8ad41e723c72f9a4445cba95fb027aa7fe7dfb26 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 20 Dec 2007 17:25:59 +0530 Subject: [PATCH] atom-xml partial support --- cfg.py | 4 ++-- util.py | 8 +++++--- wrigit.py | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cfg.py b/cfg.py index 34eaf7c..04ed0fe 100644 --- a/cfg.py +++ b/cfg.py @@ -6,7 +6,7 @@ help='Configuration file'), ... ], {'foo': 34}) ->>> print cfg['bar']['yaht'] +>>> print cfg['bar.yaht'] ... """ @@ -88,7 +88,7 @@ def setup_cfg(option_list, defaults, namespace={}): (options, args) = oparser.parse_args() if options.conf is None: - raise SystemExit, "You must specific the --conf option" + raise SystemExit, "You must specify the --conf option." # `pwd` contains the directory where the conf file lies. namespace['pwd'] = abspath(dirname(abspath(options.conf))) diff --git a/util.py b/util.py index 02fa1c4..ae0c0e6 100644 --- a/util.py +++ b/util.py @@ -18,8 +18,10 @@ def make(target, deps, content_generator, *args, **kwargs): def mako(): templates = TemplateLookup(directories=[cfg['templatedir']]) - def render(name, **kwargs): - return templates.get_template(name).render(**kwargs) + def render(name, **namespace): + import cgi + return templates.get_template(name).render( + cgi=cgi, + **namespace) return render mako = mako() - diff --git a/wrigit.py b/wrigit.py index 8bacee3..fd56997 100755 --- a/wrigit.py +++ b/wrigit.py @@ -94,10 +94,12 @@ if __name__ == '__main__': print '[%s - %s] rstdir:%s [using templatedir:%s]' % ( cfg['baseurl'], cfg['title'], cfg['rstdir'], cfg['templatedir']) - + + rstdir = cfg['rstdir'] blog_posts = [] - blog_path = abspath(join(cfg['rstdir'], 'blog')) - for f in rst.rstfiles(cfg['rstdir']): + blog_path = join(rstdir, 'blog') + + for f in rst.rstfiles(rstdir): if blog_path in f: page = BlogPost(f) blog_posts.append(page) @@ -107,9 +109,16 @@ if __name__ == '__main__': make(rst.htmlpath(f), [f], mako, 'page.mako', **locals()) - # generate blog index blog_posts.sort() blog_posts.reverse() - make(join(cfg['rstdir'], 'blog', 'index.html'), + + # generate blog index + make(join(rstdir, 'blog', 'index.html'), [p.rstfile for p in blog_posts], mako, 'blog/index.mako', **locals()) + + # generate blog feed + recent_blog_posts = blog_posts[:10] + make(join(rstdir, 'blog', 'atom.xml'), + [p.rstfile for p in recent_blog_posts], + mako, 'blog/atom.xml.mako', **locals()) -- 2.11.4.GIT