git-hooks

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.tronto.net/git-hooks
Download | Log | Files | Refs | README

commit 52b0be81663df26b56002533ec93f8008db04d1a
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 20 Nov 2022 23:31:40 +0100

First commit

Diffstat:
AMakefile | 9+++++++++
AREADME.md | 3+++
Abottom.html | 17+++++++++++++++++
Afavicon.png | 0
Alogo.png | 0
Apost-receive-stagit | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Astyle.css | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aupdate-all | 9+++++++++
8 files changed, 226 insertions(+), 0 deletions(-)

diff --git a/Makefile 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 @@ -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 @@ -0,0 +1,17 @@ +<hr class="line"> +<footer> + <table> + <tr> + <td class="contact"> + Back to + <a href="https://sebastiano.tronto.net"> + sebastiano.tronto.net + </a> + </td> + <td class="hosted"> + Generated with + <a href="https://codemadness.org/stagit.html">stagit</a> + </td> + </tr> + </table> +</footer> diff --git a/favicon.png b/favicon.png Binary files differ. diff --git a/logo.png b/logo.png Binary files differ. diff --git a/post-receive-stagit 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 \ + "/<pre id=\"blob\">" 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 \ + "<a href=\"../$name.zip\">Download</a> |" . 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' \ + "/<td><span class=\"desc\">Repositories" c \ + "<td><h1>Repositories</h1></td></tr><tr><td></td><td>" . 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 @@ -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 @@ -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