Merge pull request #50 from jvalleroy/fix-redirects

Fix redirects
This commit is contained in:
Nick Daly 2013-11-10 19:34:34 -08:00
commit 95fbf9527f
11 changed files with 20 additions and 20 deletions

View File

@ -68,7 +68,7 @@ some other websites business model.</p>
main="""
"""
form = Form(title="Configuration",
action="/apps/owncloud",
action=cfg.server_dir + "/apps/owncloud",
name="configure_owncloud",
message='')
form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable'])

View File

@ -81,11 +81,11 @@ class FirstBoot(PagePlugin):
## Update state to 1 and head there
with sqlite_db(cfg.store_file, table="firstboot", autocommit=True) as db:
db['state']=1
raise cherrypy.InternalRedirect('firstboot/state1')
raise cherrypy.InternalRedirect('state1')
main = "<p>Welcome. It looks like this FreedomBox isn't set up yet. We'll need to ask you a just few questions to get started.</p>"
form = Form(title="Welcome to Your FreedomBox!",
action="firstboot",
action="", # stay at firstboot
name="whats_my_name",
message=message)
form.html("<p>For convenience, your FreedomBox needs a name. It should be something short that doesn't contain spaces or punctuation. 'Willard' would be a good name. 'Freestyle McFreedomBox!!!' would not.</p>")
@ -123,7 +123,7 @@ TODO: explain all this cert stuff to the user.</p>
with sqlite_db(cfg.store_file, table="firstboot", autocommit=True) as db:
db['state']=5
main = main + """
<p>Welcome screen not completely implemented yet. Press <a href="router">continue</a> to
<p>Welcome screen not completely implemented yet. Press <a href="../router">continue</a> to
see the rest of the web interface.</p>"
"""
@ -132,7 +132,7 @@ see the rest of the web interface.</p>"
with sqlite_db(cfg.store_file, table="firstboot", autocommit=True) as db:
db['state']=1
#TODO: switch to HTTPS
raise cherrypy.InternalRedirect('firstboot/state1')
raise cherrypy.InternalRedirect('state1')
return self.fill_template(template="base", title=_("Installing the Certificate"), main=main,
sidebar_right=_("""<strong>Getting Help</strong><p>We've done our best to make your FreedomBox easy to use. If you have questions during setup, there are a few places to turn for help. TODO: add links to such help.</p>"""))

View File

@ -57,10 +57,10 @@ def check_auth(*args, **kwargs):
# A condition is just a callable that returns true or false
if not condition():
# Send old page as from_page parameter
raise cherrypy.HTTPRedirect("/auth/login?from_page=%s" % get_params)
raise cherrypy.HTTPRedirect(cfg.server_dir + "/auth/login?from_page=%s" % get_params)
else:
# Send old page as from_page parameter
raise cherrypy.HTTPRedirect("/auth/login?from_page=%s" % get_params)
raise cherrypy.HTTPRedirect(cfg.server_dir + "/auth/login?from_page=%s" % get_params)
cherrypy.tools.auth = cherrypy.Tool('before_handler', check_auth)

View File

@ -17,7 +17,7 @@ class AuthController(PagePlugin):
"""Called on logout"""
def get_loginform(self, username, msg='', from_page="/"):
form = Form(title="Login", action="/auth/login", message=msg)
form = Form(title="Login", action=cfg.server_dir + "/auth/login", message=msg)
form.text_input(name="from_page", value=from_page, type="hidden")
form.text_input("Username", name="username", value=username)
form.text_input("Passphrase", name="passphrase", type="password")
@ -36,7 +36,7 @@ class AuthController(PagePlugin):
else:
cherrypy.session[cfg.session_key] = cherrypy.request.login = username
self.on_login(username)
raise cherrypy.HTTPRedirect(from_page or "/")
raise cherrypy.HTTPRedirect(from_page or (cfg.server_dir + "/"))
@cherrypy.expose
def logout(self, from_page="/"):
@ -46,4 +46,4 @@ class AuthController(PagePlugin):
if username:
cherrypy.request.login = None
self.on_logout(username)
raise cherrypy.HTTPRedirect(from_page or "/")
raise cherrypy.HTTPRedirect(from_page or (cfg.server_dir + "/"))

