summaryrefslogtreecommitdiff
path: root/swat/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-30 06:15:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:14 -0500
commitca6b9f370bbd37b58dbec55c7b369d72a4684918 (patch)
tree0717452f97a0cb4a556a5c94b13e02949a52e84d /swat/scripting
parentbb2a811bf4c05013aa5b3dbe437d7caf1fea4974 (diff)
downloadsamba-ca6b9f370bbd37b58dbec55c7b369d72a4684918.tar.gz
samba-ca6b9f370bbd37b58dbec55c7b369d72a4684918.tar.bz2
samba-ca6b9f370bbd37b58dbec55c7b369d72a4684918.zip
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)
Diffstat (limited to 'swat/scripting')
-rw-r--r--swat/scripting/common.js56
-rw-r--r--swat/scripting/footer.esp1
-rw-r--r--swat/scripting/footer_columns.esp7
-rw-r--r--swat/scripting/footer_plain.esp7
-rw-r--r--swat/scripting/header.esp4
-rw-r--r--swat/scripting/header_columns.esp68
-rw-r--r--swat/scripting/header_plain.esp51
-rw-r--r--swat/scripting/preauth.esp17
8 files changed, 211 insertions, 0 deletions
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("<i>" + arguments[0] + "</i><br /><ul>\n");
+ for (i = 1; i < arguments.length; i = i + 2) {
+ write("<li><a href=\"" + arguments[i+1] + "\">" + arguments[i] + "</a></li>\n");
+ }
+ write("</ul>\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 @@
+</html>
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 */
+%>
+</div>
+</div>
+</body>
+<% 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 */
+%>
+</div>
+</div>
+</body>
+<% 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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
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"); %>
+
+<title>@@global.page.title</title>
+
+<link rel="stylesheet" href="/style/common.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/main.css" type="text/css" media="all" />
+<link rel="shortcut icon" href="/images/favicon.ico" />
+
+<!--[if gte IE 5.5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/logo.png',sizingMethod='scale');
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+<!--[if lte IE 5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+ background-image:url(/images/logo.gif);
+ background-position:center;
+ background-repeat:no-repeat;
+ top:23.5px;
+ left:-10px;
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Language" content="en-us" />
+
+</head>
+
+
+<body>
+
+<div id="banner">
+ <div class="stripe"></div>
+ <div class="logout">
+ <b>logged in as @@session.authinfo.username</b>
+ <form method="post" action="/logout.esp">
+ <input type="submit" value="Logout" />
+ </form>
+ </div>
+</div>
+
+<div id="logo">
+ <div class="logo_hack"><a href="/"><img src="/images/linkpad.gif" alt="SWAT" /></a></div>
+</div>
+
+<div class="slogan">
+ <h4>Samba Web Administration Tool</h4>
+</div>
+
+<div class="nav">
+ <%
+ include("/docs/menu.js");
+ include("/esptest/menu.js");
+ %>
+</div>
+
+
+<div id="content">
+ <div class="center">
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"); %>
+
+<title>@@global.page.title</title>
+
+<link rel="stylesheet" href="/style/common.css" type="text/css" media="all" />
+<link rel="stylesheet" href="/style/main.css" type="text/css" media="all" />
+<link rel="shortcut icon" href="/images/favicon.ico" />
+
+<!--[if gte IE 5.5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/logo.png',sizingMethod='scale');
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+<!--[if lte IE 5]>
+ <style type="text/css">
+ /*<![CDATA[*/
+ .logo_hack {
+ background-image:url(/images/logo.gif);
+ background-position:center;
+ background-repeat:no-repeat;
+ top:23.5px;
+ left:-10px;
+ }
+ /*]]>*/
+ </style>
+<![endif]-->
+
+</head>
+
+
+<body>
+
+<div id="banner">
+ <div class="stripe"></div>
+</div>
+
+<div id="logo">
+ <div class="logo_hack"><a href="/"><img src="/images/linkpad.gif" alt="SWAT" /></a></div>
+</div>
+
+<div class="slogan">
+ <h4>Samba Web Administration Tool</h4>
+</div>
+
+<div id="content">
+ <div class="center">
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");
+}
+%>