]> git.plutz.net Git - shellwiki/blob - index.cgi
track pages in git
[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 wiki_text() {
13   # Print source text of a wiki page
14   # Get page from data or underlay dir
15   local page="$(PATH "$1")" mdfile
16
17   mdfile="$(mdfile "$page")" || return 4
18   acl_read "$page" || return 3
19   cat -- "$mdfile"
20 }
21
22 if [ "$(which git)" -a ! -f "$_DATA/.gitignore" ]; then
23   cat >"$_DATA/.gitignore" <<-EOF
24         users.db
25         serverkey
26         */#attachments/
27         */#cache/
28         */#page.lock
29         */#page.*.cache
30         */#page.*.cache.*
31         EOF
32   git init "$_DATA"
33   git -C "$_DATA" add .gitignore
34   git -C "$_DATA" commit -m 'initialization' -- .gitignore
35 fi 1>&2
36
37 for handler in "$_EXEC"/handlers/*; do
38   . "$handler" && break
39 done
40
41 if [ $? != 0 ]; then
42   export ERROR_MSG="The presented URL schema cannot be handled"
43   theme_error 400
44 fi