2 # Copyright 2011 Paul Haensch
3 # This file is part of Busy
5 # Busy is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # Busy is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Busy. If not, see <http://www.gnu.org/licenses/>.
18 #info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
19 info="$(sed -r 's:(^|.*&)i=(.*)|.*:\2:;s:&.*::' <<<"${QUERY_STRING}")"
21 [ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
22 descfile="../Tasks/$info.meta"
23 commfile="../Tasks/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
25 [ -f "../Tasks/$info.lock" ] && rm "../Wiki/$info.lock"
26 anchor=$(ls ../Tasks |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
28 if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
29 (head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
30 if (egrep -xq 'headline=.+' <<<"${line}"); then
31 headline="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
32 headline="$(echo -e "${headline}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
33 elif (egrep -xq 'status=.+' <<<"${line}"); then
34 taskstatus="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
35 taskstatus="$(echo -e "${taskstatus}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
36 elif (egrep -xq 'section=.+' <<<"${line}"); then
37 section="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
38 section="$(echo -e "${section}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
39 elif (egrep -xq 'description=.+' <<<"${line}"); then
40 description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
41 description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g')"
42 elif (egrep -xq 'comm=.+' <<<"${line}"); then
43 comment="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
44 comment="$(echo -e "${comment}" |sed 's/\r//g;s/\\/\\\\/g')"
45 elif (egrep -xq 'cancel=.+' <<<"${line}"); then
51 if [ -z "$cancel" -a -n "$comment" ]; then
52 touch "../Tasks/$info"
53 echo -e "author=${REMOTE_USER}" > "$commfile"
54 echo -e "${comment}" >> "$commfile"
55 echo -n "Location: http://${HTTP_HOST}/?p=Tasks&i=$info\n\n"
56 elif [ -z "$cancel" -a -n "$description" ]; then
57 touch "../Tasks/$info"
58 echo -e "headline=${headline}" > "$descfile"
59 echo -e "status=${taskstatus}" >> "$descfile"
60 echo -e "section=${section}" >> "$descfile"
61 echo -e "${description}" >> "../Tasks/$info"
62 echo -n "Location: http://${HTTP_HOST}/?p=Tasks#$anchor\n\n"
63 elif [ -n "$cancel" ]; then
64 echo -n "Location: http://${HTTP_HOST}/?p=Tasks#$anchor\n\n"