package river

  1. Overview
  2. Docs
RSS2 and Atom feed aggregator for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.6.tar.gz
md5=0500da466b93aa356f9dabc2550a34ea
sha512=59c3663a156fa767217e6a50361b51d9582c357a479ffa22bffe76c71a770fb812e6c2787a45cae0aa2522bbabe571640861da739f9672aeccabd9514b780b24

doc/river/River/index.html

Module RiverSource

Sourcetype source = {
  1. name : string;
  2. url : string;
}

The source of a feed.

Sourcetype feed
Sourcetype post
Sourceval fetch : ?timeout:float -> ?user_agent:string -> ?repair:bool -> source -> feed

fetch ?timeout ?user_agent ?repair source returns an Atom or RSS feed from a source.

  • parameter timeout

    Connection timeout in seconds. Default: 3..

  • parameter user_agent

    Value sent in the User-Agent HTTP header. Omitted by default.

  • parameter repair

    When true, if the document fails to parse as-is, retry after two conservative fix-ups: self-closing HTML void elements (see sanitize_void_elements) and defaulting any entry missing a mandatory <updated> (see repair_missing_updated). Feeds that already parse are never modified. Default: false.

Sourceval of_string : ?repair:bool -> source -> string -> feed

of_string ?repair source xml parses the in-memory feed document xml as if it had been fetched from source.url, performing no HTTP request. See fetch for repair.

Sourceval sanitize_void_elements : string -> string

sanitize_void_elements xml rewrites HTML void elements (<img>, <br>, …) into self-closing form: both unclosed (<img ...>) and redundantly-closed (<img ...></img>) occurrences become <img ... />. Already self-closed elements and escaped (type="html") content are left untouched. This is the transform applied by fetch and of_string when ~repair:true; it is exposed for testing and reuse.

Sourceval repair_missing_updated : string -> string

repair_missing_updated xml fills in a mandatory entry-level <updated> element wherever an Atom <entry> lacks one, defaulting it to (1) the entry's own <published> if present, else (2) the feed-level <updated>. Entries that already have an <updated> and documents with no <entry> (e.g. RSS2) are left unchanged, so it is idempotent and never alters a valid feed. This is the second transform applied by fetch and of_string when ~repair:true; it is exposed for testing and reuse.

Sourceval name : feed -> string

name feed is the name of the feed source passed to fetch.

Sourceval url : feed -> string

url feed is the url of the feed source passed to fetch.

Sourceval posts : feed list -> post list

posts feeds is the list of deduplicated posts of the given feeds.

Sourceval feed : post -> feed

feed post is the feed the post originates from.

Sourceval title : post -> string

title post is the title of the post.

link post is the link of the post.

Sourceval date : post -> Syndic.Date.t option

date post is the date of the post.

Sourceval author : post -> string

author post is the author of the post.

Sourceval email : post -> string

email post is the email of the post.

Sourceval content : post -> string

content post is the content of the post.

Sourceval summary : post -> string option

summary post is the short description provided by the feed itself: the Atom <summary> or the RSS2 <description>, as plain text. None when the feed provides no such element.

Sourceval meta_description : ?timeout:float -> ?user_agent:string -> post -> string option

meta_description ?timeout ?user_agent post is a short description of the post.

When the feed provides one, summary post is returned directly. Otherwise we fetch the content of link post and look for an HTML meta tag with the name "description" or "og:description".

  • parameter timeout

    Connection timeout in seconds. Default: 3..

  • parameter user_agent

    Value sent in the User-Agent HTTP header. Omitted by default.

Sourceval seo_image : ?timeout:float -> ?user_agent:string -> post -> string option

seo_image ?timeout ?user_agent post is the image to be used by social networks and links to the post.

  • parameter timeout

    Connection timeout in seconds. Default: 3..

  • parameter user_agent

    Value sent in the User-Agent HTTP header. Omitted by default.

To get the seo image, we make get the content of link post and look for an HTML meta tag with the name "og:image" or "twitter:image".

Sourceval create_atom_entries : post list -> Syndic.Atom.entry list

create_atom_feed posts creates a list of atom entries, which can then be used to create an atom feed that is an aggregate of the posts.