From 75d7bb2acc90eb1c6daec66dc7b73573c643ce57 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Thu, 16 Apr 2015 10:40:36 +0200 Subject: Generate sitemap programatically --- scripts/bupa | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts/bupa') diff --git a/scripts/bupa b/scripts/bupa index 1208263..e87ca4c 100755 --- a/scripts/bupa +++ b/scripts/bupa @@ -104,6 +104,8 @@ def build_journal(jinja_env): with open('build/journal.atom', 'wb') as file: file.write(atom_feed.to_string().encode('utf-8')) + make_sitemap(jinja_env, entries) + def build_page(jinja_env, template, pagename): page = parse('src/'+pagename+'.rst') page.body = reST_to_html(page.body) @@ -116,6 +118,12 @@ def write_page(page, header, filename, template, jinja_env): rendered_page = template.render(page=page, title=page.title, header=header) file.write(rendered_page.encode('utf-8')) +def make_sitemap(jinja_env, entries): + template = jinja_env.get_template('sitemap.xml') + with open('build/sitemap.xml', 'wb') as f: + rendered = template.render(entries=entries) + f.write(rendered.encode('utf-8')) + def main(): arguments = docopt.docopt(__doc__, version='bupa 0.0.1') jinja_env = Environment(loader=FileSystemLoader('src/templates')) # something something jinja2 templates -- cgit v1.2.3-70-g09d2