--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/shared/blog/__init__.py Wed Jan 02 20:15:26 2019 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2008-2019 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from pyams_content.shared.blog import IWfBlogPost
+from pyams_content.shared.blog.interfaces import IBlogFolder
+from pyams_sequence.interfaces import ISequentialIdInfo
+from pyams_skin.layer import IPyAMSUserLayer
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
+from pyams_utils.interfaces.url import ICanonicalURL
+from pyams_utils.traversing import get_parent
+from pyams_utils.url import absolute_url
+
+
+@adapter_config(context=(IWfBlogPost, IPyAMSUserLayer), provides=ICanonicalURL)
+class BlogPostCanonicalUrlAdapter(ContextRequestAdapter):
+ """Blog post canonical URL adapter"""
+
+ def get_url(self, view_name=None, query=None):
+ parent = get_parent(self.context, IBlogFolder)
+ return absolute_url(parent, self.request,
+ '++oid++{0}::{1}{2}{3}'.format(
+ ISequentialIdInfo(self.context).get_base_oid().strip(),
+ self.context.content_url,
+ '/{}'.format(view_name) if view_name else '.html',
+ '?{}'.format(query) if query else ''))
--- a/src/pyams_default_theme/shared/common/url.py Sun Dec 30 18:15:50 2018 +0100
+++ b/src/pyams_default_theme/shared/common/url.py Wed Jan 02 20:15:26 2019 +0100
@@ -16,10 +16,23 @@
from pyams_sequence.interfaces import ISequentialIdInfo
from pyams_skin.layer import IPyAMSUserLayer
from pyams_utils.adapter import ContextRequestAdapter, adapter_config
-from pyams_utils.interfaces.url import IRelativeURL
+from pyams_utils.interfaces.url import ICanonicalURL, IRelativeURL
from pyams_utils.url import absolute_url, relative_url
+@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=ICanonicalURL)
+class WfSharedContentCanonicalUrlAdapter(ContextRequestAdapter):
+ """Workflow managed shared content canonical URL adapter"""
+
+ def get_url(self, view_name=None, query=None):
+ return absolute_url(self.request.root, self.request,
+ '++oid++{0}::{1}{2}{3}'.format(
+ ISequentialIdInfo(self.context).get_base_oid().strip(),
+ self.context.content_url,
+ '/{}'.format(view_name) if view_name else '.html',
+ '?{}'.format(query) if query else ''))
+
+
@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IRelativeURL)
class WfSharedContentRelativeUrlAdapter(ContextRequestAdapter):
"""Workflow managed shared content relative URL adapter"""
--- a/src/pyams_default_theme/shared/site/__init__.py Sun Dec 30 18:15:50 2018 +0100
+++ b/src/pyams_default_theme/shared/site/__init__.py Wed Jan 02 20:15:26 2019 +0100
@@ -14,12 +14,17 @@
from zope.interface import Interface
-from pyams_content.shared.site.interfaces import ISiteFolder, ISiteManager
+from pyams_content.shared.site import IWfSiteTopic
+from pyams_content.shared.site.interfaces import ISiteFolder, ISiteManager, ISiteContainer
from pyams_i18n.interfaces import II18n
+from pyams_sequence.interfaces import ISequentialIdInfo
from pyams_skin.interfaces.metas import IHTMLContentMetas
from pyams_skin.layer import IPyAMSUserLayer
from pyams_skin.metas import ContentMeta, HTMLTagMeta
-from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config, ContextRequestAdapter
+from pyams_utils.interfaces.url import ICanonicalURL
+from pyams_utils.traversing import get_parent
+from pyams_utils.url import absolute_url
@adapter_config(name='title', context=(ISiteManager, IPyAMSUserLayer, Interface), provides=IHTMLContentMetas)
@@ -38,3 +43,17 @@
description = i18n.query_attribute('header', request=self.request)
if description:
yield ContentMeta('description', description)
+
+
+@adapter_config(context=(IWfSiteTopic, IPyAMSUserLayer), provides=ICanonicalURL)
+class SiteTopicCanonicalUrlAdapter(ContextRequestAdapter):
+ """Site topic canonical URL adapter"""
+
+ def get_url(self, view_name=None, query=None):
+ parent = get_parent(self.context, ISiteContainer)
+ return absolute_url(parent, self.request,
+ '++oid++{0}::{1}{2}{3}'.format(
+ ISequentialIdInfo(self.context).get_base_oid().strip(),
+ self.context.content_url,
+ '/{}'.format(view_name) if view_name else '.html',
+ '?{}'.format(query) if query else ''))