]> git.ipfire.org Git - people/ms/webapp.git/commitdiff
Initial import.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Nov 2009 17:03:07 +0000 (18:03 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Nov 2009 17:03:07 +0000 (18:03 +0100)
12 files changed:
static/templates/template/images/de.gif [new file with mode: 0644]
static/templates/template/images/en.gif [new file with mode: 0644]
static/templates/template/images/icons.png [new file with mode: 0644]
static/templates/template/images/menu_tux.png [new file with mode: 0644]
static/templates/template/images/shadow-h.png [new file with mode: 0644]
static/templates/template/images/shadow-v.png [new file with mode: 0644]
static/templates/template/images/sprite1.png [new file with mode: 0644]
static/templates/template/style.css [new file with mode: 0644]
templates/login.html [new file with mode: 0644]
templates/logout.html [new file with mode: 0644]
templates/template.html [new file with mode: 0644]
webapp.py [new file with mode: 0644]

diff --git a/static/templates/template/images/de.gif b/static/templates/template/images/de.gif
new file mode 100644 (file)
index 0000000..8514a0a
Binary files /dev/null and b/static/templates/template/images/de.gif differ
diff --git a/static/templates/template/images/en.gif b/static/templates/template/images/en.gif
new file mode 100644 (file)
index 0000000..28f9b20
Binary files /dev/null and b/static/templates/template/images/en.gif differ
diff --git a/static/templates/template/images/icons.png b/static/templates/template/images/icons.png
new file mode 100644 (file)
index 0000000..4f913fc
Binary files /dev/null and b/static/templates/template/images/icons.png differ
diff --git a/static/templates/template/images/menu_tux.png b/static/templates/template/images/menu_tux.png
new file mode 100644 (file)
index 0000000..98fdf33
Binary files /dev/null and b/static/templates/template/images/menu_tux.png differ
diff --git a/static/templates/template/images/shadow-h.png b/static/templates/template/images/shadow-h.png
new file mode 100644 (file)
index 0000000..361ba14
Binary files /dev/null and b/static/templates/template/images/shadow-h.png differ
diff --git a/static/templates/template/images/shadow-v.png b/static/templates/template/images/shadow-v.png
new file mode 100644 (file)
index 0000000..80dd357
Binary files /dev/null and b/static/templates/template/images/shadow-v.png differ
diff --git a/static/templates/template/images/sprite1.png b/static/templates/template/images/sprite1.png
new file mode 100644 (file)
index 0000000..2377706
Binary files /dev/null and b/static/templates/template/images/sprite1.png differ
diff --git a/static/templates/template/style.css b/static/templates/template/style.css
new file mode 100644 (file)
index 0000000..78acad9
--- /dev/null
@@ -0,0 +1,474 @@
+/* CSS-Style IPFire v3 */
+
+/* Reset CSS-defaults */
+*, html, body, p, pre, span {
+       border: none;
+       margin: 0;
+       padding: 0;
+}
+
+/* Set defaults */
+*, html, body, p, span {
+       font-family: verdana, arial, sans-serif;
+       font-size: 14px;
+       color: #333333;
+}
+
+body {
+}
+
+body, .topmenu, .sh-bl, .sh-btn, .sh-br, .sh-ul, .sh-top, .sh-ur, .sh-l, .sh-r {
+       background-color: #8a0400 !important;
+}
+
+.main, .top-bgcolor {
+       /* Main BG-Color */
+       background-color: #F5F5F5;
+}
+
+/* CSS for Top-Menu and Main with shadows */
+.topmenu, .footer {
+       background:url(images/sprite1.png) repeat-x;
+}
+
+.sh-bl, .sh-btn, .sh-br, .sh-ul, .sh-top, .sh-ur {
+       background: url(images/shadow-h.png) no-repeat;
+       height: 30px;
+}
+
+.sh-l, .sh-r {
+       background: url(images/shadow-v.png) repeat-y;
+}
+
+.topmenu, .topmenu-down {
+       background-position: 0 0;
+       color:#fff;
+       width:100%;
+       height:99px;
+       text-align: center;
+}
+
+.wrapper {
+       margin:0 auto;
+       padding-left: 5px;
+       padding-right: 5px;
+       width: 1000px;
+       height: auto;
+}
+
+.sh-ul {
+       background-position: left 0;
+}
+
+.sh-top {
+       margin-right: 30px;
+       background-position: 0px -160px;
+       background-repeat:repeat-x;
+       height: 15px;
+}
+
+.sh-ur {
+       margin-left: 30px;
+       background-position: right -80px;
+}
+
+.top-bgcolor { 
+       height: 15px;
+       margin-right: 15px;
+       margin-left: -15px;
+}
+
+.sh-l {
+       background-position: left;
+}
+
+.sh-r {
+       background-position: right;
+       margin-left: 15px;
+}
+
+.main {
+       margin-right: 15px;
+       text-align: left;
+       padding-left: 1em;
+}
+
+.footer, .sh-btn {
+       background-position: -10px -110px;
+       color:#fff;
+       height:36px;
+       text-align: center;
+}
+
+.footer {
+       background-position: -10px -110px;
+       margin-right: 15px !important;
+       margin-right: 30px;
+       margin-left: -15px;
+}
+
+.sh-btn {
+       margin-right: 30px;
+       background-position: 0 bottom !important;
+       background-position: 0 -205px;
+       background-repeat:repeat-x;
+       height: 15px;
+}
+
+.sh-bl {
+       background-position: left -30px;
+       height: 50px;
+}
+
+.sh-br {
+       margin-left: 30px !important;
+       background-position: right -110px;
+       height: 50px;
+}
+
+.header_inner {
+       position: relative;
+       width: 980px;
+       height:102px;
+       margin: 0 auto;
+}
+
+.logo {
+       position: absolute;
+       top: 0;
+       float: left;
+}
+
+.topmenu h1 {
+       float: left;
+       margin-left: 105px;
+       color: #eee;
+       font-size: 1.8em;
+}
+
+.topmenu h2 {
+       float: left;
+       margin-left: 105px;
+       color: #E5CCD0;
+       font-size: 1.0em;
+       vertical-align: bottom;
+}
+
+/* Header Line's */
+.line1 {
+       height: 37px;
+}
+
+.line2 {
+       height: 32px;
+       color: #CCC;
+}
+
+.line3 {
+       height: 31px;
+}
+
+/* Lang */
+.lang {
+       position: absolute;
+       right: 0em;
+       top: 0em;
+}
+
+.lang img {
+       float: left;
+       border: none;
+       margin-right: 0.5em;
+       margin-bottom: 1.5em;
+       margin-top: 0.5em;
+       width: 30px;
+}
+
+/* Menu */
+
+.menu {
+       position: absolute;
+       left: 105px;
+       top: 0em;
+}
+
+.menu li, .menu li a, .menu li a.active, .menu li a:hover {
+       background: url(images/sprite1.png) no-repeat;
+}
+
+.menu ul {
+       list-style: none;
+}
+
+.menu li { 
+       font-size:16px;
+       float: left;
+}
+
+.menu li {
+       vertical-align: middle;
+       background-position: 0 -470px;
+}
+
+.menu li a {
+       margin-left: 1px; /*0.5em;*/
+       margin-right: 1px;
+       display: block;
+       padding: 10px 5px 0 8px;
+       height: 26px;
+       background-position: 0 -430px;
+       background-repeat: repeat-x;
+       color: #ddd;
+       font-weight: bolder;
+       vertical-align: middle;
+       font-size: 0.8em;
+       text-decoration: none;
+}
+
+.menu li a.active {
+       background-position: 0 -190px;
+       background-repeat: repeat-x;
+       color: #ddd;
+}
+
+.menu li a:hover {
+       background-position: 0 -190px;
+       background-repeat: repeat-x;
+       color: #fff;
+}
+
+img.symbol {
+       float: left;
+       margin-bottom: 0em;
+       border: 0;
+}
+
+h1, h2, h3, h4 {
+       color: #8a0400;
+}
+
+h1 {
+       font-size: 1.4em;
+}
+
+div.container h1 {
+       font-size: 1.4em;
+       border-bottom: 1px solid #ddd;
+}
+
+div.container h1 .help, div.container h1 .print {
+       margin: 2px;
+       height: 20px;
+       width: 20px;
+       float: right;
+       vertical-align: middle;
+       background-image: url(20x20-ic.png);
+       background-position:  -53px -105px;
+}
+
+div.container h1 .print {
+       background-position:  -158px -158px;
+}
+
+div.container h2 {
+       font-size: 1.1em;
+       margin-left: 3px;
+}
+
+div.container h3 {
+       font-size: 1em;
+       margin-left: 6px;
+}
+
+div.container h4 {
+       color: #666666;
+       font-size: 1em;
+       margin-left: 6px;
+}
+
+div.container {
+       background-color: #f0f0f0;
+       border:1px solid #ddd;
+       padding: 0.25em;
+       margin-bottom: 15px;
+       margin-right: 1em;
+}
+
+div.container p {
+       font-size: 14px;
+       margin-left: 12px;
+}
+
+div.container fieldset {
+       border: 1px solid #999999;
+       margin-left: 12px;
+       margin-right: 5px;
+       padding: 5px;
+       padding-left: 12px;
+}
+
+div.container fieldset legend {
+       color: #999999;
+}
+
+input {
+       border: none;
+       padding: 1px;
+       overflow: visible;
+}
+
+input[type="text"], input[type="submit"] {
+       border: 1px solid #ccc;
+}
+
+input[type="text"]:hover, input[type="text"]:focus, input[type="submit"]:hover, input[type="submit"]:focus {
+       border: 1px solid #8a0400;
+}
+
+input, label { 
+       margin-bottom: 5px;
+       padding: 2px;
+       height: 16px;
+       vertical-align: middle;
+}
+
+.w200px {
+       float: left;
+       width: 200px;
+}
+
+div.container fieldset input[type="submit"] {
+       float: right;
+       margin-left: 5px;
+       padding-left: 22px;
+       font-weight: bold;
+       color: #000;
+       height: 22px;
+}
+
+button {
+       border: 1px outset #ccc;
+       float: right;
+       margin-left: 5px;
+       padding-right: 2px;
+       height: 22px;
+}
+
+button:hover {
+       border: 1px solid #C00;
+}
+
+.bcancel, .byes, .bno {
+       background: url(20-x-ico.png) no-repeat;
+}
+
+.bcancel {
+       background-position:  0 -40px;
+}
+
+.byes {
+       background-position:  0 -20px;
+}
+
+.bno {
+       background-position:  0 -0px;
+}
+
+div.container .linecode, div.container .linecode ol, div.container .linecode ol li {
+       font-family:"Lucida Console", Monaco, monospace;
+       font-size: 14px;
+       line-height: 16px;
+}
+
+div.container .linecode {
+       white-space: pre;
+       border: 1px solid #aaa;
+       background:  #fafafa;
+       margin-top: 0.25em;
+       padding: 0.25em 0 0 4em;
+}
+
+div.container .linecode ol {
+       white-space: nowrap;
+       padding-right: 0.25em;
+}
+
+div.container .linecode ol li {
+       white-space: pre;
+}
+
+.lbg1 {
+       background: #FAFAFA;
+}
+
+.lbg2 {
+       background: #EEE;
+}
+
+div.container .tblock {
+   display: block;
+   overflow: auto;
+}
+
+div.container table .iptables {
+   border-collapse: inherit;
+}
+
+div.container .iptables th, div.container .iptables td {
+       padding: 0 5px 0 5px;
+       border: 0px solid #aaa;
+       font-size: 12px;
+       white-space:nowrap;
+}
+
+.lbg3 {
+       background: #CCC;
+}
+
+.c-lo {
+       color: #F0F;
+}
+
+.c-green {
+       color: #0C0;
+}
+
+.c-orange {
+       color: #F90;
+}
+
+.c-red {
+       color: #C00;
+}
+
+.c-blue {
+       color: #33F;
+}
+
+div.container .iptables .drop, div.container .iptables .accept, div.container .iptables .log, div.container .iptables .other {
+       padding-left: 15px;
+}
+
+.drop, .accept, .log, .other {
+       background-image: url(images/icons.png);
+       background-repeat: no-repeat;
+       width: 15px;
+       height: 12px;
+       vertical-align: middle;
+}
+
+.drop {
+       background-position: 0 -0px;
+}
+
+.accept {
+       background-position: 0 -71px;
+}
+
+.log {
+       background-position: 0 -58px;
+}
+
+.other {
+       background-position: 0 -34px;
+}
diff --git a/templates/login.html b/templates/login.html
new file mode 100644 (file)
index 0000000..a341946
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+       <head>
+               <meta http-equiv="content-type" content="text/html; charset=utf-8;charset=utf-8" />
+               <link rel="stylesheet" type="text/css" href="{{ static_url("templates/template/style.css") }}" />
+               <title>{{ _("Login") }}</title>
+       </head>
+
+       <body>
+               <div class="topmenu">                   
+                       <div class="header_inner">
+                               <div class="logo">
+                                       <a href="/">
+                                               <img src="{{ static_url("templates/template/images/menu_tux.png") }}" class="symbol" alt="IPFire" />
+                                       </a>
+                               </div>
+                               <div class="line1">
+                               </div>
+                               <div class="line2">
+                                       <h1>{{ _("IPFire Webconsole") }}</h1>
+                               </div>
+                               <div class="line3">
+                                       <h2>{{ _("Please login") }}</h2>
+                               </div>
+                       </div>
+               </div>
+
+               <div class="wrapper">
+                       <div class="sh-ul">
+                               <div class="sh-ur">
+                                       <div class="sh-top">
+                                       </div>
+                                       <div class="top-bgcolor">
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-l">
+                               <div class="sh-r">
+                                       <div class="main">
+                                               <form action="/login" method="post">
+                                                       {{ xsrf_form_html() }}
+                                                       <table>
+                                                               <tr>
+                                                                       <td>{{ _("User") }}</td>
+                                                                       <td><input type="text" name="user" /></td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td>{{ _("Password") }}</td>
+                                                                       <td><input type="password" name="password" /></td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td class="right">
+                                                                               <input class="login" type="submit" value="{{ _("Sign in") }}" />
+                                                                       </td>
+                                                               </tr>
+                                                       </table>
+                                               </form>
+                                               <br />
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-bl">
+                               <div class="sh-br">
+                                       <div class="footer">
+                                               {{ footer }}
+                                       </div>
+                                       <div class="sh-btn">
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/templates/logout.html b/templates/logout.html
new file mode 100644 (file)
index 0000000..d70689f
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+       <head>
+               <meta http-equiv="content-type" content="text/html; charset=utf-8;charset=utf-8" />
+               <link rel="stylesheet" type="text/css" href="{{ static_url("templates/template/style.css") }}" />
+               <title>{{ _("Logout") }}</title>
+       </head>
+
+       <body>
+               <div class="topmenu">                   
+                       <div class="header_inner">
+                               <div class="logo">
+                                       <a href="/">
+                                               <img src="{{ static_url("templates/template/images/menu_tux.png") }}" class="symbol" alt="IPFire" />
+                                       </a>
+                               </div>
+                               <div class="line1">
+                               </div>
+                               <div class="line2">
+                                       <h1>{{ _("IPFire Webconsole") }}</h1>
+                               </div>
+                               <div class="line3">
+                                       <h2>{{ _("Logout") }}</h2>
+                               </div>
+                       </div>
+               </div>
+
+               <div class="wrapper">
+                       <div class="sh-ul">
+                               <div class="sh-ur">
+                                       <div class="sh-top">
+                                       </div>
+                                       <div class="top-bgcolor">
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-l">
+                               <div class="sh-r">
+                                       <div class="main">
+                                               <p>{{ _("You have been sucessfully logged out.") }}</p>
+                                               <br />
+                                               <p><a href="/">{{ _("Relogin" ) }}</a></p>
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-bl">
+                               <div class="sh-br">
+                                       <div class="footer">
+                                               {{ footer }}
+                                       </div>
+                                       <div class="sh-btn">
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/templates/template.html b/templates/template.html
new file mode 100644 (file)
index 0000000..1d5c5a0
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+       <head>
+               <meta http-equiv="content-type" content="text/html; charset=utf-8;charset=utf-8" />
+               <link rel="stylesheet" type="text/css" href="{{ static_url("templates/template/style.css") }}" />
+               <title>{{ _("IPFire Webconsole") }} - {{ title }}</title>
+       </head>
+
+       <body>
+               <div class="topmenu">                   
+                       <div class="header_inner">
+                               <div class="logo">
+                                       <a href="/">
+                                               <img src="{{ static_url("templates/template/images/menu_tux.png") }}"
+                                                       class="symbol" alt="IPFire" />
+                                       </a>
+                               </div>
+                               <div class="line1">
+                                       <div class="menu">
+                                               <ul>
+                                                       <li><a href="#" class="active">Menu Item 1</a></li>
+                                                       <li><a href="#">Menu Item 2</a></li>
+                                                       <li><a href="#">Menu Item 3</a></li>
+                                                       <li><a href="#">Menu Item 4</a></li>
+                                               </ul>
+                                       </div>
+                                       <div class="lang">
+                                               {{ _("Logged in as:") }} {{ user }}
+                                               <!-- <a href="#">
+                                                       <img src="{{ static_url("templates/template/images/de.gif") }}"
+                                                               alt="{{ _("German") }}" />
+                                               </a>
+                                               <a href="#">
+                                                       <img src="{{ static_url("templates/template/images/en.gif") }}"
+                                                               alt="{{ _("English") }}" />
+                                               </a> -->
+                                               <a href="/logout">{{ _("Logout") }}</a>
+                                       </div>
+                               </div>
+                               <div class="line2">
+                                       <h1>{{ _("IPFire Webconsole") }}</h1>
+                               </div>
+                               <div class="line3">
+                                       <h2>{{ slogan }}</h2>
+                               </div>
+                       </div>
+               </div>
+
+               <div class="wrapper">
+                       <div class="sh-ul">
+                               <div class="sh-ur">
+                                       <div class="sh-top">
+                                       </div>
+                                       <div class="top-bgcolor">
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-l">
+                               <div class="sh-r">
+                                       <div class="main">
+                                               <!-- The place where containers go -->
+                                               <br />
+                                       </div>
+                               </div>
+                       </div>
+
+                       <div class="sh-bl">
+                               <div class="sh-br">
+                                       <div class="footer">
+                                               {{ footer }}
+                                       </div>
+                                       <div class="sh-btn">
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/webapp.py b/webapp.py
new file mode 100644 (file)
index 0000000..ba72804
--- /dev/null
+++ b/webapp.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+import os
+import socket
+import time
+
+import tornado.httpserver
+import tornado.ioloop
+import tornado.web
+
+BASEDIR = os.path.dirname(__file__)
+
+settings = {
+       "static_path"   : os.path.join(BASEDIR, "static"),
+       "template_path" : os.path.join(BASEDIR, "templates"),
+       "login_url"     : "/login",
+       "cookie_secret" : "123456789",
+       "xsrf_cookies"  : True,
+}
+
+class BaseHandler(tornado.web.RequestHandler):
+       def get_current_user(self):
+               return self.get_secure_cookie("user")
+
+       def footer(self):
+               return "%s" % socket.gethostname()
+
+
+class MainHandler(BaseHandler):
+       def get(self):
+               if not self.current_user:
+                       self.redirect("/login")
+                       return
+
+               self.render("template.html", title="Testsite", slogan="Security now!",
+                       footer=self.footer(), user=self.current_user)
+
+
+class LoginHandler(BaseHandler):
+       def get(self):
+               self.render("login.html", footer=self.footer())
+
+       def post(self):
+               self.set_secure_cookie("user", self.get_argument("user"))
+               self.redirect("/")
+
+class LogoutHandler(BaseHandler):
+       def get(self):
+               self.clear_cookie("user")
+               self.render("logout.html", footer=self.footer())
+
+
+application = tornado.web.Application([
+       (r"/", MainHandler),
+       (r"/login", LoginHandler),
+       (r"/logout", LogoutHandler),
+], **settings)
+
+if __name__ == "__main__":
+       http_server = tornado.httpserver.HTTPServer(application)
+       http_server.listen(8080)
+       tornado.ioloop.IOLoop.instance().start()