.mdeck (2/3): Whop static build with member and dashboard views, plus zip build script #131

Merged
time merged 6 commits from time/card-95-gh-pages into gh-pages 2026-10-18 07:07:43 +00:00
Showing only changes of commit 569ead4263 - Show all commits
+18 -18
View File
@@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
# Checks the Whop build: builds it, verifies the checksum, unzips it, serves it the way a static host does # Checks the Whop build: builds it, verifies the checksum, unzips it, serves it the way a static host does
# (real files and directory index.html first, 404.html for anything else) and requests the view paths. # (real files and a directory's index.html first, 404.html for anything else) and requests the view paths.
# #
# ventures/mdecks/tools/whop-check.sh # sh ventures/mdecks/tools/whop-check.sh
set -eu set -eu
here=$(cd "$(dirname "$0")" && pwd) here=$(cd "$(dirname "$0")" && pwd)
work=$(mktemp -d) work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT trap 'rm -rf "$work"' EXIT
"$here/whop-build.sh" "$work/out" sh "$here/whop-build.sh" "$work/out"
(cd "$work/out" && sha256sum -c mdeck-whop.zip.sha256) (cd "$work/out" && sha256sum -c mdeck-whop.zip.sha256)
python3 -c 'import sys, zipfile; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])' "$work/out/mdeck-whop.zip" "$work/site" python3 -c 'import sys, zipfile; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])' "$work/out/mdeck-whop.zip" "$work/site"
@@ -19,25 +19,25 @@ import http.server, os, threading, urllib.request, urllib.error
site = os.environ["SITE"] site = os.environ["SITE"]
class Static(http.server.SimpleHTTPRequestHandler): class Static(http.server.SimpleHTTPRequestHandler):
"""A static host: a real file, or a directory's index.html; anything else gets 404.html with a 404."""
def __init__(self, *a, **k): def __init__(self, *a, **k):
super().__init__(*a, directory=site, **k) super().__init__(*a, directory=site, **k)
def send_head(self): def do_GET(self):
path = self.translate_path(self.path) bare = self.path.split("?")[0]
if os.path.isdir(path) and not os.path.isfile(os.path.join(path, "index.html")): path = self.translate_path(bare)
path = None if os.path.isdir(path) and not bare.endswith("/"):
if path is None or not (os.path.isdir(path) or os.path.isfile(path)): return super().do_GET() # redirect to the slash form
self.path = "/404.html" if os.path.isdir(path):
self.send_response_only(404) # replaced below path = os.path.join(path, "index.html")
return self._fallback() if os.path.isfile(path):
return super().send_head() return super().do_GET()
def _fallback(self): with open(os.path.join(site, "404.html"), "rb") as f:
body = open(os.path.join(site, "404.html"), "rb").read() body = f.read()
self.wfile.write(b"") # status line already sent by send_response_only self.send_response(404)
self.send_header("Content-Type", "text/html") self.send_header("Content-Type", "text/html")
self.send_header("Content-Length", str(len(body))) self.send_header("Content-Length", str(len(body)))
self.end_headers() self.end_headers()
import io self.wfile.write(body)
return io.BytesIO(body)
def log_message(self, *a): def log_message(self, *a):
pass pass
@@ -67,7 +67,7 @@ for path, needle in [("/app.js", 'fetch("/SKILL.md")'), ("/whop.js", "data-view"
failed += not ok failed += not ok
status, body = get("/experiences/abc") status, body = get("/experiences/abc")
for gone in ("Get early access", "Pricing", "early-note"): for gone in ("Get early access", "Opens a public GitHub issue", "Pricing", "How it works"):
if gone in body: if gone in body:
print("public-page content left in the app: " + gone) print("public-page content left in the app: " + gone)
failed += 1 failed += 1