]> git.plutz.net Git - busy/blob - templates/Home.page
upgraded to fit new shcgi revision, slightly better input validation, switched to...
[busy] / templates / Home.page
1 #!/bin/zsh
2
3 switchbutton(){
4   hide="$1"; shift 1;
5   show="$1"; shift 1;
6   text="$*"
7   cat <<EOF
8   <a class="function" href="#${show}" onclick='javascript:hide_screen("${hide}");show_screen("${show}");'>${text}</a>
9 EOF
10 }
11
12 edit_intro(){
13   cat <<HomeEND
14       <div id="introedit" style="display: none;">
15         <form action="./?action=introedit&i=intro" method="post" accept-charset="UTF-8">
16           <textarea name="text" rows="10">$([ -r "Home/intro" ] && cat Home/intro)</textarea><br>
17           <input type="submit">
18           $(switchbutton introedit introtext Cancel) 
19         </form>
20       </div>
21 HomeEND
22 }
23
24 add_news(){
25   cat <<HomeEND
26   <div class="NEWS">
27     <a id="new" class='function' href='#add' onclick='javascript:hide_screen("new");show_screen("add");'>Add News</a>
28     <div id="add" style="display: none;">
29       <form action="./?action=introedit&i=news" method="post" accept-charset="UTF-8">
30         <textarea name="text" rows="10"></textarea><br>
31         <input type="submit">
32         $(switchbutton add new Cancel)
33       </form>
34     </div>
35   </div>
36 HomeEND
37 }
38
39 edit_news(){
40   each="$1"
41   info="$(sed 's:Home/::;s:.news::' <<<"$each")"
42
43   cat <<HomeEND
44       <div id="edit_$info" style="display: none;">
45         <form action="./?action=introedit&i=$info" method="post" accept-charset="UTF-8">
46           <textarea name="text" rows="10">$([ -r "$each" ] && cat $each)</textarea><br>
47           <input type="submit">
48           $(switchbutton edit_$info news_$info Cancel)
49         </form>
50       </div>
51 HomeEND
52 }
53
54 show_news(){
55   for each in $(ls -r Home/<0000000000-9999999999>_<000-999>.news); do
56     info="$(sed 's:Home/::;s:.news::' <<<"$each")"
57
58     cat <<HomeEND
59     <div class="NEWS">
60       <div id="news_$info"><div class="wikitext">
61       $([ -r "$each" ] && _wiki "$each")
62       $($ACL_EDITNEWS && echo "<hr/>$(switchbutton news_$info edit_$info Edit)")
63       </div></div>
64       $($ACL_EDITNEWS && edit_news $each)
65     </div>
66 HomeEND
67   done
68 }
69
70 cat <<HomeEND
71   <div id="LEFT">
72     <form method="GET" action="./" accept-charset="utf-8">
73       <input type="hidden" name="p" value="Home">
74       <input type="text" name="s" placeholder="Search"><br>
75       <input type="submit" value="Search News">
76     </form>
77     <hr>
78     $(searchresults)
79   </div>
80
81   <div id="MAIN">
82     <div id="INTRO">
83       <div id="introtext"><div class="wikitext">
84       $([ -r "Home/intro" ] && _wiki "Home/intro")
85       $($ACL_EDITINTRO && echo "<hr/> $(switchbutton introtext introedit Edit)")
86       </div></div>
87       $($ACL_EDITINTRO && edit_intro)
88     </div>
89
90     $($ACL_ADDNEWS && add_news)
91
92     $(show_news)
93   </div>
94   <div id="RIGHT">
95   $(sponsored)
96   </div>
97 HomeEND