aggregate_feeds.ml 1008 B

12345678910111213141516171819202122232425262728293031
  1. let sources =
  2. River.
  3. [
  4. { name = "KC Sivaramakrishnan"; url = "http://kcsrk.info/atom-ocaml.xml" };
  5. {
  6. name = "Amir Chaudhry";
  7. url = "http://amirchaudhry.com/tags/ocamllabs-atom.xml";
  8. };
  9. ]
  10. let main () =
  11. let feeds = List.map River.fetch sources in
  12. let posts = River.posts feeds in
  13. let entries = River.create_atom_entries posts in
  14. let feed =
  15. let authors = [ Syndic.Atom.author "OCaml Blog" ] in
  16. let id = Uri.of_string "https://ocaml.org/atom.xml" in
  17. let links = [ Syndic.Atom.link ~rel:Self id ] in
  18. let title : Syndic.Atom.text_construct =
  19. Text "OCaml Blog: Read the latest OCaml news from the community."
  20. in
  21. let updated = Ptime.of_float_s (Unix.gettimeofday ()) |> Option.get in
  22. Syndic.Atom.feed ~authors ~links ~id ~title ~updated entries
  23. in
  24. let out_channel = open_out "example/atom.xml" in
  25. Syndic.Atom.output feed (`Channel out_channel);
  26. close_out out_channel
  27. let () =
  28. Printexc.record_backtrace true;
  29. main ()