preview-notification-theme
Renders the email notification templates of a notification theme folder with the same MVEL engine as the server, and writes an HTML file and an .eml file for each language and each preview scenario. Use it to check a theme exported with export-notification-theme and modified on disk, before importing it again with import-notification-themes.
The command only reads the files of the theme: it does not connect to the database and does not need a running S-Filer server. The -l, -p and -cf global options are therefore not needed.
Syntax:
sfiler-config-cli [options] preview-notification-theme [command options]| Command options | Required / Optional | Description |
|---|---|---|
| -tp | Required | The directory of the unzipped theme: the folder named after the theme id (for example .../123/), or a parent folder that contains only this theme folder. |
| -od | Optional | The output directory where the generated files will be saved. If not provided, the files are saved in the email-preview-output folder of the current folder. |
| -lang | Optional | The language folders to render, separated by commas (for example en,fr). If not provided, every language folder of the theme that contains templates is rendered. |
| -sc | Optional | The ids of the preview scenarios to render, separated by commas. If not provided, all the scenarios are rendered. An id that matches no scenario is ignored; when none of the ids matches, the command lists the available ids. |
| -json | Optional | The path to a scenarios file that replaces the scenarios bundled with the command. See Preview scenarios. |
| -iu | Optional | The base URL that replaces the imagesurl variable, so that the icons of the notifications are displayed. See Displaying the icons. |
Example:
This command renders the notification of a file added to a community, in English and in French, from the theme exported and unzipped in the /tmp/theme directory.
./sfiler-config-cli.sh preview-notification-theme -tp "/tmp/theme" -od "/tmp/theme-preview" -lang en,fr -sc file_available_comm__with_note.\sfiler-config-cli.bat preview-notification-theme -tp "C:\temp\theme" -od "C:\temp\theme-preview" -lang en,fr -sc file_available_comm__with_noteThe files are written in one folder per language, with the .eml files in an eml subfolder:
theme-preview/
en/
file_available_comm__with_note.html
eml/
file_available_comm__with_note.eml
fr/
file_available_comm__with_note.html
eml/
file_available_comm__with_note.emlOpen the HTML file in a web browser to review the notification. Open the .eml file in Outlook or in another email client to see the notification as its recipients will see it, with its rendered subject.
Messages of the command
| Message | Meaning |
|---|---|
Warning: unknown variables [...] render empty [<language>/<scenario>] | A template uses a variable that no notification provides, usually because of a typing error. The variable is rendered as empty text, without error, both in the preview and on the server. |
Skip (missing template: <language>/<file>) [<scenario>] | The theme has no template for this scenario in this language. The scenario is not rendered in this language. |
Templates found in the theme but not covered by any preview scenario (not rendered) | The listed templates are present in the theme, but no scenario renders them. |
Warning: the [-iu] base URL already contains images/email, which the templates append themselves. The image paths will be doubled. | The -iu base URL ends with images/email. Remove it from the URL: the templates add it themselves. |
MVEL error for scenario [<scenario>] language [<language>] in <file>: ... | A template cannot be evaluated, for example because of an unclosed @if{} tag. The command stops and names the file and the cause of the error. |
See Also
Notification template variables lists the variables that the templates can use.
Preview scenarios
A scenario describes what a template is rendered with: the body template to load, and sample values for the variables of the notification (recipient name, file name, community, message of the sender, and so on). The command comes with scenarios for every notification of the base theme, often several per notification, for example file_deleted, file_deleted__anonymous and file_deleted__folder. To list their ids, run the command with an id that does not exist, such as -sc list.
To render other values, write your own scenarios file and pass it with -json. This file replaces the bundled scenarios: it is not merged with them, so it must contain every scenario you want to render. Start from the bundled file, which is the email-preview/preview-scenarios.json entry of sfiler-config-cli.jar. These commands, run in the folder of the configuration CLI, extract it to email-preview/preview-scenarios.json:
unzip sfiler-config-cli.jar email-preview/preview-scenarios.jsontar -xf sfiler-config-cli.jar email-preview/preview-scenarios.json{
"scenarios": [
{
"id": "user_share__with_note",
"description": "Invitation to a community, with a message from the sender",
"bodyFile": "user_share_body.html",
"framework": true,
"mock": {
"userfullname": "Jane Recipient",
"community": "Project Phoenix",
"inviter": "Alex Sender",
"messagetorecipients": "Please register before Friday."
}
}
]
}| Field | Description |
|---|---|
id | Required. The id selected by -sc, and the name of the generated files. Give each scenario its own id: the command does not check it, and two scenarios with the same id write the same files. |
description | Optional. Documents the scenario; it is not used to render it. |
bodyFile | Required. The name of the body template, as it exists in each language folder. |
framework | true to insert the body in framework.html. Only the SMS templates, which stand alone, use false. Default: false. |
mock | The values of the @{...} variables of the template. |
- The
mockvalues are flat, except for the consolidated email:consolidated_email_body.htmlreads@{vars.variable}and expects avarsobject, built as follows:- The text values of
varsare the top-level variables of the email, such asuserfullname,login_urlorsolutionName. The template reads them as@{vars.userfullname}. - Each list of
vars, such asfilesAvailableCommunity,usersAddedToShareoraccountsWillBeDeleted, holds the notifications of one type gathered in the email: one object per notification, with the fields of this notification as text values. A list that the scenario leaves out is empty, and the email shows no notification of this type. - Do not write
filesAvailable,filesAvailableListingor the lists whose name ends withGroups: the command builds them from the other lists, with the grouping and the sorting of the server (see Pre-grouped lists). - The dates of the notifications are given as instants, for example
expirationInstant. The command adds the formatted dates that the template displays, as the server does. An empty text means that the date does not apply. - The values outside
vars, such asuserfullnameorrecipientAccountType, are still needed:framework.htmlreads them for the header and the footer of the email.
- The text values of
- A variable missing from
mockis rendered as empty text, as on the server. To render a notification without a message from the sender, leave outmessagetorecipients. - The values are inserted as they are, without escaping: a value can contain HTML.
- The dates are written as ISO-8601 text (for example
uploadInstant). The preview displays them in the language of the rendered folder, in UTC.
Displaying the icons
The icons of the notifications are served by S-Filer under images/email/, and the templates reference them through the imagesurl variable. The bundled scenarios set this variable to an example address, so the icons are not displayed. To display them, pass a base URL with -iu:
the address of the S-Filer web interface, which is what the recipients use:
-iu https://portal.example.com/;or, to preview without a running server, the folder of the
sfiler-gui-ajaxweb application of a gateway, with thefile://scheme. With the default installation folders:- on Windows (installer):
-iu file:///C:/Program%20Files/Okiok%20Data/sfiler-gateway/gateway/webapps/sfiler-gui-ajax/ - on Linux (APT package):
-iu file:///opt/sfiler-gateway/webapps/sfiler-gui-ajax/
Write each space of the path as
%20: a URL that contains a space is refused.- on Windows (installer):
The base URL must be absolute (http://, https:// or file://). It should not contain images/email, which the templates add themselves: the command then displays a warning, and the image paths are doubled. A trailing slash is added when it is missing.
Warning
A web browser blocks the images of an http://localhost address when the HTML file is opened from the disk. In that case, use the file:// form.
