Skip to content

preview-notification-theme ​

Available in4.21.0 +

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:

shell
sfiler-config-cli [options] preview-notification-theme [command options]
Command optionsRequired / OptionalDescription
-tpRequiredThe 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.
-odOptionalThe 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.
-langOptionalThe 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.
-scOptionalThe 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.
-jsonOptionalThe path to a scenarios file that replaces the scenarios bundled with the command. See Preview scenarios.
-iuOptionalThe 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.

shell
./sfiler-config-cli.sh preview-notification-theme -tp "/tmp/theme" -od "/tmp/theme-preview" -lang en,fr -sc file_available_comm__with_note
shell
.\sfiler-config-cli.bat preview-notification-theme -tp "C:\temp\theme" -od "C:\temp\theme-preview" -lang en,fr -sc file_available_comm__with_note

The 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.eml

Open 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 ​

MessageMeaning
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:

shell
unzip sfiler-config-cli.jar email-preview/preview-scenarios.json
shell
tar -xf sfiler-config-cli.jar email-preview/preview-scenarios.json
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."
      }
    }
  ]
}
FieldDescription
idRequired. 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.
descriptionOptional. Documents the scenario; it is not used to render it.
bodyFileRequired. The name of the body template, as it exists in each language folder.
frameworktrue to insert the body in framework.html. Only the SMS templates, which stand alone, use false. Default: false.
mockThe values of the @{...} variables of the template.
  • The mock values are flat, except for the consolidated email: consolidated_email_body.html reads @{vars.variable} and expects a vars object, built as follows:
    • The text values of vars are the top-level variables of the email, such as userfullname, login_url or solutionName. The template reads them as @{vars.userfullname}.
    • Each list of vars, such as filesAvailableCommunity, usersAddedToShare or accountsWillBeDeleted, 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, filesAvailableListing or the lists whose name ends with Groups: 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 as userfullname or recipientAccountType, are still needed: framework.html reads them for the header and the footer of the email.
  • A variable missing from mock is rendered as empty text, as on the server. To render a notification without a message from the sender, leave out messagetorecipients.
  • 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-ajax web application of a gateway, with the file:// 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.

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.