Last active
November 25, 2020 15:02
-
-
Save ckxng/5fba350bc22e8dd981d7d5a01b5b1daa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# parse the page and pagepath from QUERY_STRING | |
page=$( | |
echo "${QUERY_STRING}" | \ | |
sed -n 's/^.*page=\([^&]*\).*$/\1/p' | \ | |
sed 's/[^a-zA-Z0-9\/\-_]/X/g' | |
) | |
if [ "${page}" = '' ]; then | |
page='index' | |
fi | |
pagepath="../pages/${page}.txt" | |
# return 404 if the page does not exist | |
if test -f $pagepath; then | |
content=$(../../go/bin/markdown $pagepath) | |
else | |
echo "Status: 404 Not Found | |
Content-type: text/html | |
Page \"${page}\" not found. | |
" | |
exit | |
fi | |
# render the page | |
echo "Content-type: text/html | |
... page template ... | |
${content} | |
... page template ... | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment