blogit v1.2.3 Blogit.Models.Configuration View Source

A module for managing and reading the blog configuration.

A repository containing the blog data can also contain an 'yml' configuration file. The file should be in the form

title: <title>
sub_title: <a-sub-title-for-the-blog>
logo_path: <path to logo for the blog>
background_image_path: <path to image at the top of the feed as background>
styles_path: <path to css file with custom styles for the blog>
social:
  rss: <show-rss-feed>(true/false)
  stars_for_blogit: <show-give-stars-for-blogit-links>(true/false)
  twitter: <twitter-id>
  facebook: <facebook-id>
  gihub: <github-id>

All of these properties are optional and there are defaults for them. For example the default title of the blog is the transformed name of the repository (name: 'my_repo' |> title: 'My Repo').

For every language code, returned by Blogit.Settings.languages/0 the file can have sub-section with custom settings. The configurations for the additional languages extend on the configuration of the default language.

title: <title>
sub_title: <a-sub-title-for-the-blog>
logo_path: <path to logo for the blog>
background_image_path: <path to image at the top of the feed as background>
styles_path: <path to css file with custom styles for the blog>
social:
  rss: <show-rss-feed>(true/false)
  stars_for_blogit: <show-give-stars-for-blogit-links>(true/false)
  twitter: <twitter-id>
  facebook: <facebook-id>
  gihub: <github-id>
bg:
  title: <title-in-bulgarian>

If the default language is en for English in the above example, the configuration for the Bulgarian language (bg) will be the same as the English one, but will another title, the one specified under bg. All the other supported keys can have custom values under bg.

Link to this section Summary

Functions

Creates a list of Blogit.Post.Configuration struct from the configuration source file contents. The list includes configuration for every configured language. The first item of the list is the configuration for the default language (The one returned by invoking Blogit.Settings.default_language/0).

Checks if the name of the configuration file of the blog is in the given list containing updated file names.

Link to this section Types

Link to this type

string_or_nil()

View Source
string_or_nil() :: String.t() | nil
Link to this type

t()

View Source
t() :: %Blogit.Models.Configuration{
  background_image_path: string_or_nil(),
  language: String.t(),
  logo_path: string_or_nil(),
  social: %{optional(String.t()) => String.t() | boolean()},
  styles_path: string_or_nil(),
  sub_title: string_or_nil(),
  title: String.t()
}

Link to this section Functions

Link to this function

from_file(repository_provider)

View Source

Creates a list of Blogit.Post.Configuration struct from the configuration source file contents. The list includes configuration for every configured language. The first item of the list is the configuration for the default language (The one returned by invoking Blogit.Settings.default_language/0).

The name and the location of the file are read from the configuration of Blogit - the configuration property configuration_file.

If the file doesn't exist or it is invalid YML file, the structure is created using the defaults.

The defaults are:

  • title - the name of the repository of the blog.
  • sub_title - nil
  • local_path - nil
  • background_image_path - nil
  • styles_path - nil
  • social: %{"rss" => true, "stars_for_blogit" => true}
  • language: : for every language

          returned by [`Blogit.Settings.languages/0`](Blogit.Settings.html#languages/0) a configuration struct
          will be created and returned by this function.
Link to this function

updated?(updates)

View Source
updated?([String.t()]) :: boolean()

Checks if the name of the configuration file of the blog is in the given list containing updated file names.

Examples

iex> Blogit.Models.Configuration.updated?(~w(one.md some_other.md))
false

iex> Blogit.Models.Configuration.updated?(~w(one.md blog.yml))
true