From b1e6491f77421ae4623391a7f53af7f3e6c13f34 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Mon, 6 Jul 2020 18:23:10 +0100 Subject: import website from previous repo --- generate-sitemap | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 generate-sitemap (limited to 'generate-sitemap') diff --git a/generate-sitemap b/generate-sitemap new file mode 100755 index 0000000..998b9ec --- /dev/null +++ b/generate-sitemap @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +from os import path +import textwrap +import sys + +from typing import List + +import jinja2 + +ROOT = 'https://ethulhu.co.uk' + +TEMPLATE = ''' + + + {% for url in urls -%} + + {{ root }}/{{ url.loc }} + + {% endfor %} + +'''.strip() + + +def loc_from_path(p: str) -> str: + basename, _ = path.splitext(p) + return '/'.join(basename.split('/')[1:]) + + +if __name__ == '__main__': + paths = sys.argv[1:] + + urls = [{'loc': loc_from_path(p)} for p in paths if p.endswith('.html')] + + environment = jinja2.Environment( + trim_blocks=True, + ) + print(environment.from_string(TEMPLATE).render(root=ROOT, urls=urls)) -- cgit v1.2.3