diff --git a/menu.py b/menu.py index 4522768a3..bcda4fd73 100644 --- a/menu.py +++ b/menu.py @@ -1,4 +1,3 @@ -from urlparse import urlparse import util import cfg @@ -70,7 +69,7 @@ class Menu(object): return request_path.startswith(self.url) def active_item(self, request): - """Return item list (e.g. submenu) of active menu item.""" + """Return the first active item that is found""" for item in self.items: if request.path.startswith(item.url): return item diff --git a/module_loader.py b/module_loader.py index cf990394b..ad5214776 100644 --- a/module_loader.py +++ b/module_loader.py @@ -48,7 +48,7 @@ def load_modules(): LOGGER.exception('Could not import modules/%s: %s', name, exception) - _include_module_urls(full_name) + _include_module_urls(full_name, name) ordered_modules = [] remaining_modules = dict(modules) @@ -97,13 +97,13 @@ def _insert_modules(module_name, module, remaining_modules, ordered_modules): ordered_modules.append(module_name) -def _include_module_urls(module_name): +def _include_module_urls(module_name, namespace): """Include the module's URLs in global project URLs list""" url_module = module_name + '.urls' try: urls.urlpatterns += django.conf.urls.patterns( '', django.conf.urls.url( - r'', django.conf.urls.include(url_module))) + r'', django.conf.urls.include(url_module, namespace))) except ImportError: LOGGER.debug('No URLs for %s', module_name) diff --git a/modules/apps/urls.py b/modules/apps/urls.py index a65383f51..b47f44cde 100644 --- a/modules/apps/urls.py +++ b/modules/apps/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.apps.apps', - url(r'^apps/$', 'index') + url(r'^apps/$', 'index', name='index') ) diff --git a/modules/config/urls.py b/modules/config/urls.py index e40bdf15a..e80f518dc 100644 --- a/modules/config/urls.py +++ b/modules/config/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.config.config', - url(r'^sys/config/$', 'index'), + url(r'^sys/config/$', 'index', name='index'), ) diff --git a/modules/diagnostics/templates/diagnostics.html b/modules/diagnostics/templates/diagnostics.html index f104ef2f8..c85203f08 100644 --- a/modules/diagnostics/templates/diagnostics.html +++ b/modules/diagnostics/templates/diagnostics.html @@ -24,8 +24,8 @@ system to confirm that network services are running and configured properly. It may take a minute to complete.
- + {% endblock %} diff --git a/modules/diagnostics/urls.py b/modules/diagnostics/urls.py index 5b3d94653..4ed974f9b 100644 --- a/modules/diagnostics/urls.py +++ b/modules/diagnostics/urls.py @@ -24,6 +24,6 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.diagnostics.diagnostics', - url(r'^sys/diagnostics/$', 'index'), - url(r'^sys/diagnostics/test/$', 'test'), + url(r'^sys/diagnostics/$', 'index', name='index'), + url(r'^sys/diagnostics/test/$', 'test', name='test'), ) diff --git a/modules/expert_mode/urls.py b/modules/expert_mode/urls.py index 83ed46428..ffb97da53 100644 --- a/modules/expert_mode/urls.py +++ b/modules/expert_mode/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.expert_mode.expert_mode', - url(r'^sys/expert/$', 'index'), + url(r'^sys/expert/$', 'index', name='index'), ) diff --git a/modules/firewall/urls.py b/modules/firewall/urls.py index 62ae413e7..be2f1494a 100644 --- a/modules/firewall/urls.py +++ b/modules/firewall/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.firewall.firewall', - url(r'^sys/firewall/$', 'index') + url(r'^sys/firewall/$', 'index', name='index') ) diff --git a/modules/first_boot/first_boot.py b/modules/first_boot/first_boot.py index c9ecf5ff9..f784c507b 100644 --- a/modules/first_boot/first_boot.py +++ b/modules/first_boot/first_boot.py @@ -21,6 +21,7 @@ The Plinth first-connection process has several stages: from django import forms from django.contrib import messages from django.core import validators +from django.core.urlresolvers import reverse from django.http.response import HttpResponseRedirect from django.template.response import TemplateResponse from gettext import gettext as _ @@ -94,7 +95,7 @@ def state0(request): """ try: if _read_state() >= 5: - return HttpResponseRedirect(cfg.server_dir) + return HttpResponseRedirect(reverse('index')) except KeyError: pass @@ -112,8 +113,7 @@ def state0(request): if success: # Everything is good, permanently mark and move to page 2 _write_state(1) - return HttpResponseRedirect( - cfg.server_dir + '/firstboot/state1') + return HttpResponseRedirect(reverse('first_boot:state1')) else: form = State0Form(initial=status, prefix='firstboot') diff --git a/modules/first_boot/templates/firstboot_state1.html b/modules/first_boot/templates/firstboot_state1.html index 7a40fcf1e..fdc675f39 100644 --- a/modules/first_boot/templates/firstboot_state1.html +++ b/modules/first_boot/templates/firstboot_state1.html @@ -23,7 +23,7 @@ {% block main_block %}Welcome screen not completely implemented yet. Press continue to see the rest of the + href="{% url 'apps:index' %}">continue to see the rest of the web interface.
We live in a world where our use of the network is mediated by diff --git a/modules/help/templates/help.html b/modules/help/templates/help.html index 6fd191d75..6269ecfa7 100644 --- a/modules/help/templates/help.html +++ b/modules/help/templates/help.html @@ -23,7 +23,7 @@
There are a variety of places to go for help with {{ cfg.product_name }} and the box it runs on.
-This front end has a
+ This front end has a
developer's manual. It isn't complete, but it is the first place
to look. Feel free to offer suggestions, edits, and screenshots for
completing it!
There is no FAQ because +
There is no FAQ because the question frequency is currently zero for all questions.
{% endblock %} diff --git a/modules/help/urls.py b/modules/help/urls.py index 3c623ebcc..6d61537f2 100644 --- a/modules/help/urls.py +++ b/modules/help/urls.py @@ -20,15 +20,14 @@ URLs for the Help module """ from django.conf.urls import patterns, url +from django.core.urlresolvers import reverse_lazy +from django.views.generic import RedirectView urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.help.help', - url(r'^help/$', 'index'), - url(r'^help/index/$', 'index'), - url(r'^help/about/$', 'about'), - url(r'^help/view/(?PWhen enabled, the owncloud installation will be available - from owncloud on the web server. Visit + from owncloud on the web server. Visit this URL to set up the initial administration account for owncloud.
diff --git a/modules/owncloud/urls.py b/modules/owncloud/urls.py index 5ad666505..faa23d43b 100644 --- a/modules/owncloud/urls.py +++ b/modules/owncloud/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.owncloud.owncloud', - url(r'^apps/owncloud/$', 'index'), + url(r'^apps/owncloud/$', 'index', name='index'), ) diff --git a/modules/packages/urls.py b/modules/packages/urls.py index ae963fb4e..60faf35bf 100644 --- a/modules/packages/urls.py +++ b/modules/packages/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.packages.packages', - url(r'^sys/packages/$', 'index'), + url(r'^sys/packages/$', 'index', name='index'), ) diff --git a/modules/pagekite/templates/pagekite_introduction.html b/modules/pagekite/templates/pagekite_introduction.html index 21668bdea..d1b675aea 100644 --- a/modules/pagekite/templates/pagekite_introduction.html +++ b/modules/pagekite/templates/pagekite_introduction.html @@ -49,7 +49,7 @@ there. In future, it might be possible to use your buddy'sConfigure + href="{% url 'pagekite:configure' %}">Configure PageKite
diff --git a/modules/pagekite/urls.py b/modules/pagekite/urls.py index 8cbad4dd5..3db1d2f98 100644 --- a/modules/pagekite/urls.py +++ b/modules/pagekite/urls.py @@ -24,6 +24,6 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.pagekite.pagekite', - url(r'^apps/pagekite/$', 'index'), - url(r'^apps/pagekite/configure/$', 'configure'), + url(r'^apps/pagekite/$', 'index', name='index'), + url(r'^apps/pagekite/configure/$', 'configure', name='configure'), ) diff --git a/modules/system/urls.py b/modules/system/urls.py index 054f9afcc..5982ce850 100644 --- a/modules/system/urls.py +++ b/modules/system/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.system.system', - url(r'^sys/$', 'index'), + url(r'^sys/$', 'index', name='index'), ) diff --git a/modules/tor/urls.py b/modules/tor/urls.py index 95e0422fc..4c13cb138 100644 --- a/modules/tor/urls.py +++ b/modules/tor/urls.py @@ -24,5 +24,5 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.tor.tor', - url(r'^apps/tor/$', 'index') + url(r'^apps/tor/$', 'index', name='index') ) diff --git a/modules/users/urls.py b/modules/users/urls.py index 8fb5d21cd..0c46aa72e 100644 --- a/modules/users/urls.py +++ b/modules/users/urls.py @@ -24,7 +24,7 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.users.users', - url(r'^sys/users/$', 'index'), - url(r'^sys/users/add/$', 'add'), - url(r'^sys/users/edit/$', 'edit') + url(r'^sys/users/$', 'index', name='index'), + url(r'^sys/users/add/$', 'add', name='add'), + url(r'^sys/users/edit/$', 'edit', name='edit') ) diff --git a/modules/xmpp/urls.py b/modules/xmpp/urls.py index 43a518c87..050026d81 100644 --- a/modules/xmpp/urls.py +++ b/modules/xmpp/urls.py @@ -24,7 +24,7 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'modules.xmpp.xmpp', - url(r'^apps/xmpp/$', 'index'), - url(r'^apps/xmpp/configure/$', 'configure'), - url(r'^apps/xmpp/register/$', 'register') + url(r'^apps/xmpp/$', 'index', name='index'), + url(r'^apps/xmpp/configure/$', 'configure', name='configure'), + url(r'^apps/xmpp/register/$', 'register', name='register') ) diff --git a/plinth.py b/plinth.py index b689f0e3b..eb4ca1edc 100755 --- a/plinth.py +++ b/plinth.py @@ -35,6 +35,7 @@ def parse_arguments(): parser.add_argument( '--pidfile', default='plinth.pid', help='specify a file in which the server may write its pid') + # TODO: server_dir is actually a url prefix; use a better variable name parser.add_argument( '--server_dir', default='/', help='web server path under which to serve') diff --git a/templates/base.html b/templates/base.html index 0d6ea93ee..5848f7bd0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -59,11 +59,11 @@ - +
- FreedomBox
+ FreedomBox
{% block add_nav_and_login %}