diff options
author | Arturo FilastoĢ <hellais@torproject.org> | 2011-08-11 13:47:41 +0200 |
---|---|---|
committer | Arturo FilastoĢ <hellais@torproject.org> | 2011-08-11 13:47:41 +0200 |
commit | 5f53648315b1ed94f263da7c13d1754073649e9c (patch) | |
tree | 351aafc66ddf294874a55bcde67fd30cc84629f2 /packages/torouter-web/tui/controllers | |
parent | 85bbadf931c74ec5bcbad7d3a5403b59b827db50 (diff) | |
download | torouter-5f53648315b1ed94f263da7c13d1754073649e9c.tar.gz torouter-5f53648315b1ed94f263da7c13d1754073649e9c.zip |
Add the base skeleton for the web user interface
Diffstat (limited to 'packages/torouter-web/tui/controllers')
-rw-r--r-- | packages/torouter-web/tui/controllers/__init__.py | 0 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/__init__.pyc | bin | 0 -> 154 bytes | |||
-rw-r--r-- | packages/torouter-web/tui/controllers/main.py | 14 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/main.pyc | bin | 0 -> 855 bytes | |||
-rw-r--r-- | packages/torouter-web/tui/controllers/network.py | 108 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/network.pyc | bin | 0 -> 5261 bytes | |||
-rw-r--r-- | packages/torouter-web/tui/controllers/old/main.py | 11 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/old/status.py | 9 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/old/wizard.py | 81 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/tor.py | 24 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/tor.pyc | bin | 0 -> 1419 bytes |
11 files changed, 247 insertions, 0 deletions
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 --- /dev/null +++ b/packages/torouter-web/tui/controllers/__init__.py diff --git a/packages/torouter-web/tui/controllers/__init__.pyc b/packages/torouter-web/tui/controllers/__init__.pyc Binary files differnew file mode 100644 index 0000000..8568b24 --- /dev/null +++ b/packages/torouter-web/tui/controllers/__init__.pyc 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 Binary files differnew file mode 100644 index 0000000..8bd620b --- /dev/null +++ b/packages/torouter-web/tui/controllers/main.pyc 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 Binary files differnew file mode 100644 index 0000000..0fa3453 --- /dev/null +++ b/packages/torouter-web/tui/controllers/network.pyc 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 Binary files differnew file mode 100644 index 0000000..21724c4 --- /dev/null +++ b/packages/torouter-web/tui/controllers/tor.pyc |