Exoplanet.Filters (Exoplanet v0.3.0)

Copy Markdown View Source

Per-feed content filters: category allow/block lists, image stripping, and summary truncation. See the Per-Feed Configuration design spec for semantics.

Summary

Functions

Applies the merged filter map to a list of Exoplanet.Post structs.

Merges a per-feed filter map onto a default filter map.

Types

t()

@type t() :: %{
  allow_categories: [String.t()],
  block_categories: [String.t()],
  strip_images: boolean(),
  excerpt_length: pos_integer() | nil
}

Functions

apply(posts, filters)

@spec apply([Exoplanet.Post.t()], t()) :: [Exoplanet.Post.t()]

Applies the merged filter map to a list of Exoplanet.Post structs.

Returns the filtered list. Posts dropped by category filters are removed entirely. The strip_images and excerpt_length filters modify each post's summary (and HTML body for image stripping).

merge(defaults, per_feed)

@spec merge(t(), map() | nil) :: t()

Merges a per-feed filter map onto a default filter map.

allow_categories and block_categories REPLACE the default value when the per-feed map sets them to a list. Other keys override field-by-field. Per-feed keys set to nil leave the default in place.