r8722: make the menu handling considerably saner and easier to follow. The whole
authorAndrew Tridgell <tridge@samba.org>
Sat, 23 Jul 2005 10:58:09 +0000 (10:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:29:59 +0000 (13:29 -0500)
menu hierarchy is now in /menu.js
(This used to be commit c2a450bb9967caa666628f067a8e732227854ce2)

28 files changed:
swat/cldap_server/index.esp
swat/docs/menu.js [deleted file]
swat/esptest/exception.esp
swat/esptest/formtest.esp
swat/esptest/include.esp
swat/esptest/index.esp
swat/esptest/ldb.esp
swat/esptest/loadparm.esp
swat/esptest/menu.js [deleted file]
swat/esptest/samr.esp
swat/esptest/session.esp
swat/esptest/showvars.esp
swat/index.esp
swat/install/index.esp
swat/install/menu.js [deleted file]
swat/install/newuser.esp
swat/install/provision.esp
swat/kdc_server/index.esp
swat/ldap_server/index.esp
swat/menu.js
swat/nbt_server/index.esp
swat/nbt_server/menu.js [deleted file]
swat/rpc_server/index.esp
swat/scripting/common.js
swat/scripting/header_columns.esp
swat/scripting/menus.js [new file with mode: 0644]
swat/smb_server/index.esp
swat/wins_server/index.esp

index 253effd55a81b4ae83d4fc32f2f0e6ea44dfa1aa..1ede0887054b4f708817924965e857a169d70372 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "CLDAP Server", ""); 
+<% page_header("columns", "CLDAP Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
diff --git a/swat/docs/menu.js b/swat/docs/menu.js
deleted file mode 100644 (file)
index 82ab02a..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* show a menu for the docs directory */
-var m = MenuObj("Samba Information", 9);
-
-m.element[0].label = "Samba4 development";
-m.element[0].link  = "http://devel.samba.org/";
-m.element[1].label = "Recent Checkins";
-m.element[1].link  = "http://build.samba.org/?tree=samba4;function=Recent+Checkins";
-m.element[2].label = "Recent Builds";
-m.element[2].link  = "http://build.samba.org/?tree=samba4;function=Recent+Builds";
-m.element[3].label = "EJS Information";
-m.element[3].link  = "http://www.appwebserver.org/products/ejs/ejs.html";
-m.element[4].label = "ESP Information";
-m.element[4].link  = "http://www.appwebserver.org/products/esp/esp.html";
-m.element[5].label = "XHTML Spec";
-m.element[5].link  = "http://www.w3.org/TR/xhtml1/";
-m.element[6].label = "JavaScript Spec";
-m.element[6].link  = "http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf";
-m.element[7].label = "CSS Specs";
-m.element[7].link = "http://www.w3.org/Style/CSS/#specs";
-m.element[8].label = "CSS1/2 Reference";
-m.element[8].link  = "http://www.w3schools.com/css/css_reference.asp";
-
-display_menu(m);
-
index f32aaeb610e38a66e3a09bbcc3a5220911f3f78d..ff28d6318e776241e0687d2b0572c834d6855628 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP Exception test", "/esptest/menu.js"); 
+<% page_header("columns", "ESP Exception test", "esptest"); 
    include("/scripting/forms.js");
 %>
 
    include("/scripting/forms.js");
 %>
 
index 32ad4a04b20ba315785fbed110dceb3c5c8ced64..23108498954b0f03ff46a866ad1290d3925f5374 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP Form Test", "/esptest/menu.js"); 
+<% page_header("columns", "ESP Form Test", "esptest"); 
    include("/scripting/forms.js");
 %>
 
    include("/scripting/forms.js");
 %>
 
index fc53a9b1f485af5a6b3bfbd9f47fc9336f415750..5d558d59dcebe0ff26f1d3565378279b8e8739fd 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP Include Test", "/esptest/menu.js"); %>
+<% page_header("columns", "ESP Include Test", "esptest"); %>
 
 including /scripting/test.ejs<p/>
 <% include("/scripting/test.ejs"); %>
 
 including /scripting/test.ejs<p/>
 <% include("/scripting/test.ejs"); %>
index fbbed9b3c46cb4c449efdc3d03e27a6cb1ea9666..663f82c5990ad5999fc56b5aca976f5abd27924c 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP Tests", "/esptest/menu.js"); %>
+<% page_header("columns", "ESP Tests", "esptest"); %>
 
 <h1>ESP Test functions</h1>
 
 
 <h1>ESP Test functions</h1>
 
index 1b1e7cd669b807bdfdd2025607b783a0e045d463..93bc9e0d810cb56c5235bc19759f3eb6879f6f96 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP ldb test", "/esptest/menu.js"); %>
+<% page_header("columns", "ESP ldb test", "esptest"); %>
 
 <h1>Samba4 ldb test</h1>
 
 
 <h1>Samba4 ldb test</h1>
 
index 2783c8e647413e567f2482f0b1d6457b5d6de880..9581af0262bcd9aca6bc7eb8d63ce2f0b37bdac8 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP loadparm test", "/esptest/menu.js" ); 
+<% page_header("columns", "ESP loadparm test", "esptest" ); 
    include("/scripting/forms.js");
 %>
 
    include("/scripting/forms.js");
 %>
 
diff --git a/swat/esptest/menu.js b/swat/esptest/menu.js
deleted file mode 100644 (file)
index d46561f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* show a menu for the esp test pages */
-simple_menu(
-       "ESP Tests",
-       "ldb database",       session_uri("/esptest/ldb.esp"),
-       "samr calls",         session_uri("/esptest/samr.esp"),
-       "html forms",         session_uri("/esptest/formtest.esp"),
-       "esp includes",       session_uri("/esptest/include.esp"),
-       "session variables",  session_uri("/esptest/session.esp"),
-       "loadparm access",    session_uri("/esptest/loadparm.esp"),
-       "exception handling", session_uri("/esptest/exception.esp"),
-       "environment variables",  session_uri("/esptest/showvars.esp"));
-
index 53e20a23ab9602a16d72370093560abd1077dccd..65902e0ce41403af01abe1897d127d8657e9f778 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP samr test", "/esptest/menu.js"); 
+<% page_header("columns", "ESP samr test", "esptest"); 
 
   libinclude("base.js");
   libinclude("samr.js");
 
   libinclude("base.js");
   libinclude("samr.js");
index 6637c782c0854747655af9e75537518ba5502c29..6213dde62f2c2324f3305f824911a3274b5ef853 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP session test", "/esptest/menu.js"); 
+<% page_header("columns", "ESP session test", "esptest"); 
    include("/scripting/forms.js");
 %>
 
    include("/scripting/forms.js");
 %>
 
index 6763f2b6ddece0fe2b33642ec3b92e20773ff463..dc55b1e58bb12437962183520ab789db7c26bc16 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "ESP standard variables test", "/esptest/menu.js"); %>
+<% page_header("columns", "ESP standard variables test", "esptest"); %>
 
 <h1>Samba4 showvars test</h1>
 
 
 <h1>Samba4 showvars test</h1>
 
