mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Use Django dispatcher instead of CherryPy dispatcher
This commit is big because anything small breaks the code. - Django dispatcher is based on regular expressions and does not need a tree structure - Reduces a lot of unnecessary dependencies among modules - Use Django sessions middlewear instead of CherryPy sessions - Introduce dependency based modules instead of numeric load order - Remove PagePlugin and simply use Django views - Eliminate page rendering wrappers in favor of Django context processors - Use custom auth for now until replaced by Django auth middlewear - Use Django templated 404 and 500 error pages
This commit is contained in:
1 parent
657bb11bbc
commit
58d13e3ed8
42 files changed
+1281
-1289
No files matched your search
@@ -20,6 +20,8 @@ Plinth module to configure Tor
|
||||
"""
|
||||
|
||||
from . import tor
|
||||
from .tor import init
|
||||
|
||||
__all__ = ['tor', 'init']
|
||||
|
||||
__all__ = ['tor']
|
||||
DEPENDS = ['apps']
|
||||
+23
-26
@@ -19,38 +19,35 @@
|
||||
Plinth module for configuring Tor
|
||||
"""
|
||||
|
||||
import cherrypy
|
||||
from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
from plugin_mount import PagePlugin
|
||||
from ..lib.auth import require
|
||||
|
||||
import actions
|
||||
import cfg
|
||||
import util
|
||||
from ..lib.auth import login_required
|
||||
|
||||
|
||||
class Tor(PagePlugin):
|
||||
order = 60 # order of running init in PagePlugins
|
||||
def init():
|
||||
"""Initialize the Tor module"""
|
||||
menu = cfg.main_menu.find('/apps')
|
||||
menu.add_item("Tor", "icon-eye-close", "/apps/tor", 30)
|
||||
|
||||
def __init__(self):
|
||||
super(Tor, self).__init__()
|
||||
|
||||
self.register_page("apps.tor")
|
||||
cfg.html_root.apps.menu.add_item("Tor", "icon-eye-close", "/apps/tor",
|
||||
30)
|
||||
@login_required
|
||||
def index(request):
|
||||
"""Service the index page"""
|
||||
output, error = actions.superuser_run("tor-get-ports")
|
||||
del error # Unused
|
||||
|
||||
@cherrypy.expose
|
||||
@require()
|
||||
def index(self):
|
||||
output, error = actions.superuser_run("tor-get-ports")
|
||||
port_info = output.split("\n")
|
||||
tor_ports = {}
|
||||
for line in port_info:
|
||||
try:
|
||||
(key, val) = line.split()
|
||||
tor_ports[key] = val
|
||||
except ValueError:
|
||||
continue
|
||||
port_info = output.split("\n")
|
||||
tor_ports = {}
|
||||
for line in port_info:
|
||||
try:
|
||||
(key, val) = line.split()
|
||||
tor_ports[key] = val
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
return util.render_template(template='tor',
|
||||
title=_('Tor Control Panel'),
|
||||
tor_ports=tor_ports)
|
||||
return TemplateResponse(request, 'tor.html',
|
||||
{'title': _('Tor Control Panel'),
|
||||
'tor_ports': tor_ports})
|
||||
Reference in new issue
Block a user