mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +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
|
Many of the services you use on the web could soon be on site
|
||||||
and under your control!</p>
|
and under your control!</p>
|
||||||
""" % (cfg.product_name)
|
""" % (cfg.product_name)
|
||||||
return util.render_template(title="User Applications", main=main,
|
return util.render_template(title="User Applications", main=main)
|
||||||
sidebar_right='')
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require()
|
@require()
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class AuthController(PagePlugin):
|
|||||||
form.text_input("Passphrase", name="passphrase", type="password")
|
form.text_input("Passphrase", name="passphrase", type="password")
|
||||||
form.submit(label="Login")
|
form.submit(label="Login")
|
||||||
|
|
||||||
return util.render_template(main=form.render(), sidebar_right=" ")
|
return util.render_template(main=form.render())
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def login(self, username=None, passphrase=None, from_page=cfg.server_dir+"/", **kwargs):
|
def login(self, username=None, passphrase=None, from_page=cfg.server_dir+"/", **kwargs):
|
||||||
|
|||||||
@ -9,6 +9,12 @@ import service
|
|||||||
import util
|
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):
|
class xmpp(PagePlugin):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
PagePlugin.__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,
|
'xmpp-bosh', _('Chat Server - web interface'), is_external=True,
|
||||||
enabled=True)
|
enabled=True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require()
|
@require()
|
||||||
def index(self, **kwargs):
|
def index(**kwargs):
|
||||||
|
del kwargs # Unused
|
||||||
main = "<p>XMPP Server Accounts and Configuration</p>"
|
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>'
|
sidebar_right = util.render_template(template='menu_block',
|
||||||
return util.render_template(title="XMPP Server", main=main, sidebar_right=sidebar_right)
|
menu=SIDE_MENU)
|
||||||
|
return util.render_template(title="XMPP Server", main=main,
|
||||||
|
sidebar_right=sidebar_right)
|
||||||
|
|
||||||
class configure(FormPlugin, PagePlugin):
|
class configure(FormPlugin, PagePlugin):
|
||||||
url = ["/services/xmpp/configure"]
|
url = ["/services/xmpp/configure"]
|
||||||
|
|
||||||
sidebar_left = ''
|
@staticmethod
|
||||||
sidebar_right = _("<strong>Configure XMPP Server</strong>")
|
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):
|
def main(self, xmpp_inband_enable=False, message=None, *args, **kwargs):
|
||||||
output, error = actions.superuser_run("xmpp-setup", 'status')
|
output, error = actions.superuser_run("xmpp-setup", 'status')
|
||||||
@ -78,14 +92,18 @@ class configure(FormPlugin, PagePlugin):
|
|||||||
opts.append('no'+key)
|
opts.append('no'+key)
|
||||||
actions.run("xmpp-setup", opts)
|
actions.run("xmpp-setup", opts)
|
||||||
|
|
||||||
main = self.main(checkedinfo['inband_enable'])
|
return ''
|
||||||
return util.render_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
|
||||||
|
|
||||||
class register(FormPlugin, PagePlugin):
|
class register(FormPlugin, PagePlugin):
|
||||||
url = ["/services/xmpp/register"]
|
url = ["/services/xmpp/register"]
|
||||||
|
|
||||||
sidebar_left = ''
|
@staticmethod
|
||||||
sidebar_right = _("<strong>Register XMPP Account</strong>")
|
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):
|
def main(self, username='', message=None, *args, **kwargs):
|
||||||
form = Form(title="Register XMPP Account",
|
form = Form(title="Register XMPP Account",
|
||||||
@ -100,8 +118,11 @@ class register(FormPlugin, PagePlugin):
|
|||||||
def process_form(self, username=None, password=None, **kwargs):
|
def process_form(self, username=None, password=None, **kwargs):
|
||||||
msg = util.Message()
|
msg = util.Message()
|
||||||
|
|
||||||
if not username: msg.add = _("Must specify a username!")
|
if not username:
|
||||||
if not password: msg.add = _("Must specify a password!")
|
msg.add(_("Must specify a username!"))
|
||||||
|
|
||||||
|
if not password:
|
||||||
|
msg.add(_("Must specify a password!"))
|
||||||
|
|
||||||
if username and password:
|
if username and password:
|
||||||
output, error = actions.superuser_run(
|
output, error = actions.superuser_run(
|
||||||
@ -110,14 +131,10 @@ class register(FormPlugin, PagePlugin):
|
|||||||
raise Exception("something is wrong: " + error)
|
raise Exception("something is wrong: " + error)
|
||||||
|
|
||||||
if "successfully registered" in output:
|
if "successfully registered" in output:
|
||||||
msg.add = _("Registered account for %s." % username)
|
msg.add(_("Registered account for %s." % username))
|
||||||
else:
|
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)
|
cfg.log(msg.text)
|
||||||
main = self.main(username, msg=msg.text)
|
|
||||||
return util.render_template(
|
return msg.text
|
||||||
title="XMPP Server Configuration",
|
|
||||||
main=main,
|
|
||||||
sidebar_left=self.sidebar_left,
|
|
||||||
sidebar_right=self.sidebar_right)
|
|
||||||
|
|||||||
@ -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
|
It appears to be mostly javascript with some bindings to make it
|
||||||
python-friendly.</p>
|
python-friendly.</p>
|
||||||
"""
|
"""
|
||||||
return util.render_template(title="File Explorer", main=main,
|
return util.render_template(title="File Explorer", main=main)
|
||||||
sidebar_right='')
|
|
||||||
|
|||||||
@ -16,10 +16,18 @@ class users(PagePlugin):
|
|||||||
self.register_page("sys.users.add")
|
self.register_page("sys.users.add")
|
||||||
self.register_page("sys.users.edit")
|
self.register_page("sys.users.edit")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require()
|
@require()
|
||||||
def index(self):
|
def index():
|
||||||
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>'
|
"""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",
|
return util.render_template(title="Manage Users and Groups",
|
||||||
sidebar_right=sidebar_right)
|
sidebar_right=sidebar_right)
|
||||||
|
|
||||||
@ -28,7 +36,6 @@ class add(FormPlugin, PagePlugin):
|
|||||||
url = ["/sys/users/add"]
|
url = ["/sys/users/add"]
|
||||||
order = 30
|
order = 30
|
||||||
|
|
||||||
sidebar_left = ''
|
|
||||||
sidebar_right = _("""<strong>Add User</strong><p>Adding a user via this
|
sidebar_right = _("""<strong>Add User</strong><p>Adding a user via this
|
||||||
administrative interface <strong>might</strong> create a system user.
|
administrative interface <strong>might</strong> create a system user.
|
||||||
For example, if you provide a user with ssh access, she will
|
For example, if you provide a user with ssh access, she will
|
||||||
@ -59,7 +66,6 @@ class add(FormPlugin, PagePlugin):
|
|||||||
cfg.log(msg.text)
|
cfg.log(msg.text)
|
||||||
main = self.main(username, name, email, msg=msg.text)
|
main = self.main(username, name, email, msg=msg.text)
|
||||||
return util.render_template(title="Manage Users and Groups", main=main,
|
return util.render_template(title="Manage Users and Groups", main=main,
|
||||||
sidebar_left=self.sidebar_left,
|
|
||||||
sidebar_right=self.sidebar_right)
|
sidebar_right=self.sidebar_right)
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +73,6 @@ class edit(FormPlugin, PagePlugin):
|
|||||||
url = ["/sys/users/edit"]
|
url = ["/sys/users/edit"]
|
||||||
order = 35
|
order = 35
|
||||||
|
|
||||||
sidebar_left = ''
|
|
||||||
sidebar_right = _("""<strong>Edit Users</strong><p>Click on a user's name to
|
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
|
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
|
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)
|
main = self.main(msg=msg.text)
|
||||||
return util.render_template(title="Manage Users and Groups",
|
return util.render_template(title="Manage Users and Groups",
|
||||||
main=main,
|
main=main,
|
||||||
sidebar_left=self.sidebar_left,
|
|
||||||
sidebar_right=self.sidebar_right)
|
sidebar_right=self.sidebar_right)
|
||||||
|
|
||||||
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'])
|
main = _("<p>Could not find a user with username of %s!</p>" % kwargs['username'])
|
||||||
return util.render_template(template="err",
|
return util.render_template(template="err",
|
||||||
title=_("Unknown User"), main=main,
|
title=_("Unknown User"), main=main,
|
||||||
sidebar_left=self.sidebar_left,
|
|
||||||
sidebar_right=sidebar_right)
|
sidebar_right=sidebar_right)
|
||||||
|
|
||||||
main = _("""<strong>Edit User '%s'</strong>""" % u['username'])
|
main = _("""<strong>Edit User '%s'</strong>""" % u['username'])
|
||||||
sidebar_right = ''
|
sidebar_right = ''
|
||||||
return util.render_template(title="Manage Users and Groups", main=main,
|
return util.render_template(title="Manage Users and Groups", main=main,
|
||||||
sidebar_left=self.sidebar_left,
|
|
||||||
sidebar_right=sidebar_right)
|
sidebar_right=sidebar_right)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user