|
1 | | -# Badge Page |
| 1 | +# Badge Pages |
2 | 2 |
|
3 | | -The badge page (`/badge/`) is a tool for OPDS and web catalog operators. It generates an "Add to Thorium Reader" badge — an SVG image wrapped in a deep link — that catalog pages can embed to let users add the catalog to Thorium Reader in one tap. |
| 3 | +The badge tools let OPDS/web catalog operators and publication hosts generate an "Add to Thorium Reader" badge — an SVG image wrapped in a deep link — to embed on their own pages so users can add the catalog or publication to Thorium Reader in one tap. |
4 | 4 |
|
5 | | -## How it works |
| 5 | +`/badge/` is a hub page (`src/pages/[lang]/badge.astro`) linking to two separate generators: |
6 | 6 |
|
7 | | -The badge is a static SVG (196×56 px) with the Thorium logo and localized "Add to Thorium Reader" text. When clicked, it opens a deep link URL that Thorium Reader intercepts to pre-fill a catalog entry. |
| 7 | +- `/badge/catalog/` — adds a catalog (and optional bookshelf) |
| 8 | +- `/badge/publication/` — adds a single publication |
8 | 9 |
|
9 | | -The deep link is built from `addCatalogScheme` (defined in `src/links.ts`) with query parameters appended: |
| 10 | +Each generator page (`src/components/badge/*`) is a form that live-updates a preview badge and an embed snippet as the operator fills it in. |
| 11 | + |
| 12 | +## Output formats |
| 13 | + |
| 14 | +Each generator's output tab offers two integration options, selected via the "integration" field: |
| 15 | + |
| 16 | +- **Link** — a static `<a href="…"><svg>…</svg></a>` snippet, wrapping the deep link scheme URL. The badge text is baked in at generation time for the selected language. |
| 17 | +- **Web component** — a `<thorium-badge-catalog>` or `<thorium-badge-publication>` custom element tag with the form values as attributes. This requires embedding the `@edrlab/thorium-badges` package (see [packages/thorium-badges/README.md](../packages/thorium-badges/README.md) and the deep-linking dev guide linked from the output panel) — the element renders its own SVG client-side and can use `lang="auto"` to detect the visitor's browser language, which the link format can't do. |
| 18 | + |
| 19 | +## Catalog badge parameters |
| 20 | + |
| 21 | +Deep link scheme: `addCatalogScheme` (`src/links.ts`), universal-link equivalent: `addCatalogUniversalLink`. |
10 | 22 |
|
11 | 23 | | Parameter | Required | Description | |
12 | 24 | |-----------|----------|-------------| |
13 | 25 | | `title` | yes | Catalog display name in Thorium Reader | |
14 | | -| `browse` | yes* | OPDS or web URL to browse the catalog | |
| 26 | +| `main` | yes* | OPDS or web URL to browse the catalog | |
15 | 27 | | `bookshelf` | yes* | OPDS or web URL for the user's bookshelf | |
| 28 | +| `passphrase` | no | Plain-text LCP passphrase | |
| 29 | +| `hashed_passphrase` | no | Pre-hashed LCP passphrase (use instead of `passphrase`) | |
| 30 | +| `open_in` | no | How to open catalog URLs: `webview` or `browser` | |
16 | 31 | | `icon` | no | Square image URL (PNG or SVG) for the catalog icon | |
17 | | -| `color` | no | Accent color (`gray`, `red`, `yellow`, `blue`, `green`, `purple`, `orange`) | |
| 32 | +| `banner` | no | Banner image URL | |
| 33 | +| `color` | no | Accent color (`gray`, `red`, `yellow`, `blue`, `green`, `purple`, `orange`, `pink`) | |
| 34 | + |
| 35 | +*At least one of `main` or `bookshelf` is required for the badge link to be generated. |
| 36 | + |
| 37 | +## Publication badge parameters |
| 38 | + |
| 39 | +Deep link scheme: `addPublicationScheme` (`src/links.ts`), universal-link equivalent: `addPublicationUniversalLink`. |
| 40 | + |
| 41 | +| Parameter | Required | Description | |
| 42 | +|-----------|----------|-------------| |
| 43 | +| `publication` | yes | Direct URL to the publication file | |
| 44 | +| `title` | no | Publication title | |
| 45 | +| `author` | no | Publication author | |
| 46 | +| `cover` | no | Cover image URL | |
18 | 47 | | `passphrase` | no | Plain-text LCP passphrase | |
19 | | -| `passphrase_hash` | no | Pre-hashed LCP passphrase (use instead of `passphrase`) | |
20 | | -| `openIn` | no | How to open catalog URLs: `webview` or `browser` | |
| 48 | +| `hashed_passphrase` | no | Pre-hashed LCP passphrase (use instead of `passphrase`) | |
21 | 49 |
|
22 | | -*At least one of `browse` or `bookshelf` is required for the badge link to be generated. |
| 50 | +The full parameter/attribute lists live in [packages/thorium-badges/src/params.ts](../packages/thorium-badges/src/params.ts), shared between the generator pages and the web component. |
23 | 51 |
|
24 | 52 | ## Output |
25 | 53 |
|
26 | | -The page produces an HTML snippet ready to paste into a catalog page: |
| 54 | +Both generators produce an HTML snippet ready to paste into a catalog or publication page: |
27 | 55 |
|
28 | 56 | ```html |
29 | | -<a href="https://www.thoriumreader.com?title=My+Catalog&browse=https%3A%2F%2F..."> |
| 57 | +<a href="https://www.thoriumreader.com/add/catalog?title=My+Catalog&main=https%3A%2F%2F..."> |
30 | 58 | <svg …>…</svg> |
31 | 59 | </a> |
32 | 60 | ``` |
33 | 61 |
|
| 62 | +## `/add/catalog/` and `/add/publication/` landing pages |
| 63 | + |
| 64 | +These are the pages the universal links (and the web component's rendered links) point to — `src/pages/[lang]/add/catalog.astro` and `.../add/publication.astro`. They show a preview of the catalog/publication being added (name, cover when available), a button that retries the deep link (`ThoriumBadge`), and download links for Thorium Desktop (`DownloadContent`) for visitors without the app installed. If the URL carries no query params at all, the page shows an "invalid link" message instead of the normal add-in-progress copy. |
| 65 | + |
34 | 66 | ## Localization |
35 | 67 |
|
36 | | -The badge text ("Add to" / "Thorium Reader") is rendered in the language selected in the form, independently of the page locale. All active site locales are available. The `badgeTexts` map (built at Astro render time from `en.json`, `fr.json`, etc.) is passed to the client script so the SVG updates live when the language selector changes. |
| 68 | +The badge text ("Add to" / "Thorium Reader") is rendered in the language selected in the generator form, independently of the page locale. All active site locales are available. The `badgeTexts` map (built at Astro render time from `en.json`, `fr.json`, etc.) is passed to the client script via `ClientData` so the SVG updates live when the language selector changes. The web component additionally supports `lang="auto"` (browser-language detection) — see [packages/thorium-badges/README.md](../packages/thorium-badges/README.md#localization). |
37 | 69 |
|
38 | | -## Updating `addCatalogScheme` |
| 70 | +## Updating `addCatalogScheme` / `addPublicationScheme` |
39 | 71 |
|
40 | | -The deep link base URL is `addCatalogScheme` in `src/links.ts`. Update it there if the scheme changes — the badge page picks it up automatically. |
| 72 | +The deep link base URLs are `addCatalogScheme`, `addPublicationScheme`, and their universal-link equivalents in `src/links.ts`. Update them there if a scheme changes — the badge pages pick it up automatically. See [links.md](links.md). |
0 commit comments