X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=c121c3879b050597602b80cb8e39845254fdf737;hb=HEAD;hp=db4d749b7c179efde9b4fec43a5158c5e4dd4d21;hpb=4bb6a2be511e608fa87fbb7b54d8ed275b844b30;p=shellwiki diff --git a/index.cgi b/index.cgi index db4d749..c121c38 100755 --- a/index.cgi +++ b/index.cgi @@ -1,15 +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" - -REV_ATTACHMENTS=${REV_ATTACHMENTS:-false} -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 @@ -23,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 - $([ "$REV_ATTACHMENTS" = true ] || printf %s "**/#attachments/") + tags/ + index/ **/#cache/ - **/#page.lock + **/#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