#!/bin/zsh info="$(egrep -o '(^|&)(i=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')" edit="$(egrep -o '(^|&)(e=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&e=')" rev="$(egrep -o '(^|&)(r=)[0-9]{10}(&|$)' <<<"${QUERY_STRING}" |tr -d '&r=')" search="$(egrep -o '(^|&)(s=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?s=::;s:\+: :g;s:%:\\x:g')" search="$(echo -e "${search}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)" [ -n "$rev" ] && rev=".$rev" if [ -n "$search" ]; then info='' edit='' rev='' fi lock="Wiki/$info.lock" [ -r "$lock" -o -n "$lock" ] && if [ "$(cut -d: -f2 "$lock")" -lt "$(date +%s)" ]; then rm "$lock" lock='' else lock="$(cut -d: -f1 "$lock")" fi if [ -n "$edit" -a -r "Wiki/${edit}${rev}" ]; then title="$(egrep -x 'title=.+' "Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')" cat <
Editing $title

$title

WikiEND elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then title="$(egrep -x 'title=.+' "Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')" cat <


Revisions: $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do revi=$(cut -d. -f2 <<<"$each") echo "$rno" rno=$(($rno+1)) done) Latest

$($LOGIN && if [ -z "$lock" ]; then [ -z "$rev" ] && echo "edit this page" [ -n "$rev" ] && echo "Click edit to derive a new page revision from this one." else echo "This page is currently being edited by $lockedit anyway" fi $LOGIN && echo '
')

Table of Content

$(cat Wiki/"${info}${rev}" |while read line; do if (egrep -q '^ *!!!' <<<"$line"); then echo "$(sed 's,^ *!!!,,' <<<"$line")
" elif (egrep -q '^ *!!' <<<"$line"); then echo "$(sed 's,^ *!!,,' <<<"$line")
" elif (egrep -q '^ *!' <<<"$line"); then echo "$(sed 's,^ *!,,' <<<"$line")
" fi done)

$title

$(_wiki Wiki/"${info}${rev}")
WikiEND echo '' elif [ -z "$info" ]; then cat <


WikiEND if [ -n "$search" ]; then echo "

Wiki search results for: $search

" for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do echo "' done echo '
' fi echo '
' stat -c '' Wiki/<0000000000-9999999999>_<000-999> && for each in Wiki/<0000000000-9999999999>_<000-999>; do info=$(sed 's,Wiki/,,' <<<"$each") title="$(egrep -x 'title=.+' "$each.meta" |cut -d= -f2- || echo '(Untitled)')" description="$(egrep -x 'description=.+' "$each.meta" |cut -d= -f2-)" owner="$(egrep -x 'owner=.+' "$each.meta" |cut -d= -f2-)" cat <

$title

$description

View $($LOGIN && echo "Change Info")
WikiEND $LOGIN && cat <
WikiEND echo '' done echo '' fi