From 94c49df7dd27629d6a28f50028db483085907c96 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 6 Oct 2025 01:06:30 +0300 Subject: added scripts used for administration of fmsbw.de --- generate-index-html.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 generate-index-html.sh (limited to 'generate-index-html.sh') diff --git a/generate-index-html.sh b/generate-index-html.sh new file mode 100755 index 0000000..bf6fd3e --- /dev/null +++ b/generate-index-html.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Generates an index.html with support for rendering a README.md if present. +# With -R an entire directory hierarchy can be converted. +# generate-index-html [-R] +set -e + +if [ "x$1" = "x-R" ]; then + exec find "$2" -type d -exec "$0" '{}' ';' +fi + +cd "$1" + +(echo 'Directory listing' + if [ -f README.md ]; then + lowdown -thtml --html-no-skiphtml --html-no-escapehtml README.md + echo '
' + fi + echo -n '
'
+ # Assumes a BSD ls.
+ ls -Flha | grep -Ev ' (\./|index\.html|README\.md|\.git/|\.gitignore)$' | \
+ cut -w -f 5- | sed -E 's|^([^\t]+\t+)([^ ]+ +)([^ ]+ +)([^ ]+ +)(.*[^*])\*?$|\1\2\3\4\5|'
+ echo '
' +) >index.html -- cgit v1.2.3