X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=61a8bb007c5d0807eaf9d6983d34637e74e583fc;hb=0d5786afa416aa19fc5c0bedd0dea93532abd34f;hp=0c7e914062c3d99c38420e106c32b6a29c3dc59d;hpb=b86e88d2d6acd3eda7d9858539818a290db67d41;p=shellwiki diff --git a/index.cgi b/index.cgi index 0c7e914..61a8bb0 100755 --- a/index.cgi +++ b/index.cgi @@ -2,21 +2,21 @@ . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh" . "${_EXEC}/cgilite/session.sh" -. "${_EXEC}/cgilite/file.sh" . "${_EXEC}/cgilite/users.sh" +. "${_EXEC}/tools.sh" . "${_EXEC}/acl.sh" -mdfile(){ - local page="$(PATH "$1")" +REV_PAGES=${REV_PAGES:-true} +REV_ATTACHMENTS=${REV_ATTACHMENTS:-false} +WIKI_THEME="${WIKI_THEME:-default}" - if [ -f "$_DATA/pages/$page/#page.md" ]; then - printf %s\\n "$_DATA/pages/$page/#page.md" - elif [ -f "$_EXEC/pages/$page/#page.md" ]; then - printf %s\\n "$_EXEC/pages/$page/#page.md" - else - return 1 - fi -} +which git >/dev/null || REV_PAGES=false +[ "$REV_PAGES" != true ] && REV_ATTACHMENTS=false + +. "${_EXEC}/themes/${WIKI_THEME}.sh" + +# Renew session cookie, only if cookie already set +[ "$(COOKIE session)" ] && SESSION_COOKIE wiki_text() { # Print source text of a wiki page @@ -28,10 +28,27 @@ wiki_text() { cat -- "$mdfile" } +if [ "$REV_PAGES" = true -a ! -f "$_DATA/.gitignore" ]; then + cat >"$_DATA/.gitignore" <<-EOF + users.db + serverkey + **/#cache/ + **/#page.lock + **/#page.*.cache + **/#page.*.cache.* + **/#page:*.*.cache + **/#page:*.*.cache.* + EOF + [ "$REV_ATTACHMENTS" != true ] \ + && printf '**/#attachments/\n' >>"$_DATA/.gitignore" + git init "$_DATA" + git -C "$_DATA" add .gitignore + git -C "$_DATA" commit -m 'initialization' -- .gitignore +fi 1>&2 + for handler in "$_EXEC"/handlers/*; do . "$handler" && break done - if [ $? != 0 ]; then export ERROR_MSG="The presented URL schema cannot be handled" theme_error 400