--- a/src/pyams_default_theme/viewlet/breadcrumb/__init__.py Mon Nov 26 11:03:24 2018 +0100
+++ b/src/pyams_default_theme/viewlet/breadcrumb/__init__.py Mon Nov 26 11:03:43 2018 +0100
@@ -12,36 +12,29 @@
__docformat__ = 'restructuredtext'
-from pyramid.location import lineage
from zope.interface import Interface
+from zope.location import ILocation
-from pyams_skin.interfaces.viewlet import IBreadcrumbItem
+from pyams_skin.interfaces.viewlet import IBreadcrumbs
from pyams_skin.layer import IPyAMSUserLayer
-from pyams_skin.viewlet.breadcrumb import BreadcrumbsContentProvider as BaseBreadcrumbsContentProvider
-from pyams_template.template import template_config
+from pyams_skin.viewlet.breadcrumb import BreadcrumbsContentProvider, BreadcrumbsAdapter as BaseBreadcrumbsAdapter
+from pyams_template.template import override_template
+from pyams_utils.adapter import adapter_config
from pyams_utils.interfaces.url import DISPLAY_CONTEXT
-from pyams_viewlet.viewlet import contentprovider_config
-@contentprovider_config(name='pyams.breadcrumbs', layer=IPyAMSUserLayer, view=Interface)
-@template_config(template='breadcrumbs.pt', layer=IPyAMSUserLayer)
-class BreadcrumbsContentProvider(BaseBreadcrumbsContentProvider):
- """Breadcrumbs content provider"""
+@adapter_config(context=(ILocation, IPyAMSUserLayer, Interface), provides=IBreadcrumbs)
+class BreadcrumbsAdapter(BaseBreadcrumbsAdapter):
+ """Breadcrumbs adapter"""
@property
def items(self):
- source = None
- registry = self.request.registry
+ source = self.request.annotations.get(DISPLAY_CONTEXT)
if source is None:
- source = self.request.annotations.get(DISPLAY_CONTEXT)
- if source is None:
- source = self.request.context
+ source = self.request.context
if source is not None:
- for context in reversed(tuple(lineage(source))):
- item = registry.queryMultiAdapter((context, self.request, self.view), IBreadcrumbItem)
- if item is None:
- item = registry.queryMultiAdapter((context, self.request), IBreadcrumbItem)
- if item is None:
- item = registry.queryAdapter(context, IBreadcrumbItem)
- if item is not None:
- yield item
+ yield from self.get_items(source)
+
+
+override_template(context=BreadcrumbsContentProvider, layer=IPyAMSUserLayer,
+ template='breadcrumbs.pt')
--- a/src/pyams_default_theme/viewlet/breadcrumb/breadcrumbs.pt Mon Nov 26 11:03:24 2018 +0100
+++ b/src/pyams_default_theme/viewlet/breadcrumb/breadcrumbs.pt Mon Nov 26 11:03:43 2018 +0100
@@ -1,6 +1,5 @@
-<ol class="breadcrumb">
- <li tal:repeat="item view.items">
- <a class="${'active' if repeat.item.end else None}"
- href="${item.url}">${item.label}</a>
- </li>
-</ol>
\ No newline at end of file
+<ol class="breadcrumb"><li
+ tal:repeat="item view.items"><a
+ tal:omit-tag="not:item.label"
+ class="${'active' if repeat.item.end else None}"
+ href="${item.url}">${item.label}</a></li></ol>
\ No newline at end of file