16 lines
871 B
Python
16 lines
871 B
Python
"""Build an offline, single-file prototype. Standard library only; no network."""
|
|
import base64
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
src = ROOT / 'src'
|
|
html = (src / 'shell.html').read_text(encoding='utf-8')
|
|
html = html.replace('{{STYLE}}', (src / 'space.css').read_text(encoding='utf-8'))
|
|
html = html.replace('{{SCRIPT}}', (src / 'atmos.js').read_text(encoding='utf-8') + '\n' + (src / 'space.js').read_text(encoding='utf-8'))
|
|
for key, filename in [('ROOM', 'her-room.jpg'), ('TALK', 'her-talk.jpg')]:
|
|
data = (ROOT.parents[1] / 'web/public/assets' / filename).read_bytes()
|
|
html = html.replace('{{' + key + '}}', 'data:image/jpeg;base64,' + base64.b64encode(data).decode())
|
|
assert '{{' not in html
|
|
(ROOT / 'index.html').write_text(html, encoding='utf-8', newline='\n')
|
|
print(f'Built offline index.html ({len(html.encode()):,} bytes)')
|