X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=9b38362b665dffae0b6a0f59286e0aff5d8da30e;hb=1ceb1ca02e8cc1a55443152b8505e3949007ce54;hp=9d2ed3d657b4f8cc16b19511c5d7a53654b361bb;hpb=3d34cb0400fc26eaefaf1b0299ddf9dcc0a090b9;p=shellwiki diff --git a/index.cgi b/index.cgi index 9d2ed3d..9b38362 100755 --- a/index.cgi +++ b/index.cgi @@ -1,10 +1,9 @@ #!/bin/sh . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh" -set -- nocookie . "${_EXEC}/cgilite/session.sh" . "${_EXEC}/cgilite/file.sh" -# . "$_EXEC"/cgilite/users.sh +. "${_EXEC}/cgilite/users.sh" . "${_EXEC}/themes/default.sh" @@ -20,6 +19,20 @@ else md() { cat; } fi +wiki_text() { + # Print source text of a wiki page + # Get page from data or underlay dir + local page="$(PATH "$1")" + + if [ -f "$_DATA/pages/$page/#page.md" ]; then + cat -- "$_DATA/pages/$page/#page.md" + elif [ -f "$_EXEC/pages/$page/#page.md" ]; then + cat -- "$_EXEC/pages/$page/#page.md" + else + return 1 + fi +} + wiki() { # Print content of a wiki page # Get page from data or underlay dir, handle caching @@ -66,24 +79,27 @@ attachment() { } case "${PATH_INFO}" in - /"[wiki]"/*) - FILE "${_EXEC}/${PATH_INFO#/\[wiki\]}" + /"[.]"/*) + FILE "${_EXEC}/${PATH_INFO#/\[.\]}" ;; */) if [ -f "$_DATA/pages/$PATH_INFO/#page.md" \ -o -f "$_EXEC/pages/$PATH_INFO/#page.md" ]; then theme_page "${PATH_INFO}" - else - theme_404 fi ;; - */"[attachment]"/*) - : # TODO: Original attachment file + */"[login]") + [ "$USER_NAME" ] \ + && REDIRECT "./" \ + || theme_login + ;; + */"[register]") + theme_register ;; */"#"*) : # TODO: Invalid page name ;; - *) - attachment "${PATH_INFO}" - ;; esac + +. "$_EXEC/page_edit.sh" +. "$_EXEC/attachment.sh"