index 2e43d3f9cfcf52c5a2bf9ab28a31aa3af0c0641d..566c7f8faefa08c08a7bee6db2269ae6b70abaa8 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "Server Status", "");
+<% page_header("columns", "Server Status", "main");
   libinclude("base.js");
   libinclude("management.js");
   libinclude("provision.js");
   libinclude("base.js");
   libinclude("management.js");
   libinclude("provision.js");
index ee16bec34a18e6bdd79919575203eb96c71cd6f4..6e35a98fd4b4b378c7aa4d3ce9bcb8ab53dd7d75 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "Server Installation", "/install/menu.js"); 
+<% page_header("columns", "Server Installation", "install"); 
 %>
 
 <h1>Installation</h1>
 %>
 
 <h1>Installation</h1>
diff --git a/swat/install/menu.js b/swat/install/menu.js
deleted file mode 100644 (file)
index e8f99f7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/* show a menu for the esp test pages */
-simple_menu(
-       "Installation",
-       "Provisioning",       session_uri("/install/provision.esp"),
-       "New User",           session_uri("/install/newuser.esp"));
index afcd9e4d55b210b636597f4dbbf388f2152478cf..9baba7c6f4a518184a435323455fe3175ccc1637 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "Add a user", "/install/menu.js"); 
+<% page_header("columns", "Add a user", "install"); 
 
   include("/scripting/forms.js");
   libinclude("base.js");
 
   include("/scripting/forms.js");
   libinclude("base.js");
index 12e378475a6341f095759cdf96610b5da7d8600a..d941fa0e61fc1aafcac8a0e0801c92f76a25cb3d 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "Provisioning", "/install/menu.js"); 
+<% page_header("columns", "Provisioning", "install"); 
 
   include("/scripting/forms.js");
   libinclude("base.js");
 
   include("/scripting/forms.js");
   libinclude("base.js");
