diff --git a/ccm-cms-assets-fileattachment/doc/freemarker/ccm-cms-assets-fileattachment.md b/ccm-cms-assets-fileattachment/doc/freemarker/ccm-cms-assets-fileattachment.md new file mode 100644 index 000000000..376f32b64 --- /dev/null +++ b/ccm-cms-assets-fileattachment/doc/freemarker/ccm-cms-assets-fileattachment.md @@ -0,0 +1,169 @@ +### ccm-cms-assets-fileattachment + +This module provides functions for dealing with file attachments. A +possible usage these functions: + +``` +<#list FileAttachments.getFileAttachments(item)> +
+#list> +``` + +#### getFileAttachments + + getFileAttachments(item: ContentItemNode): Sequence + +Return the file attachments of a content items + +##### Parameters + +`item` The content item from which the file attachments are retrieved. + +##### Returns + +A sequence of the file attachments of the provided content item. + +#### getFileType + + getFileType(file) + +Returns the type of the file attachments which is either `caption` or `file`. + +##### Parameters + +`file` The file attachment + +##### Returns + +The type of the file attachment. + +#### getMimeType + + getMimeType(file) + +Returns the mime type of the file. + +##### Parameters + +`file` The file + +##### Returns + +The mime type of the file. + +#### getMimeTypeFileExtension + + getMimeTypeFileExtension(file) + +Returns the usual file extension for the mime type of the file. + +##### Parameters + +`file` The file + +##### Returns + +The usual file extension for the mime type of the file. + +#### getFileSize + + getFileSize(file unit="byte") + +Returns the size of the file in the provided unit. + +##### Parameters + +`file`The file + +`unit` Optional parameter for unit in which the size is returned. Default +value is `byte`. Supported values are `byte`, `kB` `KiB`, `MB` and `MiB`. +All other values are interpreted as `byte`. + +##### Returns + +The size of the file in the provided unit. + + +#### getFileId + + getFileId(file) + +Returns the ID of the file. + +##### Parameters + +`file` The file + +##### Returns + +The ID of the file. + +#### getFileName + + getFileName(file) + +Returns the name of file. + +##### Parameters + +`file` The file + +##### Returns + +The name of the file. + +#### getFileDescription + + getFileDescription(file) + +Returns the name of file. + +##### Parameters + +`file` The file + +##### Returns + +The description of the file. + +#### getFileUrl + + getFileUrl(file) + +Returns the name of file. + +##### Parameters + +`file` The file + +##### Returns + +The URL of the file. diff --git a/ccm-cms-assets-imagestep/doc/freemarker/ccm-cms-assets-imagestep.md b/ccm-cms-assets-imagestep/doc/freemarker/ccm-cms-assets-imagestep.md new file mode 100644 index 000000000..0de2ec64e --- /dev/null +++ b/ccm-cms-assets-imagestep/doc/freemarker/ccm-cms-assets-imagestep.md @@ -0,0 +1,143 @@ +### ccm-cms-assets-imagestep + +Provides functions for dealing with image attachments of a content item. + +Import path: `<#import "/ccm-cms-assets-imagestep.ftl" as Images>` + +Example usage: + +``` +<#import "/ccm-cms-assets-imagestep.ftl" as Images> + +<#list Images.getImageAttachments(item)> + +#list> +``` + +#### getImageAttachments + + getImageAttachments(item) + +Get the image attachments of a content item + +##### Parameters + +`item` The content item. + +##### Returns + +A sequence of the image attachments of the provided content item. + +#### getImageId + + getImageId(image) + +Get the ID of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The id of the image. + +#### getImageName + + getImageName(image) + +Gets the name of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The name of the image. + +#### getImageCaption + + getImageCaption(image) + +Gets the caption of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The caption of the image. + +#### getImageSortKey + + getImageSortKey(image) + +Gets the sort key of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The sort key of the provided image. + +#### getImageWidth + + getImageWidth(image) + +Gets the width of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The width of the provided image. + +#### getImageHeight + + getImageHeight(image) + +Gets the height of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The height of the provided image. + +#### getImageUrl + + getImageUrl(image) + +Gets the URL of the provided image. + +##### Parameters + +`image` The image. + +##### Returns + +The URL of the provided image. + diff --git a/ccm-bookmarks/web/themes/freemarker/ccm-cms-types-bookmark.ftl b/ccm-cms-types-bookmark/web/themes/freemarker/ccm-cms-types-bookmark.ftl similarity index 100% rename from ccm-bookmarks/web/themes/freemarker/ccm-cms-types-bookmark.ftl rename to ccm-cms-types-bookmark/web/themes/freemarker/ccm-cms-types-bookmark.ftl diff --git a/ccm-themedirector/doc/freemarker/ccm-themedirector.md b/ccm-themedirector/doc/freemarker/ccm-themedirector.md index 9af9cb2a0..29c813db8 100644 --- a/ccm-themedirector/doc/freemarker/ccm-themedirector.md +++ b/ccm-themedirector/doc/freemarker/ccm-themedirector.md @@ -2,7 +2,7 @@ #### Language related -Import path: `<#import /utils.ftl as Utils>` +Import path: `<#import /language.ftl as Lang>` ##### `getAvailableLanguages` @@ -22,3 +22,107 @@ This example uses the `list` directive from Freemarker to iterate over the avail check if the curent language is the selected language. If this is the case a CSS class is added to the HTML. +#### Basic functions + +Import path: `<#import /utils.ftl as Utils>` + +##### getPageApplication + + getPageApplication() + +Return the application of the current page. + +##### getPageTitle + + getPageTitle() + +Returns the title of the current page + +##### getSiteHostName + + getSiteHostName() + +Returns the name of the host serving the site. + +##### getSiteName + + 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 +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) + +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` +section. It is possible to define different styles for different languages. +The style definition in the theme manifest must be in the format expected by the Java +[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 + +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" + }, + ... +] +``` + +The use this format: + +``` +Utils.formatDateTime('news', News.getDateTime(item)) +``` + +`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 + + 01.04.2019 + +and for english: + + 4/1/19 + + diff --git a/doc/themes-with-freemarker/makefile b/doc/themes-with-freemarker/makefile index ac74b5e15..fd3eaf9ea 100644 --- a/doc/themes-with-freemarker/makefile +++ b/doc/themes-with-freemarker/makefile @@ -1,7 +1,12 @@ +FILES = themes-with-freemarker.md +FILES += ../../ccm-themedirector/doc/freemarker/ccm-themedirector.md +FILES += ../../ccm-cms-assets-fileattachment/doc/freemarker/ccm-cms-assets-fileattachment.md +FILES += ../../ccm-cms-assets-imagestep/doc/freemarker/ccm-cms-assets-imagestep.md + all: html pdf html: - pandoc -t html -o themes-with-freemarker.html themes-with-freemarker.md ../../ccm-themedirector/doc/freemarker/ccm-themedirector.md + pandoc -t html -o themes-with-freemarker.html ${FILES} pdf: - pandoc -t latex -o themes-with-freemarker.pdf themes-with-freemarker.md ../../ccm-themedirector/doc/freemarker/ccm-themedirector.md + pandoc -t latex -o themes-with-freemarker.pdf ${FILES} diff --git a/doc/themes-with-freemarker/themes-with-freemarker.html b/doc/themes-with-freemarker/themes-with-freemarker.html index 511888698..539b50b30 100644 --- a/doc/themes-with-freemarker/themes-with-freemarker.html +++ b/doc/themes-with-freemarker/themes-with-freemarker.html @@ -39,8 +39,8 @@Import path: <#import /utils.ftl as Utils>
Sequence getAvailableLanguagesImport path: <#import /language.ftl as Lang>
getAvailableLanguagesSequence getAvailableLanguages()
Returns the available languages for the current document as sequence. These sequence can be used for creating links for selecting the language:
<ul class="language-selector">
@@ -48,3 +48,233 @@
<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 check if the curent language is the selected language. If this is the case a CSS class is added to the HTML.
Import path: <#import /utils.ftl as Utils>
getPageApplication()
+Return the application of the current page.
+getPageTitle()
+Returns the title of the current page
+getSiteHostName()
+Returns the name of the host serving the site.
+getSiteName()
+Returns the name of the site.
+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 are interpreted as true: true, yes. All other values are interpreted as false.
fromNode A XML node
attrName The name of attribute to interpret as boolean
A boolean for the value of the attribute. If the attribute is not present in the provided node the function returns false.
formatDateTime(style: String date: Node)
+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 section. It is possible to define different styles for different languages. The style definition in the theme manifest must be in the format expected by the Java DateTimeFormatter class.
style A date-time format defined in the theme manifest. The format must be formatted as expected by the DateTimeFormatter class.
date The node providing the data of the date to format.
A date formatted as defined in style.
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"
+ },
+ ...
+]
+The use this format:
+Utils.formatDateTime('news', News.getDateTime(item))
+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
01.04.2019
+and for english:
+4/1/19
+This module provides functions for dealing with file attachments. A possible usage these functions:
+<#list FileAttachments.getFileAttachments(item)>
+ <div class="file-attachments">
+
+ <h2>
+ ${getLocalizedText("layout.page.main.fileAttachments")}
+ </h2>
+
+ <ul class="file-attachments">
+ <#items as file>
+ <#if FileAttachments.getFileType(file) == "caption">
+ <li class="caption">
+ <strong>${FileAttachments.getFileName(file)}</strong>
+ <p>
+ ${FileAttachments.getFileDescription(file)}
+ </p>
+ </li>
+ <#else>
+ <li class="file-attachment">
+ <a href="${FileAttachments.getFileUrl(file)}">
+ <span class="fa fa-download"></span>
+ ${FileAttachments.getFileDescription(file)}
+ (${FileAttachments.getMimeTypeFileExtension(file)},
+ ${FileAttachments.getFileSize(file, "KiB")} KB)
+
+ </a>
+ </li>
+ </#if>
+ </#items>
+ </ul>
+ </div>
+</#list>
+getFileAttachments(item: ContentItemNode): Sequence
+Return the file attachments of a content items
+item The content item from which the file attachments are retrieved.
A sequence of the file attachments of the provided content item.
+getFileType(file)
+Returns the type of the file attachments which is either caption or file.
file The file attachment
The type of the file attachment.
+getMimeType(file)
+Returns the mime type of the file.
+file The file
The mime type of the file.
+getMimeTypeFileExtension(file)
+Returns the usual file extension for the mime type of the file.
+file The file
The usual file extension for the mime type of the file.
+getFileSize(file unit="byte")
+Returns the size of the file in the provided unit.
+fileThe file
unit Optional parameter for unit in which the size is returned. Default value is byte. Supported values are byte, kB KiB, MB and MiB. All other values are interpreted as byte.
The size of the file in the provided unit.
+getFileId(file)
+Returns the ID of the file.
+file The file
The ID of the file.
+getFileName(file)
+Returns the name of file.
+file The file
The name of the file.
+getFileDescription(file)
+Returns the name of file.
+file The file
The description of the file.
+getFileUrl(file)
+Returns the name of file.
+file The file
The URL of the file.
+Provides functions for dealing with image attachments of a content item.
+Import path: <#import "/ccm-cms-assets-imagestep.ftl" as Images>
Example usage:
+<#import "/ccm-cms-assets-imagestep.ftl" as Images>
+
+<#list Images.getImageAttachments(item)>
+ <div class="image-attachments">
+ <#items as image>
+ <figure>
+ <div>
+ <a data-fancybox="gallery">
+ <img src="${Images.getImageUrl(image)}"
+ width="100%"
+ height="auto" />
+ </a>
+ </div>
+ <figcaption>
+ ${Images.getImageCaption(image)}
+ </figcaption>
+ </figure>
+ </#items>
+ </div>
+</#list>
+getImageAttachments(item)
+Get the image attachments of a content item
+item The content item.
A sequence of the image attachments of the provided content item.
+getImageId(image)
+Get the ID of the provided image.
+image The image.
The id of the image.
+getImageName(image)
+Gets the name of the provided image.
+image The image.
The name of the image.
+getImageCaption(image)
+Gets the caption of the provided image.
+image The image.
The caption of the image.
+getImageSortKey(image)
+Gets the sort key of the provided image.
+image The image.
The sort key of the provided image.
+getImageWidth(image)
+Gets the width of the provided image.
+image The image.
The width of the provided image.
+getImageHeight(image)
+Gets the height of the provided image.
+image The image.
The height of the provided image.
+getImageUrl(image)
+Gets the URL of the provided image.
+image The image.
The URL of the provided image.
diff --git a/doc/themes-with-freemarker/themes-with-freemarker.pdf b/doc/themes-with-freemarker/themes-with-freemarker.pdf index d95162983..639c4a168 100644 Binary files a/doc/themes-with-freemarker/themes-with-freemarker.pdf and b/doc/themes-with-freemarker/themes-with-freemarker.pdf differ