From 52b0be81663df26b56002533ec93f8008db04d1a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 20 Nov 2022 23:31:40 +0100 Subject: First commit --- post-receive-stagit | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 post-receive-stagit (limited to 'post-receive-stagit') diff --git a/post-receive-stagit b/post-receive-stagit new file mode 100755 index 0000000..396eefd --- /dev/null +++ b/post-receive-stagit @@ -0,0 +1,89 @@ +#!/bin/sh + +repo="$PWD" +name="$(basename $repo .git)" +basedir="/var/www/htdocs/git.tronto.net" +htdir="$basedir/$name" +filesdir="/home/git/FILES" + +setupinfo() { + echo "Sebastiano Tronto" > owner + echo "https://git.tronto.net/$name" > url +} + +genstagit() { + rm -rf "$htdir" + mkdir -p "$basedir" + cp -r "$repo" "$htdir" + cd "$htdir" && \ + git update-server-info && \ + git archive HEAD --prefix="$name/" -o "$basedir/$name.zip" + stagit -l 100 "$repo" + git show master:README.md > file/README.md +} + +cpindexfile() { + cp "$htdir/files.html" "$htdir/index.html" +} + +cpstylefiles() { + cp $filesdir/favicon.png "$1" + cp $filesdir/logo.png "$1" + cp $filesdir/style.css "$1" +} + +formatreadme() { + printf '%s\n' \ + g/class=\"line\"/d \ + "/
" d d i "$(lowdown file/README.md)" . w \
+	| ed -s file/README.md.html > /dev/null
+}
+
+adddownloadbutton() {
+	printf '%s\n' \
+		"/log\.html\">Log<\/a>" i \
+		"Download |" . w \
+	| ed -s "$1" > /dev/null
+}
+
+addbottombar() {
+	printf '%s\n' \
+		"/<\/body>" i "$(cat $filesdir/bottom.html)" . w \
+	| ed -s "$1" > /dev/null
+}
+
+changeindextitlestyle() {
+	printf '%s\n' \
+		"/Repositories" c \
+		"

Repositories

" . w \ + | ed -s "$basedir/index.html" > /dev/null +} + +genstagitindex() { + stagit-index /home/git/*.git | \ + sed 's|/log\.html||g' > "$basedir/index.html" +} + +mkpage() { + echo "Updating stagit page for $name" + setupinfo + genstagit + cpindexfile + cpstylefiles "./" + [ -e file/README.md ] && formatreadme + for f in $(find "$htdir" -name "*.html"); do + adddownloadbutton $f + addbottombar $f + done +} + +mkindex() { + echo "Updating stagit index page" + genstagitindex + cpstylefiles "$basedir/" + addbottombar "$basedir/index.html" + changeindextitlestyle +} + +mkpage +mkindex -- cgit v1.3