Improve script a bit
This commit is contained in:
parent
976dc1adcf
commit
848fe19391
15
wiki.sh
15
wiki.sh
|
@ -2,20 +2,23 @@
|
||||||
PAGE=${REQUEST_URI#/}
|
PAGE=${REQUEST_URI#/}
|
||||||
if [ -z $PAGE ]
|
if [ -z $PAGE ]
|
||||||
then
|
then
|
||||||
PAGE=Home
|
PAGE=$INDEX
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
http_header () {
|
||||||
|
echo HTTP/1.0 $@
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
pandoc="pandoc -f gfm -t html -s --template=$TEMPLATE -V title-prefix:$SITE_TITLE -V pagetitle:$PAGE"
|
pandoc="pandoc -f gfm -t html -s --template=$TEMPLATE -V title-prefix:$SITE_TITLE -V pagetitle:$PAGE"
|
||||||
|
|
||||||
git show HEAD:"$PAGE".md > /dev/null
|
git cat-file -e HEAD:"$PAGE".md
|
||||||
|
|
||||||
if [ $? == 0 ]
|
if [ $? == 0 ]
|
||||||
then
|
then
|
||||||
echo HTTP/1.0 200 OK
|
http_header 200 OK
|
||||||
echo
|
|
||||||
git show HEAD:"$PAGE".md | $pandoc
|
git show HEAD:"$PAGE".md | $pandoc
|
||||||
else
|
else
|
||||||
echo HTTP/1.0 404 Not found
|
http_header 404 Not found
|
||||||
echo
|
|
||||||
echo "This page does not exist. [Click here]($REPO_URL/wiki/$PAGE?action=_new) to create it." | $pandoc
|
echo "This page does not exist. [Click here]($REPO_URL/wiki/$PAGE?action=_new) to create it." | $pandoc
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue