package erssical

  1. Overview
  2. Docs

Representation of Event RSS channels and queries.

module SMap : Stdlib.Map.S with type key = string

Using URLs

val url_of_string : string -> Uri.t
  • raises Failure

    in case of parse error.

val string_of_url : Uri.t -> string
val compare_url : Uri.t -> Uri.t -> int
val base_url : Uri.t

The base URL used for namespace of event fields in RSS channels.

Events

An event is represented by additional information in nodes under the <item> XML nodes. These additional nodes are prefixed by a namespace (to be valid RSS extension). This namespace must be associated to the base_url above.

type event_level =
  1. | Beginner
  2. | Confirmed
  3. | Expert
type event_type =
  1. | Conference
  2. | Seminar
  3. | Course
  4. | Workshop
  5. | Dojo
  6. | Other_type of string
type location = {
  1. loc_href : Uri.t option;
  2. loc_name : string;
}
type event = {
  1. ev_level : event_level option;
  2. ev_type : event_type option;
  3. ev_keywords : string list;
  4. ev_speakers : string list;
  5. ev_organizers : string list;
  6. ev_location : location option;
  7. ev_start : Ptime.t option;
  8. ev_end : Ptime.t option;
  9. ev_audience : string option;
}
val event : ?link:Uri.t -> ?level:event_level -> ?typ:event_type -> ?keywords:string list -> ?speakers:string list -> ?organizers:string list -> ?location:location -> ?start_date:Ptime.t -> ?end_date:Ptime.t -> ?audience:string -> unit -> event

Items and channels

type item = event Rss.item_t
type channel = (unit, event) Rss.channel_t
module ItemSet : Stdlib.Set.S with type elt = item

Filters

Filters allow to keep only some items of an Event RSS channel.

type contains_connector =
  1. | Conn_or
  2. | Conn_and
type filter_exp =
  1. | Not of filter_exp
  2. | Or of filter_exp list
  3. | And of filter_exp list
  4. | Contains of string * contains_connector * Str.regexp list
  5. | StartDate of Ptime.t option * Ptime.t option
    (*

    (after (inclusive), before (exclusive))

    *)
  6. | EndDate of Ptime.t option * Ptime.t option
    (*

    (after (inclusive), before (exclusive))

    *)
type filter = {
  1. filter_exp : filter_exp;
  2. filter_max : int option;
}

Queries

A query is composed of source RSS channels, an optional target RSS channel and an optional filter. The sources and the optional target will merged, then the filter will be be applied on the merge result to keep only selected items.

If the source if indicated with a url, additional event information can be specified for this source. In this case, this information is used to complete the event information of each item of the source channel. A typical example is to add default keywords for all items of a source channel.

The target channel is used as base channel: all its information (title, link, description, ...) is kept (except items which are processed as described above).

If no target channel is given, then the first source is used as base channel. If no source and no target is given, this is considered as an error.

The structure to compute is indicated by the "type" attribute of the "<query>" top node of the query XML document. "type" can be:

  • "application/rss+xml" to indicate that computing the query will return a new Event RSS containing (eventually filtered) items,
  • "text/calendar" to indicate that the merged channel must be converted to the Ical format.
type source =
  1. | Url of Uri.t * event
  2. | Channel of channel

A source can be a channel given directly in a <source> node, or it can be a URL, given in the "href" attribute of the <source> node. In the latter case, the channel will be fetched from this URL (using Curl library).

type query_return_type =
  1. | Rss
  2. | Ical
  3. | Debug
  4. | Xtmpl

A query can be asked to return a new channel, a calendar or debug information, i.e. text information, for example errors encountered while parsing source and target channels.

type query_result =
  1. | Res_channel of channel
  2. | Res_ical of string
  3. | Res_debug of string
  4. | Res_xtmpl of Xtmpl.Rewrite.tree

This is the result computed from a query. A calendar is just the string in the Ical format.

type query = {
  1. q_type : query_return_type;
  2. q_sources : source list;
  3. q_target : source option;
  4. q_filter : filter option;
  5. q_tmpl : Xtmpl.Rewrite.tree option;
}