#!/usr/bin/env python3 """build.py -- the starshipos-f18.com XWiki pages, made from the "StarshipOS.com" design canvas. site/com/build.py canvas/{Main,Inquiries,TryIt}.dc.html -> {Main,Inquiries,TryIt}.WebHome.xwiki The canvas is the source: its artboards are copied into canvas/ as they are, and this turns each into one {{html}} block (which needs a page author with script rights). What changes on the way: - the accent hole becomes its default colour, and the canvas's links become the wiki's pages (Main.dc.html -> /bin/view/Main/, ...) and the real domains (starshipos.org -> starshipos-f18.org); - the two images become attachments of Main.WebHome (badge.jpg, captain-bob.jpg -- web-size copies of the canvas's uploads); - Try it: the drawn console becomes the real one, an iframe of try.starshipos-f18.com; - the inquiry form posts to the .org's PublicInquiry, which files it under Inquiries there (admin-only, site/org/inquiries); the announcements form, which has no server, sends by e-mail; install.sh puts the pages and the images on the wiki. """ import os import re import sys sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import colorlock # noqa: E402 the design's colours over the wiki's high-contrast theme ACCENT = "#F5891F" FONTS = ('\n' '') ORG = "https://starshipos-f18.org/" PAGES = ["Main", "Inquiries", "TryIt"] IMAGES = {"/_blob/5b564d54d98e02ad600c913a9a1888f2": "badge.jpg", "/_blob/5483451f292782a8b366e437181c4bcf": "captain-bob.jpg"} CONSOLE = '''
StarshipOS · amd64 · your session try.starshipos-f18.com

If the console does not connect, every machine is in use: try again in a few minutes.

''' def body(src): m = re.search(r"(.*)", src, re.S) html = re.sub(r".*?", "", m.group(1), flags=re.S).strip() html = html.replace("{{accent}}", ACCENT) for p in PAGES: html = html.replace('href="%s.dc.html"' % p, 'href="/bin/view/%s/"' % p) html = html.replace('href="https://starshipos.org"', 'href="%s"' % ORG) html = html.replace(">starshipos.org", ">starshipos-f18.org") html = html.replace("on starshipos.org.", "on starshipos-f18.org.") for blob, name in IMAGES.items(): html = html.replace('src="%s"' % blob, 'src="/bin/download/Main/WebHome/%s"' % name) html = html.replace("min-height: 100vh", "min-height: 0") # inside the wiki's page, not a screen return html def try_it(html): start = html.index('
", html.index("[LIVE CONSOLE]")) + len("

") return html[:start] + CONSOLE + html[end:] def forms(html, page): if page == "Main": html = html.replace('
', '') html = html.replace('', '\n' '
', 1) for i, n in (("q-name", "name"), ("q-email", "email"), ("q-org", "organization"), ("q-topic", "topic"), ("q-msg", "message"), ("q-list", "announcements")): html = html.replace('id="%s"' % i, 'id="%s" name="%s"' % (i, n), 1) html = html.replace('