summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-02-12 17:28:20 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-12 17:28:20 +0100
commit079856ab7ae2be0be90f435949963a70e1f747a7 (patch)
tree16d6488a2f7f3492e817c60331ff22b9818e61ce
parentMerge all cgit repo rules into one. (diff)
downloadcgit-079856ab7ae2be0be90f435949963a70e1f747a7.tar.gz
cgit-079856ab7ae2be0be90f435949963a70e1f747a7.tar.xz
Add cloc to cgit about filter.
-rwxr-xr-xfiles/filters/hugo-pre.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/files/filters/hugo-pre.sh b/files/filters/hugo-pre.sh
index b716525..cd303ec 100755
--- a/files/filters/hugo-pre.sh
+++ b/files/filters/hugo-pre.sh
@@ -13,3 +13,14 @@ case $extension in
;;
esac
+prel_head="$(grep -Eo 'h=([-A-Za-z0-9.~_+]|%[A-Fa-f0-9]{2})*' <<< "$REQUEST_URI")"
+if [ $? -eq 0 ]; then
+ head=$(cut -c 3- <<< "$prel_head")
+else
+ head=$CGIT_REPO_DEFBRANCH
+fi
+
+echo "<hr/>"
+echo "<pre>"
+cloc --git "$head" --quiet --md | pandoc -f gfm -t html
+echo "</pre>"