Skip to content

feat: link page numbers to the dictionary's scan on archive.org - #120

Merged
forzagreen merged 1 commit into
mainfrom
feat/page-links-to-archive-org
Oct 16, 2026
Merged

forzagreen merged 1 commit into
mainfrom
feat/page-links-to-archive-org

Conversation

@forzagreen

Copy link
Copy Markdown
Owner

Important

Draft until the DB refresh PR for forzagreen/arabterm#65 is merged and deployed: the search query names the two new dictionary columns, so this code against the current DB would turn every search into a 500. The other way round is safe (the current code ignores the new columns).

A term's ص. N now opens page N of its paper dictionary's scan on archive.org — in the UI, the raw search and the gadget.

  • API: search_terms_mariadb joins dictionary.archive_org_url / page_offset (new in arabterm#65) and archive_page_url() turns them into page_url on each occurrence: <url>/page/n<page + page_offset - 1>/mode/1up, the same link the Cite Q module builds from Wikidata's P953 + P8330. The two columns are not repeated in every row; /api/v1/dicts returns them as they are. Both are documented in the OpenAPI schema.
  • UI (DictionaryApp.jsx, RawSearch.jsx): ص. N is a link when page_url is there; dist/ rebuilt.
  • Gadget: same in Gadget-WikiTerm.js, SearchTerm.js re-synced (npm run sync), lint clean. Needs to be copied to MediaWiki:Gadget-WikiTerm.js to reach ar.wikipedia.

Coverage: 40 of the 46 dictionaries with page numbers have a scan.

Testing

  • make test: 173 passed, including new tests for archive_page_url and for page_url in the search rows (with the DB stubbed).
  • End to end against a local MariaDB loaded with arabterm#65: "telescope" returns e.g. at_physics p. 285 → Ara1989ENFRAR/page/n404/mode/1up; for that link and two others, the OCR of the linked scan page contains "telescope" and its neighbours do not.
  • The UI was not checked in a browser (none on the dev machine).

A term's "ص. N" now opens page N of its paper dictionary's scan on
archive.org, in the UI, the raw search and the gadget.

The API builds the link once, as `page_url` on each occurrence, from the
`archive_org_url` and `page_offset` columns that arabterm adds to the
`dictionary` table: printed page p is `<url>/page/n<p + page_offset - 1>`,
the link the Cite Q module of ar.wikipedia builds from Wikidata's P953 and
P8330. /api/v1/dicts returns the two columns as they are.

Needs a DB import that has the two columns: the search query names them.
@forzagreen
forzagreen marked this pull request as ready for review October 16, 2026 10:25
@forzagreen
forzagreen merged commit bfb064e into main Oct 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant