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 13:22:32 2023 -0300
Parent: 78d0959
Added script to create file pages
diff --git a/create-file-page b/create-file-page
new file mode 100755
index 0000000..920d135
--- /dev/null
+++ b/create-file-page
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# for debugging
+# set -ex
+cat << EOF
+<!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;
+ }
+ table {width: 100%}
+ th {text-align: left}
+ 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 href=/$REPO/tree.html>tree</a>  
+ <a href=mail.html>mail</a>
+ </nav>
+ <p><i>$(cat description)</i></p>
+ </center>
+ <hr>
+ <h2>$1</h2>
+ <pre>
+ <ol>
+EOF
+ while read -r l
+ do
+ echo "<li>$l</li>"
+ done < "$OUT/tree/$1"
+
+ echo "</ol>\n</pre>\n</body>\n</html>"
diff --git a/post-receive-scripts b/post-receive-scripts
index a8b4281..2a65ca8 100755
--- a/post-receive-scripts
+++ b/post-receive-scripts
@@ -27,6 +27,7 @@ do
cp "$TMP/update-git-index" "$dir/hooks/"
cp "$TMP/update-repo-index" "$dir/hooks/"
cp "$TMP/update-repo-tree" "$dir/hooks/"
+ cp "$TMP/create-file-page" "$dir/hooks/"
done
# for this repo copy scripts
diff --git a/update-repo-tree b/update-repo-tree
index 6d49e88..82f8bf9 100755
--- a/update-repo-tree
+++ b/update-repo-tree
@@ -26,9 +26,8 @@ cat << EOF > "$OUT/tree.html"
padding: 20px;
font-family: sans-serif;
}
- table {
- width: 100%
- }
+ table {width: 100%}
+ th {text-align: left}
pre {
white-space: pre-line;
font-family: monospace;
@@ -56,14 +55,17 @@ cat << EOF > "$OUT/tree.html"
<p><i>$(cat description)</i></p>
</center>
<hr>
- <h1>Tree</h1>
+ <h2>Tree</h2>
<table>
<tr><th>Size</th><th>Name</th><th>Raw</th></tr>
EOF
# TODO: create each html page for a file
-cd "$OUT/tree" && find * -type f -printf '%s %p\n' | while read -r s f
+files="$(cd "$OUT/tree" && find * -type f -printf '%s %p\n')"
+echo $files | while read -r s f
do
+ echo "updating file $1"
+
cat <<- EOF >> "$OUT/tree.html"
<tr>
<td>$s</td>
@@ -71,4 +73,5 @@ do
<td><a href=tree/$f>raw</a></td>
</tr>
EOF
+ ./create-file-page "$f" > "$OUT/tree/$f.html"
done