]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Change breadcrumb handling
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 10:49:37 +0000 (11:49 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 10:49:37 +0000 (11:49 +0100)
This now will ignore any actions at the end of the URL

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/wiki/modules/navbar.html
src/web/wiki.py

index 350905d5376cd0576b5b70fbdfc7723ac2652b44..d93bfee9a79f9325e1cc24af04c6ced40b98c128 100644 (file)
@@ -7,7 +7,7 @@
                {% end %}
 
                <li class="breadcrumb-item {% if not suffix %}active{% end %}">
-                       {{ page_title }}
+                       <a href="{{ page }}">{{ page_title }}</a>
                </li>
 
                {% if suffix %}
index 7705e7622530f263d284ae42f21ff0a2e61b085e..55c0911a3ff1b678a51dbfd0463f92cfad4b473a 100644 (file)
@@ -270,16 +270,37 @@ class WikiListModule(ui_modules.UIModule):
 
 
 class WikiNavbarModule(ui_modules.UIModule):
+       @property
+       def path(self):
+               """
+                       Returns the path of the page (without any actions)
+               """
+               path = self.request.path.split("/")
+
+               if path and path[-1].startswith("_"):
+                       path.pop()
+
+               return "/".join(path)
+
        def render(self, suffix=None):
                _ = self.locale.translate
 
-               breadcrumbs = self.backend.wiki.make_breadcrumbs(self.request.path)
+               # Make the path
+               page = self.request.path.split("/")
 
-               # Don't search for a title for the file manager
-               if self.request.path.endswith("/files"):
-                       title = _("Files")
-               else:
-                       title = self.backend.wiki.get_page_title(self.request.path)
+               # Drop the action bit
+               if page and page[-1].startswith("_"):
+                       page.pop()
+
+               page = "/".join(page)
+
+               breadcrumbs = self.backend.wiki.make_breadcrumbs(page)
+               title = self.backend.wiki.get_page_title(page)
+
+               if self.request.path.endswith("/_edit"):
+                       suffix = _("Edit")
+               elif self.request.path.endswith("/_files"):
+                       suffix = _("Files")
 
                return self.render_string("wiki/modules/navbar.html",
-                       breadcrumbs=breadcrumbs, page_title=title, suffix=suffix)
+                       breadcrumbs=breadcrumbs, page=page, page_title=title, suffix=suffix)