Merge pull request #2 from PR0M3TH3AN/codex/create-qr-generation-script-and-update-workflow

Add QR code generation script
This commit is contained in:
thePR0M3TH3AN
2025-06-17 18:55:22 -04:00
committed by GitHub
3 changed files with 35 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ This repository contains a simple Bash script to obfuscate and minify a single H
- **Debian/Ubuntu**: This script is designed to work on Debian-based systems.
- **Node.js**: Terser and html-minifier-terser require Node.js to be installed.
- **qrencode**: Generates the QR codes used in the flyers.
### Install Node.js and npm on Debian
@@ -128,3 +129,5 @@ The `create_flyer.sh` script automates filling `config.json`, building the HTML
```
By default the script updates `src/config.json`. After answering the prompts (or extracting from the PDF), `index.html` and `nostr.html` are generated and copied along with the QR code images and PDFs. The files end up in `host/<subdomain>` which can be served statically.
QR codes are built automatically during this process. After the configuration is updated, `create_flyer.sh` calls `generate_qr.sh` to read the URLs from `config.json` and produce `qrcode-content.png` and `qrcode-tear-offs.png`.

View File

@@ -84,6 +84,9 @@ else
update_config_interactive
fi
# Regenerate QR codes based on the updated configuration
( cd src && ./generate_qr.sh )
# Run obfuscation scripts
( cd src && ./obfuscate_index.sh && ./obfuscate_nostr.sh )

29
src/generate_qr.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -e
CONFIG="src/config.json"
# Ensure dependencies
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
command -v qrencode >/dev/null 2>&1 || { echo "qrencode is required" >&2; exit 1; }
command -v convert >/dev/null 2>&1 || { echo "ImageMagick convert is required" >&2; exit 1; }
url=$(jq -r '.url' "$CONFIG")
tear=$(jq -r '.tear_off_link' "$CONFIG")
[ -n "$url" ] || { echo "URL missing in $CONFIG" >&2; exit 1; }
[ -n "$tear" ] || { echo "tear_off_link missing in $CONFIG" >&2; exit 1; }
tmp_content=$(mktemp)
tmp_tear=$(mktemp)
qrencode -o "$tmp_content" -s 10 -m 0 "$url"
qrencode -o "$tmp_tear" -s 10 -m 0 "$tear"
convert "$tmp_content" -resize 128x128 "src/qrcode-content.png"
convert "$tmp_tear" -resize 128x128 "src/qrcode-tear-offs.png"
rm -f "$tmp_content" "$tmp_tear"
echo "QR codes generated in src/"