Fix broken PDF hyperlinks
This commit is contained in:
parent
40ba09209c
commit
3a95a05284
|
|
@ -65,6 +65,10 @@ levineuwirth_handover.zip
|
|||
# Download with: make download-model
|
||||
static/models/
|
||||
|
||||
# Vendored PDF.js viewer (~18 MB uncompressed, pinned in tools/download-pdfjs.sh).
|
||||
# Download with: make download-pdfjs
|
||||
static/pdfjs/
|
||||
|
||||
# Generated WebP companions (produced by tools/convert-images.sh at build time).
|
||||
# To intentionally commit a WebP, use: git add -f path/to/file.webp
|
||||
static/**/*.webp
|
||||
|
|
|
|||
9
Makefile
9
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
.PHONY: build deploy sign download-model convert-images pdf-thumbs pdfs watch clean dev
|
||||
.PHONY: build deploy sign download-model download-pdfjs convert-images pdf-thumbs pdfs watch clean dev
|
||||
|
||||
# Source .env for GITHUB_TOKEN and GITHUB_REPO if it exists.
|
||||
# .env format: KEY=value (one per line, no `export` prefix, no quotes needed).
|
||||
|
|
@ -17,6 +17,7 @@ build:
|
|||
@date +%s > data/build-start.txt
|
||||
@./tools/convert-images.sh
|
||||
@$(MAKE) -s pdf-thumbs
|
||||
@./tools/download-pdfjs.sh
|
||||
cabal run site -- build
|
||||
pagefind --site _site
|
||||
@if [ -d .venv ]; then \
|
||||
|
|
@ -37,6 +38,12 @@ sign:
|
|||
download-model:
|
||||
@./tools/download-model.sh
|
||||
|
||||
# Vendor Mozilla's prebuilt PDF.js viewer into static/pdfjs/.
|
||||
# Runs automatically as part of `build` (skips when already present).
|
||||
# Files are gitignored; sha256-verified against tools/pdfjs-checksums.sha256.
|
||||
download-pdfjs:
|
||||
@./tools/download-pdfjs.sh
|
||||
|
||||
# Convert JPEG/PNG images to WebP companions (also runs automatically in build).
|
||||
# Requires cwebp: pacman -S libwebp / apt install webp
|
||||
convert-images:
|
||||
|
|
|
|||
BIN
static/cv.pdf
BIN
static/cv.pdf
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env bash
|
||||
# download-pdfjs.sh — Vendor Mozilla's prebuilt PDF.js viewer into static/pdfjs/.
|
||||
#
|
||||
# The Haskell link filter (build/Filters/Links.hs) rewrites every root-relative
|
||||
# .pdf link to open through /pdfjs/web/viewer.html, so this viewer must be
|
||||
# present in static/ for the site build to produce working PDF links.
|
||||
#
|
||||
# Run once before deploying. The extracted viewer is gitignored (~18 MB
|
||||
# uncompressed); re-running is safe — the script skips when the viewer
|
||||
# already exists.
|
||||
#
|
||||
# To bump the pinned version, set PDFJS_VERSION, re-run, then update
|
||||
# tools/pdfjs-checksums.sha256 with the new archive SHA-256.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
PDFJS_DIR="$REPO_ROOT/static/pdfjs"
|
||||
CHECKSUMS="$REPO_ROOT/tools/pdfjs-checksums.sha256"
|
||||
|
||||
PDFJS_VERSION="${PDFJS_VERSION:-5.6.205}"
|
||||
ARCHIVE="pdfjs-${PDFJS_VERSION}-dist.zip"
|
||||
URL="https://github.com/mozilla/pdf.js/releases/download/v${PDFJS_VERSION}/${ARCHIVE}"
|
||||
|
||||
if [ -f "$PDFJS_DIR/web/viewer.html" ]; then
|
||||
echo "pdfjs: already present at $PDFJS_DIR/web/viewer.html (skipping)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
command -v unzip >/dev/null 2>&1 || {
|
||||
echo "download-pdfjs: unzip not found — install it (pacman -S unzip / apt install unzip)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
echo "pdfjs: downloading $ARCHIVE"
|
||||
curl -fsSL --progress-bar "$URL" -o "$tmpdir/$ARCHIVE"
|
||||
|
||||
if [ -f "$CHECKSUMS" ]; then
|
||||
want=$(awk -v p="$ARCHIVE" '$2 == p { print $1; exit }' "$CHECKSUMS")
|
||||
if [ -n "$want" ]; then
|
||||
got=$(sha256sum "$tmpdir/$ARCHIVE" | awk '{ print $1 }')
|
||||
if [ "$got" != "$want" ]; then
|
||||
echo "pdfjs: sha256 mismatch for $ARCHIVE" >&2
|
||||
echo " expected $want" >&2
|
||||
echo " got $got" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "pdfjs: sha256 verified"
|
||||
else
|
||||
echo "pdfjs: no pinned checksum for $ARCHIVE in $CHECKSUMS — skipping verification" >&2
|
||||
fi
|
||||
else
|
||||
echo "pdfjs: $CHECKSUMS not found — skipping sha256 verification" >&2
|
||||
fi
|
||||
|
||||
mkdir -p "$PDFJS_DIR"
|
||||
echo "pdfjs: extracting to $PDFJS_DIR"
|
||||
unzip -q -o "$tmpdir/$ARCHIVE" -d "$PDFJS_DIR"
|
||||
|
||||
echo "pdfjs: done. static/pdfjs/web/viewer.html is ready."
|
||||
echo " Run 'make build' to include it in _site/."
|
||||
|
|
@ -0,0 +1 @@
|
|||
0555ef47464e456125dcd0b9742cfa2aaed6d282e804e4dd1f1b99316b46ac00 pdfjs-5.6.205-dist.zip
|
||||
Loading…
Reference in New Issue