]> git.plutz.net Git - busy/blob - Home.page
implemented bitcoin donations and advertisement (via http://bitcoinadvertisers.com)
[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 cat <<WikiEND
6   <div id="LEFT">
7     <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
8       <input type="hidden" name="p" value="Home">
9       <input type="text" name="s" placeholder="Search"><br>
10       <input type="submit" value="Search News">
11     </form>
12     <hr>
13 WikiEND
14 if [ -n "$search" ]; then
15   echo "<h1>News search results for: $search</h1>"
16   for each in $(grep -ile "$search" Home/<0000000000-9999999999>_<000-999>.news); do
17     id=$(sed -r 's:^.*/::;s:.news$::' <<<$each)
18     echo "<div class='search'><a href='#news_$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
19     grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
20     echo '</div>'
21   done
22   echo '<hr>'
23 fi
24
25 cat <<HomeEND
26   </div>
27
28   <div id="MAIN">
29     <div id="INTRO">
30       <div id="introtext"><div class="wikitext">
31       $([ -r "Home/intro" ] && _wiki "Home/intro")
32       $($ACL_EDITINTRO && echo "<hr><a class='function' href='#' onclick='javascript:hide_screen(\"introtext\");show_screen(\"introedit\");'>Edit</a>" )
33       </div></div>
34 HomeEND
35 $ACL_EDITINTRO && cat <<HomeEND
36       <div id="introedit" style="display: none;">
37         <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=intro" method="post" accept-charset="UTF-8">
38           <textarea name="text" rows="10">$([ -r "Home/intro" ] && cat Home/intro)</textarea><br>
39           <input type="submit">
40           <a class="function" href="#" onclick="javascript:hide_screen('introedit');show_screen('introtext');">Cancel</a>
41         </form>
42       </div>
43 HomeEND
44 echo '</div>'
45
46 $ACL_ADDNEWS && cat <<HomeEND
47   <div class="NEWS">
48     <a id="new" class='function' href='#add' onclick='javascript:hide_screen("new");show_screen("add");'>Add News</a>
49     <div id="add" style="display: none;">
50       <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=news" method="post" accept-charset="UTF-8">
51         <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
52         <input type="submit">
53         <a class="function" href="#new" onclick="javascript:hide_screen('add');show_screen('new');">Cancel</a>
54       </form>
55     </div>
56   </div>
57 HomeEND
58   
59 stat -c '' Home/<0000000000-9999999999>_<000-999>.news && for each in $(ls -c Home/<0000000000-9999999999>_<000-999>.news); do
60   info="$(sed 's:Home/::;s:.news::' <<<"$each")"
61   cat <<HomeEND
62     <div class="NEWS">
63       <div id="news_$info"><div class="wikitext">
64       $([ -r "$each" ] && _wiki "$each")
65       $($ACL_EDITNEWS && echo "<hr><a class='function' href='#edit_$info' onclick='javascript:hide_screen(\"news_$info\");show_screen(\"edit_$info\");'>Edit</a>" )
66       </div></div>
67 HomeEND
68   $ACL_EDITNEWS && cat <<HomeEND
69       <div id="edit_$info" style="display: none;">
70         <form action="/write/$($LOGIN && echo user_)introedit.cgi?i=$info" method="post" accept-charset="UTF-8">
71           <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
72           <input type="submit">
73           <a class="function" href="#news_$info" onclick="javascript:hide_screen('edit_$info');show_screen('news_$info');">Cancel</a>
74         </form>
75       </div>
76 HomeEND
77   echo '</div>'
78 done
79
80 cat <<HomeEND
81   </div>
82   <div id="RIGHT">
83   $(grep -q 'advertise=btcAd' project.meta && echo '<h1>Sponsored Links:</h1>
84     <iframe src="http://bitcoinadvertisers.com/a.php?p='$(sed -rn 's:^btcAdAddress=(.+):\1:p' project.meta)'&a='$(sed -rn 's:^btcAdContent=([1-4]):\1:p' project.meta)'&bg=FFFFFF&link=3366FF&text=414141" scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>'
85   )
86   </div>
87 HomeEND