Skip to content

Commit 1422c16

Browse files
authored
Merge pull request #5 from Armael/master
Make river compatible with the latest syndic API
2 parents 80222cf + 084c622 commit 1422c16

File tree

10 files changed

+4194
-3391
lines changed

10 files changed

+4194
-3391
lines changed

.merlin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ S lib
33
B _build/lib
44

55
PKG lwt
6+
PKG ptime.clock.os
67
PKG syndic
78
PKG cohttp
89
PKG cow

_oasis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Library "river"
1616
Findlibname: river
1717
InternalModules: Ri_http, Ri_feeds, Ri_posts, Ri_utils
1818
Modules: River
19-
BuildDepends: lwt, syndic, netstring, cohttp.lwt
19+
BuildDepends: lwt, syndic, netstring, cohttp.lwt, ptime.clock.os
2020

2121
Executable "ocl-planet"
2222
Path: examples/

_tags

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 8663c3ab8656a06dd380f152cf431435)
2+
# DO NOT EDIT (digest: 4199c91b63001772b6357e13b2e1221e)
33
# Ignore VCS directories, you can use the same kind of rule outside
44
# OASIS_START/STOP if you want to exclude directories that contains
55
# useless stuff for the build process
@@ -19,22 +19,26 @@ true: annot, bin_annot
1919
<lib/*.ml{,i,y}>: pkg_cohttp.lwt
2020
<lib/*.ml{,i,y}>: pkg_lwt
2121
<lib/*.ml{,i,y}>: pkg_netstring
22+
<lib/*.ml{,i,y}>: pkg_ptime.clock.os
2223
<lib/*.ml{,i,y}>: pkg_syndic
2324
# Executable ocl-planet
2425
<examples/ocl_planet.{native,byte}>: pkg_cohttp.lwt
2526
<examples/ocl_planet.{native,byte}>: pkg_lwt
2627
<examples/ocl_planet.{native,byte}>: pkg_netstring
28+
<examples/ocl_planet.{native,byte}>: pkg_ptime.clock.os
2729
<examples/ocl_planet.{native,byte}>: pkg_syndic
2830
<examples/ocl_planet.{native,byte}>: use_river
2931
# Executable write-atom
3032
<examples/write_atom.{native,byte}>: pkg_cohttp.lwt
3133
<examples/write_atom.{native,byte}>: pkg_lwt
3234
<examples/write_atom.{native,byte}>: pkg_netstring
35+
<examples/write_atom.{native,byte}>: pkg_ptime.clock.os
3336
<examples/write_atom.{native,byte}>: pkg_syndic
3437
<examples/write_atom.{native,byte}>: use_river
3538
<examples/*.ml{,i,y}>: pkg_cohttp.lwt
3639
<examples/*.ml{,i,y}>: pkg_lwt
3740
<examples/*.ml{,i,y}>: pkg_netstring
41+
<examples/*.ml{,i,y}>: pkg_ptime.clock.os
3842
<examples/*.ml{,i,y}>: pkg_syndic
3943
<examples/*.ml{,i,y}>: use_river
4044
# OASIS_STOP

examples/write_atom.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ let main () =
2525
let entries = mk_entries posts in
2626
let feed =
2727
let authors = [ author "OCaml Labs" ] in
28-
let id = "http://ocaml.io/blogs/atom.xml" in
29-
let links = [ link ~rel:Self @@ Uri.of_string id ] in
28+
let id = Uri.of_string "http://ocaml.io/blogs/atom.xml" in
29+
let links = [ link ~rel:Self id ] in
3030
let title : text_construct = Text "OCaml Labs: Real World Functional Programming" in
31-
let updated = CalendarLib.Calendar.now () in
31+
let updated = Ptime_clock.now () in
3232
feed ~authors ~links ~id ~title ~updated entries in
3333
let out_channel = open_out out_file in
3434
output feed (`Channel out_channel);

lib/META

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 9272c232c186df381ec324edec953109)
2+
# DO NOT EDIT (digest: f1a4ef818c8cdcff4a535ce0c7cc752f)
33
version = "0.1.3"
44
description = "A RSS/Atom feed aggregator"
5-
requires = "lwt syndic netstring cohttp.lwt"
5+
requires = "lwt syndic netstring cohttp.lwt ptime.clock.os"
66
archive(byte) = "river.cma"
77
archive(byte, plugin) = "river.cma"
88
archive(native) = "river.cmxa"

lib/ri_http.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let cache_secs = 3600. (* 1h *)
7676

7777
let get ?(cache_secs=cache_secs) url =
7878
let md5 = Digest.to_hex(Digest.string url) in
79-
let fn = Filename.concat Filename.temp_dir_name ("ocamlorg-" ^ md5) in
79+
let fn = Filename.concat (Filename.get_temp_dir_name ()) ("ocamlorg-" ^ md5) in
8080
eprintf "Downloading %s ... %!" url;
8181
let get_from_cache () =
8282
let fh = open_in fn in

lib/ri_posts.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,18 @@ let mk_entry post : entry =
237237
let contributors = [ author ~uri:(Uri.of_string post.contributor.url)
238238
post.contributor.name ] in
239239
let links = match post.link with
240-
| Some l -> [ link Syndic.Atom.Alternate l ]
240+
| Some l -> [ link ~rel:Syndic.Atom.Alternate l ]
241241
| None -> [] in
242242
(* TODO: include source *)
243243
let id = match post.link with
244-
| Some l -> Uri.to_string l
245-
| None -> Digest.to_hex (Digest.string (post.title)) in
244+
| Some l -> l
245+
| None -> Uri.of_string (Digest.to_hex (Digest.string (post.title))) in
246246
let authors = (author ~email:post.email post.author, []) in
247247
let title : text_construct = Text post.title in
248248
let updated = match post.date with
249249
(* Atom entry requires a date but RSS2 does not. So if a date
250250
* is not available, just capture the current date. *)
251-
| None -> CalendarLib.Calendar.now ()
251+
| None -> Ptime_clock.now ()
252252
| Some d -> d in
253253
entry ~content ~contributors ~links ~id ~authors ~title ~updated ()
254254

0 commit comments

Comments
 (0)