Story 006: the search as you type on the front page, over the lives on i.bytestone.org (#26)
life-weaver's kinship.wasm loaded from the site of lives, named in data-lives on the form; each match a link there; the form hands the name on as before without script. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
779e4724dc
commit
ffb865876a
5 changed files with 86 additions and 3 deletions
|
|
@ -2,13 +2,16 @@ version: "3"
|
|||
|
||||
tasks:
|
||||
check:
|
||||
desc: The front and about pages say what stories 002, 003, 004 and 005 ask, Dan Briggs's memorial is byte for byte as mirrored, no file name carries a query string
|
||||
desc: The front and about pages say what stories 002 to 006 ask, Dan Briggs's memorial is byte for byte as mirrored, no file name carries a query string
|
||||
cmds:
|
||||
- grep -q 'class="count"' site/index.html && grep -q 'data-count' site/index.html
|
||||
- grep -q 'class="memorial"' site/index.html && grep -q 'class="recent"' site/index.html && grep -q 'data-recent' site/index.html
|
||||
- grep -q "'kin.json'" site/index.html
|
||||
- grep -q 'action="https://i.bytestone.org/"' site/index.html
|
||||
- grep -q 'name="q"' site/index.html
|
||||
- grep -q 'data-lives="https://i.bytestone.org/"' site/index.html && grep -q 'id="results"' site/index.html
|
||||
- grep -q 'src="https://i.bytestone.org/wasm_exec.js"' site/index.html && grep -q "'kinship.wasm'" site/index.html
|
||||
- grep -q '\.results' site/style.css
|
||||
- grep -q 'href="/w/dbriggs/' site/index.html
|
||||
- grep -q 'href="https://i.bytestone.org/"' site/index.html
|
||||
- grep -q '2010' site/about.html
|
||||
|
|
|
|||
1
changes/26.added.md
Normal file
1
changes/26.added.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
The front page's search box searches as you type, life-weaver's search loaded from i.bytestone.org and each match a link to the person's page there; the form hands the name on as before without script
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
# 006 — The search as you type on the front page, over the lives on i.bytestone.org (#26)
|
||||
|
||||
**Status:** proposed
|
||||
**Roadmap:** #3
|
||||
|
||||
## Why
|
||||
|
||||
The front page's search box is a form: typing does nothing until
|
||||
Enter or the button, which hands the name to i.bytestone.org, where
|
||||
life-weaver's search lists matches as you type. A visitor expects the
|
||||
www box to do what the i box does. The settled model (CLAUDE.md) has
|
||||
www as the interactive layer, search included, over the records on i;
|
||||
life-weaver story 025 lets its search run on a page elsewhere, over
|
||||
the site that page names.
|
||||
|
||||
## What changes
|
||||
|
||||
- `site/index.html`: the search form names the site of lives,
|
||||
`data-lives="https://i.bytestone.org/"`, and keeps its `action`
|
||||
and button as the fallback. An `<ol id="results">` follows it. A
|
||||
script loads `wasm_exec.js` and `kinship.wasm` from the site of
|
||||
lives; once the wasm runs, the form's submit is stopped and its
|
||||
button hidden, and the box searches as you type, each match a link
|
||||
to the person's page on i. The count script reads `kin.json` from
|
||||
the same `data-lives`.
|
||||
- `site/style.css`: the results list, as the site of lives styles it,
|
||||
in this site's palette; the button hidden once the search is live.
|
||||
- `task check`: the greps below.
|
||||
|
||||
## Acceptance
|
||||
|
||||
| Request or check | Outcome |
|
||||
|---|---|
|
||||
| `/` with script, i.bytestone.org reachable | typing `dru` lists the Drummonds under the box, each an `<a href="https://i.bytestone.org/<id>/">`; the Search button is hidden; Enter does not leave the page |
|
||||
| `/?q=dru` with script | the same list on landing |
|
||||
| `/` without script, or the wasm not loaded | the form as before: Enter or Search hands the name to `https://i.bytestone.org/?q=…`, which searches it (life-weaver story 021) |
|
||||
| `/` | `data-lives="https://i.bytestone.org/"`, `id="results"`, `wasm_exec.js` and `kinship.wasm` loaded from i.bytestone.org; the count and newest lives as story 003 |
|
||||
| `/w/dbriggs/` | byte for byte as mirrored |
|
||||
|
||||
## Out of scope
|
||||
|
||||
- A preview of www searching i.bytestone.uk: the one attribute, when
|
||||
wanted.
|
||||
- The kinship overlay: it belongs to the site's own front page, which
|
||||
has a featured life.
|
||||
- life-weaver building this page: the model's end state, not yet.
|
||||
|
||||
## Decisions
|
||||
|
||||
none
|
||||
|
||||
## Done when
|
||||
|
||||
- [ ] `task check` passes
|
||||
- [ ] the acceptance table holds on www.bytestone.org
|
||||
- [ ] changelog entry
|
||||
- [ ] issue closed with a link to the release
|
||||
|
|
@ -19,13 +19,14 @@
|
|||
<p class="count"><a href="https://i.bytestone.org/"><strong data-count>The lives</strong></a> on record at i.bytestone.org, a record and a life history for each person, one page each.</p>
|
||||
|
||||
<section class="search">
|
||||
<form role="search" action="https://i.bytestone.org/" method="get">
|
||||
<form role="search" action="https://i.bytestone.org/" method="get" data-lives="https://i.bytestone.org/">
|
||||
<label for="q">Find a person</label>
|
||||
<div class="row">
|
||||
<input type="search" id="q" name="q" placeholder="A name" autocomplete="off" spellcheck="false">
|
||||
<button type="submit">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
<ol id="results" class="results"></ol>
|
||||
</section>
|
||||
|
||||
<div class="columns">
|
||||
|
|
@ -53,7 +54,7 @@
|
|||
// The count and the newest lives, read from the site of lives (story 003).
|
||||
// Without script, or if kin.json cannot be read, the written text stands.
|
||||
(async () => {
|
||||
const site = document.querySelector('form[role=search]').action;
|
||||
const site = document.querySelector('form[role=search]').dataset.lives;
|
||||
const r = await fetch(site + 'kin.json').catch(() => null);
|
||||
if (!r || !r.ok) return;
|
||||
const kin = await r.json();
|
||||
|
|
@ -81,5 +82,21 @@
|
|||
list.hidden = n === 0;
|
||||
})();
|
||||
</script>
|
||||
<script src="https://i.bytestone.org/wasm_exec.js"></script>
|
||||
<script>
|
||||
// The search as you type: life-weaver's kinship.wasm, loaded from the site
|
||||
// of lives, over its name shards (story 006). Until it runs, and without
|
||||
// script, the form hands the name to that site.
|
||||
(async () => {
|
||||
const form = document.querySelector('form[role=search]');
|
||||
if (typeof Go === 'undefined') return;
|
||||
const go = new Go();
|
||||
const r = await WebAssembly.instantiateStreaming(fetch(form.dataset.lives + 'kinship.wasm'), go.importObject).catch(e => { console.error('kinship.wasm:', e); });
|
||||
if (!r) return;
|
||||
form.addEventListener('submit', e => e.preventDefault());
|
||||
form.classList.add('live');
|
||||
go.run(r.instance);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ h2 { font-size: 1.3rem; border-bottom: 1px solid var(--rule); padding-bottom: .2
|
|||
.search .row { display: flex; gap: .5rem; }
|
||||
.search input { flex: 1; min-width: 0; font: inherit; font-size: 1.1rem; padding: .5rem .75rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); color: var(--ink); }
|
||||
.search button { font: inherit; font-size: 1rem; padding: .5rem 1rem; border: 1px solid var(--link); border-radius: 4px; background: var(--link); color: var(--paper); cursor: pointer; }
|
||||
.search form.live button { display: none; }
|
||||
.results { list-style: none; padding: 0; margin: .5rem 0 0; }
|
||||
.results li { padding: .4rem 0; border-bottom: 1px solid var(--rule); }
|
||||
.results li.none { color: var(--muted); border: 0; }
|
||||
.results .summary { font-size: .95rem; margin: 0; color: var(--muted); }
|
||||
.hint { font-size: .95rem; color: var(--muted); margin: .5rem 0 0; }
|
||||
|
||||
.card { display: flex; gap: 1.5rem; align-items: flex-start; padding: 1rem 1.25rem; background: var(--panel); border: 1px solid var(--rule); border-radius: 4px; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue