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/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 ++++++++++ 8 files changed, 211 insertions(+) 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 (limited to 'swat/scripting') 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"); +} +%> -- cgit