]> git.plutz.net Git - shellwiki/blobdiff - index.cgi
apply editor style to [newpage]
[shellwiki] / index.cgi
index 0c7e914062c3d99c38420e106c32b6a29c3dc59d..2248308ddd05ce61252beb9e1edd7fe333efdfa8 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -2,21 +2,12 @@
 
 . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh"
 . "${_EXEC}/cgilite/session.sh"
-. "${_EXEC}/cgilite/file.sh"
 . "${_EXEC}/cgilite/users.sh"
+. "${_EXEC}/tools.sh"
 . "${_EXEC}/acl.sh"
 
-mdfile(){
-  local page="$(PATH "$1")"
-
-  if   [ -f "$_DATA/pages/$page/#page.md" ]; then
-    printf %s\\n "$_DATA/pages/$page/#page.md"
-  elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
-    printf %s\\n "$_EXEC/pages/$page/#page.md"
-  else
-    return 1
-  fi
-}
+WIKI_THEME="${WIKI_THEME:-default}"
+. "${_EXEC}/themes/${WIKI_THEME}.sh"
 
 wiki_text() {
   # Print source text of a wiki page
@@ -28,6 +19,21 @@ wiki_text() {
   cat -- "$mdfile"
 }
 
+if [ "$(which git)" -a ! -f "$_DATA/.gitignore" ]; then
+  cat >"$_DATA/.gitignore" <<-EOF
+       users.db
+       serverkey
+       */#attachments/
+       */#cache/
+       */#page.lock
+       */#page.*.cache
+       */#page.*.cache.*
+       EOF
+  git init "$_DATA"
+  git -C "$_DATA" add .gitignore
+  git -C "$_DATA" commit -m 'initialization' -- .gitignore
+fi 1>&2
+
 for handler in "$_EXEC"/handlers/*; do
   . "$handler" && break
 done