From 6ec99093ed3d925550332d3fc3a247d0586093e0 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 17 Jun 2025 18:52:41 -0400 Subject: [PATCH] Add QR code generation script and integrate --- src/README.md | 3 +++ src/create_flyer.sh | 3 +++ src/generate_qr.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100755 src/generate_qr.sh diff --git a/src/README.md b/src/README.md index c9ed9a6..60ec4c2 100644 --- a/src/README.md +++ b/src/README.md @@ -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/` 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`. diff --git a/src/create_flyer.sh b/src/create_flyer.sh index 158df28..16357c2 100755 --- a/src/create_flyer.sh +++ b/src/create_flyer.sh @@ -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 ) diff --git a/src/generate_qr.sh b/src/generate_qr.sh new file mode 100755 index 0000000..7cc306f --- /dev/null +++ b/src/generate_qr.sh @@ -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/"