shots.sh wiki draws the wiki's images, a 1600x900 gallery too
The wiki's guide shots came from TestShot with no command to make them, and the wiki now has a gallery of every screen: shots.sh wiki renders both into a wiki checkout, render.py fits an image into an exact WxH, and the gallery's empty screens get sample data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd4dcb7be6
commit
74189928a9
3 files changed
+172
-64
No files matched your search
+144
-56
@@ -30,64 +30,15 @@ func TestShot(t *testing.T) {
|
||||
}{
|
||||
{"users", openUsers},
|
||||
{"dashboard", openDashboard},
|
||||
// The README's map: the sample swarm with more nodes across Iran.
|
||||
{"host-map", func(a *App) {
|
||||
openHostMap(a)
|
||||
hs := a.cur().(*hostScreen)
|
||||
ip := netip.MustParseAddr
|
||||
for i, p := range []struct {
|
||||
addr string
|
||||
ms time.Duration
|
||||
sent, in, out float64
|
||||
}{
|
||||
{"2.180.0.1", 62, 7e9, 0, 4e6}, {"2.182.32.1", 55, 5e9, 0, 2e6}, {"2.182.214.1", 48, 4e9, 3e5, 1e6},
|
||||
{"2.182.169.1", 30, 3e9, 0, 0}, {"2.183.156.1", 70, 2e9, 2e6, 0}, {"2.183.80.1", 38, 2e9, 0, 5e5},
|
||||
{"2.184.160.1", 90, 1e9, 0, 0}, {"2.181.112.1", 110, 8e8, 1e6, 0}, {"2.183.131.1", 75, 6e8, 0, 0},
|
||||
{"2.187.32.1", 66, 4e8, 0, 3e5}, {"2.183.0.1", 58, 3e8, 0, 0},
|
||||
} {
|
||||
id := string(rune('e' + i))
|
||||
hs.stats.PeerList = append(hs.stats.PeerList, deploy.Peer{ID: id, Addr: ip(p.addr), Sent: int64(p.sent), Latency: p.ms * time.Millisecond, Inbound: i%3 == 0})
|
||||
if p.in+p.out > 0 {
|
||||
hs.rates[id] = peerRate{in: p.in, out: p.out}
|
||||
hs.peerHist[id] = []float64{p.out / 2, p.in + p.out, (p.in + p.out) * 0.8}
|
||||
}
|
||||
}
|
||||
hs.stats.Peers = len(hs.stats.PeerList)
|
||||
hs.ripples = append(hs.ripples, ripple{addr: ip("2.183.80.1"), start: 0.2, join: true})
|
||||
}},
|
||||
{"host-map", openSwarm},
|
||||
// The wiki's guide, on the Friends & family preset.
|
||||
{"wiki-confirm", func(a *App) {
|
||||
a.cfg.Target = config.Target{Mode: "ssh", Host: "192.0.2.1", User: "root"}
|
||||
a.jump(a.index("Review"))
|
||||
rs := a.cur().(*reviewScreen)
|
||||
rs.checking, rs.verbose, rs.confirm = false, true, true
|
||||
rs.checks = []deploy.Finding{
|
||||
{Group: "Server", Name: "Connect", Detail: "root@192.0.2.1, Debian 12, 4 CPUs, 8 GB RAM"},
|
||||
{Group: "DNS", Name: "matrix.example.org", Service: "Synapse", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "element.example.org", Service: "Element Web", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "sable.example.org", Service: "Sable", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "call.element.example.org", Service: "Element Call", Detail: "192.0.2.1"},
|
||||
{Group: "Federation", Name: "example.org", Detail: ".well-known/matrix/server points at matrix.example.org:443"},
|
||||
}
|
||||
}},
|
||||
{"wiki-confirm", openConfirm},
|
||||
{"wiki-deploy", func(a *App) { fakeDeploy(a, false) }},
|
||||
{"wiki-deployed", func(a *App) { fakeDeploy(a, true) }},
|
||||
{"wiki-manage", func(a *App) {
|
||||
a.jump(a.index("Manage"))
|
||||
a.health = &deploy.Health{Up: true, Trusted: true, CertLeft: 89 * 24 * time.Hour}
|
||||
}},
|
||||
{"wiki-manage", openManage},
|
||||
{"wiki-dashboard", openDashboard},
|
||||
{"wiki-backups", func(a *App) {
|
||||
a.jump(a.index("Backups"))
|
||||
a.cur().(*backupsScreen).form.get("on").on = true
|
||||
}},
|
||||
{"wiki-alerts", func(a *App) {
|
||||
a.jump(a.index("Alerts"))
|
||||
f := a.cur().(*alertsScreen).form
|
||||
f.get("on").on = true
|
||||
f.get("format").choice = 2
|
||||
f.get("room").input.SetValue("#alerts:example.org")
|
||||
}},
|
||||
{"wiki-backups", openBackups},
|
||||
{"wiki-alerts", openAlerts},
|
||||
}
|
||||
// The wiki's component pages: each category's tab, and its settings.
|
||||
for i, ids := range [][]string{
|
||||
@@ -129,10 +80,88 @@ func TestShot(t *testing.T) {
|
||||
}
|
||||
}})
|
||||
}
|
||||
// The wiki's gallery: a tour of the app, drawn 142x34 to fit 1600x900.
|
||||
for _, g := range []struct {
|
||||
name string
|
||||
open func(*App)
|
||||
}{
|
||||
{"welcome", func(a *App) {}},
|
||||
{"server", func(a *App) { a.jump(a.index("Server")) }},
|
||||
{"homeserver", func(a *App) { a.jump(a.index("Homeserver")) }},
|
||||
{"components", func(a *App) { a.jump(a.index("Components")) }},
|
||||
{"settings", func(a *App) { a.jump(a.index("Settings")) }},
|
||||
{"review", openConfirm},
|
||||
{"deploy", func(a *App) { fakeDeploy(a, false) }},
|
||||
{"deployed", func(a *App) { fakeDeploy(a, true) }},
|
||||
{"manage", openManage},
|
||||
{"keys", func(a *App) { openManage(a); a.sheetOpen = true }},
|
||||
{"dashboard", openDashboard},
|
||||
{"users", openUsers},
|
||||
{"rooms", openRooms},
|
||||
{"tokens", openTokens},
|
||||
{"updates", func(a *App) {
|
||||
a.jump(a.index("Updates"))
|
||||
deliver(a, changesMsg{ch: &deploy.Changes{From: "7dbe652020aa", To: "86ebd3b5b5cc", Total: 23,
|
||||
Notices: []deploy.Notice{
|
||||
{Date: "2026-10-21", Title: "Synapse now needs PostgreSQL 15 or newer", Body: "Upgrade Postgres before updating: Manage › Upgrade Postgres does it for you.", Yours: []string{"Synapse"}},
|
||||
{Date: "2026-10-12", Title: "Jitsi moves to its stable-10314 release"},
|
||||
},
|
||||
Versions: []deploy.VersionChange{
|
||||
{Name: "matrix_synapse_version", Old: "v1.139.2", New: "v1.140.0"},
|
||||
{Name: "matrix_client_element_version", Old: "v1.12.1", New: "v1.12.3"},
|
||||
{Name: "matrix_element_call_version", Old: "v0.16.1", New: "v0.17.0"},
|
||||
{Name: "matrix_ketesa_version", New: "v0.4.0"},
|
||||
},
|
||||
Commits: []deploy.Commit{
|
||||
{Hash: "86ebd3b5b5", Date: "2026-10-28", Subject: "Upgrade Synapse (v1.139.2 -> v1.140.0)"},
|
||||
{Hash: "41c9e07a12", Date: "2026-10-27", Subject: "Upgrade Element Web (v1.12.1 -> v1.12.3)"},
|
||||
{Hash: "b03e5f8d44", Date: "2026-10-25", Subject: "Upgrade Element Call (v0.16.1 -> v0.17.0)"},
|
||||
{Hash: "9a7d21c6e0", Date: "2026-10-24", Subject: "Add Ketesa admin panel role"},
|
||||
}}})
|
||||
}},
|
||||
{"rollback", func(a *App) {
|
||||
a.jump(a.index("Rollback"))
|
||||
day := time.Date(2026, 10, 28, 4, 12, 0, 0, time.UTC)
|
||||
a.cur().(*historyScreen).list = []deploy.Deploy{
|
||||
{Time: day, Commit: "86ebd3b5b5cc", Subject: "Upgrade Synapse (v1.139.2 -> v1.140.0)", Version: "v0.5.43", Domain: "example.org", Homeserver: "synapse", Components: 6},
|
||||
{Time: day.AddDate(0, 0, -9), Commit: "7dbe652020aa", Subject: "Upgrade Element Web (v1.12.0 -> v1.12.1)", Version: "v0.5.41", Domain: "example.org", Homeserver: "synapse", Components: 6},
|
||||
{Time: day.AddDate(0, 0, -30), Commit: "c4f19a0b77de", Subject: "Upgrade Coturn (4.6.3 -> 4.7.0)", Version: "v0.5.36", Domain: "example.org", Homeserver: "synapse", Components: 5},
|
||||
}
|
||||
}},
|
||||
{"backups", openBackups},
|
||||
{"restore", func(a *App) {
|
||||
a.jump(a.index("Restore"))
|
||||
day := time.Date(2026, 10, 30, 3, 0, 0, 0, time.UTC)
|
||||
for i, size := range []int64{412 << 20, 409 << 20, 397 << 20, 371 << 20} {
|
||||
at := day.AddDate(0, 0, -i*7)
|
||||
a.cur().(*restoreScreen).list = append(a.cur().(*restoreScreen).list, deploy.LocalBackup{
|
||||
Path: "/home/demo/.local/share/interzone/backups/example.org/" + at.Format("2006-01-02-1504") + ".sql.gz", Time: at, Size: size})
|
||||
}
|
||||
}},
|
||||
{"alerts", openAlerts},
|
||||
{"maintenance", func(a *App) { deliver(a, maintainMsg("vacuum")) }},
|
||||
{"tuning", func(a *App) { // the roles of INTERZONE_PLAYBOOK, as shots.sh sets it
|
||||
a.cfg.PlaybookDir = os.Getenv("INTERZONE_PLAYBOOK")
|
||||
a.jump(a.index("Tuning"))
|
||||
}},
|
||||
{"servers", func(a *App) { a.jump(a.index("Servers")) }},
|
||||
{"move", func(a *App) { a.jump(a.index("Move")) }},
|
||||
{"mirrors", openMirrors},
|
||||
{"test", openTest},
|
||||
{"host-map", openSwarm},
|
||||
} {
|
||||
shots = append(shots, struct {
|
||||
name string
|
||||
open func(*App)
|
||||
}{"gallery-" + g.name, g.open})
|
||||
}
|
||||
for _, s := range shots {
|
||||
a := demoApp(t, 120, 36)
|
||||
if strings.HasPrefix(s.name, "gallery-") {
|
||||
a = demoApp(t, 142, 34)
|
||||
}
|
||||
a.cfg.Sources.Blackout = true // like the other shots
|
||||
if strings.HasPrefix(s.name, "wiki-") {
|
||||
if strings.HasPrefix(s.name, "wiki-") || strings.HasPrefix(s.name, "gallery-") {
|
||||
t.Setenv("XDG_CONFIG_HOME", "/home/demo/.config")
|
||||
a.cfg.Sources.Blackout = false
|
||||
a.cfg.Components = map[string]bool{}
|
||||
@@ -143,7 +172,7 @@ func TestShot(t *testing.T) {
|
||||
lipgloss.SetColorProfile(termenv.TrueColor)
|
||||
lipgloss.SetHasDarkBackground(true)
|
||||
s.open(a)
|
||||
if strings.HasPrefix(s.name, "wiki-") {
|
||||
if strings.HasPrefix(s.name, "wiki-") || strings.HasPrefix(s.name, "gallery-") {
|
||||
a.status = "" // the demo's home can't be saved to
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, s.name+".ans"), []byte(a.View()+"\n"), 0o644); err != nil {
|
||||
@@ -154,6 +183,65 @@ func TestShot(t *testing.T) {
|
||||
localMirror.Store(false)
|
||||
}
|
||||
|
||||
// openSwarm is the README's map: the sample swarm with more nodes across Iran.
|
||||
func openSwarm(a *App) {
|
||||
openHostMap(a)
|
||||
hs := a.cur().(*hostScreen)
|
||||
ip := netip.MustParseAddr
|
||||
for i, p := range []struct {
|
||||
addr string
|
||||
ms time.Duration
|
||||
sent, in, out float64
|
||||
}{
|
||||
{"2.180.0.1", 62, 7e9, 0, 4e6}, {"2.182.32.1", 55, 5e9, 0, 2e6}, {"2.182.214.1", 48, 4e9, 3e5, 1e6},
|
||||
{"2.182.169.1", 30, 3e9, 0, 0}, {"2.183.156.1", 70, 2e9, 2e6, 0}, {"2.183.80.1", 38, 2e9, 0, 5e5},
|
||||
{"2.184.160.1", 90, 1e9, 0, 0}, {"2.181.112.1", 110, 8e8, 1e6, 0}, {"2.183.131.1", 75, 6e8, 0, 0},
|
||||
{"2.187.32.1", 66, 4e8, 0, 3e5}, {"2.183.0.1", 58, 3e8, 0, 0},
|
||||
} {
|
||||
id := string(rune('e' + i))
|
||||
hs.stats.PeerList = append(hs.stats.PeerList, deploy.Peer{ID: id, Addr: ip(p.addr), Sent: int64(p.sent), Latency: p.ms * time.Millisecond, Inbound: i%3 == 0})
|
||||
if p.in+p.out > 0 {
|
||||
hs.rates[id] = peerRate{in: p.in, out: p.out}
|
||||
hs.peerHist[id] = []float64{p.out / 2, p.in + p.out, (p.in + p.out) * 0.8}
|
||||
}
|
||||
}
|
||||
hs.stats.Peers = len(hs.stats.PeerList)
|
||||
hs.ripples = append(hs.ripples, ripple{addr: ip("2.183.80.1"), start: 0.2, join: true})
|
||||
}
|
||||
|
||||
func openConfirm(a *App) {
|
||||
a.cfg.Target = config.Target{Mode: "ssh", Host: "192.0.2.1", User: "root"}
|
||||
a.jump(a.index("Review"))
|
||||
rs := a.cur().(*reviewScreen)
|
||||
rs.checking, rs.verbose, rs.confirm = false, true, true
|
||||
rs.checks = []deploy.Finding{
|
||||
{Group: "Server", Name: "Connect", Detail: "root@192.0.2.1, Debian 12, 4 CPUs, 8 GB RAM"},
|
||||
{Group: "DNS", Name: "matrix.example.org", Service: "Synapse", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "element.example.org", Service: "Element Web", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "sable.example.org", Service: "Sable", Detail: "192.0.2.1"},
|
||||
{Group: "DNS", Name: "call.element.example.org", Service: "Element Call", Detail: "192.0.2.1"},
|
||||
{Group: "Federation", Name: "example.org", Detail: ".well-known/matrix/server points at matrix.example.org:443"},
|
||||
}
|
||||
}
|
||||
|
||||
func openManage(a *App) {
|
||||
a.jump(a.index("Manage"))
|
||||
a.health = &deploy.Health{Up: true, Trusted: true, CertLeft: 89 * 24 * time.Hour}
|
||||
}
|
||||
|
||||
func openBackups(a *App) {
|
||||
a.jump(a.index("Backups"))
|
||||
a.cur().(*backupsScreen).form.get("on").on = true
|
||||
}
|
||||
|
||||
func openAlerts(a *App) {
|
||||
a.jump(a.index("Alerts"))
|
||||
f := a.cur().(*alertsScreen).form
|
||||
f.get("on").on = true
|
||||
f.get("format").choice = 2
|
||||
f.get("room").input.SetValue("#alerts:example.org")
|
||||
}
|
||||
|
||||
// fakeDeploy shows a first install part way through, or finished, without
|
||||
// starting one: entering the Deploy screen would.
|
||||
func fakeDeploy(a *App, finished bool) {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# render.py IN.ans OUT.png [WIDTH]
|
||||
# render.py IN.ans OUT.png [WIDTH | WIDTHxHEIGHT]
|
||||
# Draws a tmux "capture-pane -e" dump as a terminal window. With WIDTH the
|
||||
# image is scaled to that many pixels and reduced to 256 colours, as the
|
||||
# README's screenshots are.
|
||||
# README's screenshots are; with WIDTHxHEIGHT it is fitted into exactly
|
||||
# that size, centred on black (the wiki's gallery is 1600x900).
|
||||
# render.py --join OUT.png A.png B.png …
|
||||
# Puts already rendered windows side by side (docs/screenshots/phone.png).
|
||||
#
|
||||
# Needs Pillow, fontTools and the DejaVu and Noto symbol fonts.
|
||||
import glob, os, re, sys, unicodedata
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
||||
from fontTools.ttLib import TTFont
|
||||
|
||||
def font(name):
|
||||
@@ -69,7 +70,10 @@ def draw_emoji(img, ch, px, py):
|
||||
img.paste(e, (px + (2 * CW - e.width) // 2, py + 3), e)
|
||||
|
||||
def finish(img, out, width=None):
|
||||
if width:
|
||||
if width and "x" in width:
|
||||
img = ImageOps.pad(img.convert("RGB"), tuple(map(int, width.split("x"))), Image.LANCZOS, color=(0, 0, 0))
|
||||
elif width:
|
||||
width = int(width)
|
||||
img = img.resize((width, round(img.height * width / img.width)), Image.LANCZOS)
|
||||
img = img.convert("RGB").quantize(256, dither=Image.Dither.NONE)
|
||||
img.save(out, optimize=True)
|
||||
@@ -82,7 +86,7 @@ if sys.argv[1] == "--join":
|
||||
x = 0
|
||||
for p in parts:
|
||||
out.paste(p, (x, 0)); x += p.width + GAP
|
||||
finish(out, sys.argv[2], 1400) # as wide as the other shots
|
||||
finish(out, sys.argv[2], "1400") # as wide as the other shots
|
||||
sys.exit()
|
||||
|
||||
lines = open(sys.argv[1], encoding="utf-8").read().rstrip("\n").split("\n")
|
||||
@@ -143,4 +147,4 @@ for y, row in enumerate(cells):
|
||||
draw_emoji(img, ch, px, py); continue
|
||||
d.text((px, py + 1), ch, font=font_for(ch, b), fill=fg)
|
||||
bg = Image.new("RGBA", img.size, (0, 0, 0, 255))
|
||||
finish(Image.alpha_composite(bg, img), sys.argv[2], int(sys.argv[3]) if len(sys.argv) > 3 else None)
|
||||
finish(Image.alpha_composite(bg, img), sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
|
||||
@@ -12,6 +12,9 @@
|
||||
# scripts/screenshots/shots.sh phone A B C join three phone shots into phone.png
|
||||
# scripts/screenshots/shots.sh users draw users.png, dashboard.png and host-map.png
|
||||
# from the layout tests' sample data (no server needed)
|
||||
# scripts/screenshots/shots.sh wiki DIR draw the wiki's images from the same sample data into
|
||||
# DIR/images: the guides' (wiki-*) and the gallery's
|
||||
# (gallery/, 1600x900); the guides' live shots are taken by hand
|
||||
# scripts/screenshots/shots.sh stop
|
||||
#
|
||||
# Drive the session between grabs with tmux send-keys or tmux attach -t shot.
|
||||
@@ -82,6 +85,19 @@ users() {
|
||||
done
|
||||
}
|
||||
|
||||
wiki() {
|
||||
mkdir -p "$work/raw" "$1/images/gallery"
|
||||
(cd "$repo" && INTERZONE_PLAYBOOK="$playbook" INTERZONE_SHOT="$work/raw" go test ./internal/ui -run '^TestShot$' -count=1 >/dev/null)
|
||||
for f in "$work"/raw/wiki-*.ans; do
|
||||
n=$(basename "$f" .ans)
|
||||
python3 "$repo/scripts/screenshots/render.py" "$f" "$1/images/${n#wiki-}.png" 1400
|
||||
done
|
||||
for f in "$work"/raw/gallery-*.ans; do
|
||||
n=$(basename "$f" .ans)
|
||||
python3 "$repo/scripts/screenshots/render.py" "$f" "$1/images/gallery/${n#gallery-}.png" 1600x900
|
||||
done
|
||||
}
|
||||
|
||||
stop() {
|
||||
tmux kill-session -t shot 2>/dev/null || true
|
||||
}
|
||||
@@ -193,12 +209,12 @@ all() {
|
||||
|
||||
cmd=${1:-}
|
||||
case $cmd in
|
||||
start | grab | phone | users | stop | all)
|
||||
start | grab | phone | users | wiki | stop | all)
|
||||
shift
|
||||
"$cmd" "$@"
|
||||
;;
|
||||
*)
|
||||
sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'
|
||||
sed -n '2,25p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user