From 72d24e3b13560f94bdcfd986fda47b20f0ad4227 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 15 Jun 2026 23:36:14 +0300 Subject: Make the favicon configurable via FAVICON config / --favicon flag The generated pages link a favicon.ico that was always the bundled shuriken favicon (copy_site_favicon hard-copied share/shuriken/assets/favicon.ico). Add a FAVICON config variable and a --favicon PATH CLI flag: when set, that file is published as favicon.ico instead of the bundled default; when empty, the bundled favicon is used as before. Plumbed through apply_config_defaults, CLI_OPTION_SPEC + override allowlist, usage, print_config, the action config list and effective-setting log, and validated (a non-empty FAVICON must be a readable file) before generation. shuriken.default.conf and the README document it; a test covers a custom favicon, its appearance in --print-config, and rejection of a missing file. Co-Authored-By: Claude Opus 4.8 --- tests/cli.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests') diff --git a/tests/cli.sh b/tests/cli.sh index aa869cc..1dac04a 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -1300,6 +1300,7 @@ CONFIG_SOURCE=$TEST_REPO_ROOT/src/shuriken.default.conf INCOMING_DIR=$TEST_TMPDIR/incoming DIST_DIR=$TEST_TMPDIR/dist TEMPLATE_DIR=$TEST_REPO_ROOT/share/templates/default +FAVICON='' TITLE=A\\ simple\\ Shuriken HEIGHT=1200 THUMBHEIGHT=300 @@ -1347,6 +1348,7 @@ CONFIG_SOURCE=$config_file INCOMING_DIR=$TEST_TMPDIR/incoming DIST_DIR=$TEST_TMPDIR/dist TEMPLATE_DIR=$TEST_REPO_ROOT/share/templates/default +FAVICON='' TITLE=Minimal\\ defaults HEIGHT='' THUMBHEIGHT=30 @@ -1487,6 +1489,7 @@ CONFIG_SOURCE=$config_file INCOMING_DIR=$TEST_TMPDIR/custom-incoming DIST_DIR=$TEST_TMPDIR/custom-dist TEMPLATE_DIR=$TEST_REPO_ROOT/share/templates/default +FAVICON='' TITLE=Selected\\ config HEIGHT=120 THUMBHEIGHT=30 @@ -1529,6 +1532,7 @@ CONFIG_SOURCE=./shuriken.conf INCOMING_DIR=$TEST_TMPDIR/incoming DIST_DIR=$TEST_TMPDIR/dist TEMPLATE_DIR=$TEST_REPO_ROOT/share/templates/default +FAVICON='' TITLE=Current\\ directory\\ config HEIGHT=120 THUMBHEIGHT=30 @@ -1596,6 +1600,7 @@ CONFIG_SOURCE=./shuriken.conf INCOMING_DIR=$TEST_TMPDIR/cli-incoming DIST_DIR=$dist_dir TEMPLATE_DIR=$TEST_TMPDIR/cli-template +FAVICON='' TITLE=CLI\\ title HEIGHT=456 THUMBHEIGHT=45 @@ -3052,6 +3057,49 @@ test_generate_cli_no_splash_overrides_config() { test::teardown } +test_generate_uses_custom_favicon() { + local config_file + local fake_bin + local favicon_src + local output + + test::setup + fake_bin="$TEST_TMPDIR/bin" + config_file="$TEST_TMPDIR/shuriken.conf" + favicon_src="$TEST_TMPDIR/my-favicon.ico" + + test::install_fake_imagemagick "$fake_bin" + PATH="$fake_bin:$PATH" \ + test::generate_fixture_images "$TEST_TMPDIR/incoming" + printf 'CUSTOM-FAVICON-MARKER\n' > "$favicon_src" + test::write_album_config \ + "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \ + 'Favicon album' 40 + + ( + cd "$TEST_TMPDIR" + PATH="$fake_bin:$PATH" "$TEST_SHURIKEN" --generate --favicon "$favicon_src" + ) + + # The published favicon.ico is the custom file, not the bundled default. + test::assert_file_exists "$TEST_TMPDIR/dist/favicon.ico" + test "$(<"$TEST_TMPDIR/dist/favicon.ico")" = 'CUSTOM-FAVICON-MARKER' + # --print-config reports the configured favicon path. + test::assert_contains "FAVICON=$favicon_src" \ + "$(cd "$TEST_TMPDIR" && "$TEST_SHURIKEN" --print-config --favicon "$favicon_src")" + + # A missing favicon is rejected before any output is written. + rm -rf "$TEST_TMPDIR/dist" + output=$( + cd "$TEST_TMPDIR" + test::capture_failure_output "$TEST_SHURIKEN" \ + --generate --favicon "$TEST_TMPDIR/nope.ico" + ) + test::assert_contains 'FAVICON file' "$output" + test::assert_path_absent "$TEST_TMPDIR/dist" + test::teardown +} + # Synthetic `identify -verbose` output with EXIF the stats aggregation can parse, # so a full --generate produces a real camera leaderboard + per-camera page. test::stats_identify_output() { @@ -5701,6 +5749,9 @@ main() { test::run_case \ '--generate --no-splash keeps root index redirect' \ test_generate_cli_no_splash_overrides_config + test::run_case \ + '--generate --favicon uses a custom favicon' \ + test_generate_uses_custom_favicon test::run_case \ '--generate creates stats and per-camera pages with nav link' \ test_generate_stats_pages_created_and_nav_linked -- cgit v1.2.3