Give every trail a permanent number in trail-numbers.txt, and check it is only appended to
The Saved page's short links will be bit sets over these numbers, so a number must never change or be reused. The registry is one id per line, seeded alphabetically; build_index appends new records; the validator fails on a record with no line, a repeated id or a malformed line; check_history fails when an earlier line is changed, moved or removed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6440e43176
commit
358f0c4928
10 files changed
+580
-7
No files matched your search
@@ -397,3 +397,13 @@ An author's page opens with the name, the `summary` as its one sentence (or, wit
|
||||
| `[[author.source]]` | tables, with `summary` or `bio` | The pages the summary and bio were read on, each with `url` (`http(s)`) and `publisher` (who publishes the page). At least one is required with either; refused without; no page twice. | `url = "https://andrewskurka.com/about/"`, `publisher = "Andrew Skurka"` |
|
||||
|
||||
On an `organisation`, `summary`, `bio`, `checked` and `[[author.source]]` are refused; it may carry `url`. An unknown field is refused anywhere in an entry or a source. `tools/validate.py` runs these checks (`tools/check_datafiles.py`).
|
||||
|
||||
## `trail-numbers.txt`: a permanent number for every trail
|
||||
|
||||
One plain text file at the top level gives every trail a number that never changes and is never used again. It is one `id` per line, after a few `#` comment lines at the top. A trail's number is the zero-based index of its line among the `id` lines (the comments are not counted), so the first `id` is trail 0. The Saved page's short links are written in these numbers (see below).
|
||||
|
||||
Lines are only ever appended. A trail that is removed from the catalogue, or whose directory is renamed, keeps its line: the number is retired and no other trail gets it. `python3 tools/build_index.py`, which you run after adding a record, appends every record that has no line yet, in sorted order of the new `id`s, and says so; it never rewrites a line that is there. `tools/validate.py` fails when a record has no line, when an `id` is on two lines, or when a line is not a well-formed `id`; an `id` with no record is a retired number and is fine. `tools/check_history.py`, which CI runs against the base commit, fails when a line that was there is changed, moved or removed. The file was seeded with every record at the time, alphabetically by `id`.
|
||||
|
||||
### The short link to a saved list
|
||||
|
||||
The Saved page (`/saved/`) writes a list as `?t=<id>,<id>,...` while it holds ten trails or fewer (`SAVED_READABLE_MAX` in `web/assets/app.js`), and as `?s=<code>` when it holds more, so that the link does not grow with the list. The code is a set of trail numbers: bit N is 1 when the trail with number N is in the list. The bits are packed into bytes (bit 0 is the least significant bit of byte 0), trailing zero bytes are dropped, and the bytes are written in base64url without padding. The first character of the code is the format version, `1`, kept out of the base64url text, so that a later format can be told apart and old links keep opening; a code that starts with any other character is not understood and is shown as a link with no trails. A number that belongs to no trail on the site is ignored without a word. The page opens both forms for good; if an address has both `t` and `s`, `s` is used. A short link does not keep the order the trails were saved in: the list opens in A to Z order.
|
||||
Reference in new issue
Block a user