#!/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 <<HomeEND
+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">
/* You should have received a copy of the GNU Affero General Public License*/
/* along with Busy. If not, see <http://www.gnu.org/licenses/>.*/
-.search {
- background-color: #FFF;
- border-color: #AAF;
- border-style: solid;
- border-width: 1px;
- margin: .6em 0em;
- padding: .2em .5em .5em .5em;
- border-radius: 8px;
- -moz-border-radius: 8px;
-}
-.search h2{
- font: normal bold 1em sans-serif;
- text-align: center;
- color: #66F;
- margin: 0em 0em .3em 0em;
- border-style: none none solid none;
- border-width: 1px;
- border-color: #AAF;
-}
-
.comment {
background-color: #FFF;
border-color: #AAF;
margin: 0em 0em .5em 0em;
}
+.search {
+ background-color: #FFF;
+ border-color: #AAF;
+ border-style: solid;
+ border-width: 1px;
+ margin: .6em 0em;
+ padding: .2em .5em .5em .5em;
+ border-radius: 8px;
+ -moz-border-radius: 8px;
+}
+.search h2{
+ font: normal bold 1em sans-serif;
+ text-align: center;
+ color: #66F;
+ margin: 0em 0em .3em 0em;
+ border-style: none none solid none;
+ border-width: 1px;
+ border-color: #AAF;
+}
+
div#RIGHT {
position: absolute;
right: 0px; top: 7em;