| 1 | #!/usr/bin/env bash |
| 2 | # html-ppt :: new-deck.sh — scaffold a new deck from templates/deck.html |
| 3 | # |
| 4 | # Usage: |
| 5 | # new-deck.sh <name> [output-parent-dir] |
| 6 | # |
| 7 | # Creates <parent>/<name>/index.html with paths rewritten to point at the |
| 8 | # skill's shared assets/themes/animations. Defaults to ./examples/. |
| 9 | |
| 10 | set -euo pipefail |
| 11 | |
| 12 | NAME="${1:-}" |
| 13 | if [[ -z "$NAME" ]]; then |
| 14 | echo "usage: new-deck.sh <name> [parent-dir]" >&2 |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | PARENT="${2:-examples}" |
| 19 | HERE="$(cd "$(dirname "$0")/.." && pwd)" |
| 20 | TEMPLATE="$HERE/templates/deck.html" |
| 21 | |
| 22 | if [[ ! -f "$TEMPLATE" ]]; then |
| 23 | echo "error: template not found at $TEMPLATE" >&2 |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | OUT_DIR="$HERE/$PARENT/$NAME" |
| 28 | if [[ -e "$OUT_DIR" ]]; then |
| 29 | echo "error: $OUT_DIR already exists" >&2 |
| 30 | exit 1 |
| 31 | fi |
| 32 | mkdir -p "$OUT_DIR" |
| 33 | |
| 34 | # templates/deck.html references ../assets/...; for examples/<name>/index.html |
| 35 | # that same relative path (../../assets/...) needs one more ../. |
| 36 | sed 's|href="../assets/|href="../../assets/|g; s|src="../assets/|src="../../assets/|g; s|data-theme-base="../assets/|data-theme-base="../../assets/|g' \ |
| 37 | "$TEMPLATE" > "$OUT_DIR/index.html" |
| 38 | |
| 39 | echo "✔ created $OUT_DIR/index.html" |
| 40 | echo "" |
| 41 | echo "next steps:" |
| 42 | echo " open $OUT_DIR/index.html" |
| 43 | echo " # press T to cycle themes, ← → to navigate, O for overview" |
| 44 | echo "" |
| 45 | echo " # render to PNG:" |
| 46 | echo " $HERE/scripts/render.sh $OUT_DIR/index.html all" |
| 47 |