feat: ADD work with local .env file #14
This commit is contained in:
parent
30e6956fa4
commit
d0373f0198
4 changed files with 81 additions and 0 deletions
24
.env.example
Normal file
24
.env.example
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Shellery configuration
|
||||||
|
#
|
||||||
|
# cp .env.example .env
|
||||||
|
#
|
||||||
|
# Every value below is the built-in default, so an unedited copy changes
|
||||||
|
# nothing. .env is read from the working directory and is gitignored.
|
||||||
|
#
|
||||||
|
# Precedence: command line flags > environment > .env > these defaults.
|
||||||
|
# This file is sourced by build.sh, so shell syntax applies.
|
||||||
|
|
||||||
|
# Page title. Used for both <title> and the <h1> header.
|
||||||
|
# Special characters are HTML-escaped automatically.
|
||||||
|
# Flag: --title=TEXT
|
||||||
|
GALLERY_TITLE="Gallery"
|
||||||
|
|
||||||
|
# Show the "Powered by shellery" footer. 1 = show, 0 = hide.
|
||||||
|
# Flag: --no-footer
|
||||||
|
SHOW_FOOTER=1
|
||||||
|
|
||||||
|
# Strip EXIF/GPS/IPTC/XMP metadata from the images copied into output/.
|
||||||
|
# 1 = strip (requires exiftool), 0 = publish metadata as-is.
|
||||||
|
# Source images in images/ are never modified either way.
|
||||||
|
# Flag: --keep-exif
|
||||||
|
STRIP_EXIF=1
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,3 +5,6 @@ output/*
|
||||||
# Ignore content in images directory
|
# Ignore content in images directory
|
||||||
images/*
|
images/*
|
||||||
!images/.gitkeep
|
!images/.gitkeep
|
||||||
|
|
||||||
|
# Local configuration (see .env.example)
|
||||||
|
.env
|
||||||
|
|
|
||||||
37
README.md
37
README.md
|
|
@ -14,6 +14,7 @@ Simple SSG to create dynamic gallery one-pagers in your shell! Shell+Gallery
|
||||||
**Available**:
|
**Available**:
|
||||||
- Simple use, single dependency (exiftool)
|
- Simple use, single dependency (exiftool)
|
||||||
- Removes EXIF/GPS metadata from published images by default
|
- Removes EXIF/GPS metadata from published images by default
|
||||||
|
- Configurable title and optional footer via environment variables
|
||||||
- no Javascript
|
- no Javascript
|
||||||
- Lightbox of image with anchor
|
- Lightbox of image with anchor
|
||||||
- Order of images via filename
|
- Order of images via filename
|
||||||
|
|
@ -70,6 +71,42 @@ docker run -v $(pwd)/images:/app/images -v $(pwd)/output:/app/output localhost/s
|
||||||
|
|
||||||
The generated gallery will be in `./output/index.html`
|
The generated gallery will be in `./output/index.html`
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
All options can be set in a `.env` file, as environment variables, or as flags.
|
||||||
|
`.env.example` lists every option with its default, so an unedited copy changes nothing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
`.env` is gitignored. Precedence is **flags > environment > `.env` > defaults**, so a
|
||||||
|
`-e` value passed to the container still wins over the file. Point `ENV_FILE` at another
|
||||||
|
path to use a different file.
|
||||||
|
|
||||||
|
| Variable | Flag | Default | Effect |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `GALLERY_TITLE` | `--title=TEXT` | `Gallery` | Page `<title>` and the `<h1>` header |
|
||||||
|
| `SHOW_FOOTER` | `--no-footer` | `1` | Set to `0` to hide the "Powered by shellery" footer |
|
||||||
|
| `STRIP_EXIF` | `--keep-exif` | `1` | Set to `0` to publish image metadata as-is |
|
||||||
|
| `ENV_FILE` | - | `.env` | Path to the config file to load |
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GALLERY_TITLE="Holiday 2026" SHOW_FOOTER=0 ./build.sh
|
||||||
|
# or
|
||||||
|
./build.sh --title="Holiday 2026" --no-footer
|
||||||
|
|
||||||
|
# container, via -e
|
||||||
|
podman run -e GALLERY_TITLE="Holiday 2026" -e SHOW_FOOTER=0 \
|
||||||
|
-v $(pwd)/images:/app/images -v $(pwd)/output:/app/output \
|
||||||
|
git.uphillsecurity.com/cf7/shellery:latest
|
||||||
|
|
||||||
|
# container, via a mounted .env
|
||||||
|
podman run -v $(pwd)/.env:/app/.env:ro \
|
||||||
|
-v $(pwd)/images:/app/images -v $(pwd)/output:/app/output \
|
||||||
|
git.uphillsecurity.com/cf7/shellery:latest
|
||||||
|
```
|
||||||
|
|
||||||
### Metadata removal
|
### Metadata removal
|
||||||
|
|
||||||
EXIF, GPS, IPTC and XMP metadata is stripped from every image by default. Only the copies
|
EXIF, GPS, IPTC and XMP metadata is stripped from every image by default. Only the copies
|
||||||
|
|
|
||||||
17
build.sh
17
build.sh
|
|
@ -10,6 +10,20 @@ OUTPUT_DIR="output"
|
||||||
TEMPLATES_DIR="templates"
|
TEMPLATES_DIR="templates"
|
||||||
ASSETS_DIR="assets"
|
ASSETS_DIR="assets"
|
||||||
|
|
||||||
|
# Load .env if present; see .env.example for every option and its default.
|
||||||
|
# Precedence: command line flags > environment > .env > built-in defaults.
|
||||||
|
ENV_FILE="${ENV_FILE:-.env}"
|
||||||
|
if [[ -f "$ENV_FILE" ]]; then
|
||||||
|
# Remember caller-supplied values so the file cannot clobber them
|
||||||
|
env_override=$(export -p | grep -E '^declare -x (STRIP_EXIF|GALLERY_TITLE|SHOW_FOOTER)=' || true)
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$ENV_FILE"
|
||||||
|
if [[ -n "$env_override" ]]; then
|
||||||
|
eval "$env_override"
|
||||||
|
fi
|
||||||
|
unset env_override
|
||||||
|
fi
|
||||||
|
|
||||||
# Image metadata (EXIF/GPS/IPTC/XMP) is stripped by default.
|
# Image metadata (EXIF/GPS/IPTC/XMP) is stripped by default.
|
||||||
# Opt out with STRIP_EXIF=0 or --keep-exif.
|
# Opt out with STRIP_EXIF=0 or --keep-exif.
|
||||||
STRIP_EXIF="${STRIP_EXIF:-1}"
|
STRIP_EXIF="${STRIP_EXIF:-1}"
|
||||||
|
|
@ -30,6 +44,9 @@ for arg in "$@"; do
|
||||||
echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
|
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 " --no-footer hide the 'Powered by shellery' footer (env: SHOW_FOOTER=0)"
|
||||||
echo " --title=TEXT page title and header, default 'Gallery' (env: GALLERY_TITLE)"
|
echo " --title=TEXT page title and header, default 'Gallery' (env: GALLERY_TITLE)"
|
||||||
|
echo ""
|
||||||
|
echo "Options may also be set in .env (see .env.example)."
|
||||||
|
echo "Precedence: flags > environment > .env > defaults."
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*) echo "unknown option: $arg" >&2; exit 1 ;;
|
*) echo "unknown option: $arg" >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue