X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=c121c3879b050597602b80cb8e39845254fdf737;hb=HEAD;hp=8975ccaa0cc1b2b6e76d4f8d13474648ca0d1311;hpb=922181c682dc5d499eea65ae502e894e88e07f84;p=shellwiki diff --git a/index.cgi b/index.cgi index 8975cca..c121c38 100755 --- a/index.cgi +++ b/index.cgi @@ -1,11 +1,37 @@ #!/bin/sh +# Copyright 2022 - 2023 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +export REV_PAGES=${REV_PAGES:-true} +export REV_ATTACHMENTS=${REV_ATTACHMENTS:-false} +export WIKI_THEME="${WIKI_THEME:-default}" +export SEARCH_INDEX="${SEARCH_INDEX:-true}" +export USER_AUTH="${USER_AUTH:-default}" + . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh" . "${_EXEC}/cgilite/session.sh" -. "${_EXEC}/cgilite/file.sh" -. "${_EXEC}/cgilite/users.sh" +. "${_EXEC}/auth/${USER_AUTH}.sh" . "${_EXEC}/tools.sh" . "${_EXEC}/acl.sh" +. "${_EXEC}/themes/${WIKI_THEME}.sh" + +which git >/dev/null || REV_PAGES=false +[ "$REV_PAGES" != true ] && REV_ATTACHMENTS=false + +# Renew session cookie, only if cookie already set +[ "$(COOKIE session)" ] && SESSION_COOKIE wiki_text() { # Print source text of a wiki page @@ -17,10 +43,34 @@ wiki_text() { cat -- "$mdfile" } +if [ "$REV_PAGES" = true -a ! -f "$_DATA/.gitignore" ]; then + cat >"$_DATA/.gitignore" <<-EOF + users.db + serverkey + tags/ + index/ + **/#cache/ + **/#page.md.lock + **/#page.*.cache + **/#page.*.cache.* + **/#page:*.*.cache + **/#page:*.*.cache.* + **/#index.flag + EOF + [ "$REV_ATTACHMENTS" != true ] \ + && printf '**/#attachments/\n' >>"$_DATA/.gitignore" + git init "$_DATA" + git -C "$_DATA" add .gitignore + printf '%s\n' "" "[user]" \ + "email = \"shellwiki@localhost\"" \ + "name = \"Shellwiki\"" \ + >>"$_DATA/.git/config" + 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