--- a/src/pyams_default_theme/shared/common/__init__.py Fri Nov 13 13:24:29 2020 +0100
+++ b/src/pyams_default_theme/shared/common/__init__.py Fri Nov 13 13:29:12 2020 +0100
@@ -15,8 +15,10 @@
from pyams_content.interfaces import IBaseContent
from pyams_content.shared.common.interfaces import IWfSharedContent
from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
-from pyams_default_theme.interfaces import IContentDate, IContentTag, IContentTitle
+from pyams_default_theme.interfaces import IContentDate, IContentHeader, IContentTag, \
+ IContentTitle
from pyams_i18n.interfaces import II18n
+from pyams_sequence.interfaces import IInternalReference
from pyams_skin.interfaces.metas import IHTMLContentMetas
from pyams_skin.layer import IPyAMSUserLayer
from pyams_skin.metas import ContentMeta, HTMLTagMeta
@@ -59,7 +61,8 @@
return data_type.name
-@adapter_config(name='title', context=(IWfSharedContent, IPyAMSUserLayer, Interface),
+@adapter_config(name='title',
+ context=(IWfSharedContent, IPyAMSUserLayer, Interface),
provides=IHTMLContentMetas)
class SharedContentTitleMetasAdapter(ContextRequestViewAdapter):
"""Title metas adapter"""
@@ -77,20 +80,38 @@
yield ContentMeta('description', description)
-@adapter_config(context=(IBaseContent, IPyAMSUserLayer), provides=IContentTitle)
+@adapter_config(context=(IBaseContent, IPyAMSUserLayer),
+ provides=IContentTitle)
def base_content_title_adapter(context, request):
"""Base content title adapter"""
return II18n(context).query_attribute('title', request=request)
-@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IContentTag)
+@adapter_config(context=(IInternalReference, IPyAMSUserLayer),
+ provides=IContentTitle)
+def internal_link_content_title_adapter(context, request):
+ """Internal link content title adapter"""
+ registry = request.registry
+ return registry.queryMultiAdapter((context.target, request), IContentTitle)
+
+
+@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer),
+ provides=IContentHeader)
+def shared_content_header_adapter(context, request):
+ """Default shared content header adapter"""
+ return II18n(context).query_attribute('header', request=request)
+
+
+@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer),
+ provides=IContentTag)
def shared_content_tag_adapter(context, request):
"""Default shared content tag adapter"""
translate = request.localizer.translate
return translate(context.content_name)
-@adapter_config(context=(IWfTypedSharedContent, IPyAMSUserLayer), provides=IContentTag)
+@adapter_config(context=(IWfTypedSharedContent, IPyAMSUserLayer),
+ provides=IContentTag)
def typed_shared_content_tag_adapter(context, request):
"""Typed shared content tag adapter"""
data_type = context.get_data_type()
@@ -112,7 +133,8 @@
return self.request.registry.queryMultiAdapter((context, self.request), IContentTag)
-@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IContentDate)
+@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer),
+ provides=IContentDate)
def shared_content_date_adapter(context, request):
"""Default shared content date adapter"""
publication_info = IWorkflowPublicationInfo(context, None)
--- a/src/pyams_default_theme/shared/common/navigation.py Fri Nov 13 13:24:29 2020 +0100
+++ b/src/pyams_default_theme/shared/common/navigation.py Fri Nov 13 13:29:12 2020 +0100
@@ -16,21 +16,31 @@
from pyams_content.interfaces import IBaseContent
from pyams_content.shared.common import ISharedContent
-from pyams_default_theme.interfaces import IContentNavigationTitle
from pyams_content.shared.site import ISiteElementNavigation
+from pyams_default_theme.interfaces import IContentHeader, IContentNavigationTitle
from pyams_i18n.interfaces import II18n
+from pyams_sequence.interfaces import IInternalReference
from pyams_skin.layer import IPyAMSUserLayer
from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config
from pyams_utils.interfaces.tales import ITALESExtension
from pyams_workflow.interfaces import IWorkflowPublicationInfo
-@adapter_config(context=(IBaseContent, IPyAMSUserLayer), provides=IContentNavigationTitle)
+@adapter_config(context=(IBaseContent, IPyAMSUserLayer),
+ provides=IContentNavigationTitle)
def shared_content_navigation_title(context, request):
"""Default content navigation title adapter"""
return II18n(context).query_attribute('title', request=request)
+@adapter_config(context=(IInternalReference, IPyAMSUserLayer),
+ provides=IContentNavigationTitle)
+def internal_link_content_navigation_title(context, request):
+ """Internal link content navigation title adapter"""
+ registry = request.registry
+ return registry.queryMultiAdapter((context.target, request), IContentNavigationTitle)
+
+
@adapter_config(name='pyams_title',
context=(Interface, Interface, Interface),
provides=ITALESExtension)
@@ -40,10 +50,25 @@
def render(self, context=None):
if context is None:
context = self.context
- return self.request.registry.queryMultiAdapter((context, self.request), IContentNavigationTitle)
+ return self.request.registry.queryMultiAdapter((context, self.request),
+ IContentNavigationTitle)
-@adapter_config(context=(ISharedContent, IPyAMSUserLayer), provides=ISiteElementNavigation)
+@adapter_config(name='pyams_header',
+ context=(Interface, Interface, Interface),
+ provides=ITALESExtension)
+class PyAMSContentHeaderTALESExtension(ContextRequestViewAdapter):
+ """PyAMS content header TALES extension"""
+
+ def render(self, context=None):
+ if context is None:
+ context = self.context
+ return self.request.registry.queryMultiAdapter((context, self.request),
+ IContentHeader)
+
+
+@adapter_config(context=(ISharedContent, IPyAMSUserLayer),
+ provides=ISiteElementNavigation)
class SharedContentNavigationAdapter(ContextRequestAdapter):
"""Shared content navigation adapter"""