From 52b0be81663df26b56002533ec93f8008db04d1a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 20 Nov 2022 23:31:40 +0100 Subject: First commit --- Makefile | 9 +++++ README.md | 3 ++ bottom.html | 17 +++++++++ favicon.png | Bin 0 -> 8829 bytes logo.png | Bin 0 -> 3050 bytes post-receive-stagit | 89 ++++++++++++++++++++++++++++++++++++++++++++++ style.css | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ update-all | 9 +++++ 8 files changed, 226 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 bottom.html create mode 100644 favicon.png create mode 100644 logo.png create mode 100755 post-receive-stagit create mode 100644 style.css create mode 100755 update-all diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..68fff76 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +push: + ssh git@tronto.net mkdir -p BIN FILES + scp post-receive-stagit update-all git@tronto.net:BIN/ + scp bottom.html favicon.png logo.png style.css git@tronto.net:FILES/ + +clean: + ssh git@tronto.net rm -r FILES/* BIN/* + +.PHONY: clean push diff --git a/README.md b/README.md new file mode 100644 index 0000000..feb9692 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Git hooks + +Some scripts I use to update [my git website](https://git.tronto.net). diff --git a/bottom.html b/bottom.html new file mode 100644 index 0000000..0b3811d --- /dev/null +++ b/bottom.html @@ -0,0 +1,17 @@ +
+ diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..8a6b202 Binary files /dev/null and b/favicon.png differ diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..59708dc Binary files /dev/null and b/logo.png differ 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 diff --git a/style.css b/style.css new file mode 100644 index 0000000..567ef26 --- /dev/null +++ b/style.css @@ -0,0 +1,99 @@ +.menu { + width: 100%; +} + +.links { + text-align: right; + font-weight: bold; +} + +footer table { + font-style: italic; + width: 100%; +} + +.hosted { + text-align: right; +} + +body { + margin: auto 8px 20px 8px; +} + +img { + display: block; + margin-left: auto; + margin-right: auto; + max-width: 100%; +} + +pre, code { + background-color: #eeeeee; +} + +pre { + border: 2px solid; + padding: 6px; +} + +#blob { + background: #ffffff; + border: none; +} + +a { + color: #0f2899; + text-decoration: none; +} + +.links a { + font-weight: bold; + color: black; +} + +.hosted a, +.contact a { + font-weight: bold; +} + +a:hover { + text-decoration: underline; +} + +html { + margin: 1em auto; + max-width: 42em; +} + +h1 { + text-align: center; +} + +td h1 { + text-align: left; + font-size: 1.5em; +} + +table { + width: 100%; +} + +#files td { + font-family: monospace; + font-size: 1.2em; + min-width: 7em; +} + +#log tr:hover td, +#files tr:hover td, +#index tr:hover td { + background-color: #eeeeee; +} + +.url td { + font-family: monospace; +} + +table tr td a img { + min-width: 33px; +} diff --git a/update-all b/update-all new file mode 100755 index 0000000..890a1f5 --- /dev/null +++ b/update-all @@ -0,0 +1,9 @@ +#!/bin/sh + +for g in *.git; do + cd $g + printf '#!/bin/sh\n\n/home/git/BIN/post-receive-stagit\n' >> \ + hooks/post-receive + /home/git/BIN/post-receive-stagit + cd +done -- cgit v1.3