3 # Copyright 2022 - 2023 Paul Hänsch
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh"
18 . "${_EXEC}/cgilite/session.sh"
19 . "${_EXEC}/cgilite/users.sh"
23 export REV_PAGES=${REV_PAGES:-true}
24 export REV_ATTACHMENTS=${REV_ATTACHMENTS:-false}
25 export WIKI_THEME="${WIKI_THEME:-default}"
26 export SEARCH_INDEX="${SEARCH_INDEX:-true}"
28 which git >/dev/null || REV_PAGES=false
29 [ "$REV_PAGES" != true ] && REV_ATTACHMENTS=false
31 . "${_EXEC}/themes/${WIKI_THEME}.sh"
33 # Renew session cookie, only if cookie already set
34 [ "$(COOKIE session)" ] && SESSION_COOKIE
37 # Print source text of a wiki page
38 # Get page from data or underlay dir
39 local page="$(PATH "$1")" mdfile
41 mdfile="$(mdfile "$page")" || return 4
42 acl_read "$page" || return 3
46 if [ "$REV_PAGES" = true -a ! -f "$_DATA/.gitignore" ]; then
47 cat >"$_DATA/.gitignore" <<-EOF
60 [ "$REV_ATTACHMENTS" != true ] \
61 && printf '**/#attachments/\n' >>"$_DATA/.gitignore"
63 git -C "$_DATA" add .gitignore
64 printf '%s\n' "" "[user]" \
65 "email = \"shellwiki@localhost\"" \
66 "name = \"Shellwiki\"" \
67 >>"$_DATA/.git/config"
68 git -C "$_DATA" commit -m 'initialization' -- .gitignore
71 for handler in "$_EXEC"/handlers/*; do
75 export ERROR_MSG="The presented URL schema cannot be handled"