1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

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)
This commit is contained in:
Andrew Tridgell 2005-05-30 06:15:01 +00:00 committed by Gerald (Jerry) Carter
parent bb2a811bf4
commit ca6b9f370b
26 changed files with 610 additions and 146 deletions

6
swat/docs/menu.js Normal file
View File

@ -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");

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP Authentication Test"); %>
<h1>Samba4 unixAuth test</h1>
<form name="AuthTest" method="POST" action="@@request['SCRIPT_NAME']">
@ -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 ("<br>PRIVILEGE = " + session['PRIVILEGE'] + "\n");
%>
</BODY>
</HTML>
<% page_footer(); %>

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP Exception test"); %>
<h1>Samba4 exception test</h1>
<form name="ExceptionTest" method="POST" action="@@request['SCRIPT_NAME']">
@ -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 ...
</BODY>
</HTML>
<% page_footer(); %>

View File

@ -1,9 +1,4 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<h1>Samba4 form test</h1>
<% page_header("columns", "ESP Form Test"); %>
<form name="FormTest" method="POST" action="@@request['SCRIPT_NAME']">
firstName: <input name="firstName" type="text" value=""><br>
@ -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
}
%>
</BODY>
</HTML>
<% page_footer(); %>

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP Include Test"); %>
including /scripting/test.ejs<p>
<% include("/scripting/test.ejs"); %>
calling a function from test.ejs ...<p>
@ -14,9 +11,8 @@ calling a function from test.esp ...<p>
<% res = testfn('foo'); %>
result is: @@res
<form name="Cancel" method="POST" action="index.esp">
<form name="Cancel" method="POST" action="/">
<input name="submit" type="submit" value="Cancel"><br>
</form>
</BODY>
</HTML>
<% page_footer(); %>

View File

@ -1,32 +0,0 @@
<%
var tests = new Array("formtest", "showvars", "include",
"session", "loadparm", "exception",
"ldb", "auth");
%>
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<img src="/images/logo.png" alt="Samba">
<h1>Samba4 ESP test</h1>
Please choose one of the following tests:
<ul>
<%
for (test in tests) {
url = tests[test] + ".esp";
write("<li> <a href=" + url + ">" + tests[test] + "</a>");
}
%>
</ul>
For more information on ejs see <a
href="http://www.appwebserver.org/products/ejs/ejs.html">http://www.appwebserver.org/products/ejs/ejs.html</a><p>
For more information on esp see <a
href="http://www.appwebserver.org/products/esp/esp.html">http://www.appwebserver.org/products/esp/esp.html</a><p>
</BODY>
</HTML>

View File

@ -1,23 +0,0 @@
<%
var tests = new Array("formtest", "showvars", "include");
%>
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<img src="/images/logo.png" alt="Samba">
<h1>Samba4 ESP test</h1>
Please choose one of the following tests:
<ul>
<%
for (test in tests) {
url = tests[test] + ".html";
write("<li> <a href=" + url + ">" + tests[test] + "</a>");
}
%>
</ul>
</BODY>
</HTML>

View File

@ -1,19 +1,16 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP ldb test"); %>
<h1>Samba4 ldb test</h1>
<form name="LdbTest" method="POST" action="@@request['SCRIPT_NAME']">
<input name="submit" type="submit" value="Cancel"><br>
<form name="LdbTest" method="post" action="@@request['SCRIPT_NAME']">
<input name="submit" type="submit" value="Cancel" /><br />
</form>
<%
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] + "<br>\n");
write(j + "[" + k + "]=" + a[k] + "<br />\n");
}
} else {
write(j + "=" + r[j] + "<br>\n");
write(j + "=" + r[j] + "<br />\n");
}
}
write("<p>");
@ -43,7 +40,7 @@ Trying a attribute constrained search on samdb:<p>
<%
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:<p>
<%
var dbfile = lpGet("sam database");
res = ldbSearch(dbfile, "(objectClass=domain)");
res = ldbSearch(dbfile, "(objectClass=user)");
showLdbRes(res);
%>
and a bad search<br>
</BODY>
</HTML>
<%
res = ldbSearch("foo");
%>
all done
<% page_footer() %>

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP loadparm test"); %>
<h1>Samba4 loadparm test</h1>
<form name="LoadparmTest" method="POST" action="@@request['SCRIPT_NAME']">
@ -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");
%>
</BODY>
</HTML>
<% page_footer(); %>

11
swat/esptest/menu.js Normal file
View File

@ -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",
);

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP session test"); %>
<h1>Samba4 session test</h1>
<form name="SessionTest" method="POST" action="@@request['SCRIPT_NAME']">
@ -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'] + "<br>\n");
%>
</BODY>
</HTML>
<% page_footer(); %>

View File

@ -1,8 +1,5 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
<% page_header("columns", "ESP standard variables test"); %>
<h1>Samba4 showvars test</h1>
<%
@ -26,10 +23,10 @@ Samba4 ESP test
showArray("session", session);
%>
<form name="Cancel" method="POST" action="index.esp">
<form name="Cancel" method="POST" action="/">
<input name="submit" type="submit" value="Cancel"><br>
</form>
</ul>
</BODY>
</HTML>
<% page_footer(); %>

BIN
swat/images/linkpad.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

View File

@ -1,20 +1,7 @@
<HTML>
<TITLE>
Samba4 ESP test
</TITLE>
<BODY>
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");
}
%>
</BODY>
</HTML>
<% page_header("columns", "Welcome to SWAT"); %>
<h1>Welcome to SWAT!</h1>
Please select a menu item from the selection on the left
<% page_footer(); %>

29
swat/login.esp Normal file
View File

@ -0,0 +1,29 @@
<% page_header("plain", "SWAT Login"); %>
<form name="login" method="POST" action="@@request.SCRIPT_NAME">
Username: <input name="Username" type="text" value=""><br>
Password: <input name="Password" type="password" value=""><br>
<br>
<input name="submit" type="submit" value="Login"><br>
</form>
<%
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(); %>

8
swat/logout.esp Normal file
View File

@ -0,0 +1,8 @@
<%
page_header("plain", "Logging out");
session.AUTHENTICATED = false;
redirect("/login.esp");
page_footer();
%>

56
swat/scripting/common.js Normal file
View File

@ -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");
}

View File

@ -0,0 +1 @@
</html>

View File

@ -0,0 +1,7 @@
<%
/* footer for columns page type */
%>
</div>
</div>
</body>
<% include("/scripting/footer.esp"); %>

View File

@ -0,0 +1,7 @@
<%
/* footer for plain page type */
%>
</div>
</div>
</body>
<% include("/scripting/footer.esp"); %>

View File

@ -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>

View File

@ -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">

View File

@ -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">

View File

@ -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");
}
%>

185
swat/style/common.css Normal file
View File

@ -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;
}

107
swat/style/main.css Normal file
View File

@ -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;
}