X-Git-Url: http://git.plutz.net/?p=busy;a=blobdiff_plain;f=pages%2FWiki.sh;fp=pages%2FWiki.sh;h=b9215f9281d04808da57624c2291d309f3e0d742;hp=0000000000000000000000000000000000000000;hb=f485895094cd72318b46f39689c3ba954eb37411;hpb=904730d1782749bfac15b0344fe5782433f3099b diff --git a/pages/Wiki.sh b/pages/Wiki.sh new file mode 100755 index 0000000..b9215f9 --- /dev/null +++ b/pages/Wiki.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Copyright 2014 Paul Hänsch +# +# This file is part of Busy +# +# Busy is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Busy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Busy. If not, see . + +info="$(egrep -o '[0-9]{10}_[0-9]{3}' <<<"$_GET[\"i\"]")" +edit="$(egrep -o '[0-9]{10}_[0-9]{3}' <<<"$_GET[\"e\"]")" + rev="$(egrep -o '[0-9]{10}' <<<"$_GET[\"r\"]")" +search="$(sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' <<<"$_GET[\"s\"]")" + +[ -n "$rev" ] && rev=".$rev" +if [ -n "$search" ]; then + info='' + edit='' + rev='' +fi + +lock="$_DATA/Wiki/${info}.lock" +if ([ -r "$lock" ] && [ "$(cut -d: -f2 "$lock")" -lt "$(date +%s)" ]); then + rm "$lock" + lock='' +elif [ -r "$lock" ]; then + lock="$(cut -d: -f1 "$lock")" +else + lock='' +fi + +case "$1" in + title) + echo "Wiki" + ;; + css) + cat ${_EXEC}/templates/Wiki.css + ;; + body) + #. ${_EXEC}/templates/text_wiki.sh + if [ -n "$edit" -a -r "$_DATA/Wiki/${edit}${rev}" ]; then + title="$(egrep -x 'title=.+' "$_DATA/Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')" + . ${_EXEC}/templates/Wiki_edit.page + elif [ -n "$info" -a -r "$_DATA/Wiki/${info}${rev}" ]; then + title="$(egrep -x 'title=.+' "$_DATA/Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')" + . ${_EXEC}/templates/Wiki_show.page + elif [ -z "$info" ]; then + . ${_EXEC}/templates/Wiki_list.page + fi + ;; +esac +