[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torouter/master] Add the base skeleton for the web user interface



commit 5f53648315b1ed94f263da7c13d1754073649e9c
Author: Arturo FilastoÌ? <hellais@xxxxxxxxxxxxxx>
Date:   Thu Aug 11 13:47:41 2011 +0200

    Add the base skeleton for the web user interface
---
 packages/torouter-web/NOTES                        |    6 +
 packages/torouter-web/README                       |   13 ++-
 packages/torouter-web/config.py                    |   12 ++
 packages/torouter-web/config.pyc                   |  Bin 0 -> 228 bytes
 packages/torouter-web/runui.py                     |   29 +++++
 packages/torouter-web/runui.pyc                    |  Bin 0 -> 1271 bytes
 packages/torouter-web/tui/__init__.pyc             |  Bin 0 -> 142 bytes
 packages/torouter-web/tui/controllers/__init__.pyc |  Bin 0 -> 154 bytes
 packages/torouter-web/tui/controllers/main.py      |   14 +++
 packages/torouter-web/tui/controllers/main.pyc     |  Bin 0 -> 855 bytes
 packages/torouter-web/tui/controllers/network.py   |  108 ++++++++++++++++++++
 packages/torouter-web/tui/controllers/network.pyc  |  Bin 0 -> 5261 bytes
 packages/torouter-web/tui/controllers/old/main.py  |   11 ++
 .../torouter-web/tui/controllers/old/status.py     |    9 ++
 .../torouter-web/tui/controllers/old/wizard.py     |   81 +++++++++++++++
 packages/torouter-web/tui/controllers/tor.py       |   24 +++++
 packages/torouter-web/tui/controllers/tor.pyc      |  Bin 0 -> 1419 bytes
 packages/torouter-web/tui/models/router_config.py  |   19 ++++
 packages/torouter-web/tui/views/base.html          |   57 ++++++++++
 packages/torouter-web/tui/views/firewall.html      |    1 +
 packages/torouter-web/tui/views/index.html         |    1 +
 packages/torouter-web/tui/views/main.html          |    1 +
 packages/torouter-web/tui/views/saved.html         |    8 ++
 packages/torouter-web/tui/views/status.html        |    1 +
 packages/torouter-web/tui/views/torconfig.html     |    1 +
 packages/torouter-web/tui/views/torstatus.html     |    1 +
 packages/torouter-web/tui/views/wired.html         |    1 +
 packages/torouter-web/tui/views/wireless.html      |    8 ++
 packages/torouter-web/tui/views/wizard.html        |   12 ++
 packages/torouter-web/view.py                      |   10 ++
 packages/torouter-web/view.pyc                     |  Bin 0 -> 384 bytes
 31 files changed, 427 insertions(+), 1 deletions(-)

