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
master
jensp 2019-03-28 19:36:20 +00:00
parent 2fcae22fe7
commit 3c21aa0ceb
10 changed files with 131 additions and 77 deletions

View File

@ -7,15 +7,20 @@
<#-- <#--
Outputs the lead text the provided article. 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)> <#if (item["./lead"]?size > 0)>
${item["./lead"]} ${item["./lead"]}
<#elseif (item["./nav:attribute[@name='lead']"]?size > 0)> <#elseif (item["./nav:attribute[@name='lead']"]?size > 0)>
${item["./nav:attribute[@name='lead']"]} ${item["./nav:attribute[@name='lead']"]}
</#if> </#if>
</#macro> </#macro> -->
<#--
Gets the lead text of the provided article.
-->
<#function getLead item> <#function getLead item>
<#if (item["./lead"]?size > 0)> <#if (item["./lead"]?size > 0)>
<#return item["./lead"]> <#return item["./lead"]>
@ -26,13 +31,18 @@
<#-- <#--
Output the main text of the provided article. 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)> <#if (item["./textAsset"]?size > 0)>
${item["./textAsset/content"]} ${item["./textAsset/content"]}
</#if> </#if>
</#macro> </#macro> -->
<#--
Gets the main text the the provided article.
-->
<#function getMainText item> <#function getMainText item>
<#if (item["./textAsset"]?size > 0)> <#if (item["./textAsset"]?size > 0)>
<#return item["./textAsset/content"]> <#return item["./textAsset/content"]>

View File

@ -153,7 +153,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funEndDate item> <#function getEndDate item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate"]> <#return item["./endDate"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -161,7 +161,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateYear item> <#function getEndDateYear item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@year"]> <#return item["./endDate/@year"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -169,7 +169,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateMonth item> <#function getEndDateMonth item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@month"]> <#return item["./endDate/@month"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -177,7 +177,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateDay item> <#function getEndDateDay item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@day"]> <#return item["./endDate/@day"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -185,7 +185,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateDayNameShort item> <#function getEndDateDayNameShort item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@dayNameShort"]> <#return item["./endDate/@dayNameShort"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -193,7 +193,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateHour item> <#function getEndDateHour item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@hour"]> <#return item["./endDate/@hour"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -201,7 +201,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateMinute item> <#function getEndDateMinute item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@minute"]> <#return item["./endDate/@minute"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -209,7 +209,7 @@
</#if> </#if>
</#function> </#function>
<#function funEndDateSecond item> <#function getEndDateSecond item>
<#if (item["./endDate"]?size > 0)> <#if (item["./endDate"]?size > 0)>
<#return item["./endDate/@second"]> <#return item["./endDate/@second"]>
<#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='endDate']"]?size > 0)>
@ -217,7 +217,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDate item> <#function getStartDate item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate"]> <#return item["./startDate"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -225,7 +225,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateYear item> <#function getStartDateYear item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@year"]> <#return item["./startDate/@year"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -233,7 +233,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateMonth item> <#function getStartDateMonth item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@month"]> <#return item["./startDate/@month"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -241,7 +241,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateDay item> <#function getStartDateDay item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@day"]> <#return item["./startDate/@day"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -249,7 +249,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateDayNameShort item> <#function getStartDateDayNameShort item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@dayNameShort"]> <#return item["./startDate/@dayNameShort"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -257,7 +257,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateHour item> <#function getStartDateHour item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@hour"]> <#return item["./startDate/@hour"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -265,7 +265,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateMinute item> <#function getStartDateMinute item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@minute"]> <#return item["./startDate/@minute"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>
@ -273,7 +273,7 @@
</#if> </#if>
</#function> </#function>
<#function funStartDateSecond item> <#function getStartDateSecond item>
<#if (item["./startDate"]?size > 0)> <#if (item["./startDate"]?size > 0)>
<#return item["./startDate/@second"]> <#return item["./startDate/@second"]>
<#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='startDate']"]?size > 0)>

View File

