mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
website
This commit is contained in:
@@ -1,23 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import marko
|
||||
|
||||
|
||||
OUT_DIR = Path('_out')
|
||||
ASSETS_DIR = Path('assets')
|
||||
|
||||
|
||||
def generate():
|
||||
# licenses = open('../LICENSE.md').read().split('---')[0]
|
||||
|
||||
text_md = open('text.md').read()
|
||||
# text_md = text_md.replace('{licenses}', licenses)
|
||||
|
||||
text_html = marko.convert(text_md)
|
||||
shutil.rmtree(OUT_DIR, ignore_errors=True)
|
||||
OUT_DIR.mkdir()
|
||||
|
||||
template = open('template.html').read()
|
||||
template = template.replace('{text}', text_html)
|
||||
|
||||
style_selector = open('map_docs.html').read()
|
||||
template = template.replace('<!--map_docs-->', style_selector)
|
||||
main_md = open('blocks/main.md').read()
|
||||
main_html = marko.convert(main_md)
|
||||
|
||||
open('index.html', 'w').write(template)
|
||||
index_html = template.replace('{main}', main_html)
|
||||
|
||||
style_selector = open('blocks/map_docs.html').read()
|
||||
index_html = index_html.replace('<!--map_docs-->', style_selector)
|
||||
open(OUT_DIR / 'index.html', 'w').write(index_html)
|
||||
|
||||
make_static_page('privacy', 'Privacy Policy')
|
||||
copy_assets()
|
||||
|
||||
|
||||
def copy_assets():
|
||||
for file in ['style.css', 'logo_512.png', 'map.js']:
|
||||
shutil.copyfile(ASSETS_DIR / file, OUT_DIR / file)
|
||||
|
||||
|
||||
def make_static_page(page_str, title):
|
||||
page_md = open(f'blocks/{page_str}.md').read()
|
||||
page_html = marko.convert(page_md)
|
||||
|
||||
template = open('template_static.html').read()
|
||||
template = template.replace('{main}', page_html)
|
||||
template = template.replace('{title}', title)
|
||||
|
||||
with open(OUT_DIR / f'{page_str}.html', 'w') as fp:
|
||||
fp.write(template)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user