diff --git a/build.sh b/build.sh
index 4222e0e..2b22d7c 100755
--- a/build.sh
+++ b/build.sh
@@ -14,12 +14,22 @@ ASSETS_DIR="assets"
# Opt out with STRIP_EXIF=0 or --keep-exif.
STRIP_EXIF="${STRIP_EXIF:-1}"
+# Page title, used for both
and the
header
+GALLERY_TITLE="${GALLERY_TITLE:-Gallery}"
+
+# Show the "Powered by shellery" footer; set to 0 to hide it
+SHOW_FOOTER="${SHOW_FOOTER:-1}"
+
for arg in "$@"; do
case "$arg" in
--keep-exif) STRIP_EXIF=0 ;;
+ --no-footer) SHOW_FOOTER=0 ;;
+ --title=*) GALLERY_TITLE="${arg#--title=}" ;;
-h|--help)
- echo "usage: ./build.sh [--keep-exif]"
- echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
+ echo "usage: ./build.sh [--keep-exif] [--no-footer] [--title=TEXT]"
+ echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
+ echo " --no-footer hide the 'Powered by shellery' footer (env: SHOW_FOOTER=0)"
+ echo " --title=TEXT page title and header, default 'Gallery' (env: GALLERY_TITLE)"
exit 0 ;;
*) echo "unknown option: $arg" >&2; exit 1 ;;
esac
@@ -33,6 +43,18 @@ if [[ "$STRIP_EXIF" == "1" ]] && ! command -v exiftool >/dev/null 2>&1; then
exit 1
fi
+# Escape text destined for HTML body content
+html_escape() {
+ local s=$1
+ # Replacements are quoted: bash 5.2+ expands an unquoted & to the matched text
+ s="${s//&/"&"}"
+ s="${s//"<"}"
+ s="${s//>/">"}"
+ printf '%s' "$s"
+}
+
+TITLE_HTML=$(html_escape "$GALLERY_TITLE")
+
# Create output directory
mkdir -p "$OUTPUT_DIR"
@@ -42,8 +64,27 @@ OUTPUT_FILE="$OUTPUT_DIR/index.html"
# Assemble templates in order
for template in $(ls "$TEMPLATES_DIR"/*.tmpl | sort); do
+ skip_block=0
# Process each template line by line to handle placeholders
while IFS= read -r line; do
+ # Optional block: ...
+ if [[ "$line" == *""* ]]; then
+ if [[ "$SHOW_FOOTER" != "1" ]]; then
+ skip_block=1
+ fi
+ continue
+ fi
+ if [[ "$line" == *""* ]]; then
+ skip_block=0
+ continue
+ fi
+ if [[ "$skip_block" == "1" ]]; then
+ continue
+ fi
+
+ # Replacement is quoted: bash 5.2+ expands an unquoted & to the matched text
+ line="${line///"$TITLE_HTML"}"
+
if [[ "$line" == *""* ]]; then
# Generate gallery items (reversed order)
images=("$IMAGES_DIR"/*)
diff --git a/templates/00_meta.tmpl b/templates/00_meta.tmpl
index 6503001..7a025fe 100644
--- a/templates/00_meta.tmpl
+++ b/templates/00_meta.tmpl
@@ -5,7 +5,7 @@
- Gallery
+
diff --git a/templates/10_header.tmpl b/templates/10_header.tmpl
index 4f67869..3283e41 100644
--- a/templates/10_header.tmpl
+++ b/templates/10_header.tmpl
@@ -1,3 +1,3 @@
-