-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add preferences.qrCode for a header QR matrix linking to basics.url #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
020ec7b
feat: add preferences.qrCode for a header QR matrix linking to basics…
b8ed69d
refactor(qrCode): swap `"url"` sentinel for `auto`, polish layout + c…
b9c1cb8
test(qrCode): add fixtures for centred-image edge cases
352654c
feat(qrCode): exercise QR in preview.gif frame 6
8cc8827
feat(qrCode): also exercise QR on preview.gif frame 4
f25c8d5
refactor(qrCode): centred-header QR rides the page edge, not the text…
59888c3
refactor(qrCode): anchor centred-header QR to the top corner
596222f
refactor(qrCode): restore photo↔text gap, collapse centred-header bra…
14b10e1
fix(ci): regenerate centred_header_image.pdf against new spacing
f2a5ba1
build(make): rebuild test PDFs when renderer sources change
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Header QR matrix — opt-in via `preferences.qrCode`. Printed CVs lose | ||
| // the clickability of digital PDFs; a QR code rescues that one link | ||
| // the reader is most likely to follow (the homepage URL). Off by | ||
| // default — turn it on with `preferences.qrCode: auto` (encode | ||
| // `basics.url`) or any literal URL string. | ||
| // | ||
| // Generation is delegated to `@preview/zebra`, the only third-party | ||
| // Typst dependency this package pulls in. Zebra emits native Typst | ||
| // vector paths (not a rasterised image), so the matrix stays crisp at | ||
| // any size and inherits a `fill` colour like any other shape. The | ||
| // dependency is fetched on first compile and cached thereafter. | ||
| // | ||
| // This module owns three concerns and nothing else: validating the | ||
| // preference value, resolving it against `basics.url`, and rendering | ||
| // the matrix wrapped in `link()`. `internal/header.typ` consumes | ||
| // `_qr_render` and composes the result into the header layout — the | ||
| // header file doesn't import zebra directly, so swapping QR | ||
| // implementations stays a one-file change. | ||
|
|
||
| #import "@preview/zebra:0.1.0": qrcode | ||
|
|
||
| // Validates `preferences.qrCode`. Accepted shapes: | ||
| // - `none` — no QR rendered | ||
| // - `auto` — encode `basics.url` at render time | ||
| // - any non-empty string — encode that string verbatim | ||
| // Anything else panics with a message anchored at the preferences | ||
| // call site, so a typo (`qrCode: true`, `qrCode: 42`) surfaces up | ||
| // front rather than as a render-time failure inside `qrcode(...)`. | ||
| #let _check_qr_code(value) = { | ||
| if value == none or value == auto { return } | ||
| if type(value) != str { | ||
| panic( | ||
| "qrCode must be `none`, `auto`, or a URL string, got: " + repr(value), | ||
| ) | ||
| } | ||
| if value == "" { | ||
| panic("qrCode must be a non-empty string when not `none` / `auto`.") | ||
| } | ||
| } | ||
|
|
||
| // Resolves the validated preference against `basics`. Returns the URL | ||
| // string to encode, or `none` when no QR should render. Separated | ||
| // from `_check_qr_code` because the `auto` lookup depends on `basics` | ||
| // — only callable once `alta()` has the data dict in hand. | ||
| #let _resolve_qr_url(qr-code, basics) = { | ||
| if qr-code == none { return none } | ||
| if qr-code != auto { return qr-code } | ||
| let url = basics.at("url", default: none) | ||
| if url == none { | ||
| panic( | ||
| "preferences.qrCode is `auto` but basics.url is missing. " | ||
| + "Set basics.url to the destination URL, or pass the URL " | ||
| + "directly via preferences.qrCode.", | ||
| ) | ||
| } | ||
| if type(url) != str { | ||
| panic("basics.url must be a string, got: " + repr(url)) | ||
| } | ||
| if url == "" { | ||
| panic( | ||
| "basics.url is empty; set it to the destination URL or remove preferences.qrCode.", | ||
| ) | ||
| } | ||
| url | ||
| } | ||
|
|
||
| // `quiet-zone: 0` because the surrounding header padding already | ||
| // supplies enough whitespace; zebra's default 4-module quiet zone | ||
| // would shrink the dark matrix at the print size we target. The | ||
| // `link()` wrap lets digital readers click through to the same | ||
| // destination the QR encodes. | ||
| #let _qr_render(url, size, fill) = link( | ||
| url, | ||
| qrcode(url, width: size, quiet-zone: 0, fill: fill), | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.