diff --git a/packages/torouter-web/NOTES b/packages/torouter-web/NOTES
new file mode 100644
index 0000000..83656ab
--- /dev/null
+++ b/packages/torouter-web/NOTES
@@ -0,0 +1,6 @@
+eth0 is internet
+eth1 is private network
+
+http://wiki.debian.org/NetworkConfiguration
+
+
diff --git a/packages/torouter-web/README b/packages/torouter-web/README
index 0303fad..7a8c0fa 100644
--- a/packages/torouter-web/README
+++ b/packages/torouter-web/README
@@ -1 +1,12 @@
-This is where the web interface for Torouter will be packaged.
+TUI - Tor web User Interface
+----------------------------
+
+This is the Tor web User Interface for the Torouter.
+
+It requires web.py:
+  git clone git://github.com/webpy/webpy.git
+
+To start the web server run:
+  python runui.py
+
+- Arturo Filasto' <hellais@xxxxxxxxxxxxxx>
diff --git a/packages/torouter-web/__init__.py b/packages/torouter-web/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/packages/torouter-web/config.py b/packages/torouter-web/config.py
new file mode 100644
index 0000000..9b8f7a7
--- /dev/null
+++ b/packages/torouter-web/config.py
@@ -0,0 +1,12 @@
+# tui, Tor web UI
+# by Arturo Filasto' <hellais@xxxxxxxxxxxxxx>
+#
+
+import web, os
+
+cache = False
+
+globals = {}
+
+
+
diff --git a/packages/torouter-web/config.pyc b/packages/torouter-web/config.pyc
new file mode 100644
index 0000000..7eb9e48
Binary files /dev/null and b/packages/torouter-web/config.pyc differ
diff --git a/packages/torouter-web/runui.py b/packages/torouter-web/runui.py
new file mode 100644
index 0000000..5f27e4f
--- /dev/null
+++ b/packages/torouter-web/runui.py
@@ -0,0 +1,29 @@
+# tui - Tor web UI
+# by Arturo Filasto' <hellais@xxxxxxxxxxxxxx>
+#
+
+import web
+import config
+import tui.controllers
+
+from view import render
+
+urls = (
+    '/', 'tui.controllers.main.index',
+#    '/config/(tor|router)', 'tui.controllers.main.config',
+    '/network', 'tui.controllers.network.main',
+    '/network/firewall', 'tui.controllers.network.firewall',
+    '/network/wireless', 'tui.controllers.network.wireless',
+    '/network/wired', 'tui.controllers.network.wired',
+    '/network/status', 'tui.controllers.network.status',
+    '/tor', 'tui.controllers.tor.status',
+    '/tor/config', 'tui.controllers.tor.config'
+    )
+#    '/wizard/([0-9a-f]{1,2})?', 'tui.controllers.wizard.step',
+#    '/status', 'tui.controllers.status')
+
+if __name__ == "__main__":
+  app = web.application(urls, globals())
+  app.internalerror = web.debugerror
+  app.run()
+
diff --git a/packages/torouter-web/runui.pyc b/packages/torouter-web/runui.pyc
new file mode 100644
index 0000000..dc829b3
Binary files /dev/null and b/packages/torouter-web/runui.pyc differ
diff --git a/packages/torouter-web/tui/__init__.py b/packages/torouter-web/tui/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/packages/torouter-web/tui/__init__.pyc b/packages/torouter-web/tui/__init__.pyc
new file mode 100644
index 0000000..df02c3e
Binary files /dev/null and b/packages/torouter-web/tui/__init__.pyc differ
diff --git a/packages/torouter-web/tui/controllers/__init__.py b/packages/torouter-web/tui/controllers/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/packages/torouter-web/tui/controllers/__init__.pyc b/packages/torouter-web/tui/controllers/__init__.pyc
new file mode 100644
index 0000000..8568b24
Binary files /dev/null and b/packages/torouter-web/tui/controllers/__init__.pyc differ
diff --git a/packages/torouter-web/tui/controllers/main.py b/packages/torouter-web/tui/controllers/main.py
new file mode 100644
index 0000000..2806467
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/main.py
@@ -0,0 +1,14 @@
+import web
+import view, config
+from view import render
+
+"""
+The main page for network configuration
+"""
+class index:
+  def GET(self):
+    return render.base(render.index())
+
+  def POST(self):
+    return render.base(render.index())
+
diff --git a/packages/torouter-web/tui/controllers/main.pyc b/packages/torouter-web/tui/controllers/main.pyc
new file mode 100644
index 0000000..8bd620b
Binary files /dev/null and b/packages/torouter-web/tui/controllers/main.pyc differ
diff --git a/packages/torouter-web/tui/controllers/network.py b/packages/torouter-web/tui/controllers/network.py
new file mode 100644
index 0000000..33e7f27
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/network.py
@@ -0,0 +1,108 @@
+import web
+import view, config
+from view import render
+
+"""
+This function is used to generate the network
+submenus.
+"""
+def menu(n):
+  a = [] 
+  for i in range(0,5):
+    if i == n:
+      a.append("sel")
+    else:
+      a.append("")
+  print a
+  return """<ul>
+  <li><a href="/network" class="%s">Main</a></li>
+  <li><a href="/network/firewall" class="%s">Firewall</a></li>
+  <li><a href="/network/wireless" class="%s">Wireless</a></li>
+  <li><a href="/network/wired" class="%s">Wired</a></li>
+  <li><a href="/network/status" class="%s">Status</a></li>
+</ul>
+""" % tuple(a)
+
+"""
+The main page for network configuration
+"""
+class main:
+  def GET(self):
+    return render.base(render.main(),menu(0))
+
+  def POST(self):
+    return render.base(render.main(),menu(0))
+
+"""
+The firewall configuration page
+"""
+class firewall:
+  def GET(self):
+    return render.base(render.firewall(),menu(1))
+
+  def POST(self):
+    return render.base(render.firewall(),menu(1))
+
+"""
+Wireless network configuration page
+"""
+class wireless:
+  def get_current_config(self):
+    conf = {'essid' : None, 'encryption' : None, 'key' : None}
+    
+    # XXX Dummy default config for testing purposes
+    #     plugin here the actual code for config retreival
+    conf['essid'] = "Torouter"
+    conf['encryption'] = "WPA2"
+    conf['key'] = "ljdasjkbcuBH12389Ba"
+    
+
+    return conf
+
+  def build_form(self):
+    c = self.get_current_config()
+    ret_form = web.form.Form(
+      web.form.Textbox(name='essid', 
+        description='Wireless ESSID', value=c['essid']),
+      web.form.Dropdown(name='enctype', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
+        description='Wireless encryption scheme', value=c['encryption']),
+      web.form.Password(name='key',
+        description='key', value=c['key']),
+      web.form.Button('save')
+    )
+    self.form = ret_form
+    
+    return True
+  
+  def update_config(self, data):
+    return True
+
+  def GET(self):
+    if self.build_form():
+      return render.base(render.wireless(self.form()),menu(2))
+
+  def POST(self):
+    self.update_config(None)
+    print web.input()
+    return render.base(render.saved(web.input()),menu(2))
+
+"""
+Wired network configuration page
+"""
+class wired:
+  def GET(self):
+    return render.base(render.wired(),menu(3))
+
+  def POST(self):
+    return render.base(render.wired(),menu(3))
+
+"""
+General status page, displays a bit more detail than main
+"""
+class status:
+  def GET(self):
+    return render.base(render.status(),menu(4))
+
+  def POST(self):
+    return render.base(render.status(),menu(4))
+ 
diff --git a/packages/torouter-web/tui/controllers/network.pyc b/packages/torouter-web/tui/controllers/network.pyc
new file mode 100644
index 0000000..0fa3453
Binary files /dev/null and b/packages/torouter-web/tui/controllers/network.pyc differ
diff --git a/packages/torouter-web/tui/controllers/old/main.py b/packages/torouter-web/tui/controllers/old/main.py
new file mode 100644
index 0000000..9127e72
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/old/main.py
@@ -0,0 +1,11 @@
+import web
+
+
+class index:
+  def GET(self):
+    return "index"
+
+class config:
+  def GET(self):
+    return "config"
+
diff --git a/packages/torouter-web/tui/controllers/old/status.py b/packages/torouter-web/tui/controllers/old/status.py
new file mode 100644
index 0000000..05f0bf8
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/old/status.py
@@ -0,0 +1,9 @@
+import web 
+import config
+
+from config import views
+from web import form
+
+class status:
+  def GET():
+    print "status"
diff --git a/packages/torouter-web/tui/controllers/old/wizard.py b/packages/torouter-web/tui/controllers/old/wizard.py
new file mode 100644
index 0000000..7b82df2
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/old/wizard.py
@@ -0,0 +1,81 @@
+import web 
+
+from web import form
+from config import view
+
+class step:
+  cur_step = 1
+  next_step = 2
+  wiztext = []
+  wizform = []
+
+  wiztext.append("Tor Configuration")
+  wizform.append(form.Form(
+          form.Textbox('Nickname',
+            form.notnull, description="Relay Nickname"),
+          form.Textbox('RelayBandwidthRate',
+            form.notnull, description="Relay Bandwidth Rate"),
+          form.Textbox('RelayBandwidthBurst',
+            form.notnull, description="Relay Bandwidth Burst"),
+          form.Textbox('ContactInfo',
+            form.notnull, description="Contact Info"),
+          form.Textbox('ExitPolicy',
+            form.notnull, description="Exit Policy"),
+          form.Button('Next Step')
+          ))
+
+  wiztext.append("Wireless setup")
+  wizform.append(form.Form(
+          form.Textbox('essid',
+            form.notnull, description="Wireless ESSID"),
+          form.Textbox('mac',
+            form.notnull, description="MAC address"),
+          form.Textbox('whatever',
+            form.notnull, description="Wireless ESSID"),
+          form.Button('Next Step')
+          ))
+
+  wiztext.append("")
+  wizform.append(form.Form(
+          form.Textbox('essid',
+            form.notnull, description="Wireless ESSID"),
+          form.Textbox('mac',
+            form.notnull, description="MAC address"),
+          form.Textbox('whatever',
+            form.notnull, description="Wireless ESSID"),
+          form.Button('Next Step')
+          ))
+
+  wiztext.append("")
+  wizform.append(form.Form(
+          form.Textbox('essid',
+            form.notnull, description="Wireless ESSID"),
+          form.Textbox('mac',
+            form.notnull, description="MAC address"),
+          form.Textbox('whatever',
+            form.notnull, description="Wireless ESSID"),
+          form.Button('Next Step')
+          ))
+  
+  def GET(self, step):
+    if step:
+      self.cur_step = int(step)
+      self.next_step = int(step) + 1
+    else:
+      self.cur_step = 1
+      self.next_step = 2
+    if len(self.wizform) < int(self.cur_step):
+      return "Done!"
+    return view.wizard(self.wizform[self.cur_step-1], self.wiztext[self.cur_step-1], self.cur_step, self.next_step)
+
+  def POST(self, step):
+    x = web.input()
+    self.cur_step = int(step)
+    self.next_step = int(step) + 1
+    if len(self.wizform) < int(self.cur_step):
+      return "Done!"
+    return view.wizard(self.wizform[self.cur_step-1], self.wiztext[self.cur_step-1], self.cur_step, self.next_step)
+
+
+
+
diff --git a/packages/torouter-web/tui/controllers/tor.py b/packages/torouter-web/tui/controllers/tor.py
new file mode 100644
index 0000000..3b6116f
--- /dev/null
+++ b/packages/torouter-web/tui/controllers/tor.py
@@ -0,0 +1,24 @@
+import web
+import view, config
+from view import render
+
+"""
+The main Tor status page
+"""
+class status:
+  def GET(self):
+    return render.base(render.torstatus())
+
+  def POST(self):
+    return render.base(render.torstatus())
+
+"""
+Tor configuration page
+"""
+class config:
+  def GET(self):
+    return render.base(render.torconfig())
+
+  def POST(self):
+    return render.base(render.torconfig())
+
diff --git a/packages/torouter-web/tui/controllers/tor.pyc b/packages/torouter-web/tui/controllers/tor.pyc
new file mode 100644
index 0000000..21724c4
Binary files /dev/null and b/packages/torouter-web/tui/controllers/tor.pyc differ
diff --git a/packages/torouter-web/tui/models/router_config.py b/packages/torouter-web/tui/models/router_config.py
new file mode 100644
index 0000000..e83f9aa
--- /dev/null
+++ b/packages/torouter-web/tui/models/router_config.py
@@ -0,0 +1,19 @@
+import web
+from config import db
+
+def new_config(conf):
+  db.insert('router_config', 
+            essid=conf['essid'],
+            field1=conf['field1'],
+            field2=conf['field2']
+            )
+  
+
+def write_config():
+  db.update('router_config', 
+            essid=conf['essid'],
+            field1=conf['field1'],
+            field2=conf['field2']
+            )
+ 
+
diff --git a/packages/torouter-web/tui/views/base.html b/packages/torouter-web/tui/views/base.html
new file mode 100644
index 0000000..47091f8
--- /dev/null
+++ b/packages/torouter-web/tui/views/base.html
@@ -0,0 +1,57 @@
+$def with (page,submenu=None)
+
+<!html>
+
+<html>
+<head>
+  <title>TUI - Tor Web User Interface</title>
+  <style type="text/css">
+    body {
+      margin: 0;
+      border: 0;
+      padding: 0;
+
+    }
+
+    div.wrapper {
+      width: 800px;
+      margin: 0 auto;
+    }
+    
+    div.footer {
+      background-color: #CCC;
+      color: white;
+    }
+    
+    div.header {
+      background-color: #CCC;
+      color: white;
+    }
+
+    ul#menu {
+      list-style: none;
+
+    }
+
+  </style>
+</head>
+<body>
+<div id="header">
+  <ul id="menu">
+    <li><a href="/">Home</a></li>
+    <li><a href="/network">Network</a></li>
+    <li><a href="/tor">Tor</a></li>
+  </ul>
+  $:submenu
+</div>
+
+<div class="wrapper">
+$:page
+</div>
+
+<div class="footer">
+2011 - The Tor Project
+</div>
+
+</body>
+</html>
diff --git a/packages/torouter-web/tui/views/firewall.html b/packages/torouter-web/tui/views/firewall.html
new file mode 100644
index 0000000..c3a244d
--- /dev/null
+++ b/packages/torouter-web/tui/views/firewall.html
@@ -0,0 +1 @@
+the firewall page
diff --git a/packages/torouter-web/tui/views/index.html b/packages/torouter-web/tui/views/index.html
new file mode 100644
index 0000000..3907d84
--- /dev/null
+++ b/packages/torouter-web/tui/views/index.html
@@ -0,0 +1 @@
+The main index
diff --git a/packages/torouter-web/tui/views/main.html b/packages/torouter-web/tui/views/main.html
new file mode 100644
index 0000000..dc503e7
--- /dev/null
+++ b/packages/torouter-web/tui/views/main.html
@@ -0,0 +1 @@
+the main page
diff --git a/packages/torouter-web/tui/views/saved.html b/packages/torouter-web/tui/views/saved.html
new file mode 100644
index 0000000..ba14488
--- /dev/null
+++ b/packages/torouter-web/tui/views/saved.html
@@ -0,0 +1,8 @@
+$def with (content)
+
+<ul>
+
+$for i in content.items():
+  <li><em>$i[0]</em>: $i[1]</li>
+
+</ul>
diff --git a/packages/torouter-web/tui/views/status.html b/packages/torouter-web/tui/views/status.html
new file mode 100644
index 0000000..6a128dc
--- /dev/null
+++ b/packages/torouter-web/tui/views/status.html
@@ -0,0 +1 @@
+the status page
diff --git a/packages/torouter-web/tui/views/torconfig.html b/packages/torouter-web/tui/views/torconfig.html
new file mode 100644
index 0000000..26bd228
--- /dev/null
+++ b/packages/torouter-web/tui/views/torconfig.html
@@ -0,0 +1 @@
+The main Tor config page
diff --git a/packages/torouter-web/tui/views/torstatus.html b/packages/torouter-web/tui/views/torstatus.html
new file mode 100644
index 0000000..ed83531
--- /dev/null
+++ b/packages/torouter-web/tui/views/torstatus.html
@@ -0,0 +1 @@
+The main Tor status page
diff --git a/packages/torouter-web/tui/views/wired.html b/packages/torouter-web/tui/views/wired.html
new file mode 100644
index 0000000..3a517d1
--- /dev/null
+++ b/packages/torouter-web/tui/views/wired.html
@@ -0,0 +1 @@
+the wired page
diff --git a/packages/torouter-web/tui/views/wireless.html b/packages/torouter-web/tui/views/wireless.html
new file mode 100644
index 0000000..48242bc
--- /dev/null
+++ b/packages/torouter-web/tui/views/wireless.html
@@ -0,0 +1,8 @@
+$def with (form)
+
+<h2>Wireless configuration page</h2>
+
+<form action="" method="POST">
+$:form.render()
+</form>
+
diff --git a/packages/torouter-web/tui/views/wizard.html b/packages/torouter-web/tui/views/wizard.html
new file mode 100644
index 0000000..0890507
--- /dev/null
+++ b/packages/torouter-web/tui/views/wizard.html
@@ -0,0 +1,12 @@
+$def with (wiz_form, text, step, next_step)
+
+<h1>Step number $step</h1>
+
+$text
+
+<form action="/wizard/$next_step" method="POST">
+$:wiz_form.render()
+
+</form>
+
+<!-- a href=/wizard/$next_step>Next ($next_step)</a-->
diff --git a/packages/torouter-web/view.py b/packages/torouter-web/view.py
new file mode 100644
index 0000000..639415a
--- /dev/null
+++ b/packages/torouter-web/view.py
@@ -0,0 +1,10 @@
+import web
+import config
+
+t_globals = dict(
+  datestr=web.datestr,
+    )
+
+render = web.template.render('tui/views', cache=config.cache,  globals=t_globals)
+render._keywords['globals']['render'] = render
+
diff --git a/packages/torouter-web/view.pyc b/packages/torouter-web/view.pyc
new file mode 100644
index 0000000..b8a529b
Binary files /dev/null and b/packages/torouter-web/view.pyc differ

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits