hex/site/scripts/iphone.ts
Ryan Vogel 6b551f7cd3 Site: /hex/android, a page for Hex for Android with Hex Preview's download
Hex Preview (the Android build outside Google Play, published today as
android-preview-2305) had only a GitHub README as its download page: on a
phone the link sits under GitHub's own bars. Ryan asked for a served page at
anoma.ly/hex/android that mirrors the iPhone one.

Added:
- /hex/android (src/iphone.ts renderAndroid, written by scripts/iphone.ts with
  its social card and sitemap entry): the iPhone page's look and structure,
  with a Download Hex Preview button, the install steps, how updates work,
  questions, and help. Its labels and numbers are the Android app's own
  (Get started, Allow from this source, the 190 MB model, Android 12, hold the
  Hex key, Check for updates automatically).
- /hex/download/android (worker.ts): a 302 to the APK that latest.json on the
  android-preview branch names, so the button follows every new build without
  a site deploy. It redirects only to this repository's
  releases/download/android-preview-* files and answers 404 or 502 in plain
  text otherwise.
- Privacy policy, Hex for Android section: one item for Hex Preview's update
  check and update download (the same statement the app's own privacy text
  makes), a link to the Android page, and the policy's date.

Nothing is removed. The iPhone page is unchanged.

Verified: bun test in site/ (15 pass, two new cases in worker.test.ts for the
redirect, its refusal of another origin, and the unpublished case);
bun run build --mode dev (typecheck, 3 pages written); the built page and
card viewed at phone and desktop widths in Chrome, no horizontal overflow.
The redirect against the real branch is checked on dev.anoma.ly after the
deploy.
2026-11-23 12:25:51 -05:00

32 lines
2.1 KiB
TypeScript

// Writes the Hex for iPhone pages into the built site: iphone.html
// (/hex/iphone, the App Store support URL), privacy.html (/hex/privacy, its
// privacy policy URL), and android.html (/hex/android, Hex Preview's download
// and setup), a social card beside each (scripts/card.ts), and all three
// in the sitemap.
//
// bun scripts/iphone.ts --mode dev
import { getWorkerAssetsDir } from "@cloudflare/build-output-utils"
import { readFileSync, writeFileSync } from "node:fs"
import { join, resolve } from "node:path"
import { parseArgs } from "node:util"
import { originForMode } from "../src/base"
import { ANDROID_PATH, CARDS, IPHONE_PATH, PRIVACY_PATH, renderAndroid, renderIphone, renderPrivacy } from "../src/iphone"
import { card } from "./card"
const { values } = parseArgs({ options: { mode: { type: "string" }, out: { type: "string" } } })
const origin = originForMode(values.mode)
const assets = values.out ?? getWorkerAssetsDir(resolve(import.meta.dirname, ".."))
const address = (path: string) => `${origin.replace("https://", "")}${path.slice("/hex".length)}`
const site = (path: string) => join(assets, path.slice("/hex/".length))
writeFileSync(site(`${IPHONE_PATH}.html`), renderIphone(origin))
writeFileSync(site(`${IPHONE_PATH}.png`), await card("Hex for iPhone", CARDS.iphone.title, CARDS.iphone.line, address(IPHONE_PATH)))
writeFileSync(site(`${PRIVACY_PATH}.html`), renderPrivacy(origin))
writeFileSync(site(`${PRIVACY_PATH}.png`), await card("Hex for iPhone", CARDS.privacy.title, CARDS.privacy.line, address(PRIVACY_PATH)))
writeFileSync(site(`${ANDROID_PATH}.html`), renderAndroid(origin))
writeFileSync(site(`${ANDROID_PATH}.png`), await card("Hex for Android", CARDS.android.title, CARDS.android.line, address(ANDROID_PATH)))
const sitemap = join(assets, "sitemap.xml")
const urls = [IPHONE_PATH, PRIVACY_PATH, ANDROID_PATH].map((path) => ` <url><loc>${origin}${path.slice("/hex".length)}</loc></url>`)
writeFileSync(sitemap, readFileSync(sitemap, "utf8").replace("</urlset>", `${urls.join("\n")}\n</urlset>`))
console.log("iPhone and Android: 3 pages (iphone, privacy, android).")