Annotation of loncom/html/res/adm/pages/bookmarkmenu/admbookmarks.pm, revision 1.10
1.1 tyszkabe 1: #!/usr/bin/perl -T
2: #
1.2 tyszkabe 3: # This will take annotations and then plug them into a page.
1.1 tyszkabe 4: #
1.2 tyszkabe 5: # 08/25/00 Ben Tyszka
1.1 tyszkabe 6: #
7: #
1.2 tyszkabe 8: #
9: ##################
1.1 tyszkabe 10:
1.5 tyszkabe 11: package Apache::admbookmarks;
1.1 tyszkabe 12:
13: use strict;
1.2 tyszkabe 14: use Apache::Constants qw(:common);
1.8 tyszkabe 15: use Apache::lonnet();
1.1 tyszkabe 16:
1.4 tyszkabe 17: # --------------------------------------------------------------Put bookmarks
1.1 tyszkabe 18:
1.4 tyszkabe 19: sub write_bookmarks {
1.3 tyszkabe 20: my $marks=shift;
1.4 tyszkabe 21: Apache::lonnet::put("bookmarks",('bookmarks' => $marks));
1.2 tyszkabe 22: return;
1.1 tyszkabe 23: }
24:
1.4 tyszkabe 25: # --------------------------------------------------------------Get bookmarks
1.2 tyszkabe 26:
1.4 tyszkabe 27: sub get_bookmarks {
1.5 tyszkabe 28: my %bookmark=Apache::lonnet::get('bookmarks',('bookmarks'));
29: return %bookmark;
1.2 tyszkabe 30: }
31:
1.4 tyszkabe 32: # ---------------------------------------------------Construct bookmark editor
1.2 tyszkabe 33:
34: sub construct_editor {
1.9 tyszkabe 35: my $bookmarks=shift;
1.2 tyszkabe 36: return(<<END_HTML)
1.4 tyszkabe 37: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
38: <html>
39: <head>
40: <title>
1.8 tyszkabe 41: Bookmark Tree Viewer/Editor
1.4 tyszkabe 42: </title>
43: <script LANGUAGE="JavaScript">
44: var addressCache = "";
45: var dragCache = "";
46: var lastDrug = "";
47: var lastIcon = "";
48: var image_num=0;
1.6 tyszkabe 49: var saveVar="";
1.4 tyszkabe 50:
51: function buildUserTree() {
52: this.dropCache = "";
53: this.dragCache = "";
54: //-------------------------------------------------------------------------------
1.9 tyszkabe 55: // The FOLLOWING data is supplied by the Perl Module
56: //-------------------------------------------------------------------------------
57: $bookmarks
58: //-------------------------------------------------------------------------------
59: // The PRECEDING data is supplied by the Perl Module
1.4 tyszkabe 60: //-------------------------------------------------------------------------------
61: }
62: </script>
1.8 tyszkabe 63: <script src="/res/adm/pages/bookmarkmenu/bookmarklib.js" language="JavaScript"></script>
64: <script language="JavaScript">
65: bookmarkpal = new buildUserTree();
66: </script>
1.4 tyszkabe 67: </head>
1.6 tyszkabe 68: <FRAMESET rows="25, *, 40, 25" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 frameborder="0" border="0" framespacing="0" >
1.4 tyszkabe 69: <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5 tyszkabe 70: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ul.html" marginwidth="0" marginheight="0" scrolling="no">
71: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_uu.html" marginwidth="0" marginheight="0" scrolling="no">
72: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ur.html" marginwidth="0" marginheight="0" scrolling="no">
1.4 tyszkabe 73: </FRAMESET>
74: <FRAMESET name="contentb" cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5 tyszkabe 75: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
1.7 tyszkabe 76: <FRAME name="content" src="/res/adm/pages/bookmarkmenu/loading_bookmarks.html" marginwidth="0" marginheight="0" scrolling="yes">
1.5 tyszkabe 77: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4 tyszkabe 78: </FRAMESET>
79: <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5 tyszkabe 80: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_left.html" marginwidth="0" marginheight="0" scrolling="no">
81: <FRAME name="toolbar" src="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" marginwidth="0" marginheight="0" scrolling="no">
82: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_right.html" marginwidth="0" marginheight="0" scrolling="no">
1.4 tyszkabe 83: </FRAMESET>
84: <FRAMESET cols="25, *, 25" frameborder="0" borders="0" framespacing="0">
1.5 tyszkabe 85: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_ll.html" marginwidth="0" marginheight="0" scrolling="no">
86: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_bb.html" marginwidth="0" marginheight="0" scrolling="no">
87: <FRAME src="/res/adm/pages/bookmarkmenu/bookmarkmenu_lr.html" marginwidth="0" marginheight="0" scrolling="no">
1.4 tyszkabe 88: </FRAMESET>
89: </FRAMESET>
90: </html>
1.2 tyszkabe 91: END_HTML
1.1 tyszkabe 92: }
93:
1.5 tyszkabe 94: # ---------------------------------------------------------------Construct Error window
95:
96: sub construct_error {
97: my $error_message=shift;
98: return(<<END_ERROR)
99: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
100: <html>
101: <head>
102: <title>
103: Bookmark Tree Viewer/Editor V3
104: </title>
105: </head>
106: <body bgcolor="#BBBBBB">
107: <table bgcolor="#FFFFFF" width="100%" height="90%" align="center">
108: <td>
109: <i>
110: $error_message
111: </i>
112: </td>
113: </table>
114: <center>
115: <form>
116: <input type=button name="close" value="close window" onClick="javascript:window.close();">
117: </form>
118: </center>
119: </body>
120: </html>
121: END_ERROR
122: }
123:
1.6 tyszkabe 124: # --------------------------------------------Construct toolbar (after saving)
125:
126: sub construct_toolbar {
127: return(<<END_TOOLBAR)
128: <html>
129: <body>
1.7 tyszkabe 130: <div align="bottom">
131: <center>
132: Bookmarks saved.
133: [ <a href="/res/adm/pages/bookmarkmenu/bookmarkmenu_toolbar.html" target="toolbar">Continue</a> ]
134: </center>
135: </div>
1.6 tyszkabe 136: </body>
137: </html>
138: END_TOOLBAR
139: }
140:
1.2 tyszkabe 141: # ----------------------------------------------------------------Main Handler
1.1 tyszkabe 142:
143: sub handler {
1.6 tyszkabe 144: my $r=shift;
145: my %marks;
146: my $save_mark;
147: my $page;
148: $r->content_type('text/html');
149: $r->send_http_header;
1.9 tyszkabe 150: if (exists($ENV{'form.hiddenbookmarks'})) {
151: $marks{'bookmarks'}=$ENV{'form.hiddenbookmarks'};
152: write_bookmarks($marks{'bookmarks'});
153: if ($marks{'bookmarks'} eq 'recover') { #if statement is all debug stuff
1.10 ! tyszkabe 154: my $recover=defaultmarks();
1.9 tyszkabe 155: $r->print("BOOKMARK RECOVERY");
156: write_bookmarks($recover);
157: }
158: $page=construct_toolbar();
1.6 tyszkabe 159: } else {
1.9 tyszkabe 160: %marks=get_bookmarks();
161: if (exists($marks{"con_lost"})) {
162: #$page = construct_editor($marks{'bookmarks'}); # Delete this line and uncomment next
163: # in order to re-enable connection detection
164: $page=construct_error("Connection broken with home server. Please contact your system administrator");
165: } else {
1.10 ! tyszkabe 166: if ($marks{'bookmarks'} eq "") {
! 167: $marks{'bookmarks'}=defaultmarks();
! 168: }
1.9 tyszkabe 169: $page = construct_editor($marks{'bookmarks'});
170: }
1.6 tyszkabe 171: }
172: $r->print($page);
173: return OK;
1.1 tyszkabe 174: }
1.9 tyszkabe 175:
176: ####################################
177: #
178: # The following was used for debugging when the bookmarks get corrupted
179: # ben 10/12/2000
180: sub recovermarks {
181: return(<<END_MARKS);
182: this.bookmarks = new addFolder("Stuff", 6, "bookmarks");
183: this.bookmarks.p[0]=new addLink("MSU Engine3ering", "http://www.egr.msu.edu", "bookmarks", 0);
184: this.bookmarks.p[1]=new addLink("MSU Engine2ering", "http://www.egr.msu.edu/~tyszkabe", "bookmarks", 1);
185: this.bookmarks.p[2]=new addFolder("more crap", 5, "bookmarks.p[2]");
186: this.bookmarks.p[2].p[0]=new addLink("more of a test","http://www.transam.com","bookmarks.p[2]",0);
187: this.bookmarks.p[2].p[1]=new addLink("ALL CAPS PLEASE!","http://www.bullwinkle.com","bookmarks.p[2]",1);
188: this.bookmarks.p[2].p[2]=new addFolder("double nested", 2, "bookmarks.p[2].p[2]");
189: this.bookmarks.p[2].p[2].p[0]=new addLink("Test 12","http://www.jealousy.com","bookmarks.p[2].p[2]",0);
190: this.bookmarks.p[2].p[2].p[1]=new addFolder("empty folder",2,"bookmarks.p[2].p[2].p[1]");
191: this.bookmarks.p[2].p[2].p[1].p[0]=new addLink("bury","http://www.cool.com","bookmarks.p[2].p[2].p[1]",0);
192: this.bookmarks.p[2].p[3]=new addLink("simon and Garfunkle","www.inneptitude.com","bookmarks.p[2]",3);
193: this.bookmarks.p[2].p[4]=new addLink("garbage in garbage out","www.holy.com","bookmarks.p[2]",4);
194: this.bookmarks.p[3]=new addLink("MSU Engin4eering","st4uffcom","bookmarks",3);
195: this.bookmarks.p[4]=new addFolder("more x2",3,"bookmarks.p[4]");
196: this.bookmarks.p[4].p[0]=new addLink("Whack a holy mole","www.whackamole.com","bookmarks.p[4]",0);
197: this.bookmarks.p[4].p[1]=new addLink("molly moldy mole","http://www.molemolemole.com","bookmarks.p[4]",1);
198: this.bookmarks.p[4].p[2]=new addLink("Thou art even more holy","www.holymoly.com","bookmarks.p[4]",2);
199: this.bookmarks.p[5]=new addLink("Google","http://www.google.com/","bookmarks",5);
200: END_MARKS
201: }
202: #
203: #
204: ##########################################
1.10 ! tyszkabe 205:
! 206: ##########################################
! 207: #
! 208: # Here is a listing of default bookmarks. It may be used to replace 'recover'
! 209: # eventually, but for now these will load after all bookmarks have been deleted.
! 210: # ben 10/12/2000
! 211: sub defaultmarks {
! 212: return(<<END_MARKS);
! 213: this.bookmarks=new addFolder("Stuff",6,"bookmarks");
! 214: this.bookmarks.p[0]=new addFolder("Default Bookmarks",6,"bookmarks.p[0]");
! 215: this.bookmarks.p[0].p[0]=new addFolder("Michigan State University",6,"bookmarks.p[0].p[0]");
! 216: this.bookmarks.p[0].p[0].p[0]= new addLink("Main Website","http://www.msu.edu","bookmarks.p[0].p[0]",0);
! 217: this.bookmarks.p[0].p[0].p[1]= new addLink("College of Natural Science","http://www.ns.msu.edu","bookmarks.p[0].p[0]",1);
! 218: this.bookmarks.p[0].p[0].p[2]= new addLink("College of Engineering","http://www.egr.msu.edu","bookmarks.p[0].p[0]",2);
! 219: this.bookmarks.p[0].p[0].p[3]= new addLink("Dept. of Mathematics","http://www.math.msu.edu","bookmarks.p[0].p[0]",3);
! 220: this.bookmarks.p[0].p[0].p[4]= new addLink("Lite Lab","http://www.lite.msu.edu","bookmarks.p[0].p[0]",4);
! 221: this.bookmarks.p[0].p[0].p[5]= new addLink("Physics and Astronomy","http://www.pa.msu.edu","bookmarks.p[0].p[0]",5);
! 222: this.bookmarks.p[0].p[1]= new addFolder("Lon-Capa",6,"bookmarks.p[0].p[1]");
! 223: this.bookmarks.p[0].p[1].p[0]= new addLink("Lon-Capa org","http://lon-capa.org","bookmarks.p[0].p[1]",0);
! 224: this.bookmarks.p[0].p[1].p[1]= new addLink("Lite Lab","http://www.lite.msu.edu","bookmarks.p[0].p[1]",1);
! 225: this.bookmarks.p[0].p[2]= new addLink("Redhat","http://redhat.com","bookmarks.p[0]",2);
! 226: this.bookmarks.p[0].p[3]= new addLink("Debian","http://debian.org","bookmarks.p[0]",3);
! 227: this.bookmarks.p[1]= new addLink("Other Bookmarks","http://kirk.lite.msu.edu","bookmarks",1);
! 228: END_MARKS
! 229: }
1.1 tyszkabe 230:
231: 1;
232: __END__
1.8 tyszkabe 233:
234:
235:
236:
237:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>