diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2022-11-20 23:31:40 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2022-11-20 23:31:40 +0100 |
| commit | 52b0be81663df26b56002533ec93f8008db04d1a (patch) | |
| tree | ad72ba13e6159d647b0bf2619c88c57924a19b82 /post-receive-stagit | |
| download | git-hooks-52b0be81663df26b56002533ec93f8008db04d1a.tar.gz git-hooks-52b0be81663df26b56002533ec93f8008db04d1a.zip | |
First commit
Diffstat (limited to 'post-receive-stagit')
| -rwxr-xr-x | post-receive-stagit | 89 |
1 files changed, 89 insertions, 0 deletions
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 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | repo="$PWD" | ||
| 4 | name="$(basename $repo .git)" | ||
| 5 | basedir="/var/www/htdocs/git.tronto.net" | ||
| 6 | htdir="$basedir/$name" | ||
| 7 | filesdir="/home/git/FILES" | ||
| 8 | |||
| 9 | setupinfo() { | ||
| 10 | echo "Sebastiano Tronto" > owner | ||
| 11 | echo "https://git.tronto.net/$name" > url | ||
| 12 | } | ||
| 13 | |||
| 14 | genstagit() { | ||
| 15 | rm -rf "$htdir" | ||
| 16 | mkdir -p "$basedir" | ||
| 17 | cp -r "$repo" "$htdir" | ||
| 18 | cd "$htdir" && \ | ||
| 19 | git update-server-info && \ | ||
| 20 | git archive HEAD --prefix="$name/" -o "$basedir/$name.zip" | ||
| 21 | stagit -l 100 "$repo" | ||
| 22 | git show master:README.md > file/README.md | ||
| 23 | } | ||
| 24 | |||
| 25 | cpindexfile() { | ||
| 26 | cp "$htdir/files.html" "$htdir/index.html" | ||
| 27 | } | ||
| 28 | |||
| 29 | cpstylefiles() { | ||
| 30 | cp $filesdir/favicon.png "$1" | ||
| 31 | cp $filesdir/logo.png "$1" | ||
| 32 | cp $filesdir/style.css "$1" | ||
| 33 | } | ||
| 34 | |||
| 35 | formatreadme() { | ||
| 36 | printf '%s\n' \ | ||
| 37 | g/class=\"line\"/d \ | ||
| 38 | "/<pre id=\"blob\">" d d i "$(lowdown file/README.md)" . w \ | ||
| 39 | | ed -s file/README.md.html > /dev/null | ||
| 40 | } | ||
| 41 | |||
| 42 | adddownloadbutton() { | ||
| 43 | printf '%s\n' \ | ||
| 44 | "/log\.html\">Log<\/a>" i \ | ||
| 45 | "<a href=\"../$name.zip\">Download</a> |" . w \ | ||
| 46 | | ed -s "$1" > /dev/null | ||
| 47 | } | ||
| 48 | |||
| 49 | addbottombar() { | ||
| 50 | printf '%s\n' \ | ||
| 51 | "/<\/body>" i "$(cat $filesdir/bottom.html)" . w \ | ||
| 52 | | ed -s "$1" > /dev/null | ||
| 53 | } | ||
| 54 | |||
| 55 | changeindextitlestyle() { | ||
| 56 | printf '%s\n' \ | ||
| 57 | "/<td><span class=\"desc\">Repositories" c \ | ||
| 58 | "<td><h1>Repositories</h1></td></tr><tr><td></td><td>" . w \ | ||
| 59 | | ed -s "$basedir/index.html" > /dev/null | ||
| 60 | } | ||
| 61 | |||
| 62 | genstagitindex() { | ||
| 63 | stagit-index /home/git/*.git | \ | ||
| 64 | sed 's|/log\.html||g' > "$basedir/index.html" | ||
| 65 | } | ||
| 66 | |||
| 67 | mkpage() { | ||
| 68 | echo "Updating stagit page for $name" | ||
| 69 | setupinfo | ||
| 70 | genstagit | ||
| 71 | cpindexfile | ||
| 72 | cpstylefiles "./" | ||
| 73 | [ -e file/README.md ] && formatreadme | ||
| 74 | for f in $(find "$htdir" -name "*.html"); do | ||
| 75 | adddownloadbutton $f | ||
| 76 | addbottombar $f | ||
| 77 | done | ||
| 78 | } | ||
| 79 | |||
| 80 | mkindex() { | ||
| 81 | echo "Updating stagit index page" | ||
| 82 | genstagitindex | ||
| 83 | cpstylefiles "$basedir/" | ||
| 84 | addbottombar "$basedir/index.html" | ||
| 85 | changeindextitlestyle | ||
| 86 | } | ||
| 87 | |||
| 88 | mkpage | ||
| 89 | mkindex | ||
