From 01301fc5bfd064bd62901953053256d9202dda2d Mon Sep 17 00:00:00 2001 From: barkz Date: Fri, 11 Sep 2026 21:45:44 -0500 Subject: [PATCH] feat: name the tab glean_code_cli and give it a favicon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tab said "Glean Code" with the browser's blank-page icon, so the site was unidentifiable among open tabs. It now reads glean_code_cli — the command you type, matching the repository — and carries an icon. The site title is deliberately separate from the README's title now: a tab wants the command, and the hidden

keeps the product name "Glean Code" for screen readers and search engines. The header mark gains the same suffix: glean_code_cli. The icons are generated by .github/pages/make_icons.py — a ">" prompt and an "_" cursor in the wordmark's cyan on its dark plate: assets/favicon.svg every current browser, sharp at any size assets/apple-touch-icon.png 180x180, for an iOS home screen iOS home-screen icons have to be raster, and Pillow is not a dependency this repo is willing to take, so the PNG is encoded with zlib and struct: coverage per pixel from the distance to each stroke, one linear ramp for the edge, then IHDR/IDAT/IEND with crc32. The SVG carries its own rounded corners; the PNG is square because iOS masks its own. Tests: 1,094 -> 1,100, including that the committed icons match the generator, that the PNG really is a 180x180 PNG, and that the mark covers the pixels it should and leaves the plate alone where it should. Co-Authored-By: Claude Opus 5 (1M context) --- .github/pages/build.py | 9 ++- .github/pages/make_icons.py | 113 ++++++++++++++++++++++++++++++++++++ .github/pages/template.html | 4 +- CLAUDE.md | 2 +- README.md | 2 +- assets/apple-touch-icon.png | Bin 0 -> 925 bytes assets/favicon.svg | 5 ++ docs/TESTING.md | 4 +- tests/test_pages_build.py | 55 +++++++++++++++++- 9 files changed, 185 insertions(+), 9 deletions(-) create mode 100644 .github/pages/make_icons.py create mode 100644 assets/apple-touch-icon.png create mode 100644 assets/favicon.svg diff --git a/.github/pages/build.py b/.github/pages/build.py index 3663434..b8074af 100644 --- a/.github/pages/build.py +++ b/.github/pages/build.py @@ -25,6 +25,9 @@ HERE = pathlib.Path(__file__).resolve().parent REPO_URL = "https://github.com/barkz/glean-code-cli" +# What the browser tab says. Deliberately the command you type, not the prose +# title -- the hidden

below still carries the product name. +SITE_TITLE = "glean_code_cli" BLOB_URL = REPO_URL + "/blob/main/" # Directories copied next to index.html so relative image paths keep working. @@ -286,14 +289,14 @@ def build(out_dir=None, root=None): markdown = (root / "README.md").read_text(encoding="utf-8") template = (HERE / "template.html").read_text(encoding="utf-8") - title = page_title(markdown) + heading = page_title(markdown) content = render(markdown) if "" chevron and an "_" cursor. +CHEVRON = ((10.0, 10.0), (17.0, 16.0), (10.0, 22.0)) +STROKE_HALF = 1.6 +CURSOR = (18.6, 20.4, 26.0, 23.0) # x0, y0, x1, y1 + + +def svg(): + return ( + '\n' + ' \n' % PLATE + + ' \n' + % (CHEVRON[0][0], CHEVRON[0][1], CHEVRON[1][0], CHEVRON[1][1], + CHEVRON[2][0], CHEVRON[2][1], MARK[0], MARK[1], MARK[2], STROKE_HALF * 2) + + ' \n' + % (CURSOR[0], CURSOR[1], CURSOR[2] - CURSOR[0], CURSOR[3] - CURSOR[1], + MARK[0], MARK[1], MARK[2]) + + "\n" + ) + + +def _distance_to_segment(px, py, ax, ay, bx, by): + dx, dy = bx - ax, by - ay + span = dx * dx + dy * dy + t = 0.0 if span == 0 else ((px - ax) * dx + (py - ay) * dy) / span + t = max(0.0, min(1.0, t)) + cx, cy = ax + t * dx, ay + t * dy + return ((px - cx) ** 2 + (py - cy) ** 2) ** 0.5 + + +def _coverage(u, v, edge): + """How much of the pixel at grid point (u, v) the mark covers, 0..1.""" + inside_cursor = (CURSOR[0] <= u <= CURSOR[2]) and (CURSOR[1] <= v <= CURSOR[3]) + if inside_cursor: + return 1.0 + nearest = min( + _distance_to_segment(u, v, CHEVRON[0][0], CHEVRON[0][1], CHEVRON[1][0], CHEVRON[1][1]), + _distance_to_segment(u, v, CHEVRON[1][0], CHEVRON[1][1], CHEVRON[2][0], CHEVRON[2][1]), + ) + # linear ramp across one pixel for a clean edge + return max(0.0, min(1.0, (STROKE_HALF - nearest) / edge + 0.5)) + + +def png_rows(size=PNG_SIZE): + scale = size / 32.0 + edge = 1.0 / scale + rows = [] + for y in range(size): + v = (y + 0.5) / scale + row = bytearray() + for x in range(size): + u = (x + 0.5) / scale + alpha = _coverage(u, v, edge) + for channel in range(3): + base, mark = PLATE[channel], MARK[channel] + row.append(int(round(base + (mark - base) * alpha))) + rows.append(bytes(row)) + return rows + + +def _chunk(kind, payload): + return (struct.pack(">I", len(payload)) + kind + payload + + struct.pack(">I", zlib.crc32(kind + payload) & 0xFFFFFFFF)) + + +def png(size=PNG_SIZE): + raw = b"".join(b"\x00" + row for row in png_rows(size)) + return b"".join([ + b"\x89PNG\r\n\x1a\n", + _chunk(b"IHDR", struct.pack(">IIBBBBB", size, size, 8, 2, 0, 0, 0)), + _chunk(b"IDAT", zlib.compress(raw, 9)), + _chunk(b"IEND", b""), + ]) + + +def main(): + SVG_OUT.write_text(svg(), encoding="utf-8") + PNG_OUT.write_bytes(png()) + print("wrote %s and %s (%d bytes)" % (SVG_OUT.name, PNG_OUT.name, PNG_OUT.stat().st_size)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/pages/template.html b/.github/pages/template.html index 6db266f..47fa185 100644 --- a/.github/pages/template.html +++ b/.github/pages/template.html @@ -5,6 +5,8 @@ {{TITLE}} + + @@ -251,7 +253,7 @@
- glean_code + glean_code_cli