]> git.plutz.net Git - busy/commitdiff
porting busy to confetti framework
authorpaul <paul@plutz.net>
Mon, 17 Nov 2014 00:27:49 +0000 (00:27 +0000)
committerpaul <paul@plutz.net>
Mon, 17 Nov 2014 00:27:49 +0000 (00:27 +0000)
svn path=/trunk/; revision=54

57 files changed:
Admin.page [deleted file]
Home.page [deleted file]
Tasks.page [deleted file]
Wiki.page [deleted file]
action.sh [new file with mode: 0755]
actions/image_upload.cgi [moved from write/image_upload.cgi with 100% similarity]
actions/introedit.sh [moved from write/introedit.cgi with 56% similarity]
actions/lock.sh [moved from login.cgi with 53% similarity]
actions/login.sh [new file with mode: 0755]
actions/logout.sh [new file with mode: 0755]
actions/projectmeta.sh [new file with mode: 0755]
actions/taskmeta.sh [new file with mode: 0755]
actions/wikiedit.sh [moved from write/lock.cgi with 58% similarity]
actions/wikimeta.sh [new file with mode: 0755]
auth/permissions.sh [deleted file]
cgi.sh [new file with mode: 0755]
constants.sh [new file with mode: 0755]
index.cgi [deleted file]
index.page [deleted symlink]
page.sh [new file with mode: 0755]
pages/Admin.sh [new file with mode: 0755]
pages/Home.sh [new file with mode: 0755]
pages/Settings.sh [moved from session.cgi with 65% similarity]
pages/Subversion.sh [new file with mode: 0755]
pages/Tasks.sh [new file with mode: 0755]
pages/Wiki.sh [new file with mode: 0755]
pages/error.sh [new file with mode: 0755]
project.meta [deleted file]
templates/Admin.css [moved from Admin.css with 100% similarity]
templates/Admin.page [new file with mode: 0644]
templates/Error.page [moved from Error.page with 100% similarity]
templates/Git.page [moved from Git.page with 100% similarity]
templates/Home.css [moved from Home.css with 100% similarity]
templates/Home.page [new file with mode: 0644]
templates/Settings.page [moved from Settings.page with 100% similarity]
templates/Subversion.css [moved from Subversion.css with 100% similarity]
templates/Subversion.page [moved from Subversion.page with 76% similarity]
templates/Tasks.css [moved from Tasks.css with 100% similarity]
templates/Tasks.page [new file with mode: 0644]
templates/Wiki.css [moved from Wiki.css with 100% similarity]
templates/Wiki_edit.page [new file with mode: 0755]
templates/Wiki_list.page [new file with mode: 0755]
templates/Wiki_show.page [new file with mode: 0755]
templates/busy.css [moved from busy.css with 100% similarity]
templates/frame.html.sh [new file with mode: 0755]
templates/wikitext.css [moved from wikitext.css with 100% similarity]
write/.htaccess [deleted file]
write/projectmeta.cgi [deleted file]
write/taskmeta.cgi [deleted file]
write/user_introedit.cgi [deleted symlink]
write/user_lock.cgi [deleted symlink]
write/user_projectmeta.cgi [deleted symlink]
write/user_taskmeta.cgi [deleted symlink]
write/user_wikiedit.cgi [deleted symlink]
write/user_wikimeta.cgi [deleted symlink]
write/wikiedit.cgi [deleted file]
write/wikimeta.cgi [deleted file]

