about summary refs log tree commit diff stats
path: root/cgit-about-filter.sh
diff options
context:
space:
mode:
Diffstat (limited to 'cgit-about-filter.sh')
-rwxr-xr-xcgit-about-filter.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/cgit-about-filter.sh b/cgit-about-filter.sh new file mode 100755 index 0000000..ad2c4ce --- /dev/null +++ b/cgit-about-filter.sh
@@ -0,0 +1,32 @@
1#!/bin/sh
2
3# This may be used with the about-filter or repo.about-filter setting in cgitrc.
4# It passes formatting of about pages to differing programs, depending on the usage.
5
6# The following environment variables can be used to retrieve the configuration
7# of the repository for which this script is called:
8# CGIT_REPO_URL ( = repo.url setting )
9# CGIT_REPO_NAME ( = repo.name setting )
10# CGIT_REPO_PATH ( = repo.path setting )
11# CGIT_REPO_OWNER ( = repo.owner setting )
12# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
13# CGIT_REPO_SECTION ( = section setting )
14# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
15
16plaintext() {
17 echo "<pre><code>"
18 awk \
19 '{
20 gsub(/&/,"\\&amp;");
21 gsub(/</,"\\&lt;");
22 gsub(/>/,"\\&gt;");
23 print;
24 }'
25 echo "</pre></code>"
26}
27
28case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in
29 *.markdown|*.mdown|*.md|*.mkd) exec pandoc -thtml -fmarkdown ;;
30 *.htm|*.html) exec cat ;;
31 *) plaintext ;;
32esac