Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: blmayer (bleemayer@gmail.com)
Date: Wed Oct 4 02:20:59 2023 -0300
Parent: a6390cf
Improve page creation
diff --git a/post-receive b/post-receive index a26eb75..83d0a3c 100755 --- a/post-receive +++ b/post-receive @@ -59,8 +59,8 @@ updategit() { } updateindex() { - echo "creating archives" - tar -C "$OUT" -cz tree/ --xform="s/tree/$REPO/" > "$OUT.tar.gz" + echo "creating archive" + tar -C "$OUT" -cz raw/ --xform="s/raw/$REPO/" > "$OUT.tar.gz" echo "creating index.html" cat <<- EOF > "$OUT/index.html" @@ -68,7 +68,7 @@ updateindex() { $(pagesummary "$REPO") <hr> <p>Latest commit: $(git log -n 1 --format="(%h) by %an at %as: %s")</p> - <pre style="white-space:pre-line">$(cat "$OUT/tree/README"*)</pre> + <pre style="white-space:pre-line">$(cat "$OUT/raw/README"*)</pre> </body> </html> EOF @@ -193,7 +193,7 @@ filepage() { while IFS= read -r l do printf "<li>%s</li>\n" "$(printf "%s" "$l" | escapehtml)" - done < "$OUT/tree/$1" + done < "$OUT/raw/$1" echo "</ol>\n</pre>\n</file>\n</body>\n</html>" } @@ -209,19 +209,24 @@ updatetree() { <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 + # (cd "$OUT/tree" && find * -type f -printf '%s %p\n') | while read -r s f + git show --format='' --name-status "$1" | while read -r op f do echo "updating file $f" + [ "$op" = "D" ] && rm "$OUT/tree/$f.html"; continue cat <<- EOF >> "$OUT/tree.html" <tr> <td>$s</td> <td><a href=tree/$f.html>$f</a></td> - <td><a href=tree/$f>raw</a></td> + <td><a href=raw/$f>raw</a></td> </tr> EOF + + # create html page with file content filepage "$f" > "$OUT/tree/$f.html" done + cat <<- EOF >> "$OUT/tree.html" </table> </body> @@ -242,9 +247,9 @@ creategomod() { rm -rf "$TMP" } -[ -d "$OUT/tree" ] && rm -rf "$OUT/tree" +[ -d "$OUT/raw" ] && rm -rf "$OUT/raw" [ -d "$OUT/log" ] || mkdir -p "$OUT/log" -git clone . "$OUT/tree" +git clone . "$OUT/raw" while read oldrev newrev ref do @@ -253,7 +258,7 @@ do updategit updateindex updaterefs - updatetree + updatetree "$newrev" updatelog ;; "refs/tags/v"*) @@ -261,7 +266,7 @@ do # check repo for go mod tag="${ref#refs/tags/}" - find "$OUT/tree/" -name go.mod && creategomod "$tag" + find "$OUT/raw/" -name go.mod && creategomod "$tag" ;; *) echo "$ref received. Doing nothing." ;; esac