diff --git a/ccm-cms-types-article/doc/freemarker/ccm-cms-types-article.md b/ccm-cms-types-article/doc/freemarker/ccm-cms-types-article.md new file mode 100644 index 000000000..6fa99183c --- /dev/null +++ b/ccm-cms-types-article/doc/freemarker/ccm-cms-types-article.md @@ -0,0 +1,10 @@ +# Freemarker functions for Article content items + +## `getLead(item: Node): String` + +Retrieves the lead text of the provided article. + +## `getMainText(item: Node): String` + +Retrieves the main text of the provided item. The return value is a +HTML string. \ No newline at end of file diff --git a/ccm-cms-types-bookmark/doc/freemarker/ccm-cms-types-bookmark.md b/ccm-cms-types-bookmark/doc/freemarker/ccm-cms-types-bookmark.md new file mode 100644 index 000000000..1cd831a8b --- /dev/null +++ b/ccm-cms-types-bookmark/doc/freemarker/ccm-cms-types-bookmark.md @@ -0,0 +1,10 @@ +# Freemarker functions for Bookmark items + +## `getDescription(item: Node): String` + +Gets the description of the bookmark. + +## `getLink(item: Node): String` + +Gets the link for the bookmark's target. + diff --git a/ccm-cms/doc/ccm-cms-freemarker.md b/ccm-cms/doc/freemarker/ccm-cms.md similarity index 100% rename from ccm-cms/doc/ccm-cms-freemarker.md rename to ccm-cms/doc/freemarker/ccm-cms.md diff --git a/ccm-core/doc/ccm-core-freemarker.md b/ccm-core/doc/freemarker/ccm-core.md similarity index 100% rename from ccm-core/doc/ccm-core-freemarker.md rename to ccm-core/doc/freemarker/ccm-core.md diff --git a/ccm-themedirector/doc/ccm-themedirector-freemarker.md b/ccm-themedirector/doc/ccm-themedirector-freemarker.md deleted file mode 100644 index ce65eefea..000000000 --- a/ccm-themedirector/doc/ccm-themedirector-freemarker.md +++ /dev/null @@ -1,69 +0,0 @@ -# Freemarker functions provided by ccm-themedirector - -## Language utilities - -Provides functions for gettign the available languages for the current page. - -Import Path - :`/ccm-themedirector/language.ftl` - -### `Sequence getAvailableLanguages()` - -Returns the functions in which the primary content of the current page is available. - -## Utility functions - -Import Path - :`/ccm-themedirectory/utils.ftl` - -### `String getPageApplication()` - -Returns the application by which the current page was generated. - -### `String getPageTitle()` - -Return the title of the current page as provided by the -_Category Menu_ Component of the _ccm-navigation_ module. - -### `String getSiteHostName()` - -Returns the host name of the CCM installation as provided by the -_SiteBanner_ component of the _ccm-core_ module. - -### `String getSiteName()` - -Returns the host name of the CCM installation as provided by the -_SiteBanner_ component of the _ccm-core_ module. - -### `String formatDateTime(style: String, date: DateValueNode)` - -Formats a date or date-time value according to a pattern defined in the -theme manifest. The pattern must be a valid pattern for the Java `DateTimeFormatter` class (see https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html). The definition in the theme manifest is done in the `date-time-formats` section. A definition for a date style looks like this: - - "date-time-formats": [ - ... - { - "style": "standard", - "lang": "de", - "format": "dd. MMM YYYY" - }, - { - "style": "standard", - "lang": "en", - "format": "MM/dd/YY" - } - ... - ] - -Each style must have a name. It is possible to have different patterns -for a style for different languages. The pattern itself is provided by the `format` property. For a documentation of the pattern format -please refer to the documentation of the Java `DateTimeFormatter`. - -The second parameter of these function is a date value, at the moment -this is an XML node if several attributes providing the year, month etc. of the date. This value is usually provided by special function -for the specific content type. A typical usage of the `formatDateTime` -function looks like this: - - ${Utils.formatDateTime("standard", News.getNewsDate(item))} - -In this example the `getNewsDate` function was used to retrieve the date of a news. \ No newline at end of file diff --git a/ccm-themedirector/doc/freemarker/ccm-themedirector.md b/ccm-themedirector/doc/freemarker/ccm-themedirector.md index 29c813db8..176d2b48b 100644 --- a/ccm-themedirector/doc/freemarker/ccm-themedirector.md +++ b/ccm-themedirector/doc/freemarker/ccm-themedirector.md @@ -1,77 +1,59 @@ -### Common functions +# Freemarker functions provided by ccm-themedirector -#### Language related +## Language utilities -Import path: `<#import /language.ftl as Lang>` +Provides functions for gettign the available languages for the current page. -##### `getAvailableLanguages` +Import Path + :`/ccm-themedirector/language.ftl` - Sequence getAvailableLanguages() -Returns the available languages for the current document as sequence. These sequence can be used for creating links for selecting the language: +### `getAvailableLanguages(): Sequence ` -``` - -``` +Returns the available languages for the current document as sequence. This +sequence can be used for creating links for selecting the language: + + This example uses the `list` directive from Freemarker to iterate over the available languages returned by `getAvailableLanguages` The Freemarker build-in `?then` is used together with the `negotiatedLanguage` variable to check if the curent language is the selected language. If this is the case a CSS class is added to the HTML. -#### Basic functions +## Utility functions -Import path: `<#import /utils.ftl as Utils>` +Import Path + :`/ccm-themedirectory/utils.ftl` -##### getPageApplication - - getPageApplication() +### `String getPageApplication()` Return the application of the current page. -##### getPageTitle +### `String getPageTitle()` - getPageTitle() +Return the title of the current page as provided by the +_Category Menu_ Component of the _ccm-navigation_ module. -Returns the title of the current page +### `String getSiteHostName()` -##### getSiteHostName +Returns the host name of the CCM installation as provided by the +_SiteBanner_ component of the _ccm-core_ module. - getSiteHostName() +### `String getSiteName()` -Returns the name of the host serving the site. +Returns the host name of the CCM installation as provided by the +_SiteBanner_ component of the _ccm-core_ module. -##### getSiteName - - getSiteName() - -Returns the name of the site. - -##### getBooleanAttrValue - - getBooleanAttrValue(fromNode: Node attrName: String) +## `getBooleanAttrValue(fromNode: Node, attrName: String): boolean` A helper function which tries to convert the value of the attribute `attrName` of the node `fromNode` to a boolean. The following values are interpreted as true: `true`, `yes`. All other values are interpreted as `false`. -###### Parameters - -`fromNode` A XML node - -`attrName` The name of attribute to interpret as boolean - -###### Returns - -A boolean for the value of the attribute. If the attribute is not present -in the provided node the function returns `false`. - -##### formatDateTime - - formatDateTime(style: String date: Node) +## `formatDateTime(style: String, date: DateValueNode): String` Formats the value of date/time value node according to the provided `style`. The is defined in the theme manifest in the `date-time-formats` @@ -80,44 +62,41 @@ The style definition in the theme manifest must be in the format expected by the [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html?java/time/format/DateTimeFormatter.html) class. -###### Parameters -`style` A date-time format defined in the theme manifest. The format must be formatted as expected by the [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html?java/time/format/DateTimeFormatter.html) class. - -`date` The node providing the data of the date to format. - -###### Returns - -A date formatted as defined in `style`. - -###### Examples +#### Example In the theme manifest in the following format is defined: -``` -"date-time-formats": [ - ... - { - "style": "news", - "lang": "de", - "format": "dd.MM.YYYY" - }, - { - "style": "news", - "lang": "en", - "format": "MM/dd/YY" - }, - ... -] -``` + "date-time-formats": [ + ... + { + "style": "news", + "lang": "de", + "format": "dd.MM.YYYY" + }, + { + "style": "news", + "lang": "en", + "format": "MM/dd/YY" + }, + ... + ] -The use this format: +Each style must have a name. It is possible to have different patterns +for a style for different languages. The pattern itself is provided by the `format` property. For a documentation of the pattern format +please refer to the documentation of the Java `DateTimeFormatter`. -``` -Utils.formatDateTime('news', News.getDateTime(item)) -``` +The second parameter of these function is a date value, at the moment +this is an XML node if several attributes providing the year, month etc. of the date. This value is usually provided by special function +for the specific content type. A typical usage of the `formatDateTime` +function looks like this: -`News.getDateTime` gets the date of a news item. If the date of the news is 2019-04-01 the return value of the function for german is + ${Utils.formatDateTime("standard", News.getNewsDate(item))} + +In this example the `getNewsDate` function was used to retrieve the date of a news. + +`News.getNewsDate` gets the date of a news item. If the date of the news is +2019-04-01 the return value of the function for german is 01.04.2019