Fixed different structures, doc for Freemarker functions provided by ccm-cms-types-article and ccm-cms-types-bookmark
git-svn-id: https://svn.libreccm.org/ccm/trunk@6111 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a61bbc73f2
commit
d0fad42274
|
|
@ -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.
|
||||||
|
|
@ -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.
|
||||||
|
|
||||||
|
|
@ -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<String> 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:
|
|
||||||
|
|
||||||
<span>${Utils.formatDateTime("standard", News.getNewsDate(item))}</span>
|
|
||||||
|
|
||||||
In this example the `getNewsDate` function was used to retrieve the date of a news.
|
|
||||||
|
|
@ -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<String> `
|
||||||
|
|
||||||
```
|
Returns the available languages for the current document as sequence. This
|
||||||
<ul class="language-selector">
|
sequence can be used for creating links for selecting the language:
|
||||||
<#list Lang.getAvailableLanguages()?sort as lang>
|
|
||||||
<li class="${(lang==negotiatedLanguage)?then('selected', '')}">${lang}</li>
|
<ul class="language-selector">
|
||||||
</#list>
|
<#list Lang.getAvailableLanguages()?sort as lang>
|
||||||
</ul>
|
<li class="${(lang==negotiatedLanguage)?then('selected', '')}">${lang}</li>
|
||||||
```
|
</#list>
|
||||||
|
</ul>
|
||||||
|
|
||||||
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
|
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
|
check if the curent language is the selected language. If this is the case
|
||||||
a CSS class is added to the HTML.
|
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
|
### `String getPageApplication()`
|
||||||
|
|
||||||
getPageApplication()
|
|
||||||
|
|
||||||
Return the application of the current page.
|
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
|
## `getBooleanAttrValue(fromNode: Node, attrName: String): boolean`
|
||||||
|
|
||||||
getSiteName()
|
|
||||||
|
|
||||||
Returns the name of the site.
|
|
||||||
|
|
||||||
##### getBooleanAttrValue
|
|
||||||
|
|
||||||
getBooleanAttrValue(fromNode: Node attrName: String)
|
|
||||||
|
|
||||||
A helper function which tries to convert the value of the attribute `attrName` of the node `fromNode` to a boolean. The following values
|
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
|
are interpreted as true: `true`, `yes`. All other values are interpreted
|
||||||
as `false`.
|
as `false`.
|
||||||
|
|
||||||
###### Parameters
|
## `formatDateTime(style: String, date: DateValueNode): String`
|
||||||
|
|
||||||
`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)
|
|
||||||
|
|
||||||
Formats the value of date/time value node according to the provided
|
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`
|
`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.
|
[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.
|
#### Example
|
||||||
|
|
||||||
`date` The node providing the data of the date to format.
|
|
||||||
|
|
||||||
###### Returns
|
|
||||||
|
|
||||||
A date formatted as defined in `style`.
|
|
||||||
|
|
||||||
###### Examples
|
|
||||||
|
|
||||||
In the theme manifest in the following format is defined:
|
In the theme manifest in the following format is defined:
|
||||||
|
|
||||||
```
|
"date-time-formats": [
|
||||||
"date-time-formats": [
|
...
|
||||||
...
|
{
|
||||||
{
|
"style": "news",
|
||||||
"style": "news",
|
"lang": "de",
|
||||||
"lang": "de",
|
"format": "dd.MM.YYYY"
|
||||||
"format": "dd.MM.YYYY"
|
},
|
||||||
},
|
{
|
||||||
{
|
"style": "news",
|
||||||
"style": "news",
|
"lang": "en",
|
||||||
"lang": "en",
|
"format": "MM/dd/YY"
|
||||||
"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`.
|
||||||
|
|
||||||
```
|
The second parameter of these function is a date value, at the moment
|
||||||
Utils.formatDateTime('news', News.getDateTime(item))
|
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
|
<span>${Utils.formatDateTime("standard", News.getNewsDate(item))}</span>
|
||||||
|
|
||||||
|
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
|
01.04.2019
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue