ctucx.git: stagit

ctucx' stagit fork

commit ecbac75848acfcd7ed4bba624358ffd62624344b
parent 65a2b9768d412317adabc0d6e99894842b7738ba
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date: Mon, 22 Jun 2020 23:29:40 +0200

Add my assets
5 files changed, 108 insertions(+), 67 deletions(-)
M
example_create.sh
|
65
++++++++++++++++++++++++++++++++++++++++-------------------------
M
example_post-receive.sh
|
60
++++++++++++++++++++++++++++--------------------------------
M
favicon.ico
|
0
M
logo.png
|
0
M
style.css
|
50
++++++++++++++++++++++++++++++++++++++++----------
diff --git a/example_create.sh b/example_create.sh
@@ -15,29 +15,44 @@
 # - mkdir -p htmldir && cd htmldir
 # - sh example_create.sh
 
-# path must be absolute.
-reposdir="/var/www/domains/git.codemadness.nl/home/src"
-curdir="$(pwd)"
-
-# make index.
-stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
-
-# make files per repo.
-for dir in "${reposdir}/"*/; do
-	# strip .git suffix.
-	r=$(basename "${dir}")
-	d=$(basename "${dir}" ".git")
-	printf "%s... " "${d}"
-
-	mkdir -p "${curdir}/${d}"
-	cd "${curdir}/${d}" || continue
-	stagit -c ".cache" "${reposdir}/${r}"
-
-	# symlinks
-	ln -sf log.html index.html
-	ln -sf ../style.css style.css
-	ln -sf ../logo.png logo.png
-	ln -sf ../favicon.ico favicon.ico
-
-	echo "done"
+# path must be absolute
+reposdir="/srv/git"
+webdir="/srv/git/html"
+defaultdir="/usr/local/share/doc/stagit"
+
+mkdir -p "$webdir" || exit 1
+
+# set assets if not already there
+ln -s "$defaultdir/style.css" "$webdir/style.css" 2> /dev/null
+ln -s "$defaultdir/logo.png" "$webdir/logo.png" 2> /dev/null
+ln -s "$defaultdir/favicon.ico" "$webdir/favicon.ico" 2> /dev/null
+
+# clean
+for dir in "$webdir/"*/; do
+    rm -rf "$dir"
 done
+
+repos=""
+
+# make files per repo
+for dir in "$reposdir/"*.git/; do
+    [ ! -f "$dir/git-daemon-export-ok" ] && continue
+    repos="$repos $dir"
+
+    # strip .git suffix
+    r=$(basename "$dir")
+    d=$(basename "$dir" ".git")
+    printf "%s... " "$d"
+
+    mkdir -p "$webdir/$d"
+    cd "$webdir/$d" || continue
+    stagit -c ".stagit-build-cache" "$reposdir/$r"
+
+    # symlinks
+    ln -sf log.html index.html
+
+    echo "done"
+done
+
+# make index
+echo "$repos" | xargs stagit-index > "$webdir/index.html"
diff --git a/example_post-receive.sh b/example_post-receive.sh
@@ -14,60 +14,56 @@ export LC_CTYPE="en_US.UTF-8"
 
 name="$1"
 if test "${name}" = ""; then
-	name=$(basename "$(pwd)")
+    name=$(basename "$(pwd)")
 fi
 
-# config
-# paths must be absolute.
-reposdir="/home/src/src"
+# paths must be absolute
+reposdir="/srv/git"
 dir="${reposdir}/${name}"
-htmldir="/home/www/domains/git.codemadness.org/htdocs"
-stagitdir="/"
-destdir="${htmldir}${stagitdir}"
-cachefile=".htmlcache"
-# /config
+destdir="/srv/git/html"
+cachefile=".stagit-build-cache"
 
 if ! test -d "${dir}"; then
-	echo "${dir} does not exist" >&2
-	exit 1
+    echo "${dir} does not exist" >&2
+    exit 1
 fi
 cd "${dir}" || exit 1
 
