From: Michael Tremer Date: Thu, 30 May 2019 10:49:37 +0000 (+0100) Subject: wiki: Change breadcrumb handling X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40e481b971e65ab9978e970ba5ef4701aa253521;p=ipfire.org.git wiki: Change breadcrumb handling This now will ignore any actions at the end of the URL Signed-off-by: Michael Tremer --- diff --git a/src/templates/wiki/modules/navbar.html b/src/templates/wiki/modules/navbar.html index 350905d5..d93bfee9 100644 --- a/src/templates/wiki/modules/navbar.html +++ b/src/templates/wiki/modules/navbar.html @@ -7,7 +7,7 @@ {% end %} {% if suffix %} diff --git a/src/web/wiki.py b/src/web/wiki.py index 7705e762..55c0911a 100644 --- a/src/web/wiki.py +++ b/src/web/wiki.py @@ -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)