From ca6b9f370bbd37b58dbec55c7b369d72a4684918 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 May 2005 06:15:01 +0000 Subject: r7088: start on some real structure for the SWAT web pages - this imports the basic css pages from samba.org - i have created some useful ejs scripts in common.js that will be included by all pages - added a real login page, and a logout button showing who you are logged in as - added page_header() and page_footer() functions that take a page type, allowing for "plain" or "columms" pages - added some simple menus on the left of the columns page type, with links to the esp tests and some useful links for samba4 developers (This used to be commit 86d2ecf0f2a8de8abfdcc5f2aae7d4d969d19339) --- swat/docs/menu.js | 6 ++ swat/esptest/auth.esp | 12 +-- swat/esptest/exception.esp | 13 ++- swat/esptest/formtest.esp | 12 +-- swat/esptest/include.esp | 12 +-- swat/esptest/index.esp | 32 ------- swat/esptest/index.html | 23 ----- swat/esptest/ldb.esp | 31 ++++--- swat/esptest/loadparm.esp | 12 +-- swat/esptest/menu.js | 11 +++ swat/esptest/session.esp | 12 +-- swat/esptest/showvars.esp | 13 ++- swat/images/linkpad.gif | Bin 0 -> 270 bytes swat/index.esp | 27 ++---- swat/login.esp | 29 ++++++ swat/logout.esp | 8 ++ swat/scripting/common.js | 56 ++++++++++++ swat/scripting/footer.esp | 1 + swat/scripting/footer_columns.esp | 7 ++ swat/scripting/footer_plain.esp | 7 ++ swat/scripting/header.esp | 4 + swat/scripting/header_columns.esp | 68 ++++++++++++++ swat/scripting/header_plain.esp | 51 +++++++++++ swat/scripting/preauth.esp | 17 ++++ swat/style/common.css | 185 ++++++++++++++++++++++++++++++++++++++ swat/style/main.css | 107 ++++++++++++++++++++++ 26 files changed, 610 insertions(+), 146 deletions(-) create mode 100644 swat/docs/menu.js delete mode 100644 swat/esptest/index.esp delete mode 100644 swat/esptest/index.html create mode 100644 swat/esptest/menu.js create mode 100755 swat/images/linkpad.gif create mode 100644 swat/login.esp create mode 100644 swat/logout.esp create mode 100644 swat/scripting/common.js create mode 100644 swat/scripting/footer.esp create mode 100644 swat/scripting/footer_columns.esp create mode 100644 swat/scripting/footer_plain.esp create mode 100644 swat/scripting/header.esp create mode 100644 swat/scripting/header_columns.esp create mode 100644 swat/scripting/header_plain.esp create mode 100644 swat/scripting/preauth.esp create mode 100644 swat/style/common.css create mode 100644 swat/style/main.css diff --git a/swat/docs/menu.js b/swat/docs/menu.js new file mode 100644 index 0000000000..eceacf97e0 --- /dev/null +++ b/swat/docs/menu.js @@ -0,0 +1,6 @@ +/* show a menu for the docs directory */ +simple_menu( + "Samba Information", + "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"); diff --git a/swat/esptest/auth.esp b/swat/esptest/auth.esp index ac85ddc026..35953dc7dc 100644 --- a/swat/esptest/auth.esp +++ b/swat/esptest/auth.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP Authentication Test"); %> +

Samba4 unixAuth test

@@ -22,7 +19,7 @@ Samba4 ESP test if (request['REQUEST_METHOD'] == "POST") { /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } username = form['Username']; @@ -48,5 +45,4 @@ write ("
PRIVILEGE = " + session['PRIVILEGE'] + "\n"); %> - - +<% page_footer(); %> diff --git a/swat/esptest/exception.esp b/swat/esptest/exception.esp index d569fbe776..abea890d98 100644 --- a/swat/esptest/exception.esp +++ b/swat/esptest/exception.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP Exception test"); %> +

Samba4 exception test

