From 3c21aa0ceba4789bf0fe1aba611f2692e6114f7c Mon Sep 17 00:00:00 2001 From: jensp Date: Thu, 28 Mar 2019 19:36:20 +0000 Subject: [PATCH] Functions for many freemarker related things, renaming of freemarker files git-svn-id: https://svn.libreccm.org/ccm/trunk@5890 8810af33-2d31-482b-a856-94f89814c4df --- ...acros.ftl => ccm-cms-assets-imagestep.ftl} | 0 .../macros.ftl => ccm-cms-types-article.ftl} | 18 +++- .../macros.ftl => ccm-cms-types-event.ftl} | 32 +++---- .../macros.ftl => ccm-cms-types-newsitem.ftl} | 10 +- .../{ccm-cms/macros.ftl => ccm-cms.ftl} | 2 +- .../{macros/navigation.ftl => Navigation.ftl} | 92 +++++++++++++------ .../{macros/objectlist.ftl => ObjectList.ftl} | 0 .../web/themes/freemarker/Language.ftl | 17 ++++ .../freemarker/{macros.ftl => Utils.ftl} | 14 ++- .../web/themes/freemarker/language.ftl | 23 ----- 10 files changed, 131 insertions(+), 77 deletions(-) rename ccm-cms-assets-imagestep/web/themes/freemarker/{ccm-cms-assets-imagestep/macros.ftl => ccm-cms-assets-imagestep.ftl} (100%) rename ccm-cms-types-article/web/themes/freemarker/{ccm-cms-types-article/macros.ftl => ccm-cms-types-article.ftl} (73%) rename ccm-cms-types-event/web/themes/freemarker/{ccm-cms-types-event/macros.ftl => ccm-cms-types-event.ftl} (94%) rename ccm-cms-types-newsitem/web/themes/freemarker/{ccm-cms-types-newsitem/macros.ftl => ccm-cms-types-newsitem.ftl} (96%) rename ccm-cms/web/themes/freemarker/{ccm-cms/macros.ftl => ccm-cms.ftl} (98%) rename ccm-navigation/web/themes/freemarker/ccm-navigation/{macros/navigation.ftl => Navigation.ftl} (59%) rename ccm-navigation/web/themes/freemarker/ccm-navigation/{macros/objectlist.ftl => ObjectList.ftl} (100%) create mode 100644 ccm-themedirector/web/themes/freemarker/Language.ftl rename ccm-themedirector/web/themes/freemarker/{macros.ftl => Utils.ftl} (63%) delete mode 100644 ccm-themedirector/web/themes/freemarker/language.ftl diff --git a/ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl b/ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep.ftl similarity index 100% rename from ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep/macros.ftl rename to ccm-cms-assets-imagestep/web/themes/freemarker/ccm-cms-assets-imagestep.ftl diff --git a/ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article/macros.ftl b/ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article.ftl similarity index 73% rename from ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article/macros.ftl rename to ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article.ftl index e28b811d5..9d6ac97a9 100644 --- a/ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article/macros.ftl +++ b/ccm-cms-types-article/web/themes/freemarker/ccm-cms-types-article.ftl @@ -7,15 +7,20 @@ <#-- Outputs the lead text the provided article. + + Disabled 2019-03-25, remove 2019-04-07 if this macro is not required --> -<#macro lead item> +<#-- <#macro lead item> <#if (item["./lead"]?size > 0)> ${item["./lead"]} <#elseif (item["./nav:attribute[@name='lead']"]?size > 0)> ${item["./nav:attribute[@name='lead']"]} - + --> +<#-- + Gets the lead text of the provided article. +--> <#function getLead item> <#if (item["./lead"]?size > 0)> <#return item["./lead"]> @@ -26,13 +31,18 @@ <#-- Output the main text of the provided article. + + Disabled 2019-03-25, remove 2019-04-07 if this macro is not required --> -<#macro mainText item> +<#-- <#macro mainText item> <#if (item["./textAsset"]?size > 0)> ${item["./textAsset/content"]} - + --> +<#-- + Gets the main text the the provided article. +--> <#function getMainText item> <#if (item["./textAsset"]?size > 0)> <#return item["./textAsset/content"]> diff --git a/ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event/macros.ftl b/ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event.ftl similarity index 94% rename from ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event/macros.ftl rename to ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event.ftl index 654ef1b19..c6acc0a12 100644 --- a/ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event/macros.ftl +++ b/ccm-cms-types-event/web/themes/freemarker/ccm-cms-types-event.ftl @@ -153,7 +153,7 @@ -<#function funEndDate item> +<#function getEndDate item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -161,7 +161,7 @@ -<#function funEndDateYear item> +<#function getEndDateYear item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@year"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -169,7 +169,7 @@ -<#function funEndDateMonth item> +<#function getEndDateMonth item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@month"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -177,7 +177,7 @@ -<#function funEndDateDay item> +<#function getEndDateDay item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@day"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -185,7 +185,7 @@ -<#function funEndDateDayNameShort item> +<#function getEndDateDayNameShort item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@dayNameShort"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -193,7 +193,7 @@ -<#function funEndDateHour item> +<#function getEndDateHour item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@hour"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -201,7 +201,7 @@ -<#function funEndDateMinute item> +<#function getEndDateMinute item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@minute"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -209,7 +209,7 @@ -<#function funEndDateSecond item> +<#function getEndDateSecond item> <#if (item["./endDate"]?size > 0)> <#return item["./endDate/@second"]> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> @@ -217,7 +217,7 @@ -<#function funStartDate item> +<#function getStartDate item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -225,7 +225,7 @@ -<#function funStartDateYear item> +<#function getStartDateYear item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@year"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -233,7 +233,7 @@ -<#function funStartDateMonth item> +<#function getStartDateMonth item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@month"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -241,7 +241,7 @@ -<#function funStartDateDay item> +<#function getStartDateDay item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@day"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -249,7 +249,7 @@ -<#function funStartDateDayNameShort item> +<#function getStartDateDayNameShort item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@dayNameShort"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -257,7 +257,7 @@ -<#function funStartDateHour item> +<#function getStartDateHour item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@hour"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -265,7 +265,7 @@ -<#function funStartDateMinute item> +<#function getStartDateMinute item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@minute"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> @@ -273,7 +273,7 @@ -<#function funStartDateSecond item> +<#function getStartDateSecond item> <#if (item["./startDate"]?size > 0)> <#return item["./startDate/@second"]> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> diff --git a/ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem/macros.ftl b/ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem.ftl similarity index 96% rename from ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem/macros.ftl rename to ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem.ftl index d77e3affe..ced0c6168 100644 --- a/ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem/macros.ftl +++ b/ccm-cms-types-newsitem/web/themes/freemarker/ccm-cms-types-newsitem.ftl @@ -25,7 +25,7 @@ -<#function funNewsDate item> +<#function getNewsDate item> <#if (item["./newsDate"]?size > 0)> <#return item["./newsDate"].@@text /> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> @@ -55,7 +55,7 @@ -<#function funNewsDateYear item> +<#function getNewsDateYear item> <#if (item["./newsDate"]?size > 0)> <#return item["./newsDate/@year"]> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> @@ -74,7 +74,7 @@ -<#function funNewsDateMonth item> +<#function getNewsDateMonth item> <#if (item["./newsDate"]?size > 0)> <#return item["./newsDate/@month"]> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> @@ -93,7 +93,7 @@ -<#function funNewsDateDay item> +<#function getNewsDateDay item> <#if (item["./newsDate"]?size > 0)> <#return item["./newsDate/@day"]> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> @@ -113,7 +113,7 @@ -<#function funNewsDateDayNameShort item> +<#function getNewsDateDayNameShort item> <#if (item["./newsDate"]?size > 0)> <#return item["./newsDate/@dayNameShort"]> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> diff --git a/ccm-cms/web/themes/freemarker/ccm-cms/macros.ftl b/ccm-cms/web/themes/freemarker/ccm-cms.ftl similarity index 98% rename from ccm-cms/web/themes/freemarker/ccm-cms/macros.ftl rename to ccm-cms/web/themes/freemarker/ccm-cms.ftl index 89784d7a4..8693d5493 100644 --- a/ccm-cms/web/themes/freemarker/ccm-cms/macros.ftl +++ b/ccm-cms/web/themes/freemarker/ccm-cms.ftl @@ -6,7 +6,7 @@ > <#-- - Passed the content item provided by the model to the nested content if + Passes the content item provided by the model to the nested content if the model provides a content item. --> <#macro contentPage> diff --git a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl b/ccm-navigation/web/themes/freemarker/ccm-navigation/Navigation.ftl similarity index 59% rename from ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl rename to ccm-navigation/web/themes/freemarker/ccm-navigation/Navigation.ftl index 46631fbdf..6d4141ba9 100644 --- a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/navigation.ftl +++ b/ccm-navigation/web/themes/freemarker/ccm-navigation/Navigation.ftl @@ -5,40 +5,55 @@ "ui": "http://www.arsdigita.com/ui/1.0"} > -<#-- - Output all path tokens of the current category path. Provides the - following parameters for nested content: - - 1: title - 2: url - 3: id - - of the category. +<#-- + Get all categories from the category path. --> -<#macro categoryPath> - - <#list model["/bebop:page/nav:categoryPath/nav:category"] as token> - <#nested token["./@title"], token["./@url"], token["./@id"]> - - - +<#function getCategoryPath> + <#return model["/bebop:page/nav:categoryPath/nav:category"]> + + +<#function isRootPage> + <#return (model["/bebop:page/nav:categoryPath/nav:category"]?size <= 1)> + + +<#function getSelectedCategory> + <#return model["/bebop:page/nav:categoryPath/nav:category[last()]"]> + <#-- - Provides the following data about the current navigation instance to - the nested content: - - 1. ID of the navigation menu from which the data was retrieved - 2. URL to the root of the navigation - 3. title of the navigation + Get the title of the provided category. --> -<#macro navigationRoot navId="categoryMenu"> +<#function getCategoryTitle category> + <#return category["./@title"]> + - <#assign url=model["/bebop:page/nav:categoryMenu[@id='${navId}']/nav:category/@url"]> - <#assign title=model["/bebop:page/nav:categoryMenu[@id='categoryMenu']/nav:category/@title"]> +<#-- + Get the URL of the provided category. +--> +<#function getCategoryUrl category> + <#return category["./@url"]> + - <#nested navId, url, title> +<#-- + Get the ID get the provided category. +--> +<#function getCategoryId category> + <#return category["./@id"]> + - +<#-- + Get the URL of the root category of the navigation with the provided id. +--> +<#function getNavigationRootUrl navigationId="categoryMenu"> + <#return model["/bebop:page/nav:categoryMenu[@id='${navigationId}']/nav:category/@url"]> + + +<#-- + Get title of the navigation with the provided id. +--> +<#function getNavigationTitle navigationId="categoryMenu"> + <#return model["/bebop:page/nav:categoryMenu[@id='${navigationId}']/nav:category/@title"]> + <#-- Checks if the a categoryMenu is available in the model and shows the @@ -66,6 +81,22 @@ +<#-- + Retrieves the first level of categories from the category menu with the provided ID. + If no id is provided "categoryMenu" is used. +--> +<#function getCategoryMenu menuId="categoryMenu"> + <#return model["/bebop:page/nav:categoryMenu[@id='${menuId}']/nav:category/nav:category"]> + + +<#-- + Retrieves the first level of categories from the category hierachy with the provided ID. + If no id is provided 'categoryNav' is used. +--> +<#function getCategoryHierarchy hierarchyId="categoryNav"> + <#return model["/bebop:page/nav:categoryHierarchy[@id='${hierarchyId}']/nav:category"]> + + <#-- Checks if an categoryHierachy is avialable in the model and shows the nested content if one is avialable. The optional parameter hierarchyId @@ -118,6 +149,13 @@ +<#-- + Gets the subcategories of the provided category. +--> +<#function getSubCategories ofCategory> + <#return ofCategory["./nav:category"]> + + <#-- Passed the GreetingItem provided by the model to the nested content if their is an GreetingItem. --> diff --git a/ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl b/ccm-navigation/web/themes/freemarker/ccm-navigation/ObjectList.ftl similarity index 100% rename from ccm-navigation/web/themes/freemarker/ccm-navigation/macros/objectlist.ftl rename to ccm-navigation/web/themes/freemarker/ccm-navigation/ObjectList.ftl diff --git a/ccm-themedirector/web/themes/freemarker/Language.ftl b/ccm-themedirector/web/themes/freemarker/Language.ftl new file mode 100644 index 000000000..1f59f53e2 --- /dev/null +++ b/ccm-themedirector/web/themes/freemarker/Language.ftl @@ -0,0 +1,17 @@ +<#ftl ns_prefixes={ +"bebop":"http://www.arsdigita.com/bebop/1.0", +"cms":"http://www.arsdigita.com/cms/1.0", +"nav":"http://ccm.redhat.com/navigation", +"ui": "http://www.arsdigita.com/ui/1.0"} +> + +<#function getAvailableLanguages> + <#if (model["/bebop:page/cms:contentPanel"]?size > 0)> + <#return model["/bebop:page/cms:contentPanel/availableLanguages/language/@locale"]> + <#elseif (model["/bebop:page/nav:greetingItem"]?size > 0)> + <#return model["/bebop:page/nav:greetingItem/availableLanguages/language/@locale"]> + <#else> + <#return model["/bebop:page/ui:siteBanner/supportedLanguages/language/@locale"]> + + + diff --git a/ccm-themedirector/web/themes/freemarker/macros.ftl b/ccm-themedirector/web/themes/freemarker/Utils.ftl similarity index 63% rename from ccm-themedirector/web/themes/freemarker/macros.ftl rename to ccm-themedirector/web/themes/freemarker/Utils.ftl index 0a6650ff1..f014bbc45 100644 --- a/ccm-themedirector/web/themes/freemarker/macros.ftl +++ b/ccm-themedirector/web/themes/freemarker/Utils.ftl @@ -5,11 +5,23 @@ "ui": "http://www.arsdigita.com/ui/1.0"} > -<#-- Move to Navigation tags? --> +<#-- Move to Navigation macros/functions? --> <#macro pageTitle> ${model["//nav:categoryMenu/nav:category/@title"]} +<#function getPageTitle> + <#return model["//nav:categoryMenu/nav:category/@title"]> + + +<#function getSiteHostName> + <#return model["/bebop:page/ui:siteBanner/@hostname"]> + + +<#function getSiteName> + <#return model["/bebop:page/ui:siteBanner/@sitename"]> + + <#function getBooleanAttrValue fromNode attrName> <#assign path='@' + attrName> <#if (fromNode[path]?size > 0)> diff --git a/ccm-themedirector/web/themes/freemarker/language.ftl b/ccm-themedirector/web/themes/freemarker/language.ftl deleted file mode 100644 index c253dd3f4..000000000 --- a/ccm-themedirector/web/themes/freemarker/language.ftl +++ /dev/null @@ -1,23 +0,0 @@ -<#ftl ns_prefixes={ -"bebop":"http://www.arsdigita.com/bebop/1.0", -"cms":"http://www.arsdigita.com/cms/1.0", -"nav":"http://ccm.redhat.com/navigation", -"ui": "http://www.arsdigita.com/ui/1.0"} -> - -<#macro availableLanguages> - - <#assign langs=["empty"]> - <#if (model["/bebop:page/cms:contentPanel"]?size > 0)> - <#assign langs=model["/bebop:page/cms:contentPanel/availableLanguages/language/@locale"]> - <#elseif (model["/bebop:page/nav:greetingItem"]?size > 0)> - <#assign langs=model["/bebop:page/nav:greetingItem/availableLanguages/language/@locale"]> - <#else> - <#assign langs=model["/bebop:page/ui:siteBanner/supportedLanguages/language/@locale"]> - - - <#list langs?sort as lang> - <#nested lang, lang==negotiatedLanguage> - - -