1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889(*
* Copyright (c) 2010-2013 Anil Madhavapeddy <anil@recoil.org>
* Copyright (c) 2013 Richard Mortier <mort@cantab.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)openPrintfopenLwt.InfixopenCowopenAtom_feedopenDate(** Link stream *)typestream={name:string;icon:string;}(* Individual link *)typet={id:string;uri:Uri.t;title:string;date:Date.date;stream:stream;}letpermalinkfeedl=sprintf"%slinks/%s/%s"feed.base_uril.stream.namel.idletatom_entry_of_link(feed:Atom_feed.t)l=letperma_uri=Uri.of_string(permalinkfeedl)inletlinks=[(* Atom.mk_link ~rel:`alternate ~typ:"text/html" perma_uri; *)Atom.mk_link~rel:`alternate~typ:"text/html"l.uri;]inletcontent=Html.(list[a~href:l.uri(stringl.title);string" from ";stringl.stream.name])inletmeta={Atom.id=Uri.to_stringperma_uri;title=l.title;subtitle=None;author=None;updated=atom_datel.date;rights=feed.rights;links;}inLwt.return{Atom.entry=meta;summary=None;base=None;content}letcmp_entab=Atom.compare(atom_datea.date)(atom_dateb.date)letto_atom~feed~entries=letmk_urix=Uri.of_string(feed.base_uri^x)inletes=List.rev(List.sortcmp_ententries)inletupdated=atom_date(List.hdes).dateinletid=feed.base_uri^"links/"inletlinks=[Atom.mk_link(mk_uri"atom.xml");Atom.mk_link~rel:`alternate~typ:"text/html"(mk_uri"")]inLwt_list.map_s(atom_entry_of_linkfeed)es>|=funentries->letfeed={Atom.id;title=feed.Atom_feed.title;subtitle=feed.subtitle;author=feed.Atom_feed.author;rights=feed.rights;updated;links}in{Atom.feed=feed;entries}