summaryrefslogtreecommitdiff
path: root/syntax-highlighting-client.sh
blob: 76aced1dca62e6838078474030339cb25584b791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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"