changeset 1419:6fc41f000d24

pages (blog/view, u, files/list): custom breadcrumbs: - for `blog/view`, feed is added, then post if an item is shown - for `files/list`, files server then directories (with icons) are used - for `u` we deactivate breadcrumb for now
author Goffi <goffi@goffi.org>
date Thu, 29 Apr 2021 20:51:36 +0200
parents d6bcb0cf92d2
children 925a7c498cda
files libervia/pages/blog/view/page_meta.py libervia/pages/files/list/page_meta.py libervia/pages/u/page_meta.py
diffstat 3 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/blog/view/page_meta.py	Thu Apr 29 20:49:32 2021 +0200
+++ b/libervia/pages/blog/view/page_meta.py	Thu Apr 29 20:51:36 2021 +0200
@@ -3,7 +3,7 @@
 import html
 from libervia.server.constants import Const as C
 from twisted.words.protocols.jabber import jid
-from sat.core.i18n import _
+from sat.core.i18n import _, D_
 from sat.tools.common.template import safe
 from sat.tools.common import uri
 from sat.tools.common import data_format
@@ -102,6 +102,18 @@
         "title": "{service}'s blog".format(service=service)})
 
 
+def add_breadcrumb(self, request, breadcrumbs):
+    data = self.getRData(request)
+    breadcrumbs.append({
+        "label": D_("Feed"),
+        "url": self.getURL(data["service"].full(), data.get("node", "@"))
+    })
+    if "item" in data:
+        breadcrumbs.append({
+            "label": D_("Post"),
+        })
+
+
 async def appendComments(self, request, blog_items, profile):
     await self.fillMissingIdentities(
         request, [i['author_jid'] for i in blog_items['items']])
--- a/libervia/pages/files/list/page_meta.py	Thu Apr 29 20:49:32 2021 +0200
+++ b/libervia/pages/files/list/page_meta.py	Thu Apr 29 20:51:36 2021 +0200
@@ -22,6 +22,21 @@
     self.getPathArgs(request, ["service", "*path"], min_args=1, service="jid", path="")
 
 
+def add_breadcrumb(self, request, breadcrumbs):
+    data = self.getRData(request)
+    breadcrumbs.append({
+        "label": data["service"],
+        "url": self.getURL(data["service"].full()),
+        "icon": "server",
+    })
+    for idx, p in enumerate(data["path"]):
+        breadcrumbs.append({
+            "label": p,
+            "url": self.getURL(data["service"].full(), *data["path"][:idx+1]),
+            "icon": "folder-open-empty",
+        })
+
+
 async def prepare_render(self, request):
     data = self.getRData(request)
     thumb_limit = data.get("thumb_limit", 400)
--- a/libervia/pages/u/page_meta.py	Thu Apr 29 20:49:32 2021 +0200
+++ b/libervia/pages/u/page_meta.py	Thu Apr 29 20:51:36 2021 +0200
@@ -40,6 +40,10 @@
         "rel": "alternate",
         "title": "{target_profile}'s blog".format(target_profile=target_profile)})
 
+def add_breadcrumb(self, request, breadcrumbs):
+    # we don't want a breadcrumb here
+    pass
+
 
 @defer.inlineCallbacks
 def prepare_render(self, request):