blogit v1.2.3 Blogit.Settings View Source
Provides application-wide settings for Blogit
.
All of the functions in this modules are settings, which can be reused through the other modules.
Link to this section Summary
Functions
Returns a list of the additional or secondary languages configured for
Bogit
. These are all the language without the first one from :languages
configuration like this one
Returns the path to the configuration file of Blogit
. It can be configured
like this
Returns the default language configured for Blogit
. This is the first
language in the list of languages configured like this
Retrieves the list of supported languages configured for Blogit
.
Returns how many lines of the source file of a post should be used for
generating its preview. Can be configured in the Blogit
configuration
Returns the string "\n---\n"
- the divider used to separate the meta data
from the post content in the post markdown files. It's advisable to have it on
two places - before and after the metadata
Returns the interval used when polling the source repository for changes.
It is used only if Blogit.Settings.polling?()
returns true
.
The value is the interval in milliseconds. The configuration is specified
in seconds, like this
Returns true if polling the source repository for changes is configured to be 'on'. That can be done like this
Returns the string "posts"
- the location of the posts folder in the
repository. A custom provider can opt to not use this default location, but
the Blogit.RepositoryProviders.Git
provider expects posts to be located
in a folder named posts
in the root of the repository.
Link to this section Functions
Returns a list of the additional or secondary languages configured for
Bogit
. These are all the language without the first one from :languages
configuration like this one:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
languages: ~w(bg en)
By default it is an empty list.
Examples
iex> Application.put_env(:blogit, :languages, ["es", "bg", "de"])
iex> Blogit.Settings.additional_languages()
["bg", "de"]
iex> Application.delete_env(:blogit, :languages) # Use default
iex> Blogit.Settings.additional_languages()
[]
Returns the path to the configuration file of Blogit
. It can be configured
like this:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
configuration_file: path-to-the-file.yml
By default it is in the root of the repository and called 'blog.yml'.
Examples
iex> Application.put_env(:blogit, :configuration_file, "my_conf.yml")
iex> Blogit.Settings.configuration_file()
"my_conf.yml"
iex> Application.delete_env(:blogit, :configuration_file) # Use default
iex> Blogit.Settings.configuration_file()
"blog.yml"
Returns the default language configured for Blogit
. This is the first
language in the list of languages configured like this:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
languages: ~w(bg en)
By default it is "en"
for English.
Examples
iex> Application.put_env(:blogit, :languages, ["bg", "de"])
iex> Blogit.Settings.default_language()
"bg"
iex> Application.delete_env(:blogit, :languages) # Use default
iex> Blogit.Settings.default_language()
"en"
Retrieves the list of supported languages configured for Blogit
.
The languages can be configured like this:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
languages: ~w(bg en)
For every configured language a separate set of posts and blog configuration
is kept. Every language has its own Blogit.Components.*
processes running,
that can be queried.
By default the list of languages is ["en"]
.
Examples
iex> Application.put_env(:blogit, :languages, ["bg"])
iex> Blogit.Settings.languages()
["bg"]
iex> Application.delete_env(:blogit, :languages) # Use default
iex> Blogit.Settings.languages()
["en"]
Returns how many lines of the source file of a post should be used for
generating its preview. Can be configured in the Blogit
configuration:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
max_lines_in_preview: 30
If not configured its default value is 10
.
Examples
iex> Application.put_env(:blogit, :max_lines_in_preview, 30)
iex> Blogit.Settings.max_lines_in_preview()
30
iex> Application.delete_env(:blogit, :max_lines_in_preview) # Use default
iex> Blogit.Settings.max_lines_in_preview()
10
Returns the string "\n---\n"
- the divider used to separate the meta data
from the post content in the post markdown files. It's advisable to have it on
two places - before and after the metadata:
---
author: Dali
---
# My meta content
Examples
iex> Blogit.Settings.meta_divider()
"\n---\n"
Returns the interval used when polling the source repository for changes.
It is used only if Blogit.Settings.polling?()
returns true
.
The value is the interval in milliseconds. The configuration is specified
in seconds, like this:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
polling: true, poll_interval: 50
The default is 10_000
for ten seconds.
Examples
iex> Application.put_env(:blogit, :poll_interval, 60)
iex> Blogit.Settings.poll_interval()
60_000
iex> Application.delete_env(:blogit, :poll_interval) # Use default
iex> Blogit.Settings.poll_interval()
10_000
Returns true if polling the source repository for changes is configured to be 'on'. That can be done like this:
config :blogit,
repository_url: some-url, repository_provider: some-provider,
polling: true
The default is true
if it is not configured.
Examples
iex> Application.put_env(:blogit, :polling, true)
iex> Blogit.Settings.polling?()
true
iex> Application.put_env(:blogit, :polling, false)
iex> Blogit.Settings.polling?()
false
iex> Application.delete_env(:blogit, :polling) # Use default
iex> Blogit.Settings.polling?()
true
Returns the string "posts"
- the location of the posts folder in the
repository. A custom provider can opt to not use this default location, but
the Blogit.RepositoryProviders.Git
provider expects posts to be located
in a folder named posts
in the root of the repository.
Examples
iex> Blogit.Settings.posts_folder()
"posts"