diff options
Diffstat (limited to 'cgit-about-filter.sh')
-rwxr-xr-x | cgit-about-filter.sh | 32 |
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 | |||
16 | plaintext() { | ||
17 | echo "<pre><code>" | ||
18 | awk \ | ||
19 | '{ | ||
20 | gsub(/&/,"\\&"); | ||
21 | gsub(/</,"\\<"); | ||
22 | gsub(/>/,"\\>"); | ||
23 | print; | ||
24 | }' | ||
25 | echo "</pre></code>" | ||
26 | } | ||
27 | |||
28 | case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in | ||
29 | *.markdown|*.mdown|*.md|*.mkd) exec pandoc -thtml -fmarkdown ;; | ||
30 | *.htm|*.html) exec cat ;; | ||
31 | *) plaintext ;; | ||
32 | esac | ||