Template files within Sympa and WWSympa are text files containing programming elements (variables, conditions, loops, file inclusions) that will be parsed in order to adapt to the runtime context. These templates are an extension of programs and therefore give access to a limited list of variables (those defined in the 'hash' parameter given to the parser).
Review the Site template files (12.2, page )
and List template files (13.7, page
).
The following describes the syntactical elements of templates.
Variables are enclosed between brackets '[]'. The variable name is composed of alphanumerics (0-1a-zA-Z) or underscores (_). The syntax for accessing an element in a 'hash' is [hash->elt].
Examples:
[url] [is_owner] [list->name] [user->lang]
For each template you wish to customize, check the available variables in the documentation.
Conditions include variable comparisons (= and <>), or existence. Syntactical elements for conditions are [IF xxx], [ELSE], [ELSIF xxx] and [ENDIF].
Examples:
[IF user->lang=fr] Bienvenue dans la liste [list->name] [ELSIF user->lang=es] Bienvenida en la lista [list->name] [ELSE] Welcome in list [list->name] [ENDIF] [IF is_owner] The following commands are available only for lists owners or moderators: .... [ENDIF]
Loops make it possible to traverse a list of elements (internally represented by a 'hash' or an 'array').
Example :
A review of public lists [FOREACH l IN lists] [l->NAME] [l->subject] [END]
[elt->NAME] is a special element of the current entry providing the key in the 'hash' (in this example the name of the list). When traversing an 'array', [elt->INDEX] is the index of the current entry.
You can include another file within a template . The specified file can be included as is, or itself parsed (there is no loop detection). The file path is either specified in the directive or accessed in a variable.
Inclusion of a text file :
[INCLUDE 'archives/last_message'] [INCLUDE file_path]
The first example includes a file whose relative path is archives/last_message. The second example includes a file whose path is in file_path variable.
Inclusion and parsing of a template file :
[PARSE 'welcome.tpl'] [PARSE file_path]
The first example includes the template file welcome.tpl. The second example includes a template file whose path is in file_path variable.
You may need to exclude certain lines in a template from the parsing process. You can perform this by stopping and restarting the parsing.
Escaping sensitive JavaScript functions :
<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- for other browsers function toggle_selection(myfield) { for (i = 0; i < myfield.length; i++) { [escaped_stop] if (myfield[i].checked) { myfield[i].checked = false; }else { myfield[i].checked = true; } [escaped_start] } } // end browsers --> </SCRIPT> </HEAD>
You can change the parser's behvior by setting unsetting options. Available options are :
[SETOPTION ignore_undef] Here is an unparsed undef variable : [unknown_var] [UNSETOPTION ignore_undef]
[SETOPTION escape_html] [INCLUDE '/var/www/html/sample.html] [UNSETOPTION escape_html]
These files are used by Sympa as service messages for the HELP,
LISTS and REMIND * commands. These files are interpreted
(parsed) by Sympa and respect the template format ; every file has a .tpl extension.
See 12.1,
page .
Sympa looks for these files in the following order (where <list> is the listname if defined, <action> is the name of the command, and <lang> is the preferred language of the user) :
If the file starts with a From: line, it is considered as a full message and will be sent (after parsing) without adding SMTP headers. Otherwise the file is treated as a text/plain message body.
The following variables may be used in these template files :
This file is sent in response to a HELP command. You may use additional variables
File returned by LISTS command. An additional variable is available :
Example:
These are the public lists for [conf->email]@[conf->domain] [FOREACH l IN lists] [l->NAME]: [l->subject] [END]
This file is sent in response to a REMIND * command.
(see 21.2, page )
You may use additional variables
Example:
This is a subscription reminder. You are subscribed to the following lists : [FOREACH l IN lists [l] : [conf->wwsympa\_url]/info/[l] [END] Your subscriber e-mail : [user->email] Your password : [user->password]
This message is sent to warn the sender of a virus infected mail,
indicating the name of the virus found
(see , page
).
You may define your own web template files, different from the standard ones. WWSympa first looks for list specific web templates, then for site web templates, before falling back on its defaults.
Your list web template files should be placed in the /home/sympa/expl/mylist/wws_templates directory ; your site web templates in ~/home/sympa/expl/wws_templates directory.
There are actually 2 ways a template can include another template :
[PARSE '/home/sympa/bin/etc/wws_templates/loginbanner.us.tpl'].If you customize the loginbanner.us.tpl, you also have to customize templates that refer to it.
[PARSE action_template]
Then wwsympa.fcgi sets action_template variable to the appropriate template file path (ie : in the best place according to Sympa default rules, and in the current language).
We use (2) for some high level templates (action_template, error_template, notice_template, title_template, menu_template, list_menu_template, admin_menu_template) but then we use (1) for lower-level template inclusions.
Note that web colors are defined in Sympa's main Makefile (see 3.3,
page ).
You may extract subscribers for a list from any of :
See lparam user_data_source liste parameter 15.2.1, page .
The subscriber_table and user_table can have more fields than
the one used by Sympa. by defining these additional fields, they will be available
from within Sympa's authorization scenarios and templates (see 5.10.9,
page and 5.10.10, page
).
See 9.6, page .
Sympa was originally designed as a multilingual Mailing List Manager. Even in its earliest versions, Sympa separated messages from the code itself, messages being stored in NLS catalogues (according to the XPG4 standard). Later a lang list parameter was introduced. Nowadays Sympa is able to keep track of individual users' language preferences.
Every message sent by Sympa to users, owners and editors is outside the code, in a message catalog. These catalogs are located in the /home/sympa/nls directory. Messages have currently been translated into 14 different languages :
To tell Sympa to use a particular message catalog, you can either set the lang parameter in sympa.conf, or set the sympa.pl -l option on the command line.
The lang list parameter defines the language for a list. It is currently used by WWSympa and to initialize users' language preferences at subscription time.
In future versions, all messages returned by Sympa concerning a list should be in the list's language.
The user language preference is currently used by WWSympa only. There is no e-mail-based command for a user to set his/her language. The language preference is initialized when the user subscribes to his/her first list. WWSympa allows the user to change it.
WWSympa's homepage shows a list of topics for classifying mailing lists. This is dynamically generated using the different lists' topics configuration parameters. A list may appear in multiple categories.
The list of topics is defined in the topics.conf configuration file, located in the /home/sympa/etc directory. The format of this file is as follows :
<topic1_name> title <topic1 title> visibility <topic1 visibility> .... <topicn_name/subtopic_name> title <topicn title>
You will notice that subtopics can be used, the separator being /. The topic name is composed of alphanumerics (0-1a-zA-Z) or underscores (_). The order in which the topics are listed is respected in WWSympa's homepage. The visibility line defines who can view the topic (now available for subtopics). It refers to the associated topics_visibility authorization scenario. You will find a sample topics.conf in the sample directory ; NONE is installed as the default.
A default topic is hard-coded in Sympa: default. This default topic contains all lists for which a topic has not been specified.
See 10, page .
Sympa uses multiple heuristics to avoid loops in Mailing lists
First, it rejects messages coming from a robot (as indicated by the From: and other header fields), and messages containing commands.
Secondly, every message sent by Sympa includes an X-Loop header field set to the listname. If the message comes back, Sympa will detect that it has already been sent (unless X-Loop header fields have been erased).
Thirdly, Sympa keeps track of Message IDs and will refuse to send multiple messages with the same message ID to the same mailing list.
Finally, Sympa detect loops arising from command reports (i.e. sympa-generated replies to commands). This sort of loop might occur as follows:
1 - X sends a command to Sympa 2 - Sympa sends a command report to X 3 - X has installed a home-made vacation program replying to programs 4 - Sympa processes the reply and sends a report 5 - Looping to step 3
Sympa keeps track (via an internal counter) of reports sent to any particular address. The loop detection algorithm is :
A task is a sequence of simple actions which realize a complex routine. It is executed in background by the task manager daemon and allow the list master to automate the processing of recurrent tasks. For example a task sends every year the subscribers of a list a message to remind their subscription.
A task is created with a task model. It is a text file which describes a sequence of simple actions. It may have different versions (for instance reminding subscribers every year or semester). A task model file name has the following format : <model name>.<model version>.task. For instance remind.annual.task or remind.semestrial.task.
Sympa provides several task models stored in /home/sympa/bin/etc/global_task_models and /home/sympa/bin/etc/list_task_models directories. Others can be designed by the listmaster.
A task is global or related to a list.
You define in the list config file the model and the version you want to use (see
15.3.5, page ). Then the task manager daemon will automatically
create the task by looking for the appropriate model file in different directories in the
following order :
See also 13.9, page , to know more about standard list models provided with Sympa.
The task manager daemon checks if a version of a global task model is specified in sympa.conf and then creates a task as soon as it finds the model file by looking in different directories in the following order :
Model files are composed of comments, labels, references, variables, date values and commands. All those syntactical elements are composed of alphanumerics (0-9a-zA-Z) and underscores (_).
Here is the list of current avalable commands :
Stops the execution of the task and delete the task file
Stop the execution. The task will go on at the date value and begin at the label line.
Delete @user_selection email list and stores user emails successfully deleted in @deleted_users.
Send the template message to emails stored in @user_selection.
Store emails which match the condition in @user_selection. See 8.6 Authorization Scenarios section to know how to write conditions. Only available for list models.
Create a task for object with model file ~model type.model.task.
Send the template message to emails whose certificate has expired or will expire before the date value.
Update certificate revocation lists (CRL) which are expired or will expire before the date value. The file stores the CRL's URLs.
Clean bounces by removing unsubscribed-users archives.
Evaluate all bouncing users of all list and give them a score from 0 to 100. (0 = no bounces for this user, 100 is for users who should be removed).
Execute actions defined in list configuration on each bouncing users, according to their score.
Model files may have a scenario-like title line at the beginning.
When you change a configuration file by hand, and a task parameter is created or modified, it is up to you to remove existing task files in the task/ spool if needed. Task file names have the following format :
<date>.<label>.<model name>.<list name | global> where :
title.fr mise a jour quotidienne des listes de révocation title.us daily certificate revocation list update title.et sertifikaatide kehtivuse nimekirja uuendatakse iga päev title.hu napi frissítése a hitelesítési bizonylatok visszavonásának /ACTION update_crl (CA_list, [execution_date]+1d) next ([execution_date] + 1d, ACTION)