diff --git a/Admin.page b/Admin.page
deleted file mode 100644 (file)
index 65f9e09..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/zsh
-
-metafile=project.meta
-userlist="$(sed -rn 's|^([a-zA-Z0-9_+-]):.+$|\1|p' auth/htpasswd)"
-
-if [ "$ACL_ADMIN" = "false" ]; then
-  reason=noaccess
-  . "./Error.page"
-else
-
-  echo "
-  <div id='LEFT'></div>
-  <div id='MAIN'>
-    <div class='section'><form method='post' accept-charset='utf-8' action='write/$($LOGIN && echo user_)projectmeta.cgi'>
-      <h1>General</h1>
-
-      <fieldset><legend>Title Display</legend>
-      <div class='key'>Project Name</div>
-        <div class='value'><input type='text' name='appName' value='$(sed -rn 's:^name=(.*)$:\1:p' "$metafile")'></div><br>
-      <div class='key'>Project Slogan</div>
-        <div class='value'><input type='text' name='appSlogan' value='$(sed -rn 's:^slogan=(.*)$:\1:p' "$metafile")'></div><br>
-      </fieldset>
-
-      <fieldset><legend>Code Browser</legend>
-      <div class='key'><input type='radio' name='repoType' value='svn' $(grep -q repoType=svn $metafile && echo checked)>SVN Repository</div>
-        <div class='value'><input type='text' name='svnRepo' value='$(sed -rn 's:^svnRepo=(.*)$:\1:p' "$metafile")'></div><br>
-      <div class='key'><input type='radio' name='repoType' value='git' $(grep -q repoType=git $metafile && echo checked)>GIT Repository</div>
-        <div class='value'><input type='text' name='gitRepo' value='$(sed -rn 's:^gitRepo=(.*)$:\1:p' "$metafile")'></div><br>
-      </fieldset>
-
-      <fieldset><legend>Donations</legend>
-       <div class='key'><input type='checkbox' name='useFlattr' value='yes' $(grep -q useFlattr=yes $metafile && echo checked)>Flattr \"Thing\" URL</div>
-          <div class='value'><input type='text' name='flattrThingURL' value='$(sed -rn 's:^flattrThingURL=(.*)$:\1:p' "$metafile")'></div><br>
-       <div class='key'><input type='checkbox' name='useBitcoin' value='yes' $(grep -q useBitcoin=yes $metafile && echo checked)>Bitcoin Address</div>
-          <div class='value'><input type='text' name='btcAddress' value='$(sed -rn 's:^btcAddress=(.*)$:\1:p' "$metafile")'></div><br>
-       <div class='key'><input type='checkbox' name='usePaypal' value='yes' $(grep -q usePaypal=yes $metafile && echo checked)>Paypal Address</div>
-          <div class='value'><input type='text' name='paypalAddress' value='$(sed -rn 's:^paypalAddress=(.*)$:\1:p' "$metafile")'></div><br>
-      </fieldset>
-
-      <fieldset><legend>Advertisement</legend>
-       <div class='key'><input type='radio' name='advertise' value='no' $(grep -q advertise=no $metafile && echo checked)>No Advertisement</div><br>
-       <div class='key'><input type='radio' name='advertise' value='btcAd' $(grep -q advertise=btcAd $metafile && echo checked)>
-           <a target='_blank' href='http://bitcoinadvertisers.com'>BitCoinAdvertisers.com</a><br>Bitcoin Address:</div>
-          <div class='value'>
-          <input type='text' name='btcAdAddress' value='$(sed -rn 's:^btcAdAddress=(.*)$:\1:p' "$metafile")'>
-         <input type='checkbox' name='btcAdGamble' value='yes' $(egrep -q 'btcAdContent=[13]' project.meta && echo checked)>Allow gambling ads
-         <input type='checkbox' name='btcAdErotic' value='yes' $(egrep -q 'btcAdContent=[12]' project.meta && echo checked)>Allow erotic ads
-          </div><br>
-      </fieldset>
-      <input type='submit'>
-    </form></div>
-
-  </div>
-  <div id='RIGHT'></div>
-  "
-fi
diff --git a/Home.page b/Home.page
deleted file mode 100644 (file)
index a21de71..0000000
--- a/Home.page
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/zsh
-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)"
-
-cat <<WikiEND
-  <div id="LEFT">
-    <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
-      <input type="hidden" name="p" value="Home">
-      <input type="text" name="s" placeholder="Search"><br>
-      <input type="submit" value="Search News">
-    </form>
-    <hr>
-WikiEND
-if [ -n "$search" ]; then
-  echo "<h1>News search results for: $search</h1>"
-  for each in $(grep -ile "$search" Home/<0000000000-9999999999>_<000-999>.news); do
-    id=$(sed -r 's:^.*/::;s:.news$::' <<<$each)
-    echo "<div class='search'><a href='#news_$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
-    grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
-    echo '</div>'
-  done
-  echo '<hr>'
-fi
-
-cat <<HomeEND
-  </div>
-
-  <div id="MAIN">
-    <div id="INTRO">
-      <div id="introtext"><div class="wikitext">
-      $([ -r "Home/intro" ] && _wiki "Home/intro")
-      $($ACL_EDITINTRO && echo "<hr><a class='function' href='#' onclick='javascript:hide_screen(\"introtext\");show_screen(\"introedit\");'>Edit</a>" )
-      </div></div>
-HomeEND
-$ACL_EDITINTRO && cat <<HomeEND
-      <div id="introedit" style="display: none;">
-        <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=intro" method="post" accept-charset="UTF-8">
-          <textarea name="text" rows="10">$([ -r "Home/intro" ] && cat Home/intro)</textarea><br>
-          <input type="submit">
-          <a class="function" href="#" onclick="javascript:hide_screen('introedit');show_screen('introtext');">Cancel</a>
-        </form>
-      </div>
-HomeEND
-echo '</div>'
-
-$ACL_ADDNEWS && cat <<HomeEND
-  <div class="NEWS">
-    <a id="new" class='function' href='#add' onclick='javascript:hide_screen("new");show_screen("add");'>Add News</a>
-    <div id="add" style="display: none;">
-      <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=news" method="post" accept-charset="UTF-8">
-        <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
-        <input type="submit">
-        <a class="function" href="#new" onclick="javascript:hide_screen('add');show_screen('new');">Cancel</a>
-      </form>
-    </div>
-  </div>
-HomeEND
-  
-stat -c '' Home/<0000000000-9999999999>_<000-999>.news && for each in $(ls -c Home/<0000000000-9999999999>_<000-999>.news); do
-  info="$(sed 's:Home/::;s:.news::' <<<"$each")"
-  cat <<HomeEND
-    <div class="NEWS">
-      <div id="news_$info"><div class="wikitext">
-      $([ -r "$each" ] && _wiki "$each")
-      $($ACL_EDITNEWS && echo "<hr><a class='function' href='#edit_$info' onclick='javascript:hide_screen(\"news_$info\");show_screen(\"edit_$info\");'>Edit</a>" )
-      </div></div>
-HomeEND
-  $ACL_EDITNEWS && cat <<HomeEND
-      <div id="edit_$info" style="display: none;">
-        <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=$info" method="post" accept-charset="UTF-8">
-          <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
-          <input type="submit">
-          <a class="function" href="#news_$info" onclick="javascript:hide_screen('edit_$info');show_screen('news_$info');">Cancel</a>
-        </form>
-      </div>
-HomeEND
-  echo '</div>'
-done
-
-cat <<HomeEND
-  </div>
-  <div id="RIGHT">
-  $(grep -q 'advertise=btcAd' project.meta && echo '<h1>Sponsored Links:</h1>
-    <iframe src="http://bitcoinadvertisers.com/a.php?p='$(sed -rn 's:^btcAdAddress=(.+):\1:p' project.meta)'&a='$(sed -rn 's:^btcAdContent=([1-4]):\1:p' project.meta)'&bg=FFFFFF&link=3366FF&text=414141" scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>
-    <iframe src="http://bitcoinadvertisers.com/a.php?p='$(sed -rn 's:^btcAdAddress=(.+):\1:p' project.meta)'&a='$(sed -rn 's:^btcAdContent=([1-4]):\1:p' project.meta)'&bg=FFFFFF&link=3366FF&text=414141" scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>'
-  )
-  </div>
-HomeEND
diff --git a/Tasks.page b/Tasks.page
deleted file mode 100644 (file)
index f36a969..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/bin/zsh
-
-info="$(sed -r 's:(^|.*&)i=([0-9]{10}_[0-9]{3}).*|.*:\2:;s:&.*::' <<<"${QUERY_STRING}")"
-edit="$(sed -r 's:(^|.*&)e=([0-9]{10}_[0-9]{3}).*|.*:\2:;s:&.*::' <<<"${QUERY_STRING}")"
-search="$(sed -r 's:(^|.*&)s=(.*)|.*:\2:;s:&.*::;s:\+: :g;s:%:\\x:g' <<<"${QUERY_STRING}")"
-search="$(echo -e "${search}" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
-new="$(sed -r 's:(^|.*&)n=(.*)|.*:\2:;s:&.*::;s:\+: :g;s:%:\\x:g' <<<"${QUERY_STRING}")"
-new="$(echo -e "${new}" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
-
-[ -z "$ACL_CREATETASK" ] && ACL_CREATETASK=false
-
-cat <<TasksEND
-  <div id="LEFT">
-    <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
-      <input type="hidden" name="p" value="Tasks">
-      <input type="text" name="s" placeholder="Search"><br>
-      <input type="submit" value="Search Tasks">
-    </form>
-    <hr>
-TasksEND
-#search results
-if [ -n "$search" ]; then
-  echo "<h1>Tasks search results for: $search</h1>"
-  for each in $(grep -ile "$search" Tasks/<0000000000-9999999999>_<000-999>); do
-    id=$(sed -r 's:^.*/::;s:.task$::' <<<$each)
-    echo "<div class='search'><a href='${SCRIPTNAME}?p=Tasks&amp;i=$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
-    grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
-    echo '</div>'
-  done
-  echo '<hr>'
-fi
-echo '</div><div id="MAIN">'
-
-#Display single task
-if [ -n "$info" -a -r "Tasks/$info" -a -r "Tasks/$info.meta" ]; then
-  datafile="Tasks/$info"
-  metafile="Tasks/$info.meta"
-  headline="$(sed -rn '/^headline=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
-  taskstatus="$(sed -rn '/^status=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
-  section="$(sed -rn '/^section=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
-  attendant="$(sed -rn '/^attendant=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
-  [ -z "$section" ] && section='(none)'
-  [ -z "$attendant" ] && attendant='(none)'
-  cat <<TasksEND
-    <div class="Task">
-      <div class="wikitext">
-       <h1>$headline</h1>
-       $(_wiki "$datafile")
-      </div>
-      <table><tr>
-       <td><b>Status</b><br>
-       $taskstatus</td>
-       <td><b>Section</b><br>
-       $section</td>
-       <td><b>Attendant</b><br>
-       $attendant</td>
-      </tr></table>
-    </div>
-TasksEND
-fi
-
-#create task main dialog
-[ -z "$info" -a -n "$new" ] && cat <<TaskEnd
-<form class="Task" style="height:20em;" method="post" action="write/$($LOGIN && echo user_)taskmeta.cgi" accept-charset="UTF-8">
-  <h1>$new</h1>
-  <input type="hidden" name="headline" value="$new">
-  <input type="hidden" name="status" value="new">
-  <div style="width:60%;left:3.5em;">
-    <b>Description:</b><br>
-    <textarea name="description" rows="11"></textarea>
-  </div><div style="width:30%;right:.5em;">
-    <b>Section:</b><br>
-    <select name="section" size="6" style="width:80%">
-    $(for each in $(egrep -hx 'section=.+' Tasks/<0000000000-9999999999>_<000-999>.meta |sort -u); do
-        echo "<option>$(sed 's:section=::' <<<"$each")</option>"
-      done)
-    </select><br>
-    <b>other section:</b><br>
-    <input type="text" name="section">
-    <input type="submit" name="submit" value="Robots click here" style="display:none;">
-    <input type="submit" name="submit" value="Create Task">
-    <input type="submit" name="submit" value="Robots click here" style="display:none;">
-  </div>
-</form>
-TaskEnd
-
-#Plain list of tasks (default)
-[ -z "$info" -a -z "$new" ] && stat -c '' Tasks/<0000000000-9999999999>_<000-999>.meta && for each in Tasks/<0000000000-9999999999>_<000-999>.meta(.om); do
-  info="$(basename "$each" |sed 's:.meta$::')"
-  headline="$(sed -rn '/^headline=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
-  taskstatus="$(sed -rn '/^status=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
-  section="$(sed -rn '/^section=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
-  attendant="$(sed -rn '/^attendant=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
-  [ -z "$section" ] && section='(none)'
-  [ -z "$attendant" ] && attendant='(none)'
-  cat <<TasksEND
-   <div class="Task">
-     <a href="${SCRIPTNAME}?p=Tasks&amp;i=${info}"><b>$headline</b></a><br>
-     <span><b>Status:</b> $taskstatus</span>
-     <span><b>Section:</b> $section</span>
-     <span><b>Attendant:</b> $attendant</span>
-   </div>
-TasksEND
-done
-
-#dropdown dialog for adding a task
-echo '</div> <div id="RIGHT">'
-$ACL_CREATETASK && [ -z "$new" ] && cat <<TasksEND
-      <a id='newTask_button' class='function' href='#' onclick='javascript:show_screen("newTask");hide_screen("newTask_button");'>New Task</a>
-      <div id="newTask" style="display: none;">
-        <form action="/${SCRIPTNAME}" method="get" accept-charset="UTF-8">
-          <b>Headline:</b><br>
-          <input type="hidden" name="p" value="Tasks">
-          <textarea name="n" rows="2" style="width:99%;"></textarea><br>
-          <input type="submit" value="Submit">
-          <a class="function" href="#" onclick="javascript:hide_screen('newTask');show_screen('newTask_button');">Cancel</a>
-        </form>
-      </div>
-TasksEND
-echo '</div>'
diff --git a/Wiki.page b/Wiki.page
deleted file mode 100755 (executable)
index 07055b3..0000000
--- a/Wiki.page
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/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 <<WikiEND
-    <form class="edit" action="write/$($LOGIN && echo user_)wikiedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
-      <div id="LEFT">
-       Editing <b>$title</b><br>
-        <input type="submit" value="Submit">
-        <input type="submit" name="cancel" value="Cancel">
-       <hr>
-      </div>
-      <div id="MAIN">
-       <div class="wiki">
-          <h1>$title</h1>
-          <textarea name="page" rows=30 cols=40>$(cat "Wiki/${edit}${rev}")</textarea>
-        </div>
-      </div>
-    </form>
-    <div id="RIGHT">
-    $(stat -c '' Wiki/${edit}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${edit}.comment.<0000000000-9999999999>_<000-999>); do
-      author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
-      echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
-      tail -n+2 $each |_wiki
-      echo '</div></div>'
-    done)
-    </div>
-WikiEND
-
-elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then
-  title="$(egrep -x 'title=.+' "Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')"
-
-  cat <<WikiEND
-    <div id="LEFT">
-      <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
-       <input type="hidden" name="p" value="Wiki">
-       <input type="text" name="s" placeholder="Search"><br>
-       <input type="submit" value="Search Wiki">
-      </form>
-      <hr>
-
-      <b>Revisions:</b>
-      $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do
-       revi=$(cut -d. -f2 <<<"$each")
-       echo "<a class='rev' href='?p=Wiki&amp;i=$info&amp;r=$revi'>$rno</a>"
-       rno=$(($rno+1))
-        done) <a class='rev' href='?p=Wiki&amp;i=$info'>Latest</a><br>
-      <hr>
-      $($LOGIN && if [ -z "$lock" ]; then
-          [ -z "$rev" ] && echo "<a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&amp;e=$info'>edit this page</a>"
-         [ -n "$rev" ] && echo "Click <a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&amp;e=${info}&amp;r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
-        else
-         echo "<b>This page is currently being edited by $lock</b><a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&amp;e=$info'>edit anyway</a>"
-        fi
-        $LOGIN && echo '<hr>')
-      <h1>Table of Content</h1>
-      <div class="toc">
-        $(cat Wiki/"${info}${rev}" |while read line; do
-       if (egrep -q '^ *!!!' <<<"$line"); then
-         echo "<a class='i2' href='#$(sed 's,^ *!!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!!,,' <<<"$line")</a><br>"
-       elif (egrep -q '^ *!!' <<<"$line"); then
-         echo "<a class='i1' href='#$(sed 's,^ *!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!,,' <<<"$line")</a><br>"
-       elif (egrep -q '^ *!' <<<"$line"); then
-         echo "<a class='i0' href='#$(sed 's,^ *! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!,,' <<<"$line")</a><br>"
-          fi
-        done)
-      </div>
-      <hr>
-    </div>
-    <div id="MAIN">
-      <div class="wiki"><div class="wikitext">
-        <h1>$title</h1>
-        $(_wiki Wiki/"${info}${rev}")
-      </div></div>
-    </div>
-WikiEND
-
-  echo '<div id="RIGHT">'
-$LOGIN && cat <<WikiEND
-      <a id='comment_button' class='function' href='#' onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
-      <div id="comment" style="display: none;">
-        <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
-          <b>Comment:</b><br>
-          <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
-          <input type="submit" value="Submit">
-          <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
-        </form>
-      </div>
-WikiEND
-  stat -c '' Wiki/${info}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${info}.comment.<0000000000-9999999999>_<000-999>); do
-    author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
-    echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
-    tail -n+2 $each |_wiki
-    echo '</div></div>'
-  done
-  echo '</div>'
-  
-elif [ -z "$info" ]; then
-  cat <<WikiEND
-    <div id="LEFT">
-      <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
-       <input type="hidden" name="p" value="Wiki">
-       <input type="text" name="s" placeholder="Search"><br>
-       <input type="submit" value="Search Wiki">
-      </form>
-      <hr>
-WikiEND
-  if [ -n "$search" ]; then
-    echo "<h1>Wiki search results for: $search</h1>"
-    for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
-      echo "<div class='search'><a href='?p=Wiki&amp;i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
-      grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
-      echo '</div>'
-    done
-    echo '<hr>'
-  fi
-  echo '</div><div id="RIGHT">'
-  $LOGIN && cat <<WikiEND
-    <a id='addp_button' class='function' href='#' onclick='javascript:show_screen("add_page");hide_screen("addp_button");'>Add a new Page</a>
-    <div id="add_page" style="display: none;">
-      <form action="/write/$($LOGIN && echo user_)wikimeta.cgi" method="post" accept-charset="UTF-8">
-        <br><b>Title:</b><br>
-       <input type="text" name="title" placeholder="Fill in a title"><br>
-        <b>Description:</b><br>
-        <textarea name="desc" rows="6" ></textarea><br>
-        <input type="submit" value="Submit">
-        <a class="function" href="#" onclick="javascript:hide_screen('add_page');show_screen('addp_button');">Cancel</a>
-      </form>
-    </div>
-WikiEND
-  echo '</div><div id="MAIN">'
-
-  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 <<WikiEND
-    <div class="article">
-      <div id="display_$info">
-        <a name="$info" href="/?p=Wiki&amp;i=$info"><h1>$title</h1></a>
-        $description<br><br>
-        <a class="function" href="/?p=Wiki&amp;i=$info">View</a> 
-        $($ACL_WIKIEDIT && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
-      </div>
-WikiEND
-    $ACL_WIKIEDIT && cat <<WikiEND
-      <div id="change_$info" style="display: none;">
-        <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
-         <b>Title:</b> <input type="text" name="title" value="$title"><br>
-         <b>Description:</b><br>
-         <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>
-         <input type="submit" value="Submit">
-          <a class="function" href="#" onclick="javascript:hide_screen('change_$info');show_screen('display_$info');">Cancel</a>
-       </form>
-      </div>
-WikiEND
-    echo '</div>'
-  done
-  echo '</div>'
-fi
diff --git a/action.sh b/action.sh
new file mode 100755 (executable)
index 0000000..0c46d73
--- /dev/null
+++ b/action.sh
@@ -0,0 +1,24 @@
+#!/bin/zsh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+# 
+# Confetti 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.
+# 
+# Confetti 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 Confetti.  If not, see <http://www.gnu.org/licenses/>. 
+
+ACTION="$(echo "$_GET[\"action\"]" |egrep '^[a-zA-Z0-9_-]+$')"
+ACTION="${_EXEC}/actions/${ACTION}.sh"
+[ -x "$ACTION" ] || echo -n "Location: http://$HTTP_HOST/?page=error\n\n"
+
+. $ACTION
similarity index 56%
rename from write/introedit.cgi
rename to actions/introedit.sh
index 7d0887e4beafaea8ea4f9a962817bdc9f8e2bf1d..d55b1b2396ee2a97e29519c562a25b4581a2884c 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/zsh
 #!/bin/zsh
-# Copyright 2011 Paul Haensch
+# Copyright 2011 - 2014 Paul Haensch
 # This file is part of Busy
 #
 # Busy is free software: you can redistribute it and/or modify
 # This file is part of Busy
 #
 # Busy is free software: you can redistribute it and/or modify
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
-[ "$HTTPS" = "on" ] && proto=https || proto=http
-. ../auth/permissions.sh
 
 
-info="$(egrep -o '(^|&)i=([0-9]{10}_[0-9]{3}|intro|news)(&|$)' <<<"${QUERY_STRING}" |sed 's:&::g;s:i=::')"
+info="$(echo -E "$_GET[\"i\"]" |grep -Ex 'intro|news')"
 
 if [ "$info" = "news" ]; then
   $ACL_ADDNEWS || info=''
 
 if [ "$info" = "news" ]; then
   $ACL_ADDNEWS || info=''
@@ -27,24 +25,15 @@ elif [ "$info" = "intro" ]; then
 elif [ -z "$info" ]; then
   $ACL_EDITNEWS || info=''
 fi
 elif [ -z "$info" ]; then
   $ACL_EDITNEWS || info=''
 fi
-[ -n "$info" ] || echo -n "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+[ -n "$info" ] || echo -n "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
 [ -n "$info" ] || exit 0
 
 [ "$info" = "news" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
 [ "$info" != "intro" ] && info="${info}.news"
 [ "$info" = "intro" ] && ($ACL_EDITINTRO || info='')
 
 [ -n "$info" ] || exit 0
 
 [ "$info" = "news" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
 [ "$info" != "intro" ] && info="${info}.news"
 [ "$info" = "intro" ] && ($ACL_EDITINTRO || info='')
 
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (echo "${line}" | egrep -xq 'text=.+'); then
-    text="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    text=$(echo -e "${text}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g')
-  elif (echo "${line}" | egrep -xq 'cancel=.+'); then
-    cancel=true
-  fi
-done
-fi
+cgi_post
 
 
-[ -z "$cancel" ] && echo -e "${text}" >"../Home/$info"
+[ -z "$_POST[\"cancel\"]" ] && echo -E "$_POST[\"text\"]" >"$_DATA/Home/$info"
 
 
-echo -n "Location: ${proto}://${HTTP_HOST}/?p=Home\n\n"
+echo -n "Location: ${HTTP_REFERER}\n\n"
similarity index 53%
rename from login.cgi
rename to actions/lock.sh
index 856b0c041070453d803377a090dfb22acc8a8c77..dadfd1ff832719f3515989d74c719fd787270660 100755 (executable)
--- a/login.cgi
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (echo "${line}" | egrep -xq 'user=.+'); then
-    user="$(echo "${line}" |cut -d= -f2- |sed 's/+/ /g;s/%/\\x/g')"
-    user=$(echo -e "${user}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)
-  elif (echo "${line}" | egrep -xq 'pass=.+'); then
-    pass="$(echo "${line}" |cut -d= -f2- |sed 's/+/ /g;s/%/\\x/g')"
-    pass=$(echo -e "${pass}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g')
-  fi
-done
-fi
+$ACL_WIKIEDIT || echo "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+$ACL_WIKIEDIT || exit 0 
 
 
-echo -n "Location: https://${user}:${pass}@${HTTP_HOST}/session.cgi?${QUERY_STRING}\n\n"
+page="$(echo -E "$_GET[\"p\"]" |egrep -Ex 'Wiki')"
+edit="$(echo -E "$_GET[\"e\"]" |egrep -Ex '[0-9]{10}_[0-9]{3}(_[0-9]{1,4})?')"
+
+case "$page" in
+  Wiki)        [ -f "$_DATA/Wiki/${edit}" ] && echo "${USER}:$(($(date +%s)+600))" >"$_DATA/Wiki/${edit}.lock"
+        echo -n "Location: //${HTTP_HOST}/?p=Wiki&e=$edit\n\n"
+       ;;
+  *)   echo -n "Location: //${HTTP_HOST}/?p=Error&r=input&$page\n\n"
+       exit 0
+       ;;
+esac
diff --git a/actions/login.sh b/actions/login.sh
new file mode 100755 (executable)
index 0000000..6705eca
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/zsh
+# Copyright 2011 Paul Haensch
+# 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 <http://www.gnu.org/licenses/>.
+
+cgi_post
+
+user="$(echo -E "$_POST[\"user\"]" |sed -rn '1{/^[a-zA-Z0-9_+@.-]+$/p}')"
+pass="$_POST[\"pass\"]"
+userfile="$_DATA/auth/user$(echo -E "$user" |sha1sum |cut -c1-40)"
+
+if [ -r "$userfile" ]; then
+  salt=$(sed -nr 's:^salt=(.+)$:\1:p' "$userfile")
+  ssum=$(sed -nr 's:^auth=(.+)$:\1:p' "$userfile")
+  rsum=$(echo -E "$salt$pass" |sha1sum |cut -c1-40)
+fi
+if [ "$ssum" = "$rsum" ]; then
+  sid="$(apg -n1 -a1 -m32 -x32 -M CLN)"
+  sessionfile="$_DATA/auth/session$sid"
+  echo -E "$user $(($(date +%s) + 1800))" >"$sessionfile" 
+  echo -E "Location: $HTTP_REFERER"
+  echo -E "Set-Cookie: session=$sid; HttpOnly"
+else
+  echo -E "Location: $HTTP_REFERER"
+fi
+echo ''
diff --git a/actions/logout.sh b/actions/logout.sh
new file mode 100755 (executable)
index 0000000..86fc7b1
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/zsh
+
+# 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 <http://www.gnu.org/licenses/>. 
+
+sessfile="$_DATA/auth/session$(sed -rn 's:^.*session=([a-zA-Z0-9]{32}).*$:\1:p' <<<"$HTTP_COOKIE")"
+[ -f "$sessfile" ] && rm "$sessfile"
+
+echo -E "Location: $HTTP_REFERER"
+echo ''
+
diff --git a/actions/projectmeta.sh b/actions/projectmeta.sh
new file mode 100755 (executable)
index 0000000..ac7e454
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/zsh
+
+# Copyright 2012 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 <http://www.gnu.org/licenses/>.
+
+metafile="$_DATA/project.meta"
+
+$ACL_ADMIN || echo "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+$ACL_ADMIN || exit 0 
+
+cgi_post
+
+[ "$_POST[\"btcAdGamble\"]"  = yes -a "$_POST[\"btcAdErotic\"]" = yes ] && btcAdContent=1
+[ "$_POST[\"btcAdGamble\"]" != yes -a "$_POST[\"btcAdErotic\"]" = yes ] && btcAdContent=2
+[ "$_POST[\"btcAdGamble\"]"  = yes -a "$_POST[\"btcAdErotic\"]" != yes ] && btcAdContent=3
+[ "$_POST[\"btcAdGamble\"]" != yes -a "$_POST[\"btcAdErotic\"]" != yes ] && btcAdContent=4
+
+echo -E "\
+name=$_POST[\"appName\"]
+slogan=$_POST[\"appSlogan\"]
+repoType=$(echo -E "$_POST[\"repoType\"]" |grep -Ex 'svn|git')
+svnRepo=$_POST[\"svnRepo\"]
+gitRepo=$_POST[\"gitRepo\"]
+useFlattr=$(echo -E "$_POST[\"useFlattr\"]" |grep -Ex 'yes')
+flattrThingURL=$_POST[\"flattrThingURL\"]
+usePaypal=$(echo -E "$_POST[\"usePaypal\"]" |grep -Ex 'yes')
+paypalAddress=$_POST[\"paypalAddress\"]
+useBitcoin=$(echo -E "$_POST[\"useBitcoin\"]" |grep -Ex 'yes')
+btcAddress=$_POST[\"btcAddress\"]
+advertise=$(echo -E "$_POST[\"advertise\"]" |grep -Ex 'btcAd|no')
+btcAdAddress=$_POST[\"btcAdAddress\"]
+btcAdContent=$btcAdContent
+" >"$metafile"
+
+echo -n "Location: ${HTTP_REFERER}\n\n"
diff --git a/actions/taskmeta.sh b/actions/taskmeta.sh
new file mode 100755 (executable)
index 0000000..0b2544d
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/zsh
+# Copyright 2011 Paul Haensch
+# 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 <http://www.gnu.org/licenses/>.
+
+$ACL_CREATETASK || echo "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+$ACL_CREATETASK || exit 0
+
+info="$_GET[\"i\"]"
+
+[ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
+descfile="$_DATA/Tasks/$info.meta"
+commfile="$_DATA/Tasks/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
+
+[ -f "$_DATA/Tasks/$info.lock" ] && rm "$_DATA/Wiki/$info.lock"
+anchor=$(ls $_DATA/Tasks |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
+
+cgi_post
+headline="$_POST[\"headline\"]"
+taskstatus="$_POST[\"status\"]"
+section="$_POST[\"section\"]"
+description="$_POST[\"description\"]"
+comment="$_POST[\"comm\"]"
+[ -n "$_POST[\"cancel\"]" ] && cancel=true
+[ "$_POST[\"submit\"]" = "Robots click here" ] && cancel=true
+
+if [ -z "$cancel" -a -n "$comment" ]; then
+  touch "$_DATA/Tasks/$info"
+  echo -e "author=${USER}" > "$commfile"
+  echo -e "${comment}" >> "$commfile"
+  echo -n "Location: //${HTTP_HOST}/?p=Tasks&i=$info\n\n"
+elif [ -z "$cancel" -a -n "$description" ]; then
+  touch "$_DATA/Tasks/$info"
+  echo -e "headline=${headline}" > "$descfile"
+  echo -e "status=${taskstatus}" >> "$descfile"
+  echo -e "section=${section}" >> "$descfile"
+  echo -e "${description}" >> "$_DATA/Tasks/$info"
+  echo -n "Location: //${HTTP_HOST}/?p=Tasks#$anchor\n\n"
+elif [ -n "$cancel" ]; then
+  echo -n "Location: //${HTTP_HOST}/?p=Tasks#$anchor\n\n"
+fi
similarity index 58%
rename from write/lock.cgi
rename to actions/wikiedit.sh
index 33989b67440f2c789c569cc1298e399bbf1da39f..4c614093235f00e11b0ed96c8161a458390849df 100755 (executable)
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU Affero General Public License
 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
 
-[ "$HTTPS" = "on" ] && proto=https || proto=http
-. ../auth/permissions.sh
 $ACL_WIKIEDIT || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
 $ACL_WIKIEDIT || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
-$ACL_WIKIEDIT || exit 0 
+$ACL_WIKIEDIT || exit 0
 
 
-page=$(egrep -o '(^|&)p=(QandA|Locations|Wiki)(&|$)' <<<"${QUERY_STRING}" |sed 's,p=,,;s,&,,g')
-edit=$(egrep -o '(^|&)e=[0-9]{10}_[0-9]{3}(_[0-9]{1,4})?(&|$)' <<<"${QUERY_STRING}" |tr -d 'e=&')
+info="$(echo "$_GET[\"i\"]" |grep -Ex '[0-9]{10}_[0-9]{3}')"
+[ -f "$_DATA/Wiki/$info.lock" ] && rm "$_DATA/Wiki/$info.lock"
 
 
-case "$page" in
-  Wiki)        [ -f "../Wiki/${edit}" ] && echo "${REMOTE_USER}:$(($(date +%s)+600))" >"../Wiki/${edit}.lock"
-       ;;
-  *)   echo -n "Location: http://$host/?p=Error&r=input&$page\n\n"
-       exit 0
-       ;;
-esac
-echo -n "Location: ${proto}://${HTTP_HOST}/?${QUERY_STRING}\n\n"
+cgi_post
+page="$_POST[\"page\"]"
+[ -n "$_POST[\"cancel\"]" ] && cancel=true
+
+[ -z "$cancel" -a -f "$_DATA/Wiki/$info" ] && mv "$_DATA/Wiki/$info" "$_DATA/Wiki/$info.$(date +%s)"
+[ -z "$cancel" ] && echo -e "${page}" >"$_DATA/Wiki/$info"
+
+echo -n "Location: //${HTTP_HOST}/?p=Wiki&i=$info\n\n"
diff --git a/actions/wikimeta.sh b/actions/wikimeta.sh
new file mode 100755 (executable)
index 0000000..74b8ac9
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/zsh
+# Copyright 2011 - 2014 Paul Haensch
+# 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 <http://www.gnu.org/licenses/>.
+
+$ACL_WIKIEDIT || echo "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+$ACL_WIKIEDIT || exit 0 
+
+info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
+info="$(echo -E "$_GET[\"i\"]" |grep -Ex '[0-9]{10}_[0-9]{3}')"
+
+[ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
+descfile="$_DATA/Wiki/$info.meta"
+commfile="$_DATA/Wiki/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
+
+[ -f "$_DATA/Wiki/$info.lock" ] && rm "$_DATA/Wiki/$info.lock"
+anchor=$(ls "$_DATA/Wiki" |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
+
+cgi_post
+title="$_POST[\"title\"]"
+description="$_POST[\"desc\"]"
+comment="$_POST[\"comm\"]"
+[ -n "$_POST[\"cancel\"]" ] && cancel=true
+
+if [ -z "$cancel" -a -n "$comment" ]; then
+  touch "$_DATA/Wiki/$info"
+  echo -e "author=${USER}" > "$commfile"
+  echo -e "${comment}" >> "$commfile"
+  echo -n "Location: //${HTTP_HOST}/?p=Wiki&i=$info\n\n"
+elif [ -z "$cancel" -a -n "$description" ]; then
+  touch "$_DATA/Wiki/$info"
+  echo -e "title=${title}" > "$descfile"
+  echo -e "description=${description}" >> "$descfile"
+  echo -n "Location: //${HTTP_HOST}/?p=Wiki#$anchor\n\n"
+elif [ -n "$cancel" ]; then
+  echo -n "Location: //${HTTP_HOST}/?p=Wiki#$anchor\n\n"
+fi
diff --git a/auth/permissions.sh b/auth/permissions.sh
deleted file mode 100755 (executable)
index f943be3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-ANL_ADMIN="paul"
-ANL_EDITINTRO="paul"
-ANL_ADDNEWS="paul"
-ANL_EDITNEWS="paul"
-ANL_CREATETASK=".*"
-ANL_WIKIEDIT="paul"
-
-[ -n "$REMOTE_USER" ] && USER="$REMOTE_USER" || USER="#NONE#"
-egrep -xq "$ANL_ADMIN"      <<<"$USER" && ACL_ADMIN=true      || ACL_ADMIN=false
-egrep -xq "$ANL_EDITINTRO"  <<<"$USER" && ACL_EDITINTRO=true  || ACL_EDITINTRO=false
-egrep -xq "$ANL_ADDNEWS"    <<<"$USER" && ACL_ADDNEWS=true    || ACL_ADDNEWS=false
-egrep -xq "$ANL_EDITNEWS"   <<<"$USER" && ACL_EDITNEWS=true   || ACL_EDITNEWS=false
-egrep -xq "$ANL_CREATETASK" <<<"$USER" && ACL_CREATETASK=true || ACL_CREATETASK=false
-egrep -xq "$ANL_WIKIEDIT"   <<<"$USER" && ACL_WIKIEDIT=true   || ACL_WIKIEDIT=false
-
diff --git a/cgi.sh b/cgi.sh
new file mode 100755 (executable)
index 0000000..d35b368
--- /dev/null
+++ b/cgi.sh
@@ -0,0 +1,54 @@
+#!/bin/zsh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+# 
+# Confetti 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.
+# 
+# Confetti 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 Confetti.  If not, see <http://www.gnu.org/licenses/>. 
+
+declare -A _GET
+declare -A _POST
+declare -A _REF
+
+cgi_get() {  # parse HTTP GET string
+  echo "$QUERY_STRING" |tr '&' '\n' |while read query; do
+    key="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
+    val="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
+    _GET["$key"]="$(echo -e "$(echo -E "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")"
+  done
+}
+
+cgi_post() {  # parse HTTP POST string
+  sed -u 1q |tr '&' '\n' |while read query; do
+    key="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
+    val="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
+    value="$(echo -e "$(echo -E "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g;')")"
+    if [ -n "$_POST[\"$key\"]" ]; then
+      n=0
+      while [ -n "$_POST[\"$key$n\"]" ]; do n=$(($n + 1)); done
+      _POST["$key$n"]="$value"
+    else
+      _POST["$key"]="$value"
+    fi
+    #debug "_POST[$key] => $value"
+  done
+}
+
+cgi_refdata() { # Parse GET data from referer
+  echo "$HTTP_REFERER" |cut -d'?' -f2- |tr '&' '\n' |while read query; do
+    key="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
+    val="$(echo -E "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
+    _REF["$key"]="$(echo -e "$(echo -E "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")"
+  done
+}
diff --git a/constants.sh b/constants.sh
new file mode 100755 (executable)
index 0000000..2636e0b
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/zsh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+# 
+# Confetti 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.
+# 
+# Confetti 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 Confetti.  If not, see <http://www.gnu.org/licenses/>. 
+
+umask=002
+#alias _wiki="stx2any --no-template --link-abbrevs --quote -T html"
+_wiki(){
+  markdown $* |sed -r 's:<(h[1-6])>(.+)</h[1-6]>:<\1><a name="\2">\2</a></\1>:g'
+}
+
+LOGIN=false
+USER="#NONE#"
+_GET["p"]=Home
+
+sessfile="$_DATA/auth/session$(sed -rn 's:^.*session=([a-zA-Z0-9]{32}).*$:\1:p' <<<"$HTTP_COOKIE")"
+if [ -r "$sessfile" ]; then
+  cat "$sessfile" |read user expire
+  if [ "$(date +%s)" -lt "$expire" ]; then
+    echo -E "$user $(($(date +%s) + 1800))" >"$sessfile"
+    USER="$user"
+    LOGIN=true
+  else
+    [ -f "$sessfile" ] && rm "$sessfile"
+    sess_msg="Your session has expired!"
+  fi
+fi
+
+unset sessfile user expire
+. $_DATA/auth/permissions.sh
diff --git a/index.cgi b/index.cgi
deleted file mode 100755 (executable)
index 6084c3e..0000000
--- a/index.cgi
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2011 Paul Haensch
-# 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 <http://www.gnu.org/licenses/>.
-
-umask=002
-alias _wiki="stx2any --no-template --link-abbrevs --quote -T html"
-. auth/permissions.sh
-
-page=$(egrep -o '(^|&)p=[a-zA-Z0-9/_-]+(&|$)' <<<"${QUERY_STRING}" |sed 's,&,,g;s,p=,,')
-
-[ -z "$LOGIN" ] && LOGIN=false
-[ -z "$page" ] && page=Home
-
-if (! $LOGIN && egrep -qx "https?://${HTTP_HOST}/(session.cgi\?|write/).*" <<<"${HTTP_REFERER}"); then
-  echo -n "Location: https://${HTTP_HOST}/session.cgi?${QUERY_STRING}\n\n"
-  exit 0
-fi
-
-echo -n "Content-type: text/html\n\n"
-
-cat <<END_index.cgi
-<!DOCTYPE HTML>
-<!-- DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" -->
-
-<html>
-  <head>
-    <title>$(sed -rn 's:^name=(.*)$:\1:p' project.meta) - Busy</title>
-    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
-    <link rel="stylesheet" type="text/css" href="busy.css">
-    <link rel="stylesheet" type="text/css" href="wikitext.css">
-    $([ -r "${page}.css" ] && echo '<link rel="stylesheet" type="text/css" href="'"$page"'.css">')
-    <style type="text/css"><!-- --></style>
-
-    <script type="text/javascript">
-    <!--
-      function show_screen(id){
-        document.getElementById(id).style.display = "inline";
-      }
-      function hide_screen(id){
-        document.getElementById(id).style.display = "none";
-      }
-    -->
-    </script>
-    
-    <!-- Script for Flattr Button -->
-    <script type="text/javascript">
-    /* <![CDATA[ */
-        (function() {
-            var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
-            s.type = 'text/javascript';
-            s.async = true;
-            s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
-            t.parentNode.insertBefore(s, t);
-        })();
-    /* ]]> */</script>
-
-  </head>
-  <body onload="init();">
-    <div id="TITLE">
-      <h1 id="NAME">$(egrep '^name=.*$' project.meta |cut -d= -f2-)</h1>
-      <span id="SLOGAN">$(egrep '^slogan=.*$' project.meta |cut -d= -f2-)</span>
-    </div>
-    <div id="USERMENU">
-$( $LOGIN || echo '<form action="https://'${HTTP_HOST}'/login.cgi?'${QUERY_STRING:gs/&/&amp;/}'" method="post" accept-charset="UTF-8">
-                    Login:<br>
-                    <input type="text" name="user" value placeholder="Username"><br>
-                    <input type="password" name="pass" value placeholder="Password"><br>
-                    <input type="submit" value="Go!">
-                  </form>')
-$( $LOGIN && echo "You are loggeed in as <b>${REMOTE_USER}</b><br>")
-$( $LOGIN && $ACL_ADMIN && echo '<a href="?p=Admin">Admin</a><br>')
-$( $LOGIN && echo '<a href="?p=Settings">My Settings</a><br>')
-    </div>
-    <div id="ACCOUNTING">
-      $(btcAddress="$(sed -rn 's:^btcAddress=(.*)$:\1:p' project.meta)"
-        flattrThingURL=$(sed -rn 's:^flattrThingURL=(.*)$:\1:p' project.meta)
-
-        grep -q 'useBitcoin=yes' project.meta && [ \! -f "QRcodes/bitcoin:${btcAddress}.png" ] &&\
-          qrencode -o "QRcodes/bitcoin:${btcAddress}.png" "bitcoin:$btcAddress"
-        grep -q 'useBitcoin=yes' project.meta && echo '
-        <a href="#" onclick="javascript:show_screen('\'btcqr\'')"><img src="http://bitcoin.it/img/bc_logo_135.png" height="60"></a>
-        <div id='btcqr' style="display:none;">
-          <a href="#" onclick="javascript:hide_screen('\'btcqr\'')">close</a><br>
-          <img src="QRcodes/bitcoin:'$btcAddress'.png"><br>
-          Address:<br><a href="bitcoin:'$btcAddress'">'$btcAddress'</a>
-        </div>
-        '
-        grep -q 'useFlattr=yes' project.meta && echo '
-       <a class="FlattrButton" style="display:none;" href="http://'${HTTP_HOST}'"></a>
-       <noscript> <a href="'$flattrThingURL'" target="_blank">
-         <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" />
-        </a></noscript>
-      ')
-    </div>
-    <div id="MENU">
-      <a href='/?p=Home'>Home</a>
-      <a href='/?p=Wiki'>Wiki</a>
-      <a href='/?p=Subversion'>Code</a>
-      <a href='/?p=Tasks'>Tasks</a>
-    </div>
-      $(if [ -r "./${page}.page" ]; then
-       . "./${page}.page"
-        else
-       echo '<h2>Page not found or nevermore</h2>'
-       echo 'Quoth the Raven: 404'
-        fi
-      )
-  </body>
-</html>
-END_index.cgi
-
diff --git a/index.page b/index.page
deleted file mode 120000 (symlink)
index c31de76..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Wiki.page
\ No newline at end of file
diff --git a/page.sh b/page.sh
new file mode 100755 (executable)
index 0000000..4e370c0
--- /dev/null
+++ b/page.sh
@@ -0,0 +1,34 @@
+#!/bin/zsh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+# 
+# Confetti 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.
+# 
+# Confetti 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 Confetti.  If not, see <http://www.gnu.org/licenses/>. 
+
+echo -n "Content-Type: text/html;charset=utf-8\n\n"
+
+PAGE="$(echo -E "$_GET[\"p\"]" |egrep '^[a-zA-Z0-9_-]+$')"
+PAGE="${_EXEC}/pages/${PAGE}.sh"
+[ -x "$PAGE" ] || PAGE="${_EXEC}/pages/error.sh"
+
+NAVIGATION() {
+  for each in "${_EXEC}"/pages/*.sh; do
+    link="$(echo -E "$each" |sed -r "s:^.*/([^/]*)\.sh$:\1:")"
+    title="$($each title)"
+    [ -n "$title" ] && echo -E "/?page=$link $title"
+  done
+}
+
+. ${_EXEC}/templates/frame.html.sh
diff --git a/pages/Admin.sh b/pages/Admin.sh
new file mode 100755 (executable)
index 0000000..7f5dad3
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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 <http://www.gnu.org/licenses/>. 
+
+metafile=$_DATA/project.meta
+
+case "$1" in
+  title)
+    echo "Admin"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Admin.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_admin.sh
+    if [ "$ACL_ADMIN" = "false" ]; then
+      reason=noaccess
+      . ${_EXEC}/templates/Error.page
+    else
+      . ${_EXEC}/templates/Admin.page
+    fi
+  ;;
+esac
+  
diff --git a/pages/Home.sh b/pages/Home.sh
new file mode 100755 (executable)
index 0000000..eea4316
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/zsh
+
+# 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 <http://www.gnu.org/licenses/>. 
+
+
+searchresults() {
+  search="$(echo "$_GET[\"s\"]" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g')"
+
+  if [ -n "$search" ]; then
+    echo "<h1>News search results for: $search</h1>"
+    for each in $(grep -ile "$search" Home/<0000000000-9999999999>_<000-999>.news); do
+      id=$(sed -r 's:^.*/::;s:.news$::' <<<$each)
+      echo "<div class='search'><a href='#news_$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
+      grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
+      echo '</div>'
+    done
+    echo '<hr>'
+  fi
+}
+
+sponsored() {
+  btcAdAddress="$(sed -rn 's:^btcAdAddress=(.+):\1:p' project.meta)"
+  btcAdContent="$(sed -rn 's:^btcAdContent=([1-4]):\1:p' project.meta)"
+  grep -q 'advertise=btcAd' project.meta && cat <<EOF
+  <h1>Sponsored Links:</h1>
+  <iframe src="http://bitcoinadvertisers.com/a.php?p=${btcAdAddress}&a=${btcAdContent}&bg=FFFFFF&link=3366FF&text=414141"
+          scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>
+  <iframe src="http://bitcoinadvertisers.com/a.php?p=${btcAdAddress}&a=${btcAdContent}&bg=FFFFFF&link=3366FF&text=414141"
+          scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>
+EOF
+}
+
+case "$1" in
+  title)
+    echo "Home"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Home.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_home.sh
+    . ${_EXEC}/templates/Home.page
+  ;;
+esac
+  
similarity index 65%
rename from session.cgi
rename to pages/Settings.sh
index ff9f900fe6f3535248d46f2f1acedef804e6ea5d..76e658e18af13d78a9d9a5e8004acb5b06b345ca 100755 (executable)
@@ -1,20 +1,32 @@
-#!/bin/zsh
-# Copyright 2011 Paul Haensch
-# This file is part of Busy
+#!/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 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.
 # 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
 # You should have received a copy of the GNU Affero General Public License
-# along with Busy.  If not, see <http://www.gnu.org/licenses/>.
+# along with Busy. If not, see <http://www.gnu.org/licenses/>. 
 
 
-# This file must be password protected by the webserver (e.g. via a Files clause in .htaccess)
-LOGIN=true
-. ./index.cgi
+case "$1" in
+  title)
+    echo "Settings"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Settings.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_settings.sh
+    . ${_EXEC}/templates/Settings.page
+  ;;
+esac
+  
diff --git a/pages/Subversion.sh b/pages/Subversion.sh
new file mode 100755 (executable)
index 0000000..fa86d8b
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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 <http://www.gnu.org/licenses/>. 
+
+url="$(echo "$_GET[\"i\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
+rev="$(echo "$_GET[\"r\"]" |sed -rn '1{/^[0-9]+$/p}')"
+
+baseuri=$(sed -rn 's:^svnRepo=(.*)$:\1:p' project.meta)
+lastrev=$(svn info "$baseuri" |sed -rn 's;^Revision: *([0-9]+);\1;p')
+[ -z "$rev" ] && rev="$lastrev"
+
+case "$1" in
+  title)
+    echo "Code"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Subversion.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_subversion.sh
+    . ${_EXEC}/templates/Subversion.page
+  ;;
+esac
+  
diff --git a/pages/Tasks.sh b/pages/Tasks.sh
new file mode 100755 (executable)
index 0000000..0950be0
--- /dev/null
@@ -0,0 +1,40 @@
+#!/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 <http://www.gnu.org/licenses/>. 
+
+info="$(echo "$_GET[\"i\"]" |sed -rn '1{/^[0-9]{10}_[0-9]{3}$/p}')"
+edit="$(echo "$_GET[\"e\"]" |sed -rn '1{/^[0-9]{10}_[0-9]{3}$/p}')"
+search="$(echo "$_GET[\"s\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
+new="$(echo -e "$_GET[\"n\"]" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
+
+[ -z "$ACL_CREATETASK" ] && ACL_CREATETASK=false
+
+
+case "$1" in
+  title)
+    echo "Tasks"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Tasks.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_tasks.sh
+    . ${_EXEC}/templates/Tasks.page
+  ;;
+esac
+  
diff --git a/pages/Wiki.sh b/pages/Wiki.sh
new file mode 100755 (executable)
index 0000000..b9215f9
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>. 
+
+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
+  
diff --git a/pages/error.sh b/pages/error.sh
new file mode 100755 (executable)
index 0000000..c42df35
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+# 
+# Confetti 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.
+# 
+# Confetti 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 Confetti.  If not, see <http://www.gnu.org/licenses/>. 
+
+case "$1" in
+  title)
+  ;;
+  css)
+  ;;
+  body)
+cat <<EOF
+Page not found or nevermore<br />
+Quoth the server: 404
+EOF
+  ;;
+esac
+  
diff --git a/project.meta b/project.meta
deleted file mode 100644 (file)
index 8879a90..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-name=Busy
-slogan=Letting You do the Work.
-repoType=svn
-svnRepo=http://svn.plutz.net/busy
-gitRepo=http://d00m.org/~someone/git/qtc.git
-useFlattr=yes
-flattrThingURL=http://flattr.com/thing/599434/Busy-Software-Project-Management
-usePaypal=
-paypalAddress=
-useBitcoin=yes
-btcAddress=1PriLnvqxVmq68oiW54WTnveQ2e7eWiJmL
-advertise=btcAd
-btcAdAddress=1PswQ3kEKQSRHsMQYaTSgfrWEvHPZbkpZN
-btcAdContent=3
-
similarity index 100%
rename from Admin.css
rename to templates/Admin.css
diff --git a/templates/Admin.page b/templates/Admin.page
new file mode 100644 (file)
index 0000000..e869e4b
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/zsh
+
+cat <<AdminEND
+  <div id="LEFT"></div>
+  <div id="MAIN">
+    <div class="section"><form method="post" accept-charset="utf-8" action="/?action=projectmeta">
+      <h1>General</h1>
+
+      <fieldset><legend>Title Display</legend>
+      <div class="key">Project Name</div>
+        <div class="value"><input type="text" name="appName" value="$(sed -rn 's:^name=(.*)$:\1:p' "$metafile")"></div><br>
+      <div class="key">Project Slogan</div>
+        <div class="value"><input type="text" name="appSlogan" value="$(sed -rn 's:^slogan=(.*)$:\1:p' "$metafile")"></div><br>
+      </fieldset>
+
+      <fieldset><legend>Code Browser</legend>
+      <div class="key"><input type="radio" name="repoType" value="svn" $(grep -q repoType=svn $metafile && echo checked)>SVN Repository</div>
+        <div class="value"><input type="text" name="svnRepo" value="$(sed -rn 's:^svnRepo=(.*)$:\1:p' "$metafile")"></div><br>
+      <div class="key"><input type="radio" name="repoType" value="git" $(grep -q repoType=git $metafile && echo checked)>GIT Repository</div>
+        <div class="value"><input type="text" name="gitRepo" value="$(sed -rn 's:^gitRepo=(.*)$:\1:p' "$metafile")"></div><br>
+      </fieldset>
+
+      <fieldset><legend>Donations</legend>
+       <div class="key"><input type="checkbox" name="useFlattr" value="yes" $(grep -q useFlattr=yes $metafile && echo checked)>Flattr \"Thing\" URL</div>
+          <div class="value"><input type="text" name="flattrThingURL" value="$(sed -rn 's:^flattrThingURL=(.*)$:\1:p' "$metafile")"></div><br>
+       <div class="key"><input type="checkbox" name="useBitcoin" value="yes" $(grep -q useBitcoin=yes $metafile && echo checked)>Bitcoin Address</div>
+          <div class="value"><input type="text" name="btcAddress" value="$(sed -rn 's:^btcAddress=(.*)$:\1:p' "$metafile")"></div><br>
+       <div class="key"><input type="checkbox" name="usePaypal" value="yes" $(grep -q usePaypal=yes $metafile && echo checked)>Paypal Address</div>
+          <div class="value"><input type="text" name="paypalAddress" value="$(sed -rn 's:^paypalAddress=(.*)$:\1:p' "$metafile")"></div><br>
+      </fieldset>
+
+      <fieldset><legend>Advertisement</legend>
+       <div class="key"><input type="radio" name="advertise" value="no" $(grep -q advertise=no $metafile && echo checked)>No Advertisement</div><br>
+       <div class="key"><input type="radio" name="advertise" value="btcAd" $(grep -q advertise=btcAd $metafile && echo checked)>
+           <a target="_blank" href="http://bitcoinadvertisers.com">BitCoinAdvertisers.com</a><br>Bitcoin Address:</div>
+          <div class="value">
+          <input type="text" name="btcAdAddress" value="$(sed -rn 's:^btcAdAddress=(.*)$:\1:p' "$metafile")">
+         <input type="checkbox" name="btcAdGamble" value="yes" $(egrep -q 'btcAdContent=[13]' project.meta && echo checked)>Allow gambling ads
+         <input type="checkbox" name="btcAdErotic" value="yes" $(egrep -q 'btcAdContent=[12]' project.meta && echo checked)>Allow erotic ads
+          </div><br>
+      </fieldset>
+      <input type="submit">
+    </form></div>
+
+  </div>
+  <div id="RIGHT"></div>
+AdminEND
similarity index 100%
rename from Error.page
rename to templates/Error.page
similarity index 100%
rename from Git.page
rename to templates/Git.page
similarity index 100%
rename from Home.css
rename to templates/Home.css
diff --git a/templates/Home.page b/templates/Home.page
new file mode 100644 (file)
index 0000000..67d41fb
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/zsh
+
+switchbutton(){
+  hide="$1"; shift 1;
+  show="$1"; shift 1;
+  text="$*"
+  cat <<EOF
+  <a class="function" href="#${show}" onclick='javascript:hide_screen("${hide}");show_screen("${show}");'>${text}</a>
+EOF
+}
+
+edit_intro(){
+  cat <<HomeEND
+      <div id="introedit" style="display: none;">
+        <form action="/?action=introedit&i=intro" method="post" accept-charset="UTF-8">
+          <textarea name="text" rows="10">$([ -r "Home/intro" ] && cat Home/intro)</textarea><br>
+          <input type="submit">
+          $(switchbutton introedit introtext Cancel) 
+        </form>
+      </div>
+HomeEND
+}
+
+add_news(){
+  cat <<HomeEND
+  <div class="NEWS">
+    <a id="new" class='function' href='#add' onclick='javascript:hide_screen("new");show_screen("add");'>Add News</a>
+    <div id="add" style="display: none;">
+      <form action="/?action=introedit&i=news" method="post" accept-charset="UTF-8">
+        <textarea name="text" rows="10"></textarea><br>
+        <input type="submit">
+        $(switchbutton add new Cancel)
+      </form>
+    </div>
+  </div>
+HomeEND
+}
+
+edit_news(){
+  each="$1"
+  info="$(sed 's:Home/::;s:.news::' <<<"$each")"
+
+  cat <<HomeEND
+      <div id="edit_$info" style="display: none;">
+        <form action="/?action=introedit&i=$info" method="post" accept-charset="UTF-8">
+          <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
+          <input type="submit">
+          $(switchbutton edit_$info news_$info Cancel)
+        </form>
+      </div>
+HomeEND
+}
+
+show_news(){
+  stat -c '' Home/<0000000000-9999999999>_<000-999>.news && for each in $(ls -c Home/<0000000000-9999999999>_<000-999>.news); do
+    info="$(sed 's:Home/::;s:.news::' <<<"$each")"
+
+    cat <<HomeEND
+    <div class="NEWS">
+      <div id="news_$info"><div class="wikitext">
+      $([ -r "$each" ] && _wiki "$each")
+      $($ACL_EDITNEWS && echo "<hr/>$(switchbutton news_$info edit_$info Edit)")
+      </div></div>
+      $($ACL_EDITNEWS && edit_news $each)
+    </div>
+HomeEND
+  done
+}
+
+cat <<HomeEND
+  <div id="LEFT">
+    <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
+      <input type="hidden" name="p" value="Home">
+      <input type="text" name="s" placeholder="Search"><br>
+      <input type="submit" value="Search News">
+    </form>
+    <hr>
+    $(searchresults)
+  </div>
+
+  <div id="MAIN">
+    <div id="INTRO">
+      <div id="introtext"><div class="wikitext">
+      $([ -r "Home/intro" ] && _wiki "Home/intro")
+      $($ACL_EDITINTRO && echo "<hr/> $(switchbutton introtext introedit Edit)")
+      </div></div>
+      $($ACL_EDITINTRO && edit_intro)
+    </div>
+
+    $($ACL_ADDNEWS && add_news)
+
+    $(show_news)
+  </div>
+  <div id="RIGHT">
+  $(sponsored)
+  </div>
+HomeEND
similarity index 100%
rename from Settings.page
rename to templates/Settings.page
similarity index 100%
rename from Subversion.css
rename to templates/Subversion.css
similarity index 76%
rename from Subversion.page
rename to templates/Subversion.page
index 93b55293c63a7f11bb3daa9515eb2243072daefa..72f8189bb00995ebd7fc8a28b9c33148f160fe3f 100755 (executable)
@@ -1,11 +1,4 @@
 #!/bin/zsh
 #!/bin/zsh
-url="$(sed -rn 's:\+: :g;s:%:\\x:g;s:^(.*&)?i=([^&]+)(&.*)?$:\2:p' <<<"${QUERY_STRING}")"
-url="$(echo -e "${url}" |sed -rn '1{s:\t: :g;s:\r::g;s:\\:\\\\:g;p}')"
-rev="$(sed -rn 's:\+: :g;s:%:\\x:g;s:^(.*&)?r=([0-9]+)(&.*)?$:\2:p' <<<"${QUERY_STRING}")"
-
-baseuri=$(sed -rn 's:^svnRepo=(.*)$:\1:p' project.meta)
-lastrev=$(svn info "$baseuri" |sed -rn 's;^Revision: *([0-9]+);\1;p')
-[ -z "$rev" ] && rev="$lastrev"
 
 cat <<SVNEND
   <div id="LEFT">
 
 cat <<SVNEND
   <div id="LEFT">
similarity index 100%
rename from Tasks.css
rename to templates/Tasks.css
diff --git a/templates/Tasks.page b/templates/Tasks.page
new file mode 100644 (file)
index 0000000..423dec3
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/zsh
+
+show_search(){
+  if [ -n "$search" ]; then
+    echo "<h1>Tasks search results for: $search</h1>"
+    for each in $(grep -ile "$search" Tasks/<0000000000-9999999999>_<000-999>); do
+      id=$(sed -r 's:^.*/::;s:.task$::' <<<$each)
+      echo "<div class='search'><a href='${SCRIPTNAME}?p=Tasks&amp;i=$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
+      grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
+      echo '</div>'
+    done
+    echo '<hr>'
+  fi
+}
+
+show_task(){
+  datafile="Tasks/$info"
+  metafile="Tasks/$info.meta"
+  headline="$(sed -rn '/^headline=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
+  taskstatus="$(sed -rn '/^status=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
+  section="$(sed -rn '/^section=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
+  attendant="$(sed -rn '/^attendant=/{s:^[a-z]+=(.+)$:\1:p;q}' "$metafile")"
+  [ -z "$section" ] && section='(none)'
+  [ -z "$attendant" ] && attendant='(none)'
+  cat <<TasksEND
+    <div class="Task">
+      <div class="wikitext">
+      <h1>$headline</h1>
+      $(_wiki "$datafile")
+      </div>
+      <table><tr>
+      <td><b>Status</b><br>
+      $taskstatus</td>
+      <td><b>Section</b><br>
+      $section</td>
+      <td><b>Attendant</b><br>
+      $attendant</td>
+      </tr></table>
+    </div>
+TasksEND
+}
+
+setup_taks(){
+  cat <<TaskEnd
+  <form class="Task" style="height:20em;" method="post" action="write/$($LOGIN && echo user_)taskmeta.cgi" accept-charset="UTF-8">
+    <h1>$new</h1>
+    <input type="hidden" name="headline" value="$new">
+    <input type="hidden" name="status" value="new">
+    <div style="width:60%;left:3.5em;">
+      <b>Description:</b><br>
+      <textarea name="description" rows="11"></textarea>
+    </div><div style="width:30%;right:.5em;">
+      <b>Section:</b><br>
+      <select name="section" size="6" style="width:80%">
+      $(for each in $(egrep -hx 'section=.+' Tasks/<0000000000-9999999999>_<000-999>.meta |sort -u); do
+          echo "<option>$(sed 's:section=::' <<<"$each")</option>"
+        done)
+      </select><br>
+      <b>other section:</b><br>
+      <input type="text" name="section">
+      <input type="submit" name="submit" value="Robots click here" style="display:none;">
+      <input type="submit" name="submit" value="Create Task">
+      <input type="submit" name="submit" value="Robots click here" style="display:none;">
+    </div>
+  </form>
+TaskEnd
+}
+
+list_tasks(){
+  stat -c '' Tasks/<0000000000-9999999999>_<000-999>.meta \
+  && for each in Tasks/<0000000000-9999999999>_<000-999>.meta(.om); do
+    info="$(basename "$each" |sed 's:.meta$::')"
+    headline="$(sed -rn '/^headline=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
+    taskstatus="$(sed -rn '/^status=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
+    section="$(sed -rn '/^section=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
+    attendant="$(sed -rn '/^attendant=/{s:^[a-z]+=(.+)$:\1:p;q}' "$each")"
+    [ -z "$section" ] && section='(none)'
+    [ -z "$attendant" ] && attendant='(none)'
+    cat <<TasksEND
+      <div class="Task">
+        <a href="${SCRIPTNAME}?p=Tasks&amp;i=${info}"><b>$headline</b></a><br>
+        <span><b>Status:</b> $taskstatus</span>
+        <span><b>Section:</b> $section</span>
+        <span><b>Attendant:</b> $attendant</span>
+      </div>
+TasksEND
+  done
+}
+
+new_task(){
+  cat <<TasksEND
+      <a id='newTask_button' class='function' href='#' onclick='javascript:show_screen("newTask");hide_screen("newTask_button");'>New Task</a>
+      <div id="newTask" style="display: none;">
+        <form action="/${SCRIPTNAME}" method="get" accept-charset="UTF-8">
+          <b>Headline:</b><br>
+          <input type="hidden" name="p" value="Tasks">
+          <textarea name="n" rows="2" style="width:99%;"></textarea><br>
+          <input type="submit" value="Submit">
+          <a class="function" href="#" onclick="javascript:hide_screen('newTask');show_screen('newTask_button');">Cancel</a>
+        </form>
+      </div>
+TasksEND
+}
+
+cat <<TasksEND
+  <div id="LEFT">
+    <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
+      <input type="hidden" name="p" value="Tasks">
+      <input type="text" name="s" placeholder="Search"><br>
+      <input type="submit" value="Search Tasks">
+    </form>
+    <hr>
+    $(show_search)
+  </div><div id="MAIN">
+
+    $([ -n "$info" -a -r "Tasks/$info" -a -r "Tasks/$info.meta" ] && show_task)
+    $([ -z "$info" -a -n "$new" ] && setup_task)
+    $([ -z "$info" -a -z "$new" ] && list_tasks)
+ </div> <div id="RIGHT">
+    $($ACL_CREATETASK && [ -z "$new" ] && new_task)
+ </div>
+TasksEND
similarity index 100%
rename from Wiki.css
rename to templates/Wiki.css
diff --git a/templates/Wiki_edit.page b/templates/Wiki_edit.page
new file mode 100755 (executable)
index 0000000..a803ca9
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/zsh
+
+list_comments() {
+  base="$1"
+  
+  stat -c '' Wiki/${base}.comment.<0000000001-9999999999>_<000-999> \
+  && for each in $(ls -c Wiki/${base}.comment.<0000000001-9999999999>_<000-999>); do
+    author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
+    echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
+    tail -n+2 $each |_wiki
+    echo '</div></div>'
+  done
+}
+
+cat <<WikiEND
+    <form class="edit" action="/?action=wikiedit&i=$edit" method="post" accept-charset="UTF-8">
+      <div id="LEFT">
+       Editing <b>$title</b><br>
+        <input type="submit" value="Submit">
+        <input type="submit" name="cancel" value="Cancel">
+       <hr>
+      </div>
+      <div id="MAIN">
+       <div class="wiki">
+          <h1>$title</h1>
+          <textarea name="page" rows=30 cols=40>$(cat "$_DATA/Wiki/${edit}${rev}")</textarea>
+        </div>
+      </div>
+    </form>
+    <div id="RIGHT">
+    $(list_comments $edit)
+    </div>
+WikiEND
diff --git a/templates/Wiki_list.page b/templates/Wiki_list.page
new file mode 100755 (executable)
index 0000000..317e45a
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/zsh
+
+list_search(){
+  if [ -n "$search" ]; then
+    echo "<h1>Wiki search results for: $search</h1>"
+    for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
+      echo "<div class='search'><a href='?p=Wiki&amp;i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
+      grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
+      echo '</div>'
+    done
+    echo '<hr>'
+  fi
+}
+
+change_wiki(){
+  info="$1"
+
+  cat <<WikiEND
+      <div id="change_$info" style="display: none;">
+        <form action="/?action=wikimeta&i=$info" method="post" accept-charset="UTF-8">
+         <b>Title:</b> <input type="text" name="title" value="$title"><br>
+         <b>Description:</b><br>
+         <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>
+         <input type="submit" value="Submit">
+          <a class="function" href="#" onclick="javascript:hide_screen('change_$info');show_screen('display_$info');">Cancel</a>
+       </form>
+      </div>
+WikiEND
+}
+
+add_page() {
+  cat <<WikiEND
+    <a id='addp_button' class='function' href='#' onclick='javascript:show_screen("add_page");hide_screen("addp_button");'>Add a new Page</a>
+    <div id="add_page" style="display: none;">
+      <form action="/?action=wikimeta" method="post" accept-charset="UTF-8">
+        <br><b>Title:</b><br>
+       <input type="text" name="title" placeholder="Fill in a title"><br>
+        <b>Description:</b><br>
+        <textarea name="desc" rows="6" ></textarea><br>
+        <input type="submit" value="Submit">
+        <a class="function" href="#" onclick="javascript:hide_screen('add_page');show_screen('addp_button');">Cancel</a>
+      </form>
+    </div>
+WikiEND
+}
+
+list_wikis(){
+  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 <<WikiEND
+    <div class="article">
+      <div id="display_$info">
+        <a name="$info" href="/?p=Wiki&amp;i=$info"><h1>$title</h1></a>
+        $description<br><br>
+        <a class="function" href="/?p=Wiki&amp;i=$info">View</a> 
+        $($ACL_WIKIEDIT && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
+      </div>
+      $($ACL_WIKIEDIT && change_wiki $info)
+    </div>
+WikiEND
+  done
+}
+
+cat <<WikiEND
+    <div id="LEFT">
+      <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
+       <input type="hidden" name="p" value="Wiki">
+       <input type="text" name="s" placeholder="Search"><br>
+       <input type="submit" value="Search Wiki">
+      </form>
+      <hr>
+      $(list_search)
+    </div><div id="RIGHT">
+      $($LOGIN && add_page)
+    </div><div id="MAIN">
+      $(list_wikis)
+    </div>
+WikiEND
diff --git a/templates/Wiki_show.page b/templates/Wiki_show.page
new file mode 100755 (executable)
index 0000000..87e848f
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/zsh
+
+list_comments() {
+  base="$1"
+  
+  stat -c '' Wiki/${base}.comment.<0000000001-9999999999>_<000-999> \
+  && for each in $(ls -c Wiki/${base}.comment.<0000000001-9999999999>_<000-999>); do
+    author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
+    echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
+    tail -n+2 $each |_wiki
+    echo '</div></div>'
+  done
+}
+
+add_comment(){
+  info="$1"
+
+  cat <<WikiEND
+      <a id='comment_button' class='function' href='#'
+         onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
+      <div id="comment" style="display: none;">
+        <form action="/?action=wikimeta&i=$info" method="post" accept-charset="UTF-8">
+          <b>Comment:</b><br>
+          <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
+          <input type="submit" value="Submit">
+          <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
+        </form>
+      </div>
+WikiEND
+}
+
+cat <<WikiEND
+    <div id="LEFT">
+      <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
+       <input type="hidden" name="p" value="Wiki">
+       <input type="text" name="s" placeholder="Search"><br>
+       <input type="submit" value="Search Wiki">
+      </form>
+      <hr>
+
+      <b>Revisions:</b>
+      $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do
+       revi=$(cut -d. -f2 <<<"$each")
+       echo "<a class='rev' href='?p=Wiki&amp;i=$info&amp;r=$revi'>$rno</a>"
+       rno=$(($rno+1))
+        done) <a class='rev' href='?p=Wiki&amp;i=$info'>Latest</a><br>
+      <hr>
+      $($LOGIN && if [ -z "$lock" ]; then
+          [ -z "$rev" ] && echo "<a class='function' href='/?action=lock&amp;p=Wiki&amp;e=$info'>edit this page</a>"
+         [ -n "$rev" ] && echo "Click <a class='function' href='/?action=lock&amp;p=Wiki&amp;e=${info}&amp;r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
+        else
+         echo "<b>This page is currently being edited by $lock</b><a class='function' href='/?action=lock&amp;p=Wiki&amp;e=$info'>edit anyway</a>"
+        fi
+        $LOGIN && echo '<hr>')
+      <h1>Table of Content</h1>
+      <div class="toc">
+        $(cat Wiki/"${info}${rev}" |while read line; do
+       if (egrep -q '^ *###' <<<"$line"); then
+         echo "<a class='i2' href='#$(sed 's,^ *### *,,;' <<<"$line")'>$(sed 's,^ *###,,' <<<"$line")</a><br>"
+       elif (egrep -q '^ *##' <<<"$line"); then
+         echo "<a class='i1' href='#$(sed 's,^ *## *,,;' <<<"$line")'>$(sed 's,^ *##,,' <<<"$line")</a><br>"
+       elif (egrep -q '^ *#' <<<"$line"); then
+         echo "<a class='i0' href='#$(sed 's,^ *# *,,;' <<<"$line")'>$(sed 's,^ *#,,' <<<"$line")</a><br>"
+          fi
+        done)
+      </div>
+      <hr>
+    </div>
+    <div id="MAIN">
+      <div class="wiki"><div class="wikitext">
+        <h1>$title</h1>
+        $(_wiki Wiki/"${info}${rev}")
+      </div></div>
+    </div>
+
+    <div id="RIGHT">
+      $($LOGIN && add_comment $info)
+      $(list_comments $info)
+    </div>
+WikiEND
similarity index 100%
rename from busy.css
rename to templates/busy.css
diff --git a/templates/frame.html.sh b/templates/frame.html.sh
new file mode 100755 (executable)
index 0000000..9695122
--- /dev/null
@@ -0,0 +1,115 @@
+# Copyright 2011 - 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 <http://www.gnu.org/licenses/>. 
+
+list_accounts(){
+  btcAddress="$(sed -rn 's:^btcAddress=(.*)$:\1:p' project.meta)"
+  flattrThingURL=$(sed -rn 's:^flattrThingURL=(.*)$:\1:p' project.meta)
+
+  grep -q 'useBitcoin=yes' project.meta \
+  && [ \! -f "QRcodes/bitcoin:${btcAddress}.png" ] \
+  && qrencode -o "QRcodes/bitcoin:${btcAddress}.png" "bitcoin:${btcAddress}"
+  grep -q 'useBitcoin=yes' project.meta \
+  && cat <<PageEND
+  <a href="#" onclick="javascript:show_screen('btcqr')"><img src="http://bitcoin.it/img/bc_logo_135.png" height="60"></a>
+  <div id="btcqr" style="display:none;">
+    <a href="#" onclick="javascript:hide_screen('btcqr')">close</a><br>
+    <img src="QRcodes/bitcoin:${btcAddress}.png"><br>
+    Address:<br><a href="bitcoin:${btcAddress}">$btcAddress</a>
+  </div>
+PageEND
+
+  grep -q 'useFlattr=yes' project.meta \
+  && cat <<PageEND
+  <a class="FlattrButton" style="display:none;" href="http://${HTTP_HOST}"></a>
+  <noscript> <a href="${flattrThingURL}" target="_blank">
+    <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" />
+  </a></noscript>
+PageEND
+}
+
+cat <<EOF
+<!Doctype HTML>
+
+<html>
+  <head>
+    <title>$(sed -rn 's:^name=(.*)$:\1:p' $_DATA/project.meta) - Busy $(. $PAGE title)</title>
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+    <style type="text/css"><!-- 
+    $(cat $_EXEC/templates/busy.css)
+    $(cat $_EXEC/templates/wikitext.css)
+    $(. $PAGE css)
+    --></style>
+
+    <script type="text/javascript">
+    <!--
+      function show_screen(id){
+        document.getElementById(id).style.display = "inline";
+      }
+      function hide_screen(id){
+        document.getElementById(id).style.display = "none";
+      }
+    -->
+    </script>
+    
+    <!-- Script for Flattr Button -->
+    <script type="text/javascript">
+    /* <![CDATA[ */
+        (function() {
+            var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
+            s.type = 'text/javascript';
+            s.async = true;
+            s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
+            t.parentNode.insertBefore(s, t);
+        })();
+    /* ]]> */</script>
+
+  </head>
+
+  <body onload="init();">
+    <div id="TITLE">
+      <h1 id="NAME">$(egrep '^name=.*$' project.meta |cut -d= -f2-)</h1>
+      <span id="SLOGAN">$(egrep '^slogan=.*$' project.meta |cut -d= -f2-)</span>
+    </div>
+    <div id="USERMENU">
+      $( $LOGIN || echo '<form action="/?action=login" method="post" accept-charset="UTF-8">
+                           Login:<br>
+                          <input type="text" name="user" value placeholder="Username"><br>
+                          <input type="password" name="pass" value placeholder="Password"><br>
+                          <input type="submit" value="Go!">
+                        </form>')
+      $( $LOGIN && echo "You are loggeed in as <b>${USER}</b><br>")
+      $( $LOGIN && $ACL_ADMIN && echo '<a href="?p=Admin">Admin</a><br>')
+      $( $LOGIN && echo '<a href="?p=Settings">My Settings</a><br>')
+      $( $LOGIN && echo '<a href="?action=logout">Log Out</a><br>')
+      $sess_msg
+    </div>
+    <div id="ACCOUNTING">
+      $(list_accounts)
+    </div>
+    <div id="MENU">
+      <a href='/?p=Home'>Home</a>
+      <a href='/?p=Wiki'>Wiki</a>
+      <a href='/?p=Subversion'>Code</a>
+      <a href='/?p=Tasks'>Tasks</a>
+    </div>
+
+    $(. $PAGE body)
+  </body>
+</html>
+EOF
+
+# vi:set filetype=html:
similarity index 100%
rename from wikitext.css
rename to templates/wikitext.css
diff --git a/write/.htaccess b/write/.htaccess
deleted file mode 100644 (file)
index 607090d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Options +ExecCGI
-AddHandler cgi-script .cgi
-DirectoryIndex index.cgi
-
-#RewriteEngine On
-#RewriteCond   %{SERVER_PORT}  80
-#RewriteRule   ^.*(/write/.*)$     https://%{SERVER_NAME}/$1
-
-<FilesMatch "^user_">
-AuthType Basic
-AuthName "Busy Login"
-AuthUserFile /srv/busy.plutz.net/http/auth/htpasswd
-Require valid-user
-</FilesMatch>
diff --git a/write/projectmeta.cgi b/write/projectmeta.cgi
deleted file mode 100755 (executable)
index c2ee442..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2012 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 <http://www.gnu.org/licenses/>.
-
-metafile="../project.meta"
-
-[ "$HTTPS" = "on" ] && proto=https || proto=http
-. ../auth/permissions.sh
-$ACL_ADMIN || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
-$ACL_ADMIN || exit 0 
-
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' \
-  |sed -rn '/^((appName|appSlogan|svnRepo|gitRepo|flattrThingURL|paypalAddress|btcAddress|btcAdAddress)=.*|repoType=(svn|git)|(useFlattr|usePaypal|useBitcoin|btcAdGamble|btcAdErotic)=yes|advertise=(btcAd|no))$/{
-            s:\+: :g;s:%:\\x:g;p}' \
-  |while line="$(line)"; do
-    eval "$(echo -e "$line" |sed -r 's:[\n\r'\'']::g;s:^([a-zA-Z0-9_+-]+)=(.*)$:\1='"'\2'"':;')"
-  done
-fi
-
-[ "$btcAdGamble" = yes -a "$btcAdErotic" = yes ] && btcAdContent=1
-[ "$btcAdGamble" != yes -a "$btcAdErotic" = yes ] && btcAdContent=2
-[ "$btcAdGamble" = yes -a "$btcAdErotic" != yes ] && btcAdContent=3
-[ "$btcAdGamble" != yes -a "$btcAdErotic" != yes ] && btcAdContent=4
-
-echo "\
-name=$appName
-slogan=$appSlogan
-repoType=$repoType
-svnRepo=$svnRepo
-gitRepo=$gitRepo
-useFlattr=$useFlattr
-flattrThingURL=$flattrThingURL
-usePaypal=$usePaypal
-paypalAddress=$paypalAddress
-useBitcoin=$useBitcoin
-btcAddress=$btcAddress
-advertise=$advertise
-btcAdAddress=$btcAdAddress
-btcAdContent=$btcAdContent
-" >"$metafile"
-
-echo -n "Location: ${proto}://${HTTP_HOST}/?p=Admin\n\n"
diff --git a/write/taskmeta.cgi b/write/taskmeta.cgi
deleted file mode 100755 (executable)
index 7b09551..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/zsh
-# Copyright 2011 Paul Haensch
-# 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 <http://www.gnu.org/licenses/>.
-
-#info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
-[ "$HTTPS" = "on" ] && PROTO=https || proto=http
-
-. ../auth/permissions.sh
-$ACL_CREATETASK || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
-$ACL_CREATETASK || exit 0
-
-info="$(sed -r 's:(^|.*&)i=(.*)|.*:\2:;s:&.*::' <<<"${QUERY_STRING}")"
-
-[ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
-descfile="../Tasks/$info.meta"
-commfile="../Tasks/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
-
-[ -f "../Tasks/$info.lock" ] && rm "../Wiki/$info.lock"
-anchor=$(ls ../Tasks |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
-
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (egrep -xq 'headline=.+' <<<"${line}"); then
-    headline="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    headline="$(echo -e "${headline}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
-  elif (egrep -xq 'status=.+' <<<"${line}"); then
-    taskstatus="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    taskstatus="$(echo -e "${taskstatus}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
-  elif (egrep -xq 'section=.+' <<<"${line}"); then
-    section="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    section="$(echo -e "${section}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
-  elif (egrep -xq 'description=.+' <<<"${line}"); then
-    description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g')"
-  elif (egrep -xq 'comm=.+' <<<"${line}"); then
-    comment="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    comment="$(echo -e "${comment}" |sed 's/\r//g;s/\\/\\\\/g')"
-  elif (egrep -xq 'cancel=.+' <<<"${line}"); then
-    cancel="true"
-  elif (egrep -xq 'submit=Robots click here' <<<"${line}"); then
-    cancel="true"
-  fi
-done
-fi
-
-if [ -z "$cancel" -a -n "$comment" ]; then
-  touch "../Tasks/$info"
-  echo -e "author=${REMOTE_USER}" > "$commfile"
-  echo -e "${comment}" >> "$commfile"
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks&i=$info\n\n"
-elif [ -z "$cancel" -a -n "$description" ]; then
-  touch "../Tasks/$info"
-  echo -e "headline=${headline}" > "$descfile"
-  echo -e "status=${taskstatus}" >> "$descfile"
-  echo -e "section=${section}" >> "$descfile"
-  echo -e "${description}" >> "../Tasks/$info"
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks#$anchor\n\n"
-elif [ -n "$cancel" ]; then
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks#$anchor\n\n"
-fi
diff --git a/write/user_introedit.cgi b/write/user_introedit.cgi
deleted file mode 120000 (symlink)
index a23710b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-introedit.cgi
\ No newline at end of file
diff --git a/write/user_lock.cgi b/write/user_lock.cgi
deleted file mode 120000 (symlink)
index a247558..0000000
+++ /dev/null
@@ -1 +0,0 @@
-lock.cgi
\ No newline at end of file
diff --git a/write/user_projectmeta.cgi b/write/user_projectmeta.cgi
deleted file mode 120000 (symlink)
index 7c85894..0000000
+++ /dev/null
@@ -1 +0,0 @@
-projectmeta.cgi
\ No newline at end of file
diff --git a/write/user_taskmeta.cgi b/write/user_taskmeta.cgi
deleted file mode 120000 (symlink)
index b6544bf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-taskmeta.cgi
\ No newline at end of file
diff --git a/write/user_wikiedit.cgi b/write/user_wikiedit.cgi
deleted file mode 120000 (symlink)
index 368a76b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-wikiedit.cgi
\ No newline at end of file
diff --git a/write/user_wikimeta.cgi b/write/user_wikimeta.cgi
deleted file mode 120000 (symlink)
index 002e11e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-wikimeta.cgi
\ No newline at end of file
diff --git a/write/wikiedit.cgi b/write/wikiedit.cgi
deleted file mode 100755 (executable)
index fc437ee..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/zsh
-# Copyright 2011 Paul Haensch
-# 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 <http://www.gnu.org/licenses/>.
-
-[ "$HTTPS" = "on" ] && proto=https || proto=http
-. ../auth/permissions.sh
-$ACL_WIKIEDIT || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
-$ACL_WIKIEDIT || exit 0
-
-info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&=i')"
-[ -f "../Wiki/$info.lock" ] && rm "../Wiki/$info.lock"
-
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (echo "${line}" | egrep -xq 'page=.+'); then
-    page="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    page=$(echo -e "${page}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g')
-  elif (echo "${line}" | egrep -xq 'cancel=.+'); then
-    cancel=true
-  fi
-done
-fi
-
-[ -z "$cancel" -a -f "../Wiki/$info" ] && mv "../Wiki/$info" "../Wiki/$info.$(date +%s)"
-[ -z "$cancel" ] && echo -e "${page}" >"../Wiki/$info"
-
-echo -n "Location: ${proto}://${HTTP_HOST}/?p=Wiki&i=$info\n\n"
diff --git a/write/wikimeta.cgi b/write/wikimeta.cgi
deleted file mode 100755 (executable)
index af72eab..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/zsh
-# Copyright 2011 Paul Haensch
-# 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 <http://www.gnu.org/licenses/>.
-
-[ "$HTTPS" = "on" ] && proto=https || proto=http
-. ../auth/permissions.sh
-env >../debug
-$ACL_WIKIEDIT || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
-$ACL_WIKIEDIT || exit 0 
-
-info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
-
-[ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
-descfile="../Wiki/$info.meta"
-commfile="../Wiki/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
-
-[ -f "../Wiki/$info.lock" ] && rm "../Wiki/$info.lock"
-anchor=$(ls ../Wiki |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
-
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (egrep -xq 'title=.+' <<<"${line}"); then
-    title="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    title="$(echo -e "${title}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
-  elif (egrep -xq 'desc=.+' <<<"${line}"); then
-    description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g')"
-  elif (egrep -xq 'comm=.+' <<<"${line}"); then
-    comment="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    comment="$(echo -e "${comment}" |sed 's/\r//g;s/\\/\\\\/g')"
-  elif (egrep -xq 'cancel=.+' <<<"${line}"); then
-    cancel="true"
-  fi
-done
-fi
-
-if [ -z "$cancel" -a -n "$comment" ]; then
-  touch "../Wiki/$info"
-  echo -e "author=${REMOTE_USER}" > "$commfile"
-  echo -e "${comment}" >> "$commfile"
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Wiki&i=$info\n\n"
-elif [ -z "$cancel" -a -n "$description" ]; then
-  touch "../Wiki/$info"
-  echo -e "title=${title}" > "$descfile"
-  echo -e "description=${description}" >> "$descfile"
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Wiki#$anchor\n\n"
-elif [ -n "$cancel" ]; then
-  echo -n "Location: ${proto}://${HTTP_HOST}/?p=Wiki#$anchor\n\n"
-fi