Added custom title meta adapter for site root
authorThierry Florac <thierry.florac@onf.fr>
Thu, 05 Jul 2018 12:41:22 +0200
changeset 368 e1c1c57c2d4c
parent 367 a211d8c17334
child 369 baf764fa893a
Added custom title meta adapter for site root
src/pyams_skin/metas.py
--- a/src/pyams_skin/metas.py	Thu Jul 05 12:33:05 2018 +0200
+++ b/src/pyams_skin/metas.py	Thu Jul 05 12:41:22 2018 +0200
@@ -10,6 +10,8 @@
 # FOR A PARTICULAR PURPOSE.
 #
 from pyams_i18n.interfaces import II18n
+from pyams_skin.interfaces.configuration import IConfiguration
+from pyams_utils.interfaces.site import ISiteRoot
 
 __docformat__ = 'restructuredtext'
 
@@ -161,6 +163,17 @@
         yield HTMLTagMeta('title', title)
 
 
+@adapter_config(name='title', context=(ISiteRoot, Interface, Interface), provides=IHTMLContentMetas)
+class SiteRootTitleMetasAdapter(ContextRequestViewAdapter):
+    """Site root title metas adapter"""
+
+    order = 1
+
+    def get_metas(self):
+        config = IConfiguration(self.context)
+        yield HTMLTagMeta('title', config.title)
+
+
 @adapter_config(name='content-type', context=(Interface, Interface, Interface), provides=IHTMLContentMetas)
 class ContentTypeMetasAdapter(ContextRequestViewAdapter):
     """Content-type metas adapter"""