]> git.plutz.net Git - shellwiki/blob - index.cgi
Merge commit '3e23ea79fad3824fcf71532ff605bd753f83c0b3'
[shellwiki] / index.cgi
1 #!/bin/sh
2
3 . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh"
4 . "${_EXEC}/cgilite/session.sh"
5 . "${_EXEC}/cgilite/users.sh"
6 . "${_EXEC}/tools.sh"
7 . "${_EXEC}/acl.sh"
8
9 WIKI_THEME="${WIKI_THEME:-default}"
10 . "${_EXEC}/themes/${WIKI_THEME}.sh"
11
12 # Renew session cookie, only if cookie already set
13 [ "$(COOKIE session)" ] && SESSION_COOKIE
14
15 wiki_text() {
16   # Print source text of a wiki page
17   # Get page from data or underlay dir
18   local page="$(PATH "$1")" mdfile
19
20   mdfile="$(mdfile "$page")" || return 4
21   acl_read "$page" || return 3
22   cat -- "$mdfile"
23 }
24
25 if [ "$(which git)" -a ! -f "$_DATA/.gitignore" ]; then
26   cat >"$_DATA/.gitignore" <<-EOF
27         users.db
28         serverkey
29         */#attachments/
30         */#cache/
31         */#page.lock
32         */#page.*.cache
33         */#page.*.cache.*
34         EOF
35   git init "$_DATA"
36   git -C "$_DATA" add .gitignore
37   git -C "$_DATA" commit -m 'initialization' -- .gitignore
38 fi 1>&2
39
40 for handler in "$_EXEC"/handlers/*; do
41   . "$handler" && break
42 done
43
44 if [ $? != 0 ]; then
45   export ERROR_MSG="The presented URL schema cannot be handled"
46   theme_error 400
47 fi