49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
"""Prepare the nkbmusic.com website in site/ for upload.
|
|
|
|
Writes site/config.js (backend URL and public key, from env.json) and site/sitemap.xml
|
|
(home and legal pages).
|
|
|
|
python tools/build_site.py [--play-url URL] [--app-store-url URL]
|
|
"""
|
|
import argparse
|
|
import datetime
|
|
import json
|
|
import pathlib
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
SITE = ROOT / 'site'
|
|
BASE = 'https://nkbmusic.com'
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument('--play-url', default='https://play.google.com/store/apps/details?id=com.metatroncubesolutions.nanga_kathai', help='Google Play link')
|
|
ap.add_argument('--app-store-url', default='https://apps.apple.com/app/id6829229617', help='App Store link')
|
|
args = ap.parse_args()
|
|
|
|
env = json.loads((ROOT / 'env.json').read_text(encoding='utf-8'))
|
|
config = {
|
|
'supabaseUrl': env['SUPABASE_URL'],
|
|
# The publishable (anon) key is public by design; row-level security protects the data.
|
|
'supabaseKey': env['SUPABASE_PUBLISHABLE_KEY'],
|
|
'mediaBaseUrl': env['MEDIA_BASE_URL'],
|
|
'playUrl': args.play_url,
|
|
'appStoreUrl': args.app_store_url,
|
|
}
|
|
(SITE / 'config.js').write_text(f'window.NK_CONFIG = {json.dumps(config, indent=2)};\n', encoding='utf-8')
|
|
|
|
today = datetime.date.today().isoformat()
|
|
urls = [(f'{BASE}/', '1.0'), (f'{BASE}/privacy', '0.3'), (f'{BASE}/terms', '0.3'),
|
|
(f'{BASE}/delete-account', '0.3')]
|
|
body = '\n'.join(f' <url><loc>{u}</loc><lastmod>{today}</lastmod><priority>{p}</priority></url>'
|
|
for u, p in urls)
|
|
(SITE / 'sitemap.xml').write_text(
|
|
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
|
f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n{body}\n</urlset>\n', encoding='utf-8')
|
|
(SITE / 'robots.txt').write_text(f'User-agent: *\nAllow: /\n\nSitemap: {BASE}/sitemap.xml\n', encoding='utf-8')
|
|
print(f'config.js, sitemap.xml ({len(urls)} URLs) and robots.txt written to {SITE}')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|