]> git.plutz.net Git - busy/blob - Home.page
modified to use acl engine
[busy] / Home.page
1 #!/bin/zsh
2 search="$(egrep -o '(^|&)(s=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?s=::;s:\+: :g;s:%:\\x:g')"
3 search="$(echo -e "${search}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)"
4
5 [ -z "$ACL_EDITINTRO" ] && ACL_EDITINTRO=false
6 [ -z "$ACL_ADDNEWS" ] && ACL_ADDNEWS=false
7 [ -z "$ACL_EDITNEWS" ] && ACL_EDITNEWS=false
8
9 cat <<WikiEND
10   <div id="LEFT">
11     <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
12       <input type="hidden" name="p" value="Home">
13       <input type="text" name="s" placeholder="Search"><br>
14       <input type="submit" value="Search News">
15     </form>
16     <hr>
17 WikiEND
18 if [ -n "$search" ]; then
19   echo "<h1>News search results for: $search</h1>"
20   for each in $(grep -ile "$search" Home/<0000000000-9999999999>_<000-999>.news); do
21     id=$(sed -r 's:^.*/::;s:.news$::' <<<$each)
22     echo "<div class='search'><a href='#news_$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
23     grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
24     echo '</div>'
25   done
26   echo '<hr>'
27 fi
28
29 cat <<HomeEND
30   </div>
31
32   <div id="MAIN">
33     <div id="INTRO">
34       <div id="introtext"><div class="wikitext">
35       $([ -r "Home/intro" ] && _wiki "Home/intro")
36       $($ACL_EDITINTRO && echo "<hr><a class='function' href='#' onclick='javascript:hide_screen(\"introtext\");show_screen(\"introedit\");'>Edit</a>" )
37       </div></div>
38 HomeEND
39 $ACL_EDITINTRO && cat <<HomeEND
40       <div id="introedit" style="display: none;">
41         <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=intro" method="post" accept-charset="UTF-8">
42           <textarea name="text" rows="10">$([ -r "Home/intro" ] && cat Home/intro)</textarea><br>
43           <input type="submit">
44           <a class="function" href="#" onclick="javascript:hide_screen('introedit');show_screen('introtext');">Cancel</a>
45         </form>
46       </div>
47 HomeEND
48 echo '</div>'
49
50 $ACL_ADDNEWS && cat <<HomeEND
51   <div class="NEWS">
52     <a id="new" class='function' href='#add' onclick='javascript:hide_screen("new");show_screen("add");'>Add News</a>
53     <div id="add" style="display: none;">
54       <form action="/write/introedit.cgi?i=news" method="post" accept-charset="UTF-8">
55         <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
56         <input type="submit">
57         <a class="function" href="#new" onclick="javascript:hide_screen('add');show_screen('new');">Cancel</a>
58       </form>
59     </div>
60   </div>
61 HomeEND
62   
63 stat -c '' Home/<0000000000-9999999999>_<000-999>.news && for each in $(ls -c Home/<0000000000-9999999999>_<000-999>.news); do
64   info="$(sed 's:Home/::;s:.news::' <<<"$each")"
65   cat <<HomeEND
66     <div class="NEWS">
67       <div id="news_$info"><div class="wikitext">
68       $([ -r "$each" ] && _wiki "$each")
69       $($ACL_EDITNEWS && echo "<hr><a class='function' href='#edit_$info' onclick='javascript:hide_screen(\"news_$info\");show_screen(\"edit_$info\");'>Edit</a>" )
70       </div></div>
71 HomeEND
72   $ACL_EDITNEWS && cat <<HomeEND
73       <div id="edit_$info" style="display: none;">
74         <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=$info" method="post" accept-charset="UTF-8">
75           <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
76           <input type="submit">
77           <a class="function" href="#news_$info" onclick="javascript:hide_screen('edit_$info');show_screen('news_$info');">Cancel</a>
78         </form>
79       </div>
80 HomeEND
81   echo '</div>'
82 done
83
84 cat <<HomeEND
85   </div>
86   <div id="RIGHT">
87   </div>
88 HomeEND