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 [ -n "$rev" ] && rev=".$rev"
10 if [ -n "$search" ]; then
16 lock="Wiki/$info.lock"
17 [ -r "$lock" -o -n "$lock" ] && if [ "$(cut -d: -f2 "$lock")" -lt "$(date +%s)" ]; then
21 lock="$(cut -d: -f1 "$lock")"
24 if [ -n "$edit" -a -r "Wiki/$edit" ]; then
25 title="$(egrep -x 'title=.+' "Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')"
27 <form class="edit" action="write/scriptedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
28 <div id="RIGHT"></div>
30 Editing <b>$title</b><br>
32 <input type="submit" name="cancel" value="Cancel">
38 <textarea name="page" rows=30 cols=40>$(cat "Wiki/$edit")</textarea>
44 elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then
45 title="$(egrep -x 'title=.+' "Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')"
49 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
50 <input type="hidden" name="p" value="Wiki">
51 <input type="text" name="s" placeholder="Search"><br>
52 <input type="submit" value="Search Wiki">
57 $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do
58 revi=$(cut -d. -f2 <<<"$each")
59 echo "<a class='rev' href='?p=Wiki&i=$info&r=$revi'>$rno</a>"
61 done) <a class='rev' href='?p=Wiki&i=$info'>Latest</a><br>
63 $($LOGIN && [ -z "$rev" ] && if [ -z "$lock" ]; then
64 echo "<a class='function' href='write/lock.cgi?p=Wiki&e=$info'>edit this page</a>"
66 echo "<b>This page is currently being edited by $lock</b><a class='function' href='write/lock.cgi?p=Wiki&e=$info'>edit anyway</a>"
68 $LOGIN && echo '<hr>')
69 <h1>Table of Content</h1>
71 $(cat Wiki/"${info}${rev}" |while read line; do
72 if (egrep -q '^ *!!!' <<<"$line"); then
73 echo "<a class='i2' href='#$(sed 's,^ *!!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!!,,' <<<"$line")</a><br>"
74 elif (egrep -q '^ *!!' <<<"$line"); then
75 echo "<a class='i1' href='#$(sed 's,^ *!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!,,' <<<"$line")</a><br>"
76 elif (egrep -q '^ *!' <<<"$line"); then
77 echo "<a class='i0' href='#$(sed 's,^ *! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!,,' <<<"$line")</a><br>"
86 $(_wiki Wiki/"${info}${rev}")
91 echo '<div id="RIGHT">'
92 $LOGIN && cat <<WikiEND
93 <a id='comment_button' class='function' href='#' onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
94 <div id="comment" style="display: none;">
95 <form action="/write/wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
97 <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
99 <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
103 stat -c '' Wiki/${info}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${info}.comment.<0000000000-9999999999>_<000-999>); do
104 author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
105 echo "<div class="comment"><h1>$author wrote:</h1>"
111 elif [ -z "$info" ]; then
114 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
115 <input type="hidden" name="p" value="Wiki">
116 <input type="text" name="s" placeholder="Search"><br>
117 <input type="submit" value="Search Wiki">
121 if [ -n "$search" ]; then
122 echo "<h1>Search results for: $search</h1>"
123 for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
124 echo "<div class='search'><a href='?p=Wiki&i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
125 grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
130 echo '</div><div id="RIGHT">'
131 $LOGIN && cat <<WikiEND
132 <a id='addp_button' class='function' href='#' onclick='javascript:show_screen("add_page");hide_screen("addp_button");'>Add a new Page</a>
133 <div id="add_page" style="display: none;">
134 <form action="/write/wikimeta.cgi" method="post" accept-charset="UTF-8">
135 <br><b>Title:</b><br>
136 <input type="text" name="title" placeholder="Fill in a title"><br>
137 <b>Description:</b><br>
138 <textarea name="desc" rows="6" ></textarea><br>
139 <input type="submit">
140 <a class="function" href="#" onclick="javascript:hide_screen('add_page');show_screen('addp_button');">Cancel</a>
144 echo '</div><div id="MAIN">'
146 stat -c '' Wiki/<0000000000-9999999999>_<000-999> && for each in Wiki/<0000000000-9999999999>_<000-999>; do
147 info=$(sed 's,Wiki/,,' <<<"$each")
148 title="$(egrep -x 'title=.+' "$each.meta" |cut -d= -f2- || echo '(Untitled)')"
149 description="$(egrep -x 'description=.+' "$each.meta" |cut -d= -f2-)"
150 owner="$(egrep -x 'owner=.+' "$each.meta" |cut -d= -f2-)"
153 <div class="article">
154 <div id="display_$info">
155 <a name="$info" href="/?p=Wiki&i=$info"><h1>$title</h1></a>
157 <a class="function" href="/?p=Wiki&i=$info">View</a>
158 $($LOGIN && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Title</a>")
161 $LOGIN && cat <<WikiEND
162 <div id="change_$info" style="display: none;">
163 <form action="/write/wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
164 <b>Title:</b> <input type="text" name="title" value="$title"><br>
165 <b>Description:</b><br>
166 <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>
167 <input type="submit">
168 <a class="function" href="#" onclick="javascript:hide_screen('change_$info');show_screen('display_$info');">Cancel</a>