Project configuration file
Overview
The project.conf file (placed in config directory) is the place where the settings for application are stored. Having everything in one configuration file makes it easier to understand, maintain and develop.
Configuration file contains Erlang tuples: the first element of each is the option name; the second element is the option value.
All settings are read during the start of the application, so after every change we must reload them manually, by typing
e_conf:reinstall().
Types of options
The following options are being used in the application:
{upload_dir, Dir}
Dir specifies the directory, where the user's uploaded files will be stored. The set directory will be placed inside the docroot folder. By default it is set to upload. This option can be accessed with the command:
e_conf:upload_dir().
{default_language, LanguageCode}
LanguageCode specifies the default language of translation: if none is set in thesession:lang key in e_dict, this one will be used. By default it is set to en. This option can be accessed with command:
e_conf:default_language().
{language_files, [LanguageFilesSpecs]}
LanguageFilesSpecs specifies the language files with the translations. This option has been described in more detail in e_lang section.
{cache_dir, Dir}
Dir is the directory, where the cached templates are stored. By default it is set to templates/cache. This option can be accessed with the command:
e_conf:cache_dir().
{host, Host}
Host is the absolute address of the service. It can be helpful for building absolute links. By default it is set to localhost. This option can be accessed with the command:
e_conf:host().
{primitive_types, ListOfPrimitiveTypes}
ListOfPrimitiveTypes defines user-prepared primitive types, which can be used in building application models. We have to provide both wpart_NameOfTheType and wtype_NameOfTheType modules with the corresponding wpart and wtype behaviours. By default it is set to []. This option can be accessed with the command:
e_conf:primitive_types().
{debug_mode, Bool}
Bool specifies if debugging mode is enabled. If so, all Erlang errors will be rendered as an error 501 (with explanations) instead of displaying the user-specified template. By default it is set to false. This option can be accessed with command:
e_conf:debug_mode().
{http_port, PortNo}
{https_port, PortNo}
PortNo specifies the port number for the incoming http and https connections. The numbers should be the same as those in the server configuration file. They can be used in the redirection between protocols if running on different than the default ports (80 for http and 443 for https). These options can be accessed with the commands:
e_conf:http_port().
e_conf:https_port(). To easily redirect user from http to https connection, just return:
{redirect, "https://" ++ e_conf:host() ++ ":" ++ e_conf:https_port() ++ "/" ++ wpart:fget("__path")}.If the server is running on the default ports we can return:{redirect, "https://" ++ e_conf:host() ++ "/" ++ wpart:fget("__path")}.{project_name, Name}
Name specifies the string representing the project name. By default is set to erlang-web. This option can be accessed with the command:
e_conf:project_name().
{couchdb_address, URL}
URL specifies the CouchDB address. This address is used only when our DBMS is set to CouchDB for communicating with CouchDB server. By default it is set to http://localhost:5984/. This option can be accessed with the command:
e_conf:couchdb_address().
{dbms, DBMS}
DBMS is the type of the DB engine used in our project. It could either mnesia or couchdb. This option has been described in more detail in e_db section. By default it is set to mnesia.
You can also place your own options inside the project.conf file. These settings can be found in e_conf ets table under your own defined key.
Example
This is a simple example of project.conf file:
{upload_dir, "user_upload"}.
{host, "example.org"}.
{default_language, de}.
{language_files, [{en, "config/languages/en.conf"},
{de, "config/languages/de.conf"}]}.
{admin_logins, [adam, michael]}.
{primitive_types, [embedded_video]}.The configuration of your application will be as follows:
upload directory will be set to user_upload
hostname will be set to example.org
default language for the translation will be de
there will be two translation files: for en - (config/languages/en.conf) and for de - (config/languages/de.conf)
cache directory will be set to templates/cache (by default)
user-defined setting, admin logins will be set to [adam, michael]
there will be a new primitive type: embedded_video