index ed70f7ff46ad8df5988a2becde77b4933da2719c..69a8b0736bf0bc6a45762d70c44e8bcdc8b56873 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "Kerberos Server", ""); 
+<% page_header("columns", "Kerberos Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
index 57f259c3b6e49c040b60acfcd77537c02209c1e2..c4ed146b187bcf7041fd7411eefd3d97bb9ea010 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "LDAP Server", ""); 
+<% page_header("columns", "LDAP Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
index 3f926dc7a2ed620dd866bc0a33aab685fe883db8..17a2952e04da851566479737e728befaf83d01c4 100644 (file)
@@ -1,12 +1,59 @@
-/* show a menu for the esp test pages */
-simple_menu(
+/*
+  the menu hierarchy for SWAT
+*/
+
+include("/scripting/menus.js");
+
+swat_menus = new Object();
+
+swat_menus.main = simple_menu(
        "Main Menu",
        "Main Menu",
-       "File Server",        session_uri("/smb_server/"),
+       "Servers",            session_uri("/?menu=servers"),
+       "Installation",       session_uri("/install/"),
+       "ESP Tests",          session_uri("/esptest/"));
+
+swat_menus.servers = simple_menu(
+       "Servers",
        "LDAP Server",        session_uri("/ldap_server/"),
        "CLDAP Server",       session_uri("/cldap_server/"),
        "RPC Server",         session_uri("/rpc_server/"),
        "NBT Server",         session_uri("/nbt_server/"),
        "WINS Server",        session_uri("/wins_server/"),
        "LDAP Server",        session_uri("/ldap_server/"),
        "CLDAP Server",       session_uri("/cldap_server/"),
        "RPC Server",         session_uri("/rpc_server/"),
        "NBT Server",         session_uri("/nbt_server/"),
        "WINS Server",        session_uri("/wins_server/"),
-       "Kerberos Server",    session_uri("/kdc_server/"),
-       "Installation",       session_uri("/install/"),
-       "ESP Tests",          session_uri("/esptest/"));
+       "Kerberos Server",    session_uri("/kdc_server/"));
+
+swat_menus.esptests = simple_menu(
+       "ESP Tests",
+       "ldb database",          session_uri("/esptest/ldb.esp"),
+       "samr calls",            session_uri("/esptest/samr.esp"),
+       "html forms",            session_uri("/esptest/formtest.esp"),
+       "esp includes",          session_uri("/esptest/include.esp"),
+       "session variables",     session_uri("/esptest/session.esp"),
+       "loadparm access",       session_uri("/esptest/loadparm.esp"),
+       "exception handling",    session_uri("/esptest/exception.esp"),
+       "environment variables", session_uri("/esptest/showvars.esp"));
+
+
+swat_menus.install = simple_menu(
+       "Installation",
+       "Provisioning",       session_uri("/install/provision.esp"),
+       "New User",           session_uri("/install/newuser.esp"));
+
+
+swat_menus.nbt_server = simple_menu(
+       "NBT Server",
+       "Statistics",          session_uri("/nbt_server/index.esp"));
+
+
+swat_menus.docs = simple_menu(
+       "Links",
+       "Samba4 development", "http://devel.samba.org/",
+       "Recent Checkins", "http://build.samba.org/?tree=samba4;function=Recent+Checkins",
+       "Recent Builds", "http://build.samba.org/?tree=samba4;function=Recent+Builds",
+       "EJS Information", "http://www.appwebserver.org/products/ejs/ejs.html",
+       "ESP Information", "http://www.appwebserver.org/products/esp/esp.html",
+       "XHTML Spec", "http://www.w3.org/TR/xhtml1/",
+       "JavaScript Spec", "http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf",
+       "CSS Specs", "http://www.w3.org/Style/CSS/#specs",
+       "CSS1/2 Reference", "http://www.w3schools.com/css/css_reference.asp");
+
+
index 133615c52cdce68a34413a26c16545d1ced8fe3c..1928f12d1b40f4bce4c37312b83c9cb2ad4a3cc8 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "NBT Server", "/nbt_server/menu.js"); 
+<% page_header("columns", "NBT Server", "nbt_server"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
diff --git a/swat/nbt_server/menu.js b/swat/nbt_server/menu.js
deleted file mode 100644 (file)
index fd445bf..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/* show a menu for the esp test pages */
-simple_menu(
-       "NBT Server",
-       "Statistics",          session_uri("/nbt_server/index.esp"));
index 5c429077836be1847dc76a85ca62bff824f541fb..46c8c8a7a77acb34372345132cf178f4f4242e6f 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "RPC Server", ""); 
+<% page_header("columns", "RPC Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
index 84a142160331a2a8701ed8a941d6e6b963dfe306..dde40c8e38a469032248b7d79c3c3ec4980c189b 100644 (file)
@@ -88,48 +88,6 @@ function always_allowed(uri) {
        return false;
 }
 
        return false;
 }
 