@ -25,7 +25,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funNewsDate item> <#function getNewsDate item>
<#if (item["./newsDate"]?size > 0)> <#if (item["./newsDate"]?size > 0)>
<#return item["./newsDate"].@@text /> <#return item["./newsDate"].@@text />
<#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)>
@ -55,7 +55,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funNewsDateYear item> <#function getNewsDateYear item>
<#if (item["./newsDate"]?size > 0)> <#if (item["./newsDate"]?size > 0)>
<#return item["./newsDate/@year"]> <#return item["./newsDate/@year"]>
<#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)>
@ -74,7 +74,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funNewsDateMonth item> <#function getNewsDateMonth item>
<#if (item["./newsDate"]?size > 0)> <#if (item["./newsDate"]?size > 0)>
<#return item["./newsDate/@month"]> <#return item["./newsDate/@month"]>
<#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)>
@ -93,7 +93,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funNewsDateDay item> <#function getNewsDateDay item>
<#if (item["./newsDate"]?size > 0)> <#if (item["./newsDate"]?size > 0)>
<#return item["./newsDate/@day"]> <#return item["./newsDate/@day"]>
<#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)>
@ -113,7 +113,7 @@
</#if> </#if>
</#macro> </#macro>
<#function funNewsDateDayNameShort item> <#function getNewsDateDayNameShort item>
<#if (item["./newsDate"]?size > 0)> <#if (item["./newsDate"]?size > 0)>
<#return item["./newsDate/@dayNameShort"]> <#return item["./newsDate/@dayNameShort"]>
<#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)> <#elseif (item["./nav:attribute[@name='newsDate']"]?size > 0)>

View File

@ -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. the model provides a content item.
--> -->
<#macro contentPage> <#macro contentPage>

View File

@ -6,39 +6,54 @@
> >
<#-- <#--
Output all path tokens of the current category path. Provides the Get all categories from the category path.
following parameters for nested content:
1: title
2: url
3: id
of the category.
--> -->
<#macro categoryPath> <#function getCategoryPath>
<#return model["/bebop:page/nav:categoryPath/nav:category"]>
</#function>
<#list model["/bebop:page/nav:categoryPath/nav:category"] as token> <#function isRootPage>
<#nested token["./@title"], token["./@url"], token["./@id"]> <#return (model["/bebop:page/nav:categoryPath/nav:category"]?size <= 1)>
</#list> </#function>
</#macro> <#function getSelectedCategory>
<#return model["/bebop:page/nav:categoryPath/nav:category[last()]"]>
</#function>
<#-- <#--
Provides the following data about the current navigation instance to Get the title of the provided category.
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
--> -->
<#macro navigationRoot navId="categoryMenu"> <#function getCategoryTitle category>
<#return category["./@title"]>
</#function>
<#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"]>
</#function>
<#nested navId, url, title> <#--
Get the ID get the provided category.
-->
<#function getCategoryId category>
<#return category["./@id"]>
</#function>
</#macro> <#--
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"]>
</#function>
<#--
Get title of the navigation with the provided id.
-->
<#function getNavigationTitle navigationId="categoryMenu">
<#return model["/bebop:page/nav:categoryMenu[@id='${navigationId}']/nav:category/@title"]>
</#function>
<#-- <#--
Checks if the a categoryMenu is available in the model and shows the Checks if the a categoryMenu is available in the model and shows the
@ -66,6 +81,22 @@
</#macro> </#macro>
<#--
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"]>
</#function>
<#--
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"]>
</#function>
<#-- <#--
Checks if an categoryHierachy is avialable in the model and shows the Checks if an categoryHierachy is avialable in the model and shows the
nested content if one is avialable. The optional parameter hierarchyId nested content if one is avialable. The optional parameter hierarchyId
@ -118,6 +149,13 @@
</#macro> </#macro>
<#--
Gets the subcategories of the provided category.
-->
<#function getSubCategories ofCategory>
<#return ofCategory["./nav:category"]>
</#function>
<#-- <#--
Passed the GreetingItem provided by the model to the nested content if their is an GreetingItem. Passed the GreetingItem provided by the model to the nested content if their is an GreetingItem.
--> -->

View File

@ -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"]>
</#if>
</#function>

View File

@ -5,11 +5,23 @@
"ui": "http://www.arsdigita.com/ui/1.0"} "ui": "http://www.arsdigita.com/ui/1.0"}
> >
<#-- Move to Navigation tags? --> <#-- Move to Navigation macros/functions? -->
<#macro pageTitle> <#macro pageTitle>
${model["//nav:categoryMenu/nav:category/@title"]} ${model["//nav:categoryMenu/nav:category/@title"]}
</#macro> </#macro>
<#function getPageTitle>
<#return model["//nav:categoryMenu/nav:category/@title"]>
</#function>
<#function getSiteHostName>
<#return model["/bebop:page/ui:siteBanner/@hostname"]>
</#function>
<#function getSiteName>
<#return model["/bebop:page/ui:siteBanner/@sitename"]>
</#function>
<#function getBooleanAttrValue fromNode attrName> <#function getBooleanAttrValue fromNode attrName>
<#assign path='@' + attrName> <#assign path='@' + attrName>
<#if (fromNode[path]?size > 0)> <#if (fromNode[path]?size > 0)>

View File

@ -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"]>
</#if>
<#list langs?sort as lang>
<#nested lang, lang==negotiatedLanguage>
</#list>
</#macro>