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