@@ -15,7 +12,7 @@ Samba4 ESP test if (request['REQUEST_METHOD'] == "POST") { /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } function TestFunction(arg1, arg2) { @@ -33,5 +30,5 @@ if (request['REQUEST_METHOD'] == "POST") { %> and here is some filler text ... - - + +<% page_footer(); %> diff --git a/swat/esptest/formtest.esp b/swat/esptest/formtest.esp index 7996900eb2..89e542c552 100644 --- a/swat/esptest/formtest.esp +++ b/swat/esptest/formtest.esp @@ -1,9 +1,4 @@ - - -Samba4 ESP test - - -

Samba4 form test

+<% page_header("columns", "ESP Form Test"); %> firstName:
@@ -20,7 +15,7 @@ Samba4 ESP test /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } %> You chose firstName=@@form['firstName'] lastName=@@form['lastName'] @@ -37,5 +32,4 @@ Samba4 ESP test } %> - - +<% page_footer(); %> diff --git a/swat/esptest/include.esp b/swat/esptest/include.esp index 9b67a768da..f7fd5e0b91 100644 --- a/swat/esptest/include.esp +++ b/swat/esptest/include.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP Include Test"); %> + including /scripting/test.ejs

<% include("/scripting/test.ejs"); %> calling a function from test.ejs ...

@@ -14,9 +11,8 @@ calling a function from test.esp ...

<% res = testfn('foo'); %> result is: @@res - +

- - +<% page_footer(); %> diff --git a/swat/esptest/index.esp b/swat/esptest/index.esp deleted file mode 100644 index 40f6cbc38b..0000000000 --- a/swat/esptest/index.esp +++ /dev/null @@ -1,32 +0,0 @@ -<% - var tests = new Array("formtest", "showvars", "include", - "session", "loadparm", "exception", - "ldb", "auth"); -%> - - - -Samba4 ESP test - - -Samba -

Samba4 ESP test

- -Please choose one of the following tests: - - -For more information on ejs see http://www.appwebserver.org/products/ejs/ejs.html

- -For more information on esp see http://www.appwebserver.org/products/esp/esp.html

- - - diff --git a/swat/esptest/index.html b/swat/esptest/index.html deleted file mode 100644 index 0c64b4ffcf..0000000000 --- a/swat/esptest/index.html +++ /dev/null @@ -1,23 +0,0 @@ -<% - var tests = new Array("formtest", "showvars", "include"); -%> - - - -Samba4 ESP test - - -Samba -

Samba4 ESP test

- -Please choose one of the following tests: - - - diff --git a/swat/esptest/ldb.esp b/swat/esptest/ldb.esp index 3285574bf2..1bc75bce73 100644 --- a/swat/esptest/ldb.esp +++ b/swat/esptest/ldb.esp @@ -1,19 +1,16 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP ldb test"); %> +

Samba4 ldb test

