3 info="$(egrep -o '(^|&)(i=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
4 edit="$(egrep -o '(^|&)(e=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&e=')"
5 rev="$(egrep -o '(^|&)(r=)[0-9]{10}(&|$)' <<<"${QUERY_STRING}" |tr -d '&r=')"
6 search="$(egrep -o '(^|&)(s=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?s=::;s:\+: :g;s:%:\\x:g')"
7 search="$(echo -e "${search}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)"
9 [ -z "$ACL_WIKIEDIT" ] && ACL_WIKIEDIT=false
11 [ -n "$rev" ] && rev=".$rev"
12 if [ -n "$search" ]; then
18 lock="Wiki/$info.lock"
19 [ -r "$lock" -o -n "$lock" ] && if [ "$(cut -d: -f2 "$lock")" -lt "$(date +%s)" ]; then
23 lock="$(cut -d: -f1 "$lock")"
26 if [ -n "$edit" -a -r "Wiki/${edit}${rev}" ]; then
27 title="$(egrep -x 'title=.+' "Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')"
29 <form class="edit" action="write/$($LOGIN && echo user_)wikiedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
31 Editing <b>$title</b><br>
32 <input type="submit" value="Submit">
33 <input type="submit" name="cancel" value="Cancel">
39 <textarea name="page" rows=30 cols=40>$(cat "Wiki/${edit}${rev}")</textarea>
44 $(stat -c '' Wiki/${edit}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${edit}.comment.<0000000000-9999999999>_<000-999>); do
45 author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
46 echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
47 tail -n+2 $each |_wiki
53 elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then
54 title="$(egrep -x 'title=.+' "Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')"
58 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
59 <input type="hidden" name="p" value="Wiki">
60 <input type="text" name="s" placeholder="Search"><br>
61 <input type="submit" value="Search Wiki">
66 $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do
67 revi=$(cut -d. -f2 <<<"$each")
68 echo "<a class='rev' href='?p=Wiki&i=$info&r=$revi'>$rno</a>"
70 done) <a class='rev' href='?p=Wiki&i=$info'>Latest</a><br>
72 $($LOGIN && if [ -z "$lock" ]; then
73 [ -z "$rev" ] && echo "<a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=$info'>edit this page</a>"
74 [ -n "$rev" ] && echo "Click <a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=${info}&r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
76 echo "<b>This page is currently being edited by $lock</b><a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=$info'>edit anyway</a>"
78 $LOGIN && echo '<hr>')
79 <h1>Table of Content</h1>
81 $(cat Wiki/"${info}${rev}" |while read line; do
82 if (egrep -q '^ *!!!' <<<"$line"); then
83 echo "<a class='i2' href='#$(sed 's,^ *!!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!!,,' <<<"$line")</a><br>"
84 elif (egrep -q '^ *!!' <<<"$line"); then
85 echo "<a class='i1' href='#$(sed 's,^ *!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!,,' <<<"$line")</a><br>"
86 elif (egrep -q '^ *!' <<<"$line"); then
87 echo "<a class='i0' href='#$(sed 's,^ *! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!,,' <<<"$line")</a><br>"
94 <div class="wiki"><div class="wikitext">
96 $(_wiki Wiki/"${info}${rev}")
101 echo '<div id="RIGHT">'
102 $LOGIN && cat <<WikiEND
103 <a id='comment_button' class='function' href='#' onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
104 <div id="comment" style="display: none;">
105 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
107 <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
108 <input type="submit" value="Submit">
109 <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
113 stat -c '' Wiki/${info}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${info}.comment.<0000000000-9999999999>_<000-999>); do
114 author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
115 echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
116 tail -n+2 $each |_wiki
121 elif [ -z "$info" ]; then
124 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
125 <input type="hidden" name="p" value="Wiki">
126 <input type="text" name="s" placeholder="Search"><br>
127 <input type="submit" value="Search Wiki">
131 if [ -n "$search" ]; then
132 echo "<h1>Wiki search results for: $search</h1>"
133 for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
134 echo "<div class='search'><a href='?p=Wiki&i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
135 grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
140 echo '</div><div id="RIGHT">'
141 $LOGIN && cat <<WikiEND
142 <a id='addp_button' class='function' href='#' onclick='javascript:show_screen("add_page");hide_screen("addp_button");'>Add a new Page</a>
143 <div id="add_page" style="display: none;">
144 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi" method="post" accept-charset="UTF-8">
145 <br><b>Title:</b><br>
146 <input type="text" name="title" placeholder="Fill in a title"><br>
147 <b>Description:</b><br>
148 <textarea name="desc" rows="6" ></textarea><br>
149 <input type="submit" value="Submit">
150 <a class="function" href="#" onclick="javascript:hide_screen('add_page');show_screen('addp_button');">Cancel</a>
154 echo '</div><div id="MAIN">'
156 stat -c '' Wiki/<0000000000-9999999999>_<000-999> && for each in Wiki/<0000000000-9999999999>_<000-999>; do
157 info=$(sed 's,Wiki/,,' <<<"$each")
158 title="$(egrep -x 'title=.+' "$each.meta" |cut -d= -f2- || echo '(Untitled)')"
159 description="$(egrep -x 'description=.+' "$each.meta" |cut -d= -f2-)"
160 owner="$(egrep -x 'owner=.+' "$each.meta" |cut -d= -f2-)"
163 <div class="article">
164 <div id="display_$info">
165 <a name="$info" href="/?p=Wiki&i=$info"><h1>$title</h1></a>
167 <a class="function" href="/?p=Wiki&i=$info">View</a>
168 $($ACL_WIKIEDIT && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
171 $ACL_WIKIEDIT && cat <<WikiEND
172 <div id="change_$info" style="display: none;">
173 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
174 <b>Title:</b> <input type="text" name="title" value="$title"><br>
175 <b>Description:</b><br>
176 <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>
177 <input type="submit" value="Submit">
178 <a class="function" href="#" onclick="javascript:hide_screen('change_$info');show_screen('display_$info');">Cancel</a>