-/*
-  create a menu object with the defaults filled in, ready for display_menu()
- */
-function MenuObj(name, num_elements)
-{
-       var o = new Object();
-       o.name = name;
-       o.class = "menu";
-       o.style = "simple";
-       o.orientation = "vertical"
-       o.element = new Array(num_elements);
-       for (i in o.element) {
-               o.element[i] = new Object();
-       }
-       return o;
-}
-
-/*
-  display a menu object. Currently only the "simple", "vertical" menu style
-  is supported
-*/
-function display_menu(m) {
-       assert(m.style == "simple" && m.orientation == "vertical");
-       write('<div class="' + m.class + '">\n');
-       write("<i>" + m.name + "</i><br /><ul>\n");
-       for (i = 0; i < m.element.length; i++) {
-               var e = m.element[i];
-               write("<li><a href=\"" + e.link + "\">" + e.label + "</a></li>\n");
-       }
-       write("</ul></div>\n");
-}
-
-function simple_menu() {
-       var i, m = MenuObj(arguments[0], (arguments.length-1)/2);
-       for (i=0;i<m.element.length;i++) {
-               var ndx = i*2;
-               m.element[i].label = arguments[ndx+1];
-               m.element[i].link = arguments[ndx+2];
-       }
-       display_menu(m);
-}
-
 /*
   display a table element
 */
 /*
   display a table element
 */
index 0320e6628341a5dcaccde08c7724863e67257fff..20238b588eb8ad20a8c7118577ae9119e7037edd 100644 (file)
@@ -62,20 +62,20 @@ filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/logo.png'
 
 <div id="nav">
      <% 
 
 <div id="nav">
      <% 
-     if (global.page.menu) {
-          include(global.page.menu);
-         write('<a href="/">Main Menu</a>');
-     } else {
-         include("/menu.js");
-     }
+       include("/menu.js");
+        if (form['menu']) {
+               global.page.menu = form['menu'];
+       }
+        swat_menus[global.page.menu].display();
+        if (global.page.menu != "main") {
+               write('<a href="/">Main Menu</a>');
+       }
      %>
 </div>
 
 <div id="links">
   <div class="related">
      %>
 </div>
 
 <div id="links">
   <div class="related">
-     <% 
-     include("/docs/menu.js"); 
-     %>
+     <% swat_menus.docs.display(); %>
   </div>
 </div>
 
   </div>
 </div>
 
diff --git a/swat/scripting/menus.js b/swat/scripting/menus.js
new file mode 100644 (file)
index 0000000..ddd97c4
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+       menu object for SWAT
+*/
+
+/*
+  display a menu object. Currently only the "simple", "vertical" menu style
+  is supported
+*/
+function menu_display() {
+       var i, m = this;
+       assert(m.style == "simple" && m.orientation == "vertical");
+       write('<div class="' + m.class + '">\n');
+       write("<i>" + m.name + "</i><br /><ul>\n");
+       for (i = 0; i < m.element.length; i++) {
+               var e = m.element[i];
+               write("<li><a href=\"" + e.link + "\">" + e.label + "</a></li>\n");
+       }
+       write("</ul></div>\n");
+}
+
+
+/*
+  create a menu object with the defaults filled in, ready for display_menu()
+ */
+function MenuObj(name, num_elements)
+{
+       var i, o = new Object();
+       o.name = name;
+       o.class = "menu";
+       o.style = "simple";
+       o.orientation = "vertical"
+       o.element = new Array(num_elements);
+       for (i in o.element) {
+               o.element[i] = new Object();
+       }
+       o.display = menu_display;
+       return o;
+}
+
+/*
+  return a menu object created using a title, followed by
+  a set of label/link pairs
+*/
+function simple_menu() {
+       var i, m = MenuObj(arguments[0], (arguments.length-1)/2);
+       for (i=0;i<m.element.length;i++) {
+               var ndx = i*2;
+               m.element[i].label = arguments[ndx+1];
+               m.element[i].link = arguments[ndx+2];
+       }
+       return m;
+}
+
index 8ca34e3dc3f388f1147fe5f78c29b9e329fa5b25..f0f46204920923231b3bf11b92e2527aa14349e1 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "SMB Server", ""); 
+<% page_header("columns", "SMB Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");
index d24fa3410dfe2618aff3086c76a28f6afe4a54de..b91ef6fc244cd2d059c8f8238187cffc3149b4eb 100644 (file)
@@ -1,4 +1,4 @@
-<% page_header("columns", "WINS Server", ""); 
+<% page_header("columns", "WINS Server", "servers"); 
 
   libinclude("base.js");
   libinclude("management.js");
 
   libinclude("base.js");
   libinclude("management.js");