X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=c121c3879b050597602b80cb8e39845254fdf737;hb=HEAD;hp=091254cf76795f1fdb0342edd47d59ebce923deb;hpb=db7154116045a351e110409413aeeb9aad2b4c07;p=shellwiki diff --git a/index.cgi b/index.cgi index 091254c..c121c38 100755 --- a/index.cgi +++ b/index.cgi @@ -1,14 +1,35 @@ #!/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/users.sh" +. "${_EXEC}/auth/${USER_AUTH}.sh" . "${_EXEC}/tools.sh" . "${_EXEC}/acl.sh" - -WIKI_THEME="${WIKI_THEME:-default}" . "${_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 @@ -22,25 +43,34 @@ wiki_text() { cat -- "$mdfile" } -if [ "$(which git)" -a ! -f "$_DATA/.gitignore" ]; then +if [ "$REV_PAGES" = true -a ! -f "$_DATA/.gitignore" ]; then cat >"$_DATA/.gitignore" <<-EOF users.db serverkey - */#attachments/ - */#cache/ - */#page.lock - */#page.*.cache - */#page.*.cache.* + 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