diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2015-04-16 10:40:36 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2015-04-16 10:40:36 +0200 |
commit | 75d7bb2acc90eb1c6daec66dc7b73573c643ce57 (patch) | |
tree | d8ceac2c957d922065738a70d2b4d7c3e9df65b4 /scripts | |
parent | 16636a29eb55dc5d958feacd2bb7a99cdc1bb884 (diff) | |
download | website-75d7bb2acc90eb1c6daec66dc7b73573c643ce57.tar.xz |
Generate sitemap programatically
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bupa | 8 |
1 files changed, 8 insertions, 0 deletions
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 |