aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-11-20 23:31:40 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2022-11-20 23:31:40 +0100
commit52b0be81663df26b56002533ec93f8008db04d1a (patch)
treead72ba13e6159d647b0bf2619c88c57924a19b82
downloadgit-hooks-52b0be81663df26b56002533ec93f8008db04d1a.tar.gz
git-hooks-52b0be81663df26b56002533ec93f8008db04d1a.zip
First commit
-rw-r--r--Makefile9
-rw-r--r--README.md3
-rw-r--r--bottom.html17
-rw-r--r--favicon.pngbin0 -> 8829 bytes
-rw-r--r--logo.pngbin0 -> 3050 bytes
-rwxr-xr-xpost-receive-stagit89
-rw-r--r--style.css99
-rwxr-xr-xupdate-all9
8 files changed, 226 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..68fff76
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
1push:
2 ssh git@tronto.net mkdir -p BIN FILES
3 scp post-receive-stagit update-all git@tronto.net:BIN/
4 scp bottom.html favicon.png logo.png style.css git@tronto.net:FILES/
5
6clean:
7 ssh git@tronto.net rm -r FILES/* BIN/*
8
9.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 @@
1# Git hooks
2
3Some 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 @@
1<hr class="line">
2<footer>
3 <table>
4 <tr>
5 <td class="contact">
6 Back to
7 <a href="https://sebastiano.tronto.net">
8 sebastiano.tronto.net
9 </a>
10 </td>
11 <td class="hosted">
12 Generated with
13 <a href="https://codemadness.org/stagit.html">stagit</a>
14 </td>
15 </tr>
16 </table>
17</footer>
diff --git a/favicon.png b/favicon.png
new file mode 100644
index 0000000..8a6b202
--- /dev/null
+++ b/favicon.png
Binary files differ
diff --git a/logo.png b/logo.png
new file mode 100644
index 0000000..59708dc
--- /dev/null
+++ b/logo.png
Binary files 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 @@
1#!/bin/sh
2
3repo="$PWD"
4name="$(basename $repo .git)"
5basedir="/var/www/htdocs/git.tronto.net"
6htdir="$basedir/$name"
7filesdir="/home/git/FILES"
8
9setupinfo() {
10 echo "Sebastiano Tronto" > owner
11 echo "https://git.tronto.net/$name" > url
12}
13
14genstagit() {
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
25cpindexfile() {
26 cp "$htdir/files.html" "$htdir/index.html"
27}
28
29cpstylefiles() {
30 cp $filesdir/favicon.png "$1"
31 cp $filesdir/logo.png "$1"
32 cp $filesdir/style.css "$1"
33}
34
35formatreadme() {
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
42adddownloadbutton() {
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
49addbottombar() {
50 printf '%s\n' \
51 "/<\/body>" i "$(cat $filesdir/bottom.html)" . w \
52 | ed -s "$1" > /dev/null
53}
54
55changeindextitlestyle() {
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
62genstagitindex() {
63 stagit-index /home/git/*.git | \
64 sed 's|/log\.html||g' > "$basedir/index.html"
65}
66
67mkpage() {
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
80mkindex() {
81 echo "Updating stagit index page"
82 genstagitindex
83 cpstylefiles "$basedir/"
84 addbottombar "$basedir/index.html"
85 changeindextitlestyle
86}
87
88mkpage
89mkindex
diff --git a/style.css b/style.css
new file mode 100644
index 0000000..567ef26
--- /dev/null
+++ b/style.css
@@ -0,0 +1,99 @@
1.menu {
2 width: 100%;
3}
4
5.links {
6 text-align: right;
7 font-weight: bold;
8}
9
10footer table {
11 font-style: italic;
12 width: 100%;
13}
14
15.hosted {
16 text-align: right;
17}
18
19body {
20 margin: auto 8px 20px 8px;
21}
22
23img {
24 display: block;
25 margin-left: auto;
26 margin-right: auto;
27 max-width: 100%;
28}
29
30pre, code {
31 background-color: #eeeeee;
32}
33
34pre {
35 border: 2px solid;
36 padding: 6px;
37}
38
39#blob {
40 background: #ffffff;
41 border: none;
42}
43
44a {
45 color: #0f2899;
46 text-decoration: none;
47}
48
49.links a {
50 font-weight: bold;
51 color: black;
52}
53
54.hosted a,
55.contact a {
56 font-weight: bold;
57}
58
59a:hover {
60 text-decoration: underline;
61}
62
63html {
64 margin: 1em auto;
65 max-width: 42em;
66}
67
68h1 {
69 text-align: center;
70}
71
72td h1 {
73 text-align: left;
74 font-size: 1.5em;
75}
76
77table {
78 width: 100%;
79}
80
81#files td {
82 font-family: monospace;
83 font-size: 1.2em;
84 min-width: 7em;
85}
86
87#log tr:hover td,
88#files tr:hover td,
89#index tr:hover td {
90 background-color: #eeeeee;
91}
92
93.url td {
94 font-family: monospace;
95}
96
97table tr td a img {
98 min-width: 33px;
99}
diff --git a/update-all b/update-all
new file mode 100755
index 0000000..890a1f5
--- /dev/null
+++ b/update-all
@@ -0,0 +1,9 @@
1#!/bin/sh
2
3for g in *.git; do
4 cd $g
5 printf '#!/bin/sh\n\n/home/git/BIN/post-receive-stagit\n' >> \
6 hooks/post-receive
7 /home/git/BIN/post-receive-stagit
8 cd
9done

Generated with cgit - Back to sebastiano.tronto.net