-
-
+ +
<% if (request['REQUEST_METHOD'] == "POST") { /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } } @@ -27,10 +24,10 @@ function showLdbRes(res) { var a = r[j]; if (typeof(a) == "object") { for (k in a) { - write(j + "[" + k + "]=" + a[k] + "
\n"); + write(j + "[" + k + "]=" + a[k] + "
\n"); } } else { - write(j + "=" + r[j] + "
\n"); + write(j + "=" + r[j] + "
\n"); } } write("

"); @@ -43,7 +40,7 @@ Trying a attribute constrained search on samdb:

<% var dbfile = lpGet("sam database"); -var attrs = new Array("name", "dnsDomain", "objectSid"); +var attrs = new Array("name", "dnsDomain", "objectSid", "dn"); res = ldbSearch(dbfile, "(objectClass=domain)", attrs); showLdbRes(res); @@ -54,10 +51,16 @@ and now an unconstrained search:

<% var dbfile = lpGet("sam database"); -res = ldbSearch(dbfile, "(objectClass=domain)"); +res = ldbSearch(dbfile, "(objectClass=user)"); showLdbRes(res); %> +and a bad search
+ +<% +res = ldbSearch("foo"); +%> + +all done - - +<% page_footer() %> diff --git a/swat/esptest/loadparm.esp b/swat/esptest/loadparm.esp index b9f2c54ec5..0ed69d939a 100644 --- a/swat/esptest/loadparm.esp +++ b/swat/esptest/loadparm.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP loadparm test"); %> +

Samba4 loadparm test

@@ -37,7 +34,7 @@ function showValue(name, v) { if (request['REQUEST_METHOD'] == "POST") { /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } var v; @@ -73,5 +70,4 @@ showParameter("server signing"); showParameter("interfaces"); %> - - +<% page_footer(); %> diff --git a/swat/esptest/menu.js b/swat/esptest/menu.js new file mode 100644 index 0000000000..3b16824fad --- /dev/null +++ b/swat/esptest/menu.js @@ -0,0 +1,11 @@ +/* show a menu for the esp test pages */ +simple_menu( + "ESP Tests", + "ldb database", "/esptest/ldb.esp", + "html forms", "/esptest/formtest.esp", + "esp includes", "/esptest/include.esp", + "session variables", "/esptest/session.esp", + "loadparm access", "/esptest/loadparm.esp", + "exception handling", "/esptest/exception.esp", + ); + diff --git a/swat/esptest/session.esp b/swat/esptest/session.esp index e1d6a6370d..3d787012c6 100644 --- a/swat/esptest/session.esp +++ b/swat/esptest/session.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP session test"); %> +

Samba4 session test

@@ -22,7 +19,7 @@ Samba4 ESP test if (request['REQUEST_METHOD'] == "POST") { /* if they cancelled then take them back to the list of tests */ if (form['submit'] == "Cancel") { - redirect("index.esp"); + redirect("/"); } name = form['Name']; @@ -61,5 +58,4 @@ showArray("session", session); write("SessionId=" + request['SESSION_ID'] + "
\n"); %> - - +<% page_footer(); %> diff --git a/swat/esptest/showvars.esp b/swat/esptest/showvars.esp index 04bfb7b1f6..262a0962b7 100644 --- a/swat/esptest/showvars.esp +++ b/swat/esptest/showvars.esp @@ -1,8 +1,5 @@ - - -Samba4 ESP test - - +<% page_header("columns", "ESP standard variables test"); %> +

Samba4 showvars test

<% @@ -26,10 +23,10 @@ Samba4 ESP test showArray("session", session); %> - +
- - + +<% page_footer(); %> diff --git a/swat/images/linkpad.gif b/swat/images/linkpad.gif new file mode 100755 index 0000000000..613b4f55ef Binary files /dev/null and b/swat/images/linkpad.gif differ diff --git a/swat/index.esp b/swat/index.esp index 373bd9f74e..325deeddae 100644 --- a/swat/index.esp +++ b/swat/index.esp @@ -1,20 +1,7 @@ - - -Samba4 ESP test - - -redirecting you to the test pages ... -<% -if (server['SERVER_PROTOCOL'] == "http" && - server['TLS_SUPPORT'] == "True") { - if (headers['HOST']) { - redirect("https://" + headers['HOST'] + request['REQUEST_URI']); - } else { - redirect("https://" + server['SERVER_NAME'] + ":" + server['SERVER_PORT'] + request['REQUEST_URI']); - } -} else { - redirect("esptest/index.esp"); -} -%> - - +<% page_header("columns", "Welcome to SWAT"); %> + +

Welcome to SWAT!

+ +Please select a menu item from the selection on the left + +<% page_footer(); %> diff --git a/swat/login.esp b/swat/login.esp new file mode 100644 index 0000000000..1dfc1142e6 --- /dev/null +++ b/swat/login.esp @@ -0,0 +1,29 @@ +<% page_header("plain", "SWAT Login"); %> + +
+ Username:
+ Password:
+
+
+
+ +<% + if (request.REQUEST_METHOD == "POST") { + /* for now just authenticate everyone */ + session.AUTHENTICATED = true; + session.authinfo = new Object(); + + session.authinfo.username = form.Username; + + /* if the user was asking for the login page, then now + redirect them to the main page. Otherwise just + redirect them to the current page, which will now + show its true content */ + if (request.REQUEST_URI == "/login.esp") { + redirect("/"); + } else { + redirect(request.REQUEST_URI); + } + } +%> +<% page_footer(); %> diff --git a/swat/logout.esp b/swat/logout.esp new file mode 100644 index 0000000000..b725d63a64 --- /dev/null +++ b/swat/logout.esp @@ -0,0 +1,8 @@ +<% +page_header("plain", "Logging out"); + +session.AUTHENTICATED = false; +redirect("/login.esp"); + +page_footer(); +%> diff --git a/swat/scripting/common.js b/swat/scripting/common.js new file mode 100644 index 0000000000..0691512fb2 --- /dev/null +++ b/swat/scripting/common.js @@ -0,0 +1,56 @@ +/* + js functions and code common to all pages +*/ + +/* define some global variables for this request */ +global.page = new Object(); + +/* fill in some defaults */ +global.page.title = "Samba Web Administration Tool"; + +/* + show the page header. page types include "plain" and "column" +*/ +function page_header(pagetype, title) { + global.page.pagetype = pagetype; + global.page.title = title; + include("/scripting/header_" + pagetype + ".esp"); +} + +/* + show the page footer, getting the page type from page.pagetype + set in page_header() +*/ +function page_footer() { + include("/scripting/footer_" + global.page.pagetype + ".esp"); +} + +/* + check if a uri is one of the 'always allowed' pages, even when not logged in + This allows the login page to use the same style sheets and images +*/ +function always_allowed(uri) { + var allowed = new Array("/images/favicon.ico", + "/images/linkpad.gif", + "/images/logo.png", + "/style/main.css", + "/style/common.css"); + for (i in allowed) { + if (allowed[i] == uri) { + return true; + } + } + return false; +} + +/* + display a simple menu. First argument is menu title, followed by + pairs of menu item name and link +*/ +function simple_menu() { + write("" + arguments[0] + "
\n"); +} diff --git a/swat/scripting/footer.esp b/swat/scripting/footer.esp new file mode 100644 index 0000000000..5f85cabb08 --- /dev/null +++ b/swat/scripting/footer.esp @@ -0,0 +1 @@ + diff --git a/swat/scripting/footer_columns.esp b/swat/scripting/footer_columns.esp new file mode 100644 index 0000000000..29b06a4caa --- /dev/null +++ b/swat/scripting/footer_columns.esp @@ -0,0 +1,7 @@ +<% + /* footer for columns page type */ +%> + + + +<% include("/scripting/footer.esp"); %> diff --git a/swat/scripting/footer_plain.esp b/swat/scripting/footer_plain.esp new file mode 100644 index 0000000000..ea0a3f7816 --- /dev/null +++ b/swat/scripting/footer_plain.esp @@ -0,0 +1,7 @@ +<% + /* footer for plain page type */ +%> + + + +<% include("/scripting/footer.esp"); %> diff --git a/swat/scripting/header.esp b/swat/scripting/header.esp new file mode 100644 index 0000000000..1630b2be04 --- /dev/null +++ b/swat/scripting/header.esp @@ -0,0 +1,4 @@ + + + diff --git a/swat/scripting/header_columns.esp b/swat/scripting/header_columns.esp new file mode 100644 index 0000000000..6122124b05 --- /dev/null +++ b/swat/scripting/header_columns.esp @@ -0,0 +1,68 @@ +<% include("/scripting/header.esp"); %> + +@@global.page.title + + + + + + + + + + + + + + + + + + + + + +
+

Samba Web Administration Tool

+
+ + + + +
+
diff --git a/swat/scripting/header_plain.esp b/swat/scripting/header_plain.esp new file mode 100644 index 0000000000..69bd0cd718 --- /dev/null +++ b/swat/scripting/header_plain.esp @@ -0,0 +1,51 @@ +<% include("/scripting/header.esp"); %> + +@@global.page.title + + + + + + + + + + + + + + + + + + +
+

Samba Web Administration Tool

+
+ +
+
diff --git a/swat/scripting/preauth.esp b/swat/scripting/preauth.esp new file mode 100644 index 0000000000..489f6b5004 --- /dev/null +++ b/swat/scripting/preauth.esp @@ -0,0 +1,17 @@ +<% +include("/scripting/common.js"); + +/* this script is called on every web request. If it produces any + output at all then that output is returned and the requested page + is not given or processed. +*/ +if (server['SERVER_PROTOCOL'] == "http" && + server['TLS_SUPPORT'] == "True") { + write("redirect to https"); + redirect("https://" + headers['HOST'] + request['REQUEST_URI']); +} else if (always_allowed(request['REQUEST_URI']) != true && + session['AUTHENTICATED'] == undefined) { + /* present the login page */ + include("/login.esp"); +} +%> diff --git a/swat/style/common.css b/swat/style/common.css new file mode 100644 index 0000000000..58406ccc40 --- /dev/null +++ b/swat/style/common.css @@ -0,0 +1,185 @@ +/* common.css */ + + /********* Basic elements across the site **********/ + /***************************************************/ + +body { + margin:0; + background-color:#E5E9F5; + font-family:Lucidasans, Helvetica, Verdana, sans-serif; + font-size:medium; + color:#000; +} +h1 { + font-size:x-large; +} +h2 { + text-align:left; + color:#FFFF64; + font-size:large; + background-color:#3878CD; + margin-top:60px; + margin-bottom:15px; + padding:2px; + padding-left:5px; +} +h3 { + font-size:medium; +} +h5 { + font-size:small; + text-align:right; + display:inline; +} +* html h5 { + padding-right:4px; +} +h6 { + font-size:small; + text-align:right; + text-align:right; +} +h6 a { + margin-right:3px; +} +table.real thead { + background-color: #E5E9F5; +} +table.real th, +table.real td { + border: 1px solid #3878CD; + padding: 2px; +} +table.real { + border: 2px solid #3878CD; + background-color: #F5F8FF; +} +a:link:hover { + color:#CC0033; + background-color:#FFFF64; +} +ol li { + margin-bottom:12px; +} +blockquote { + margin:35px; + padding:15px; + border-left:2px groove #CCC; + border-top:2px groove #CCC; +} +img { + border:0; +} +.punch { /*creates a bold typeface */ + font-weight:bold; +} + + /********************* header styles *******************************/ + /******************************************************************/ +#banner { + position:absolute; + top:0; + left:0; + height:90px; + width:100%; + padding-top:4px; + background-color:#FFFF64; +} +.logout { + text-align:right; + +} +.logout form { + display:inline; +} +.stripe { + position:absolute; + top:40px; + left:0; + height:55px; + width:100%; + background-color:#3878CD; + border-top:2px solid #575756; + border-bottom:2px solid #575756; +} +.slogan { + position:absolute; + left:187px; + z-index:1; +} +html>body .slogan { /**** Opera needs its own rule *********/ + top:100px; +} +:root .slogan { /**** Undo the Opera rule for all other browsers ****/ + top:80px; +} +* html .slogan { /** Then, give IE 5/6 its own rule ****** */ + top:100px; +} + + /******** PNG logo with transparency across browsers */ + /******************************************************/ +#logo>.logo_hack { + background-image:url(/images/logo.png); + background-position:center; + background-repeat:no-repeat; +} +.logo_hack { + position:absolute; + top:25px; + left:0; + width:250px; + height:119px; + padding:0; + margin:0; +} +.logo_hack a:hover { + background:transparent; +} + + /******** Main nav menu styles ****************/ + /**********************************************/ +.nav { + position:absolute; + top:152px; + left:20px; + width:180px; + background-color:#F5F8FF; + border:2px groove #3878CD; + padding:0; + padding-bottom:5px; + margin:0; + z-index:1; +} +.nav ul { + list-style-type:none; + text-align:center; + padding:0; + margin:0; +} +.nav a, +.nav a:link, +.nav a:visited { + display:block; + height:20px; + font-size:small; + color:#2B5C9F; +} +.nav a:hover { + color:#FFF; + background-color:#3878CD; +} +.nav a:active { + color:#FFFF64; + background-color:#3878CD; + font-size:14px; +} +.nav img { + padding:0; + margin:0; + width:180px; + height:30px; +} +.colophon { + margin-left:20px; +} diff --git a/swat/style/main.css b/swat/style/main.css new file mode 100644 index 0000000000..15f768d186 --- /dev/null +++ b/swat/style/main.css @@ -0,0 +1,107 @@ +/* main.css */ + + /******* Links for right-hand side of the page ******/ + /****************************************************/ +#links { + float:right; + margin:115px 1em 0 0; + padding:0; + width:173px; +} +* html #links { /* Applies to IE5/6 only */ + margin:115px .5% 0 0; +} +#links h4 { + margin-top:10px; + margin-left:1.5px; + font-size:small; +} +#links ul { + list-style-type:none; + padding:0; + padding-top:5px; + margin-left:20px; +} +#links a { + font-size:small; +} +#links p { + margin-top:25px; + margin-left:20px; +} +.releases { + padding:2px; + margin-top:35px; + border:1px solid #CCC; + background-color:#E5E9F5; +} +.beyond, .related, .intl { + padding:2px; + margin-top:25px; + border:1px solid #CCC; + background-color:#E5E9F5; +} +.beyond li { + margin-bottom:10px; +} +.contacts li{ + list-style-type:disc; +} + /****** Formats the page layout ********************/ + /**************************************************/ +#content>.center { + min-height:800px; + z-index:0; +} +.center { + margin:0 22% 0 175px; + padding-top:130px; + padding-left:35px; + padding-bottom:50px; + padding-right:15px; + background-color:#FFF; + border-left:1px solid #FFFF64; + border-right:1px solid #FFFF64; + z-index:-1; +} +.center ul { + list-style-type:none; +} +.headline { + margin-left:20px; + font-style:italic; +} + /*********T-shirts and mirror footnotes *************/ + /****************************************************/ +.plugs { + font-style:italic; + text-align:center; + border-top:2px groove #3878CD; + border-bottom:2px groove #3878CD; + padding:10px; + margin-top:100px; +} +.plugs p { + padding:30px; +} +.plugs img { + float:left; +} +.request { + margin-top:50px; + font-style:italic; + font-size:small; +} +#noswp img { + border:1px solid #3868CD; + width:370px; + height:90px; +} +#noswp a:hover { + background-color:transparent; +} +#noswp { + width:auto; + text-align:center; + margin:10px 0 25px 0; +} -- cgit