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}"
27 which git >/dev/null || REV_PAGES=false
28 [ "$REV_PAGES" != true ] && REV_ATTACHMENTS=false
30 . "${_EXEC}/themes/${WIKI_THEME}.sh"
32 # Renew session cookie, only if cookie already set
33 [ "$(COOKIE session)" ] && SESSION_COOKIE
36 # Print source text of a wiki page
37 # Get page from data or underlay dir
38 local page="$(PATH "$1")" mdfile
40 mdfile="$(mdfile "$page")" || return 4
41 acl_read "$page" || return 3
45 if [ "$REV_PAGES" = true -a ! -f "$_DATA/.gitignore" ]; then
46 cat >"$_DATA/.gitignore" <<-EOF
56 [ "$REV_ATTACHMENTS" != true ] \
57 && printf '**/#attachments/\n' >>"$_DATA/.gitignore"
59 git -C "$_DATA" add .gitignore
60 printf '%s\n' "" "[user]" \
61 "email = \"shellwiki@localhost\"" \
62 "name = \"Shellwiki\"" \
63 >>"$_DATA/.git/config"
64 git -C "$_DATA" commit -m 'initialization' -- .gitignore
67 for handler in "$_EXEC"/handlers/*; do
71 export ERROR_MSG="The presented URL schema cannot be handled"