z_sites_config (zotonic_core v1.0.0-rc.17)

Load and manage site configuration files.

Summary

Functions

Check if the Erlang application is a Zotonic site. A Zotonic site has a site configuration file in its priv directory.

Iff a site is running in backup environment, and its config files are restored from a remote system, then the environment in the config file is overwritten by the config from the remote environment. To keep the site in backup environment, we write a file "priv/BACKUP". If this file is present then it is hard-coded to set the environment to backup and the site to enabled.

Remove the priv/BACKUP file. After this the site will use the environment from the config files.

Merge the global config options into the site's options, adding defaults.

Functions

app_is_site(App)

-spec app_is_site(atom()) -> boolean().

Check if the Erlang application is a Zotonic site. A Zotonic site has a site configuration file in its priv directory.

config_files(Site)

-spec config_files(atom()) -> [file:filename_all()].

config_files(Node, Site)

-spec config_files(node(), atom()) -> [file:filename_all()].

maybe_set_backup_env(Context)

-spec maybe_set_backup_env(Context) -> ok | {error, Reason}
                              when Context :: z:context(), Reason :: term().

Iff a site is running in backup environment, and its config files are restored from a remote system, then the environment in the config file is overwritten by the config from the remote environment. To keep the site in backup environment, we write a file "priv/BACKUP". If this file is present then it is hard-coded to set the environment to backup and the site to enabled.

maybe_unset_backup_env(Context)

-spec maybe_unset_backup_env(Context) -> ok | {error, Reason}
                                when Context :: z:context(), Reason :: term().

Remove the priv/BACKUP file. After this the site will use the environment from the config files.

merge_global_configs(Sitename, SiteConfig, GlobalConfig)

-spec merge_global_configs(Sitename, SiteConfig, GlobalConfig) -> MergedConfig
                              when
                                  Sitename :: atom(),
                                  SiteConfig :: map(),
                                  GlobalConfig :: map(),
                                  MergedConfig :: map().

Merge the global config options into the site's options, adding defaults.

read_configs(Fs)

-spec read_configs([file:filename_all()]) -> {ok, map()} | {error, term()}.

security_dir(Site)

-spec security_dir(atom()) -> {ok, file:filename_all()} | {error, term()}.

site_config(Site)

-spec site_config(Site) -> {ok, Config} | {error, Reason}
                     when Site :: atom(), Config :: map(), Reason :: term().