mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Convert right sidebar menus to templates
This commit is contained in:
parent
8e8ac77661
commit
6d83ad3c00
@ -26,8 +26,7 @@ class Apps(PagePlugin):
|
||||
Many of the services you use on the web could soon be on site
|
||||
and under your control!</p>
|
||||
""" % (cfg.product_name)
|
||||
return util.render_template(title="User Applications", main=main,
|
||||
sidebar_right='')
|
||||
return util.render_template(title="User Applications", main=main)
|
||||
|
||||
@cherrypy.expose
|
||||
@require()
|
||||
|
||||
@ -28,7 +28,7 @@ class AuthController(PagePlugin):
|
||||
form.text_input("Passphrase", name="passphrase", type="password")
|
||||
form.submit(label="Login")
|
||||
|
||||
return util.render_template(main=form.render(), sidebar_right=" ")
|
||||
return util.render_template(main=form.render())
|
||||
|
||||
@cherrypy.expose
|
||||
def login(self, username=None, passphrase=None, from_page=cfg.server_dir+"/", **kwargs):
|
||||
|
||||
@ -9,6 +9,12 @@ import service
|
||||
import util
|
||||
|
||||
|
||||
SIDE_MENU = {'title': _('XMPP'),
|
||||
'items': [{'url': '/services/xmpp/configure',
|
||||
'text': 'Configure XMPP Server'},
|
||||
{'url': '/services/xmpp/register',
|
||||
'text': 'Register XMPP Account'}]}
|
||||
|
||||
class xmpp(PagePlugin):
|
||||
def __init__(self, *args, **kwargs):
|
||||
PagePlugin.__init__(self, *args, **kwargs)
|
||||
@ -27,19 +33,27 @@ class xmpp(PagePlugin):
|
||||
'xmpp-bosh', _('Chat Server - web interface'), is_external=True,
|
||||
enabled=True)
|
||||
|
||||
@staticmethod
|
||||
@cherrypy.expose
|
||||
@require()
|
||||
def index(self, **kwargs):
|
||||
def index(**kwargs):
|
||||
del kwargs # Unused
|
||||
main = "<p>XMPP Server Accounts and Configuration</p>"
|
||||
sidebar_right = '<strong><a href="'+cfg.server_dir+'/services/xmpp/configure">Configure XMPP Server</a></strong><br />'
|
||||
sidebar_right = sidebar_right + '<strong><a href="'+cfg.server_dir+'/services/xmpp/register">Register XMPP Account</a></strong>'
|
||||
return util.render_template(title="XMPP Server", main=main, sidebar_right=sidebar_right)
|
||||
|
||||
sidebar_right = util.render_template(template='menu_block',
|
||||
menu=SIDE_MENU)
|
||||
return util.render_template(title="XMPP Server", main=main,
|
||||
sidebar_right=sidebar_right)
|
||||
|
||||
class configure(FormPlugin, PagePlugin):
|
||||
url = ["/services/xmpp/configure"]
|
||||
|
||||
sidebar_left = ''
|
||||
sidebar_right = _("<strong>Configure XMPP Server</strong>")
|
||||
@staticmethod
|
||||
def sidebar_right(**kwargs):
|
||||
"""Return rendered string for sidebar on the right"""
|
||||
del kwargs # Unused
|
||||
|
||||
return util.render_template(template='menu_block', menu=SIDE_MENU)
|
||||
|
||||
def main(self, xmpp_inband_enable=False, message=None, *args, **kwargs):
|
||||
output, error = actions.superuser_run("xmpp-setup", 'status')
|
||||
@ -78,14 +92,18 @@ class configure(FormPlugin, PagePlugin):
|
||||
opts.append('no'+key)
|
||||
actions.run("xmpp-setup", opts)
|
||||
|
||||
main = self.main(checkedinfo['inband_enable'])
|
||||
return util.render_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||
return ''
|
||||
|
||||
|
||||
class register(FormPlugin, PagePlugin):
|
||||
url = ["/services/xmpp/register"]
|
||||
|
||||
sidebar_left = ''
|
||||
sidebar_right = _("<strong>Register XMPP Account</strong>")
|
||||
@staticmethod
|
||||
def sidebar_right(**kwargs):
|
||||
"""Return rendered string for sidebar on the right"""
|
||||
del kwargs # Unused
|
||||
|
||||
return util.render_template(template='menu_block', menu=SIDE_MENU)
|
||||
|
||||
def main(self, username='', message=None, *args, **kwargs):
|
||||
form = Form(title="Register XMPP Account",
|
||||
@ -100,8 +118,11 @@ class register(FormPlugin, PagePlugin):
|
||||
def process_form(self, username=None, password=None, **kwargs):
|
||||
msg = util.Message()
|
||||
|
||||
if not username: msg.add = _("Must specify a username!")
|
||||
if not password: msg.add = _("Must specify a password!")
|
||||
if not username:
|
||||
msg.add(_("Must specify a username!"))
|
||||
|
||||
if not password:
|
||||
msg.add(_("Must specify a password!"))
|
||||
|
||||
if username and password:
|
||||
output, error = actions.superuser_run(
|
||||
@ -110,14 +131,10 @@ class register(FormPlugin, PagePlugin):
|
||||
raise Exception("something is wrong: " + error)
|
||||
|
||||
if "successfully registered" in output:
|
||||
msg.add = _("Registered account for %s." % username)
|
||||
msg.add(_("Registered account for %s." % username))
|
||||
else:
|
||||
msg.add = _("Failed to register account for %s: %s" % (username, output))
|
||||
msg.add(_("Failed to register account for %s: %s" % (username, output)))
|
||||
|
||||
cfg.log(msg.text)
|
||||
main = self.main(username, msg=msg.text)
|
||||
return util.render_template(
|
||||
title="XMPP Server Configuration",
|
||||
main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=self.sidebar_right)
|
||||
|
||||
return msg.text
|
||||
|
||||
@ -34,5 +34,4 @@ href="http://blogfreakz.com/jquery/web-based-filemanager/">FileManager</a>.
|
||||
It appears to be mostly javascript with some bindings to make it
|
||||
python-friendly.</p>
|
||||
"""
|
||||
return util.render_template(title="File Explorer", main=main,
|
||||
sidebar_right='')
|
||||
return util.render_template(title="File Explorer", main=main)
|
||||
|
||||
@ -16,10 +16,18 @@ class users(PagePlugin):
|
||||
self.register_page("sys.users.add")
|
||||
self.register_page("sys.users.edit")
|
||||
|
||||
@staticmethod
|
||||
@cherrypy.expose
|
||||
@require()
|
||||
def index(self):
|
||||
sidebar_right = '<strong><a href="'+cfg.server_dir+'/sys/users/add">Add User</a></strong><br/><strong><a href="'+cfg.server_dir+'/sys/users/edit">Edit Users</a></strong>'
|
||||
def index():
|
||||
"""Return a rendered users page"""
|
||||
menu = {'title': _('Users and Groups'),
|
||||
'items': [{'url': '/sys/users/add',
|
||||
'text': _('Add User')},
|
||||
{'url': '/sys/users/edit',
|
||||
'text': _('Edit Users')}]}
|
||||
sidebar_right = util.render_template(template='menu_block',
|
||||
menu=menu)
|
||||
return util.render_template(title="Manage Users and Groups",
|
||||
sidebar_right=sidebar_right)
|
||||
|
||||
@ -28,7 +36,6 @@ class add(FormPlugin, PagePlugin):
|
||||
url = ["/sys/users/add"]
|
||||
order = 30
|
||||
|
||||
sidebar_left = ''
|
||||
sidebar_right = _("""<strong>Add User</strong><p>Adding a user via this
|
||||
administrative interface <strong>might</strong> create a system user.
|
||||
For example, if you provide a user with ssh access, she will
|
||||
@ -59,7 +66,6 @@ class add(FormPlugin, PagePlugin):
|
||||
cfg.log(msg.text)
|
||||
main = self.main(username, name, email, msg=msg.text)
|
||||
return util.render_template(title="Manage Users and Groups", main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=self.sidebar_right)
|
||||
|
||||
|
||||
@ -67,7 +73,6 @@ class edit(FormPlugin, PagePlugin):
|
||||
url = ["/sys/users/edit"]
|
||||
order = 35
|
||||
|
||||
sidebar_left = ''
|
||||
sidebar_right = _("""<strong>Edit Users</strong><p>Click on a user's name to
|
||||
go to a screen for editing that user's account.</p><strong>Delete
|
||||
Users</strong><p>Check the box next to a users' names and then click
|
||||
@ -115,7 +120,6 @@ class edit(FormPlugin, PagePlugin):
|
||||
main = self.main(msg=msg.text)
|
||||
return util.render_template(title="Manage Users and Groups",
|
||||
main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=self.sidebar_right)
|
||||
|
||||
sidebar_right = ''
|
||||
@ -124,11 +128,9 @@ class edit(FormPlugin, PagePlugin):
|
||||
main = _("<p>Could not find a user with username of %s!</p>" % kwargs['username'])
|
||||
return util.render_template(template="err",
|
||||
title=_("Unknown User"), main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=sidebar_right)
|
||||
|
||||
main = _("""<strong>Edit User '%s'</strong>""" % u['username'])
|
||||
sidebar_right = ''
|
||||
return util.render_template(title="Manage Users and Groups", main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=sidebar_right)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user