Sitemaps.Config (Sitemaps v0.1.2)

Copy Markdown View Source

Configuration for the generation of the sitemap. Here we define some values that are going to be in use for the sitemap files or index files but we cannot add in the individual adds, i.e. hostname.

In addition, we define here some configuration for the maximum number of files, links, news, images, and sizes.

Summary

Types

t()

The configuration struct contains the following data

Functions

Returns a specification to start this module under a supervisor.

Set the configuration from default source. It's first trying to get from system environment variables and if they are not set, then from application configuration.

Let's configure the values of the configuration via the first parameter. If we pass nil then it's using configure/0. The order of the configuration is: parameter, or system environment variable, or configuration from the application.

Get the configuration from the agent where we have it stored.

Set the configuration inside of the agent.

Passing as first parameter a list of tuples, we use set/2 for setting each pair of key-value data from the overwrite parameter.

Types

keys()

@type keys() ::
  :max_sitemap_files
  | :max_sitemap_links
  | :max_sitemap_news
  | :max_sitemap_images
  | :max_sitemap_file_size
  | :host
  | :filename
  | :public_path
  | :files_path
  | :verbose
  | :compress
  | :create_index

t()

@type t() :: %Sitemaps.Config{
  compress: boolean(),
  create_index: boolean(),
  filename: String.t(),
  files_path: String.t(),
  host: String.t(),
  max_sitemap_file_size: pos_integer(),
  max_sitemap_files: pos_integer(),
  max_sitemap_images: pos_integer(),
  max_sitemap_links: pos_integer(),
  max_sitemap_news: pos_integer(),
  public_path: String.t(),
  verbose: boolean()
}

The configuration struct contains the following data:

  • max_sitemap_files: max sitemap links per index file.
  • max_sitemap_links: max links per sitemap.
  • max_sitemap_news: max news sitemap per index file.
  • max_sitemap_images: max images per URL.
  • max_sitemap_file_size: max sitemap file size in bytes.
  • host: your domain, also host with http/https scheme.
  • filename: name of the sitemap file.
  • public_path: after domain path's location on URL.
  • files_path: generating sitemaps to this directory path.
  • verbose: give more output for each step or not.
  • compress: if the sitemap files and indexes should be compressed.
  • create_index: if we need to create index files or not.

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

configure()

Set the configuration from default source. It's first trying to get from system environment variables and if they are not set, then from application configuration.

configure(overwrite)

Let's configure the values of the configuration via the first parameter. If we pass nil then it's using configure/0. The order of the configuration is: parameter, or system environment variable, or configuration from the application.

The environment variables you can set:

  • SITEMAPS_MAXFILES for :max_sitemap_files, default value: 10_000
  • SITEMAPS_MAXLINKS for :max_sitemap_links, default value: 10_000
  • SITEMAPS_MAXNEWS for :max_sitemap_news, default value: 1_000
  • SITEMAPS_MAXIMAGES for :max_sitemap_images, default value: 1_000
  • SITEMAPS_MAXFILESIZE for :max_sitemap_file_size, default value: 5_000_000
  • SITEMAPS_HOST for :host, default value: "http://www.example.com"
  • SITEMAPS_FILENAME for :filename, default value: "sitemap"
  • SITEMAPS_SITEMAPS_PATH for :files_path, default value: "sitemaps/"
  • SITEMAPS_PUBLIC_PATH for :public_path, default value: "sitemaps/"
  • SITEMAPS_VERBOSE for :verbose, default value: true
  • SITEMAPS_COMPRESS for :compress, default value: true
  • SITEMAPS_CREATE_INDEX for :create_index, default value: "auto"

get()

Get the configuration from the agent where we have it stored.

set(key, value)

@spec set(keys(), any()) :: :ok

Set the configuration inside of the agent.

update(overwrite)

@spec update([{keys(), any()}]) :: :ok

Passing as first parameter a list of tuples, we use set/2 for setting each pair of key-value data from the overwrite parameter.