From 8d0d41b5eedfad75f739aef5460a29286af74a88 Mon Sep 17 00:00:00 2001 From: Artur Raglis Date: Sun, 17 May 2026 18:43:41 +0200 Subject: [PATCH] docs/: add ToS-gate Base64 URLs mechanism - docs/javascripts/tos-gate.js - new revealGated() function, intentionally no rel="noreferrer - main.py - Added tos_gated_downloads(section_id, files, tos_url) macro; tos_checkbox kept for other uses - mkdocs.yml - Added javascripts/tos-gate.js to extra_javascript - overrides/main.html - New pins Referrer-Policy: strict-origin-when-cross-origin globally Signed-off-by: Artur Raglis --- README.md | 68 ++++++++++++++----- docs/javascripts/tos-gate.js | 28 ++++++++ .../gigabyte_mz33-ar1/building-manual.md | 8 +-- docs/variants/gigabyte_mz33-ar1/releases.md | 41 ++++------- main.py | 35 ++++++++++ mkdocs.yml | 1 + overrides/main.html | 6 ++ 7 files changed, 141 insertions(+), 46 deletions(-) create mode 100644 docs/javascripts/tos-gate.js create mode 100644 overrides/main.html diff --git a/README.md b/README.md index f56245ed..df23c9ea 100644 --- a/README.md +++ b/README.md @@ -121,37 +121,73 @@ instead. To embed an video simply type the following in markdown: ### Embedding ToS checkbox -A ToS acceptance checkbox can be added to any release page to gate binary -downloads behind a user acknowledgement. The feature is opt-in per page. +A ToS acceptance checkbox can be added to any page to gate binary downloads +and/or prose content behind a user acknowledgement. The feature is opt-in per +page. -**1. Add the checkbox macro** above the content you want to protect: +#### Gating download buttons + +Use the `tos_gated_downloads` macro and pass a unique `section_id` together +with the list of files. Use the **group format** to preserve subsection +headings matching the original release layout: ```md -{{ tos_checkbox("unique-section-id") }} +{{ tos_gated_downloads("vendor-board-vXYZ-binaries", [ + {"group": "Raw firmware image", "note": "(vendor_board_vX.Y.Z.rom)", "items": [ + {"label": "sha256", "url": "https://dl.3mdeb.com/.../file.rom.sha256"}, + {"label": "sha256.sig", "url": "https://dl.3mdeb.com/.../file.rom.sha256.sig"} + ]}, + {"group": "SBOM CycloneDX", "items": [ + {"label": "sbom.json", "url": "https://dl.3mdeb.com/.../file.sbom.json"}, + {"label": "sha256", "url": "https://dl.3mdeb.com/.../file.sbom.json.sha256"}, + {"label": "sha256.sig", "url": "https://dl.3mdeb.com/.../file.sbom.json.sha256.sig"} + ]} +]) }} ``` -**2. Wrap the protected content** in an HTML div with a matching `id`: +Download links are **not** emitted into the HTML source - they are +base64-encoded in a `data-payload` attribute and injected by `tos-gate.js` only +after the user checks the box. This keeps URLs out of page source and prevents +them from being indexed. + +Download buttons with groups example: +[`docs/variants/gigabyte_mz33-ar1/releases.md`][tos-example] + +#### Optional argument (`tos_url`) + +Overrides the default Terms of Service link: ```md -