View File

@ -23,7 +23,7 @@ class router(PagePlugin):
reflect that we've moved down into the submenu hierarchy.
Otherwise, it's hard to know which menu portion to make active
or expand or contract."""
raise cherrypy.HTTPRedirect('/router/setup')
raise cherrypy.HTTPRedirect(cfg.server_dir + '/router/setup')
@cherrypy.expose
@require()
@ -138,7 +138,7 @@ class wan(FormPlugin, PagePlugin):
exec("if not '%(k)s' in kwargs: store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})
form = Form(title="WAN Connection",
action="/router/setup/wan/index",
action=cfg.server_dir + "/router/setup/wan/index",
name="wan_connection_form",
message=message)
form.dropdown('Connection Type', vals=["DHCP", "Static IP"], id="connect_type", onchange="hideshow_static()")

View File

@ -43,7 +43,7 @@ class xmpp(PagePlugin):
main = "<p>XMPP Server Configuration</p>"
form = Form(title="Configuration",
action="/services/xmpp",
action=cfg.server_dir + "/services/xmpp",
name="configure_xmpp",
message='')
form.checkbox(_("Allow In-Band Registration"), name="xmpp_inband_enable",
@ -66,7 +66,7 @@ class register(FormPlugin, PagePlugin):
def main(self, username='', message=None, *args, **kwargs):
form = Form(title="Register XMPP Account",
action="/services/xmpp/register/index",
action=cfg.server_dir + "/services/xmpp/register/index",
name="register_xmpp_form",
message=message)
form.text_input(_("Username"), name="username", value=username)

View File

@ -19,7 +19,7 @@ class Sharing(PagePlugin):
reflect that we've moved down into the submenu hierarchy.
Otherwise, it's hard to know which menu portion to make active
or expand or contract."""
raise cherrypy.HTTPRedirect('/sharing/files')
raise cherrypy.HTTPRedirect(cfg.server_dir + '/sharing/files')
@cherrypy.expose
@require()

View File

@ -112,7 +112,7 @@ class general(FormPlugin, PagePlugin):
## And now, the form.
form = Form(title=_("General Config"),
action="/sys/config/general/index",
action=cfg.server_dir + "/sys/config/general/index",
name="config_general_form",
message=message )
form.html(self.help())

View File

@ -47,7 +47,7 @@ class experts(FormPlugin, PagePlugin):
expert = cfg.users.expert()
cfg.log("Expert mode is %s" % expert)
form = Form(title=_("Expert Mode"),
action="/sys/config/experts",
action=cfg.server_dir + "/sys/config/experts",
name="expert_mode_form",
message=message )
form.html(self.help())

View File

@ -33,7 +33,7 @@ class add(FormPlugin, PagePlugin):
def main(self, username='', name='', email='', message=None, *args, **kwargs):
form = Form(title="Add User",
action="/sys/users/add/index",
action=cfg.server_dir + "/sys/users/add/index",
onsubmit="return md5ify('add_user_form', 'password')",
name="add_user_form",
message=message)
@ -80,7 +80,7 @@ class edit(FormPlugin, PagePlugin):
def main(self, msg=''):
users = cfg.users.get_all()
add_form = Form(title=_("Edit or Delete User"), action="/sys/users/edit", message=msg)
add_form = Form(title=_("Edit or Delete User"), action=cfg.server_dir + "/sys/users/edit", message=msg)
add_form.html('<span class="indent"><strong>Delete</strong><br /></span>')
for uname in users:
user = User(uname[1])

View File

@ -57,7 +57,7 @@ class wan(FormPlugin, PagePlugin):
exec("if not '%(k)s' in kwargs: store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})
form = Form(title=_("Accessing the %s" % cfg.box_name),
action="/sys/config/wan",
action=cfg.server_dir + "/sys/config/wan",
name="admin_wan_form",
message=message )
form.html(self.help())