summaryrefslogtreecommitdiff
path: root/syntax-highlighting-client.sh
diff options
context:
space:
mode:
Diffstat (limited to 'syntax-highlighting-client.sh')
-rwxr-xr-xsyntax-highlighting-client.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/syntax-highlighting-client.sh b/syntax-highlighting-client.sh
new file mode 100755
index 0000000..76aced1
--- /dev/null
+++ b/syntax-highlighting-client.sh
@@ -0,0 +1,22 @@
+#!/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.
+#
+# This script requires that syntax-highlighting-server.py be started to handle
+# highlighting requests.
+
+# configure this to your syntax-highlighting port
+base_url="http://localhost:4872/"
+
+path=$(curl -Gso /dev/null \
+ -w "%{url_effective}" \
+ --data-urlencode "filename=$1" \
+ /highlight)
+
+exec curl -sSf \
+ -H 'Content-Type: text/plain' \
+ -H 'Expect:' \
+ --data-binary @- \
+ "${base_url%/}$path"