2023-09-18 03:45:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
PAGE=${REQUEST_URI#/}
|
|
|
|
if [ -z $PAGE ]
|
|
|
|
then
|
2023-09-19 19:58:23 +00:00
|
|
|
PAGE=$INDEX
|
2023-09-18 03:45:31 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-19 19:58:23 +00:00
|
|
|
http_header () {
|
|
|
|
echo HTTP/1.0 $@
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2023-09-18 03:45:31 +00:00
|
|
|
pandoc="pandoc -f gfm -t html -s --template=$TEMPLATE -V title-prefix:$SITE_TITLE -V pagetitle:$PAGE"
|
|
|
|
|
2023-09-19 19:58:23 +00:00
|
|
|
git cat-file -e HEAD:"$PAGE".md
|
2023-09-18 03:45:31 +00:00
|
|
|
|
|
|
|
if [ $? == 0 ]
|
|
|
|
then
|
2023-09-19 19:58:23 +00:00
|
|
|
http_header 200 OK
|
2023-09-18 03:45:31 +00:00
|
|
|
git show HEAD:"$PAGE".md | $pandoc
|
|
|
|
else
|
2023-09-19 19:58:23 +00:00
|
|
|
http_header 404 Not found
|
2023-09-18 03:45:31 +00:00
|
|
|
echo "This page does not exist. [Click here]($REPO_URL/wiki/$PAGE?action=_new) to create it." | $pandoc
|
|
|
|
fi
|