+[ -f "${dir}/git-daemon-export-ok" ] || exit 0
+
 # detect git push -f
 force=0
 while read -r old new ref; do
-	test "${old}" = "0000000000000000000000000000000000000000" && continue
-	test "${new}" = "0000000000000000000000000000000000000000" && continue
+    test "${old}" = "0000000000000000000000000000000000000000" && continue
+    test "${new}" = "0000000000000000000000000000000000000000" && continue
 
-	hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
-	if test -n "${hasrevs}"; then
-		force=1
-		break
-	fi
+    hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
+    if test -n "${hasrevs}"; then
+        force=1
+        break
+    fi
 done
 
-# strip .git suffix.
+# strip .git suffix
 r=$(basename "${name}")
 d=$(basename "${name}" ".git")
 printf "[%s] stagit HTML pages... " "${d}"
 
+# remove folder if forced update
+[ "${force}" = "1" ] && printf "forced update... " && rm -rf "${destdir}/${d}"
+
 mkdir -p "${destdir}/${d}"
 cd "${destdir}/${d}" || exit 1
 
-# remove commits and ${cachefile} on git push -f, this recreated later on.
-if test "${force}" = "1"; then
-	rm -f "${cachefile}"
-	rm -rf "commit"
-fi
-
-# make index.
-stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
-
-# make pages.
+# make pages
 stagit -c "${cachefile}" "${reposdir}/${r}"
-
 ln -sf log.html index.html
-ln -sf ../style.css style.css
-ln -sf ../logo.png logo.png
+
+# make index
+repos=""
+for dir in "$reposdir/"*.git/; do
+    [ -f "$dir/git-daemon-export-ok" ] && repos="$repos $dir"
+done
+echo "$repos" | xargs stagit-index > "${destdir}/index.html"
 
 echo "done"
diff --git a/favicon.ico b/favicon.ico  Binary files differ.
diff --git a/logo.png b/logo.png  Binary files differ.
diff --git a/style.css b/style.css
@@ -1,7 +1,41 @@
+:root {
+	--diff-green: #181;
+	--diff-red: #e02;
+	--links: #00c;
+	--code-border: #d2d2d2;
+	--gray: #777;
+	--hover-bg: #eee;
+}
+
 body {
 	color: #000;
 	background-color: #fff;
 	font-family: monospace;
+	max-width: 900px;
+	margin: 8px auto;
+	padding: 5px;
+}
+
+#content {
+	max-width: 800px;
+	overflow-x: auto;
+	margin: auto;
+}
+
+#log, #index {
+	min-width: 600px;
+	overflow-x: auto;
+}
+
+pre {
+	overflow-x: auto;
+	border: 1px solid var(--code-border);
+	border-radius: 4px;
+	padding: 10px;
+}
+
+a {
+	color: var(--links);
 }
 
 h1, h2, h3, h4, h5, h6 {

@@ -29,7 +63,7 @@ a.line {
 }
 
 #blob a {
-	color: #777;
+	color: var(--gray);
 }
 
 #blob a:hover {

@@ -55,7 +89,7 @@ table td {
 #index tr:hover td,
 #log tr:hover td,
 #files tr:hover td {
-	background-color: #eee;
+	background-color: var(--hover-bg);
 }
 
 #index tr td:nth-child(2),

@@ -70,12 +104,12 @@ td.num {
 }
 
 .desc {
-	color: #777;
+	color: var(--gray);
 }
 
 hr {
 	border: 0;
-	border-top: 1px solid #777;
+	border-top: 1px solid var(--gray);
 	height: 1px;
 }
 

@@ -83,20 +117,16 @@ pre {
 	font-family: monospace;
 }
 
-pre a.h {
-	color: #00a;
-}
-
 .A,
 span.i,
 pre a.i {
-	color: #070;
+	color: var(--diff-green);
 }
 
 .D,
 span.d,
 pre a.d {
-	color: #e00;
+	color: var(--diff-red);
 }
 
 pre a.h:hover,