# HG changeset patch # User Thierry Florac # Date 1605270269 -3600 # Node ID 094d9b11bc83ccca2be48ed070b43de5f75885b1 # Parent 43de10a58806635ab888256d5b5c893ea9ee5b9f Added CSS classes getters to manage header diff -r 43de10a58806 -r 094d9b11bc83 src/pyams_default_theme/features/header/interfaces.py --- a/src/pyams_default_theme/features/header/interfaces.py Fri Nov 13 13:23:00 2020 +0100 +++ b/src/pyams_default_theme/features/header/interfaces.py Fri Nov 13 13:24:29 2020 +0100 @@ -22,12 +22,19 @@ from pyams_default_theme import _ +PYAMS_HEADER_MAIN_CLASS_KEY = 'pyams.header.main_class' +PYAMS_HEADER_TITLE_MAIN_CLASS_KEY = 'pyams.header.title.main_class' +PYAMS_HEADER_TITLE_INNER_CLASS_KEY = 'pyams.header.title.inner_class' +PYAMS_HEADER_NAVIGATION_MAIN_CLASS_KEY = 'pyams.header.navigation.main_class' +PYAMS_HEADER_NAVIGATION_INNER_CLASS_KEY = 'pyams.header.navigation.inner_class' + + class ISimpleHeaderRendererSettings(IHeaderRendererSettings): """Simple header renderer settings""" apply_on_root = Bool(title=_("Apply on root?"), - description=_("If 'no', header settings will not be applied on site root but only " - "on inner sites"), + description=_("If 'no', header settings will not be applied on site " + "root but only on inner sites"), required=True, default=True) diff -r 43de10a58806 -r 094d9b11bc83 src/pyams_default_theme/features/header/skin/__init__.py --- a/src/pyams_default_theme/features/header/skin/__init__.py Fri Nov 13 13:23:00 2020 +0100 +++ b/src/pyams_default_theme/features/header/skin/__init__.py Fri Nov 13 13:24:29 2020 +0100 @@ -23,8 +23,12 @@ from pyams_content.features.renderer.interfaces import HIDDEN_RENDERER_NAME from pyams_content.root import ISiteRoot from pyams_default_theme.features.header import SimpleHeaderRendererSettings -from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings -from pyams_default_theme.features.header.skin.interfaces import IHeaderClass, INavigationClass +from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings, \ + PYAMS_HEADER_MAIN_CLASS_KEY, PYAMS_HEADER_NAVIGATION_INNER_CLASS_KEY, \ + PYAMS_HEADER_NAVIGATION_MAIN_CLASS_KEY, PYAMS_HEADER_TITLE_INNER_CLASS_KEY, \ + PYAMS_HEADER_TITLE_MAIN_CLASS_KEY +from pyams_default_theme.features.header.skin.interfaces import IHeaderClass, \ + IInnerNavigationClass, IInnerTitleClass, INavigationClass, ITitleClass from pyams_default_theme.features.renderer import BaseContentRenderer from pyams_portal.interfaces import PREVIEW_MODE from pyams_portal.portlet import PORTLETS_CACHE_KEY, PORTLETS_CACHE_NAME, PORTLETS_CACHE_REGION @@ -83,14 +87,47 @@ @property def main_header_class(self): request = self.request - return request.registry.queryMultiAdapter((request.context, request), IHeaderClass, - default='') + header_class = request.annotations.get(PYAMS_HEADER_MAIN_CLASS_KEY) + if header_class is None: + header_class = request.registry.queryMultiAdapter((request.context, request), + IHeaderClass, default='') + return header_class + + @property + def main_title_class(self): + request = self.request + title_class = request.annotations.get(PYAMS_HEADER_TITLE_MAIN_CLASS_KEY) + if title_class is None: + title_class = request.registry.queryMultiAdapter((request.context, request), + ITitleClass, default='') + return title_class + + @property + def inner_title_class(self): + request = self.request + title_class = request.annotations.get(PYAMS_HEADER_TITLE_INNER_CLASS_KEY) + if title_class is None: + title_class = request.registry.queryMultiAdapter((request.context, request), + IInnerTitleClass, default='') + return title_class @property def main_navigation_class(self): request = self.request - return request.registry.queryMultiAdapter((request.context, request), INavigationClass, - default='') + nav_class = request.annotations.get(PYAMS_HEADER_NAVIGATION_MAIN_CLASS_KEY) + if nav_class is None: + nav_class = request.registry.queryMultiAdapter((request.context, request), + INavigationClass, default='') + return nav_class + + @property + def inner_navigation_class(self): + request = self.request + nav_class = request.annotations.get(PYAMS_HEADER_NAVIGATION_INNER_CLASS_KEY) + if nav_class is None: + nav_class = request.registry.queryMultiAdapter((request.context, request), + IInnerNavigationClass, default='') + return nav_class @property def search_target(self): @@ -126,7 +163,8 @@ # Hidden header renderer # -@adapter_config(name=HIDDEN_RENDERER_NAME, context=(IHeaderTarget, IPyAMSLayer), provides=IHeaderRenderer) +@adapter_config(name=HIDDEN_RENDERER_NAME, context=(IHeaderTarget, IPyAMSLayer), + provides=IHeaderRenderer) class HiddenHeaderRenderer(BaseHeaderRenderer): """Hidden header renderer""" diff -r 43de10a58806 -r 094d9b11bc83 src/pyams_default_theme/features/header/skin/interfaces.py --- a/src/pyams_default_theme/features/header/skin/interfaces.py Fri Nov 13 13:23:00 2020 +0100 +++ b/src/pyams_default_theme/features/header/skin/interfaces.py Fri Nov 13 13:24:29 2020 +0100 @@ -19,5 +19,17 @@ """Custom header CSS class""" +class ITitleClass(Interface): + """Main title CSS class""" + + +class IInnerTitleClass(Interface): + """Inner title CSS class""" + + class INavigationClass(Interface): """Custom navigation CSS class""" + + +class IInnerNavigationClass(Interface): + """Inner navigation CSS class"""