upload
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
BASE_URL="${BASE_URL:-http://localhost:8080}"
|
||||
INPUT="${1:-examples/sample-report.json}"
|
||||
OUT="${2:-output/all-themes}"
|
||||
mkdir -p "$OUT"
|
||||
mapfile -t THEMES < <(curl -fsS "$BASE_URL/themes" | python3 -c 'import json,sys; print("\\n".join(json.load(sys.stdin)["themes"]))')
|
||||
for theme in "${THEMES[@]}"; do
|
||||
tmp="$(mktemp)"
|
||||
python3 - "$INPUT" "$theme" > "$tmp" <<'PY'
|
||||
import json,sys
|
||||
payload=json.load(open(sys.argv[1],encoding='utf-8'))
|
||||
payload['design']['theme']=sys.argv[2]
|
||||
payload['design'].pop('palette_mode',None)
|
||||
json.dump(payload,sys.stdout,ensure_ascii=False)
|
||||
PY
|
||||
curl -fsS -X POST "$BASE_URL/render" -H 'Content-Type: application/json' --data-binary "@$tmp" -o "$OUT/$theme.pdf"
|
||||
rm -f "$tmp"
|
||||
echo "$theme.pdf"
|
||||
done
|
||||
Reference in New Issue
Block a user