mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-07 14:38:42 +00:00
Add batch import script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@ tmp*/
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
*~
|
*~
|
||||||
*.swp
|
*.swp
|
||||||
|
imports/*.json
|
||||||
|
11
README.md
11
README.md
@@ -81,6 +81,17 @@ Additional documentation is available in the `src/` directory; see [src/README.m
|
|||||||
2. Run `./src/create_flyer.sh` and follow the prompts, or use `./src/create_flyer.sh --from-pdf path/to/form.pdf`.
|
2. Run `./src/create_flyer.sh` and follow the prompts, or use `./src/create_flyer.sh --from-pdf path/to/form.pdf`.
|
||||||
3. Host the generated `host/<subdomain>` directory.
|
3. Host the generated `host/<subdomain>` directory.
|
||||||
|
|
||||||
|
## Batch Import
|
||||||
|
Place configuration files in an `imports/` directory at the project root. Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./src/import_from_json.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Each JSON file is copied to `src/config.json` and processed with
|
||||||
|
`create_flyer.sh --no-interaction`. Existing folders under `host/` with the
|
||||||
|
same subdomain are removed before new files are written.
|
||||||
|
|
||||||
## Hosting Options
|
## Hosting Options
|
||||||
The folder under `host/<subdomain>` contains all of the files needed to serve
|
The folder under `host/<subdomain>` contains all of the files needed to serve
|
||||||
the flyer as a static website. A few easy ways to make it publicly accessible
|
the flyer as a static website. A few easy ways to make it publicly accessible
|
||||||
|
0
imports/.gitkeep
Normal file
0
imports/.gitkeep
Normal file
@@ -15,10 +15,11 @@ done
|
|||||||
|
|
||||||
CONFIG_PATH="src/config.json"
|
CONFIG_PATH="src/config.json"
|
||||||
FROM_PDF=""
|
FROM_PDF=""
|
||||||
|
NON_INTERACTIVE=0
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-c config_path] [--from-pdf PDF]"
|
echo "Usage: $0 [-c config_path] [--from-pdf PDF] [--no-interaction]"
|
||||||
echo "Create and deploy a flyer based on config.json."
|
echo "Create and deploy a flyer based on config.json."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +34,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
FROM_PDF="$2"
|
FROM_PDF="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-n|--no-interaction)
|
||||||
|
NON_INTERACTIVE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
@@ -89,10 +94,12 @@ update_config_from_pdf() {
|
|||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "$FROM_PDF" ]]; then
|
if [[ $NON_INTERACTIVE -eq 0 ]]; then
|
||||||
update_config_from_pdf
|
if [[ -n "$FROM_PDF" ]]; then
|
||||||
else
|
update_config_from_pdf
|
||||||
update_config_interactive
|
else
|
||||||
|
update_config_interactive
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Regenerate QR codes based on the updated configuration
|
# Regenerate QR codes based on the updated configuration
|
||||||
|
21
src/import_from_json.sh
Executable file
21
src/import_from_json.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
IMPORT_DIR="imports"
|
||||||
|
shopt -s nullglob
|
||||||
|
files=("$IMPORT_DIR"/*.json)
|
||||||
|
|
||||||
|
if [[ ${#files[@]} -eq 0 ]]; then
|
||||||
|
echo "No JSON files found in $IMPORT_DIR"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for json in "${files[@]}"; do
|
||||||
|
echo "Processing $json"
|
||||||
|
cp "$json" src/config.json
|
||||||
|
subdomain=$(jq -r '.subdomain' "$json")
|
||||||
|
dest="host/$subdomain"
|
||||||
|
rm -rf "$dest"
|
||||||
|
./src/create_flyer.sh --no-interaction
|
||||||
|
done
|
Reference in New Issue
Block a user