Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (git@myr.sh)
Date: Wed Sep 20 01:19:32 2023 -0300
Parent: f9da3c6
Added script to create tree page * Adjusted README * Improved code efficiency
diff --git a/README.md b/README.md
index 7c7fde0..bdd49af 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,12 @@
# Dovel Scripts
-This repo has shell scripts that are part of the dovel project, some are
-meant only for deployment on our website. Some explanation:
+This repo has shell scripts that are part of the dovel project, some are meant only for deployment on our website. Some explanation:
- post-receive: git hook to build html pages
- update*: used by git to creat html pages
- receive-localhost: saves emails and create html pages
-## Contributing
-Scripts are super welcome, as well as full programs to be compiled. Add here
-anything that may help saving emails the way you like.
+## Contributing
+Scripts are super welcome, as well as full programs to be compiled. Add here anything that may help saving emails the way you like.
diff --git a/post-receive b/post-receive
index 599c628..94af5c3 100755
--- a/post-receive
+++ b/post-receive
@@ -3,9 +3,13 @@
# for debugging
# set -ex
+REPO="$(basename $PWD)"
OUT="$HOME/www/dovel.email"
GITDIR="$HOME/git/dovel.email"
+[ -d "$OUT/$REPO/tree" ] || mkdir -p "$OUT/$REPO/tree"
+
+git clone . "$OUT/$REPO/tree"
# latter on the latest commits section
# git --git-dir "$dir" log -n 1 --format="%h at %ah"
diff --git a/update-git-index b/update-git-index
index 1d66e8d..36be761 100755
--- a/update-git-index
+++ b/update-git-index
@@ -1,8 +1,6 @@
#!/bin/sh
echo "updating git pages"
-OUT="$HOME/www/dovel.email"
-GITDIR="$HOME/git/dovel.email"
# git.html lists all repos
cat << EOF > "$OUT/git.html"
diff --git a/update-repo-index b/update-repo-index
index f906565..420b460 100755
--- a/update-repo-index
+++ b/update-repo-index
@@ -4,16 +4,11 @@
# set -ex
echo "updating git index"
-REPO="$(basename $PWD)"
OUT="$HOME/www/dovel.email/$REPO"
-[ -d "$OUT" ] || mkdir "$OUT"
-
# archives
echo "creating archives"
-TMP="$(mktemp -d)"
-git clone . "$TMP"
-tar -czf "$OUT/$REPO.zip" "$TMP"
+tar -czf "$OUT/$REPO.zip" "$OUT/tree/"
git archive -o "$OUT/$REPO-HEAD.zip" HEAD
echo "creating index.html"
@@ -62,9 +57,9 @@ cat << EOF > "$OUT/index.html"
</nav>
<p><i>$(cat description)</i></p>
</center>
- <p>Latest commit: $(git log -n 1 --format="(%h) by %an at %as: %s")</p>
<hr>
- <pre>$(cat "$TMP/README"*)</pre>
+ <p>Latest commit: $(git log -n 1 --format="(%h) by %an at %as: %s")</p>
+ <pre>$(cat "$OUT/tree/README"*)</pre>
</body>
</html>
EOF
diff --git a/update-repo-tree b/update-repo-tree
new file mode 100755
index 0000000..c92624e
--- /dev/null
+++ b/update-repo-tree
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# for debugging
+# set -ex
+echo "updating git tree"
+
+OUT="$HOME/www/dovel.email/$REPO"
+
+echo "creating tree.html"
+cat << EOF > "$OUT/tree.html"
+<!DOCTYPE html>
+<html>
+<head>
+ <title>$REPO's git</title>
+ <meta charset="UTF-8">
+ <meta name="author" content="Brian Lee Mayer">
+ <meta name="description" content="This is the development homepage of the Dovel project, this is the repo $REPO. Find here code, all mailing lists and latest development changes.">
+ <meta name="language" content="english">
+ <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="light dark">
+ <style>
+ body {
+ max-width: 600px;
+ margin: 60px auto;
+ padding: 20px;
+ font-family: sans-serif;
+ }
+ pre {
+ white-space: pre-line;
+ font-family: monospace;
+ background: lightgray;
+ padding: 8px;
+ border-radius: 8px;
+ }
+ ol li {padding-bottom: 10px}
+ tt {font-weight: bold}
+ @media (prefers-color-scheme: dark) {
+ pre {background: darkslategray}
+ }
+ </style>
+</head>
+<body>
+ <center>
+ <h1>$REPO</h1>
+ <nav>
+ <a href=index.html>index</a>  
+ <a href=refs.html>refs</a>  
+ <a href=log.html>log</a>  
+ <a>tree</a>  
+ <a href=mail.html>mail</a>
+ </nav>
+ <p><i>$(cat description)</i></p>
+ </center>
+ <hr>
+ <h1>Tree</h1>
+ <table>
+ <tr><th>Size</th><th>Name</th><th>Raw</th></tr>
+EOF
+
+cd "$OUT/tree" && find * -type f -printf '%s %p\n' | while read -r s f
+do
+ cat <<- EOF >> "$OUT/tree.html"
+ <tr>
+ <td>$s</td>
+ <td><a href=$f.html>$f</a></td>
+ <td><a href=$f>raw</a></td>
+ </tr>
+ EOF
+done