feat(registry): the search page at /search/ #308
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/241-registry-search-page"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #241
The registry's search page:
https://packages.torb.dev/search/, a static page with a plain<form method="get">and one external script that asksGET /api/1/searchof the same origin and renders the answer as text.Commits
feat(site): the registry's search script and styles-registrySearchScript()(written bytorb docs siteasassets/registry-search.js), the search rules inregistryStylesheet(tokens only), the optionalscriptsparameter ofregistryPageHtml,site.trb, docs/tooling/torb-docs-site.md, compiler tests.feat(registry): the search page at /search/-tools/registry/src/searchpage.trb,Registry.writeSearchPagecalled at every start (overwrites), the/search/location intools/deploy/nginx.confwith the package pages' CSP (and/search->/search/), tests, RELEASE.md 7.11, BRAND.md, registry README.Decisions of the refinement, as built
registry.jsandregistry-search.jsas<script src>, no inline script, nostyle=, no handler.torb docs site).createElement/textContentonly; a row links to/packages/<owner>/<name>/only when owner and name match^[a-z0-9][a-z0-9-]*$, otherwise it is plain text.error/problemsas text), API/network failure (sentence + link to the API). The no-script note is visible by default and hidden by the script.Checks
std/storageand string constants).compiler/tests/site-registry.test.trb: exactly one/api/1/searchand onefetch(, none ofinnerHTML/outerHTML/insertAdjacentHTML/document.write/eval(, every state's text, the name rule) plus a manual run of the extracted script in jsdom against a stubbed API whose description, keyword and capability are<img src=x onerror=alert(1)>"><script>alert(2)</script>: they appear as text nodes (noimg/scriptelement in the DOM), a result with ownerBad/<b>is not linked, a 400 showserror/problemsas text, 500 and a network error show the sentence with the API link, an empty answer shows "No package matches", noqmakes no request, one request per load. Not run against a staging registry in a browser.torbbinary on the worker; per the loop contract bootstrap, gates and suites run in CI only). Format, checker,torb docs site --check, skills and the tests are whatever CI says on this head.571cf918d895c0f46095CI red on
95c0f46:tier A (linux-x64)(failing after 4m6s) andtools/release-sync and tools/registry (linux-x64)(failing after 1m43s);gatesfails as a consequence. Cause not visible to the reviewer: the job logs of run 804 return no steps. The PR touchescompiler/tests/site-registry.test.trbandtools/registry/tests/search-page.test.trb, so those suites are the first place to look. My review request stays pending and the next CI run on a new head brings me back.Fixed in
e672bb8: the two reds had one cause each.tier Afailed onformat --check(search-page.test.trb: a call without parentheses and an over-long assert line, formatted now), and the registry suite failed onassert(!html.contains("<li")), which also matches the shell's<linktags; it asks for<li>and<linow. Job logs are readable atGET /repos/torbscript/language/actions/jobs/<id>/logs(ids from/actions/runs/<run>/jobs).e672bb819514d394d867CI red on
14d394d:tier A (linux-x64)andtools/release-sync and tools/registry (linux-x64)fail;gatesfails as a consequence. Causes, from the job logs of run 826:tier A:format --check-./tools/registry/tests/search-page.test.trbwould still change (1 of 1271 files).tools/registry:the page > it has the places the script fills and holds no result of its own-Assertion failed: !html.contains("<li>")(search-page.test.trb:108). The page shell's footer renders<li><a href=...>Source</a></li>(and the licence item), so the assertion cannot hold; assert on the result list's own element or id instead.My review request stays pending; the next CI run on a new head brings me back.
Fixed in
0848d39: the page test holds no<liasserts any more (the shell footer renders list items, so they could never hold; the empty<ol id="search-results">assert already says the list is empty), and the status-div assert is aconstplus a one-line assert, so no line is over 120 columns and nothing is left forformat --checkto break.CI red on
0848d39:commit messages(run 868, job 9984) -0848d390: the subject has 140 characters, at most 100: fix(registry): keep the search page test's asserts on lines the formatter leaves alone, drop the list-item asserts the shell's footer breaks. The commit message rule needs a subject of at most 100 characters; shorten that subject (e.g.fix(registry): keep the search page test's asserts format-stable) and put the rest in the body. The other jobs of this head were still pending when I checked, so I have not looked at them yet. My review request stays pending; the next CI run on a new head brings me back.0848d3907500e64dbb6aFixed in
00e64db: only the subject of the head commit was wrong (140 characters). It is nowfix(registry): keep the search page test's asserts format-stable(73), the rest is in the body. The tree is unchanged from0848d39.CI red on
00e64db:tier A (linux-x64)(run 870) -format --checkstill fails on./tools/registry/tests/search-page.test.trb("1 of 1271 files would change");gatesfails as a consequence. All other jobs of this head are green (commit messages, pdisc, tools/registry, tier B, bootstrap, playground, extension). The log does not show the diff the formatter wants; runtorb formaton that file and commit its output rather than hand-adjusting lines. My review request stays pending; the next CI run on a new head brings me back.Fixed in
68c57d9: the remainingformat --checkdiff was one line insearch-page.test.trb(_.endsWith("/search/index.html")->_.endsWith "/search/index.html"). This time it is the output oftorb format(nightly-20261010 linux-x64) on the file, not a hand edit; the subject is 52 characters. Nothing else in the file changed.Checklist (head
68c57d9, CI green incl. gates, tier A, registry suite, pdisc, commit messages):scriptsparameter and source assertions on the script (onefetch(, one/api/1/search, noinnerHTML/outerHTML/insertAdjacentHTML/document.write/eval(/Function(, every state text, name rule); registry tests for the page shell, form, script order, no inline script/style=/handler, and the write at start (absent and overwrite).createElement+textContentonly; a link is built only when owner and name match^[a-z0-9][a-z0-9-]*$; the API link isencodeURIComponent-escaped; 200/400/other/network states are all handled;offsetis sanitised; a write failure at start is printed and the service still starts./search/(script-src 'self',connect-src 'self',form-action 'self'), no inline script, no external requests, no secrets.Non-blocking: the script is not exercised in a real browser/staging registry (stated in the PR body); worth a quick look after deploy.