View Source Franklin.Articles (Franklin v0.1.0)

Link to this section Summary

Types

Attribute map type relative to the create_article/1 function.

Attribute map type relative to the update_article/2 function.

Functions

Attempts to create a new Article entity.

Returns {:ok, %Article{}} when an article with the given identity can be found and {:error, :article_not_found} if unsuccessful.

Returns {:ok, %Article{}} when an article with the given slug value can be found and {:error, :article_not_found} if unsuccessful.

Returns a list of Article entities sorted by :published_at descending.

Subscribes the calling process to a Phoenix.PubSub topic relative to the passed in article_id.

Attempts to update the given Article entity.

Link to this section Types

@type create_attrs() :: %{
  :body => String.t(),
  optional(:id) => Ecto.UUID.t(),
  published_at: DateTime.t(),
  slug: String.t(),
  title: String.t()
}

Attribute map type relative to the create_article/1 function.

@type update_attrs() :: %{
  optional(:body) => String.t(),
  optional(:published_at) => DateTime.t(),
  optional(:title) => String.t(),
  optional(:slug) => String.t()
}

Attribute map type relative to the update_article/2 function.

Link to this section Functions

@spec create_article(create_attrs()) ::
  {:ok, Ecto.UUID.t()} | {:error, Franklin.ValidationErrorMap.t()}

Attempts to create a new Article entity.

Returns {:ok, uuid} when successful and {:error, validation_error_map} if there was a problem.

attributes

Attributes

  • :body - A Markdown-flavored string value no more that 100 MBs in length.
  • :id - (optional) An Ecto.UUID value that will be used as the identity of this article. Will be generated if not provided.
  • :published_at - A DateTime value representing the public-facing publication date of the article.
  • :slug - The URL fragment used to identify a single article.
  • :title - A plain-text string value using 1 to 255 characters in length.
@spec fetch_article(Franklin.Articles.Article.id()) ::
  {:ok, Franklin.Articles.Article.t()} | {:error, :article_not_found}

Returns {:ok, %Article{}} when an article with the given identity can be found and {:error, :article_not_found} if unsuccessful.

Link to this function

fetch_article_by_slug(slug)

View Source
@spec fetch_article_by_slug(Franklin.Articles.Article.slug()) ::
  {:ok, Franklin.Articles.Article.t()} | {:error, :article_not_found}

Returns {:ok, %Article{}} when an article with the given slug value can be found and {:error, :article_not_found} if unsuccessful.

Link to this function

list_articles(criteria \\ %{})

View Source

Returns a list of Article entities sorted by :published_at descending.

@spec subscribe(Ecto.UUID.t()) :: :ok | {:error, term()}

Subscribes the calling process to a Phoenix.PubSub topic relative to the passed in article_id.

This topic will receive the following messages:

  • {:article_created, %{id: uuid}}
  • {:article_deleted, %{id: uuid}}
  • {:article_body_updated, %{id: uuid}}
  • {:article_slug_updated, %{id: uuid}}
  • {:article_published_at_updated, %{id: uuid}}
  • {:article_title_updated, %{id: uuid}}
Link to this function

update_article(article, attrs)

View Source
@spec update_article(Franklin.Articles.Article.t(), update_attrs()) ::
  {:ok, Ecto.UUID.t()} | {:error, Franklin.ValidationErrorMap.t()}

Attempts to update the given Article entity.

Returns {:ok, uuid} when successful and {:error, validation_error_map} if there was a problem.

attributes

Attributes

  • :body - A Markdown-flavored string value no more that 100 MBs in length.
  • published_at - A DateTime value representing the public-facing published date of the article.
  • :title - A plain-text string value using 1 to 255 characters in length.