summaryrefslogtreecommitdiff
path: root/usr/lib
diff options
context:
space:
mode:
authorXiao Pan <xyz@flylightning.xyz>2025-07-10 08:08:59 +0000
committerXiao Pan <xyz@flylightning.xyz>2025-07-10 08:08:59 +0000
commit5abb40c5be90e5257cdfae51c165f00c5398f32c (patch)
tree40a115444d89d6f6c82b854c185790686d0bdb95 /usr/lib
parent673c18cbf2c80de0aa5aa03b24cd026cf742412b (diff)
starting to move studio website to ca, now moving configs
Diffstat (limited to 'usr/lib')
-rwxr-xr-xusr/lib/cgit/filters/about-formatting-edited.sh29
-rwxr-xr-xusr/lib/cgit/filters/syntax-highlighting-edited.sh33
2 files changed, 62 insertions, 0 deletions
diff --git a/usr/lib/cgit/filters/about-formatting-edited.sh b/usr/lib/cgit/filters/about-formatting-edited.sh
new file mode 100755
index 00000000..e919e54d
--- /dev/null
+++ b/usr/lib/cgit/filters/about-formatting-edited.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# This may be used with the about-filter or repo.about-filter setting in cgitrc.
+# It passes formatting of about pages to differing programs, depending on the usage.
+
+# Markdown support requires python and markdown-python.
+# RestructuredText support requires python and docutils.
+# Man page support requires groff.
+
+# The following environment variables can be used to retrieve the configuration
+# of the repository for which this script is called:
+# CGIT_REPO_URL ( = repo.url setting )
+# CGIT_REPO_NAME ( = repo.name setting )
+# CGIT_REPO_PATH ( = repo.path setting )
+# CGIT_REPO_OWNER ( = repo.owner setting )
+# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
+# CGIT_REPO_SECTION ( = section setting )
+# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
+
+# note `pwd` when cgit run this script is /, can be tested by `cat '<p>$(pwd)</p>'`
+# so need to get those scripts location via $0, $0 is /usr/lib/cgit/filters/about-formatting-edited.sh
+dir="$(dirname "$0")/html-converters/"
+case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in
+ *.markdown|*.mdown|*.md|*.mkd) exec cmark;;
+# *.rst) exec "$dir/rst2html";;
+ *.[1-9]) exec "$dir/man2html";;
+ *.htm|*.html) exec cat;;
+ *.txt|*) exec "$dir/txt2html";;
+esac
diff --git a/usr/lib/cgit/filters/syntax-highlighting-edited.sh b/usr/lib/cgit/filters/syntax-highlighting-edited.sh
new file mode 100755
index 00000000..111b1928
--- /dev/null
+++ b/usr/lib/cgit/filters/syntax-highlighting-edited.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# This script can be used to implement syntax highlighting in the cgit
+# tree-view by referring to this file with the source-filter or repo.source-
+# filter options in cgitrc.
+#
+# Note: the highlight command (https://gitlab.com/saalen/highlight) uses css for syntax
+# highlighting, I choose to output a file /usr/share/webapps/cgit/highlight.css
+# by `highlight -O xhtml --print-style` and import it in mycgit.css for cgit to use.
+#
+# The following environment variables can be used to retrieve the configuration
+# of the repository for which this script is called:
+# CGIT_REPO_URL ( = repo.url setting )
+# CGIT_REPO_NAME ( = repo.name setting )
+# CGIT_REPO_PATH ( = repo.path setting )
+# CGIT_REPO_OWNER ( = repo.owner setting )
+# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
+# CGIT_REPO_SECTION ( = section setting )
+# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
+
+syntax=
+case "$1" in
+ nginx.conf) syntax=nginx;;
+ pacman.conf) syntax=ini;;
+ cgitrc) syntax=ini;;
+ .gitolite.rc) syntax=perl;;
+esac
+
+# `--force` needed for highlight; one example is `< textfile highlight -O ansi --force`, without `--force` will error 1 and no output
+if [ "$syntax" ]; then
+ exec highlight --force -f -I -O xhtml -S "$syntax" 2>/dev/null
+else
+ exec highlight --force -f -I -O xhtml --syntax-by-name "$1" 2>/dev/null
+fi