From 43470b5ec3d451aa75acf2cda40cf2dcc019efab Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 31 Dec 2006 20:05:29 +0000 Subject: r20444: WEB Application framework / SWAT. We're now at the stage where the web application framework should build and install automatically. Derrell (This used to be commit 0201baef46c1701007e0a4cdd95edee287939318) --- webapps/images/logo.png | Bin 0 -> 9329 bytes webapps/login.esp | 59 ++++++++ webapps/scripting/common.js | 125 +++++++++++++++++ webapps/scripting/footer_columns.esp | 7 + webapps/scripting/footer_desktop.esp | 6 + webapps/scripting/footer_plain.esp | 7 + webapps/scripting/forms.js | 112 +++++++++++++++ webapps/scripting/header_columns.esp | 81 +++++++++++ webapps/scripting/header_desktop.esp | 20 +++ webapps/scripting/header_plain.esp | 25 ++++ webapps/scripting/preauth.esp | 49 +++++++ webapps/style/columns.css | 73 ++++++++++ webapps/style/common.css | 265 +++++++++++++++++++++++++++++++++++ webapps/style/swat.css | 40 ++++++ webapps/style/wide.css | 113 +++++++++++++++ webapps/swat/Makefile | 6 +- 16 files changed, 985 insertions(+), 3 deletions(-) create mode 100644 webapps/images/logo.png create mode 100644 webapps/login.esp create mode 100644 webapps/scripting/common.js create mode 100644 webapps/scripting/footer_columns.esp create mode 100644 webapps/scripting/footer_desktop.esp create mode 100644 webapps/scripting/footer_plain.esp create mode 100644 webapps/scripting/forms.js create mode 100644 webapps/scripting/header_columns.esp create mode 100644 webapps/scripting/header_desktop.esp create mode 100644 webapps/scripting/header_plain.esp create mode 100644 webapps/scripting/preauth.esp create mode 100644 webapps/style/columns.css create mode 100644 webapps/style/common.css create mode 100644 webapps/style/swat.css create mode 100644 webapps/style/wide.css (limited to 'webapps') diff --git a/webapps/images/logo.png b/webapps/images/logo.png new file mode 100644 index 0000000000..6df4ace659 Binary files /dev/null and b/webapps/images/logo.png differ diff --git a/webapps/login.esp b/webapps/login.esp new file mode 100644 index 0000000000..ffbeee8d5e --- /dev/null +++ b/webapps/login.esp @@ -0,0 +1,59 @@ +<% page_header("plain", "Samba WEB Application Login", ""); + libinclude("auth.js"); + include("/scripting/forms.js"); + +if (request['SESSION_EXPIRED'] == "True") { + write("Your session has expired - please authenticate again
\n"); +} + +var f = FormObj("login", 3, 1); +f.element[0].label = "Username"; +f.element[0].value = form['Username']; +f.element[1].label = "Password"; +f.element[1].value = form['Password']; +f.element[1].type = "password"; +f.element[2].label = "Domain"; +f.element[2].type = "select"; +f.element[2].list = getDomainList(); +f.submit[0] = "Login"; + +f.display(); +%> + +<% + if (request.REQUEST_METHOD == "POST") { + var creds = credentials_init(); + creds.set_username(form.Username); + creds.set_password(form.Password); + creds.set_domain(form.Domain); + creds.set_workstation(request['REMOTE_HOST']); + + auth = userAuth(creds, request['REMOTE_SOCKET_ADDRESS']); + if (auth == undefined) { + write("Invalid login - please try again
\n"); + } else if (auth.result) { + session.AUTHENTICATED = true; + session.authinfo = new Object(); + + session.authinfo.username = auth.username; + session.authinfo.domain = auth.domain; + session.authinfo.credentials = creds; + session.authinfo.session_info = auth.session_info; + + /* 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(session_uri("/")); + } else { + redirect(session_uri(request.REQUEST_URI)); + } + } else if (auth.report == undefined) { + write("Login failed - please try again
\n"); + } else { + write("Login failed: " + auth.report + " - please try again
\n"); + } + } +%> +<% page_footer(); %> diff --git a/webapps/scripting/common.js b/webapps/scripting/common.js new file mode 100644 index 0000000000..523e6fed2f --- /dev/null +++ b/webapps/scripting/common.js @@ -0,0 +1,125 @@ +/* + js functions and code common to static pages +*/ + +/* define some global variables for this request */ +global.page = new Object(); + +/* fill in some defaults */ +global.page.title = "Samba Web Administration Tool"; + +libinclude("base.js"); + +/* to cope with browsers that don't support cookies we append the sessionid + to the URI */ +global.SESSIONURI = ""; +if (request['COOKIE_SUPPORT'] != "True") { + global.SESSIONURI="?SwatSessionId=" + request['SESSION_ID']; +} + +/* + possibly adjust a local URI to have the session id appended + used for browsers that don't support cookies +*/ +function session_uri(uri) { + return uri + global.SESSIONURI; +} + +/* + like printf, but to the web page +*/ +function writef() +{ + write(vsprintf(arguments)); +} + +/* + like writef with a
+*/ +function writefln() +{ + write(vsprintf(arguments)); + write("
\n"); +} + + +/* if the browser was too dumb to set the HOST header, then + set it now */ +if (headers['HOST'] == undefined) { + headers['HOST'] = server['SERVER_HOST'] + ":" + server['SERVER_PORT']; +} + +/* + show the page header. page types include "plain" and "column" +*/ +function page_header(pagetype, title, menu) { + global.page.pagetype = pagetype; + global.page.title = title; + global.page.menu = menu; + 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"); +} + + +/* + display a table element +*/ +function table_element(i, o) { + write("" + i + ""); + if (typeof(o[i]) == "object") { + var j, first; + first = true; + for (j in o[i]) { + if (first == false) { + write("
"); + } + write(o[i][j]); + first = false; + } + } else { + write(o[i]); + } + write("\n"); +} + +/* + display a ejs object as a table. The header is optional +*/ +function simple_table(v) { + if (v.length == 0) { + return; + } + write("\n"); + var r; + for (r in v) { + table_element(r, v); + } + write("
\n"); +} + +/* + display an array of objects, with the header for each element from the given + attribute +*/ +function multi_table(array, header) { + var i, n; + write("\n"); + for (i=0;i\n"); + for (r in v) { + if (r != header) { + table_element(r, v); + } + } + } + write("
' + v[header] + "
\n"); +} + diff --git a/webapps/scripting/footer_columns.esp b/webapps/scripting/footer_columns.esp new file mode 100644 index 0000000000..7b5baaf0c8 --- /dev/null +++ b/webapps/scripting/footer_columns.esp @@ -0,0 +1,7 @@ +<% + /* footer for columns page type */ +%> + + + + diff --git a/webapps/scripting/footer_desktop.esp b/webapps/scripting/footer_desktop.esp new file mode 100644 index 0000000000..5e563dab88 --- /dev/null +++ b/webapps/scripting/footer_desktop.esp @@ -0,0 +1,6 @@ +<% + /* footer for desktop page type */ +%> + + + diff --git a/webapps/scripting/footer_plain.esp b/webapps/scripting/footer_plain.esp new file mode 100644 index 0000000000..31ef8dd4ee --- /dev/null +++ b/webapps/scripting/footer_plain.esp @@ -0,0 +1,7 @@ +<% + /* footer for plain page type */ +%> + + + + diff --git a/webapps/scripting/forms.js b/webapps/scripting/forms.js new file mode 100644 index 0000000000..2de9e34462 --- /dev/null +++ b/webapps/scripting/forms.js @@ -0,0 +1,112 @@ +/* + js functions for forms +*/ + + +/* + display a simple form from a ejs Form object + caller should fill in + f.name = form name + f.action = action to be taken on submit (optional, defaults to current page) + f.class = css class (optional, defaults to 'form') + f.submit = an array of submit labels + f.add(name, label, [type], [value]) = + Add another element + f.element[i].label = element label + f.element[i].name = element name (defaults to label) + f.element[i].type = element type (defaults to text) + f.element[i].value = current value (optional, defaults to "") + */ +function form_display() { + var f = this; + var i, size = 20; + write('
\n'); + if (f.element.length > 0) { + write("\n"); + } + for (i in f.element) { + var e = f.element[i]; + if (e.name == undefined) { + e.name = e.label; + } + if (e.value == undefined) { + e.value = ""; + } + if (strlen(e.value) > size) { + size = strlen(e.value) + 4; + } + } + for (i in f.element) { + var e = f.element[i]; + write(""); + write(""); + if (e.type == "select") { + write('\n'); + } else { + var sizestr = ""; + if (e.type == "text" || e.type == "password") { + sizestr = sprintf('size="%d"', size); + } + writef('\n', + e.name, e.type, e.value, sizestr); + } + write(""); + } + if (f.element.length > 0) { + write("
" + e.label + "
\n"); + } + for (i in f.submit) { + write('\n'); + } + write("
\n"); +} + +function __addMethod(name, label) +{ + var f = this; + var i = f.element.length; + f.element[i] = new Object(); + f.element[i].name = name; + f.element[i].label = label; + f.element[i].type = "text"; + f.element[i].value = ""; + if (arguments.length > 2) { + f.element[i].type = arguments[2]; + } + if (arguments.length > 3) { + f.element[i].value = arguments[3]; + } +} + +/* + create a Form object with the defaults filled in, ready for display() + */ +function FormObj(name, num_elements, num_submits) +{ + var f = new Object(); + f.name = name; + f.element = new Array(num_elements); + f.submit = new Array(num_submits); + f.action = session_uri(request.REQUEST_URI); + f.class = "defaultform"; + f.add = __addMethod; + for (i in f.element) { + f.element[i] = new Object(); + f.element[i].type = "text"; + f.element[i].value = ""; + } + f.display = form_display; + + return f; +} + diff --git a/webapps/scripting/header_columns.esp b/webapps/scripting/header_columns.esp new file mode 100644 index 0000000000..a8ffed984e --- /dev/null +++ b/webapps/scripting/header_columns.esp @@ -0,0 +1,81 @@ + + + + + @@global.page.title + + + + + + + + + + + + + + + + + + + + + +
+

Samba Web Administration Tool

+
+ + + + + + +
+
diff --git a/webapps/scripting/header_desktop.esp b/webapps/scripting/header_desktop.esp new file mode 100644 index 0000000000..cf8268f535 --- /dev/null +++ b/webapps/scripting/header_desktop.esp @@ -0,0 +1,20 @@ + + + + + + + + @@global.page.title + + + + + + + diff --git a/webapps/scripting/header_plain.esp b/webapps/scripting/header_plain.esp new file mode 100644 index 0000000000..ae11b6fc50 --- /dev/null +++ b/webapps/scripting/header_plain.esp @@ -0,0 +1,25 @@ + + + + + @@global.page.title + + + + + + + + + + + +
+

Samba Web Administration Tool

+
+ +
+
diff --git a/webapps/scripting/preauth.esp b/webapps/scripting/preauth.esp new file mode 100644 index 0000000000..84534cacef --- /dev/null +++ b/webapps/scripting/preauth.esp @@ -0,0 +1,49 @@ +<% +include("/scripting/common.js"); + +/* + 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 str = string_init(); + + /* allow the primary web application to do its own authentication */ + var s = str.split('/', uri); + if (s[0] == "" && (s.length == 1 || /* no path provided */ + s[1] == 'index.html' || + s[1] == "script" || + s[1] == "resource")) { + return true; + } + + var s = str.split('.', uri); + if (s.length < 2) { + return false; + } + + var ext = s[s.length-1]; + var allowed = new Array("ico", "gif", "png","css", "js"); + for (i in allowed) { + if (allowed[i] == ext) { + return true; + } + } + return false; +} + + +/* 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/webapps/style/columns.css b/webapps/style/columns.css new file mode 100644 index 0000000000..e78da9b3d7 --- /dev/null +++ b/webapps/style/columns.css @@ -0,0 +1,73 @@ +/* + columns.css + Copyright (C) 2004-2005 Deryck Hodge + + Creates a puesdo-three-column view. + + You may freely use and modify the styles here, but if you + intend to recreate the samba.org look exactly, please ask + permission first. +*/ + + +/* Middle content column +***********************************************************/ +#content { + position:absolute; + top:100px; + margin:0 20% 0 175px; + padding-top:30px; + padding-left:35px; + padding-bottom:50px; + padding-right:15px; + background-color:#FFF; + border-left:1px solid #FFFF64; + border-right:1px solid #FFFF64; +} +* html #content { + width:51%; + margin-right:0; +} +#content ul { + list-style-type:none; +} + + +/* Misc +************************************************************/ +.headline { + margin-left:20px; + font-style:italic; +} +.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; +} diff --git a/webapps/style/common.css b/webapps/style/common.css new file mode 100644 index 0000000000..614beaaa8e --- /dev/null +++ b/webapps/style/common.css @@ -0,0 +1,265 @@ +/* + common.css + Copyright (C) 2004-2005 Deryck Hodge + + Basic styles common to all of samba.org, including VirtualHosts + bugzilla.samba.org, build.samba.org, and news.samba.org. + + You may freely use and modify the styles here, but if you + intend to recreate the samba.org look exactly, please ask + permission first. +*/ + + +/* Base elements +***********************************************************/ +body { + margin:0; + padding:0; + background-color:#E5E9F5; + font-family:Lucidasans, Helvetica, Verdana, sans-serif; + font-size:medium; + color:#000; +} +body#news { + background:none; + background-color:#FFF; +} +blockquote { + margin:35px; + padding:15px; + border-left:2px groove #CCC; + border-top:2px groove #CCC; +} +img { + border:0; +} + + + +/* Headings +***********************************************************/ +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; +} + + +/* Lists +***********************************************************/ +ol li { + margin-bottom:12px; +} + + +/* Tables +***********************************************************/ +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; +} + + +/* Header +***********************************************************/ +#banner { + position:absolute; + top:0; + left:0; + height:95px; + width:100%; + padding-top:4px; + z-index:1; +} +.srch { + text-align:right; + margin:0 5px 0 0; +} +.srch form { + display:inline; +} + + +/* Slogan ("Opening windows to a wider world") +***********************************************************/ +.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; +} + + +/* Logo (with hacks for PNG 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; + z-index:1; +} +.logo_hack a:hover { + background:transparent; +} + + +/* Nav menu +***********************************************************/ +#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; +} + + +/* links menu +***********************************************************/ +#links { + position:absolute; + top:152px; + left:81%; + width:180px; + padding:0; + width:18%; + background-color:#F5F8FF; + border:2px groove #3878CD; + padding:0; + padding-bottom:5px; + margin:0; + z-index:1; +} +#links ul { + list-style-type:none; + text-align:center; + padding:0; + margin:0; +} +#links a, +#links a:link, +#links a:visited { + display:block; + height:20px; + font-size:small; + color:#2B5C9F; +} +#links a:hover { + color:#FFF; + background-color:#3878CD; +} +#links a:active { + color:#FFFF64; + background-color:#3878CD; + font-size:14px; +} +#links img { + padding:0; + margin:0; + width:180px; + height:30px; +} + + +/* Text and alignment formats +***********************************************************/ +.punch { + font-weight:bold; +} +.tilt { + font-style:italic; +} +.colophon { + margin-left:20px; +} diff --git a/webapps/style/swat.css b/webapps/style/swat.css new file mode 100644 index 0000000000..c41e4eaf10 --- /dev/null +++ b/webapps/style/swat.css @@ -0,0 +1,40 @@ +/* + swat.css + + Styles added to the samba.org stylesheets + specifically for SWAT. +*/ + + +/* Forms +***********************************************************/ +.logout { + text-align:right; +} +.logout form { + display:inline; +} + + +/* Tables +***********************************************************/ +table.data { + border: 2px; +} +table.data th { + margin-top:20px; + text-align:left; + background-color: #F5C915; +} +table.data tr { + background-color: #E5C995; + text-align:left; +} + +/* Temp fix for content sections that don't span the window. + This is not cross-browser and won't be the final way I handle + this, but I can't stand looking at small boxes while I work. :-) */ +#content { + min-width:55%; + min-height:800px; +} diff --git a/webapps/style/wide.css b/webapps/style/wide.css new file mode 100644 index 0000000000..0107b33698 --- /dev/null +++ b/webapps/style/wide.css @@ -0,0 +1,113 @@ +/* + wide.css + Copyright (C) 2004-2005 Deryck Hodge + + An alternate two-column "wide" style for those pages + with lots and lots of text (download, devel, etc.) + + You may freely use and modify the styles here, but if you + intend to recreate the samba.org look exactly, please ask + permission first. +*/ + + +/* Primary content section +***********************************************************/ +#content { + position:absolute; + top:100px; + clear:left; + margin:0 1% 0 175px; + padding-top:30px; + padding-left:35px; + padding-bottom:50px; + padding-right:15px; + background-color:#FFF; + border-left:1px solid #FFFF64; + border-right:1px solid #FFFF64; +} +* html #content { + width:70%; +} +#content h4 { + font-weight:bold; + margin:50px 10px 15px 0; +} +pre { + margin:15px 0 30px 5px; +} + + +/* Team section +***********************************************************/ +.teampic { + text-align:center; +} +.teampic img { + width:431px; + height:300px; +} + + +/* Release history/Release notes +***********************************************************/ +.notes { + position:absolute; + top:265px; + left:0; +} +.notes h6 { + text-align:left; + margin:10px 5px; +} +.notes ul { + list-style-type:none; + text-align:left; + padding-left:12px; + margin:0 0 0 10px; + font-size:10px; +} +.intro { + margin-top:30px; +} +.headline { + margin-left:20px; + font-style:italic; +} +.latest ul { + list-style-type:none; + margin-left:40px; +} + + +/* Support providers pages +***********************************************************/ +#countries { + float:left; + margin:240px 0 0 5px; + padding:0; + background-color:#E5E9F5; +} +#countries ul { + list-style-type:none; +} +#countries a { + font-size:small; +} +#countries h4 { + margin-top:10px; + margin-left:1px; + font-size:small; +} +.disclaimer { + margin:30px; + font-style:italic; +} +.info { + margin:75px 15px 15px 15px; + padding:10px; + font-size:small; + border-top:1px dotted #3878CD; + border-bottom:1px dotted #3878CD; +} + diff --git a/webapps/swat/Makefile b/webapps/swat/Makefile index aa17420c73..bf8af850ff 100644 --- a/webapps/swat/Makefile +++ b/webapps/swat/Makefile @@ -227,16 +227,16 @@ fix-build-rights: info-build: @echo "****************************************************************************" - @echo " GENERATING SWAT BUILD" + @echo " GENERATING SWAT WEB APPLICATION BUILD" @echo "****************************************************************************" info-source: @echo "****************************************************************************" - @echo " GENERATING SWAT SOURCE" + @echo " GENERATING SWAT WEB APPLICATION SOURCE" @echo "****************************************************************************" ################################################################################### -# INSTALL TARGETS +# INSTALL TARGETS (for developer use only) ################################################################################### install: -- cgit