diff --git a/demo_ref.eliom b/demo_ref.eliom index c7eb5b1..78b559f 100644 --- a/demo_ref.eliom +++ b/demo_ref.eliom @@ -10,7 +10,8 @@ open%shared Eliom.Content.Html.F Ocsigen Start is creating a session group for each user. *) let%server last_visit = - Eliom.Reference.eref ~persistent:"demo_last_visit" + Eliom.Reference.eref + ~persistent:("demo_last_visit", [%json: Os.Date.local_calendar option]) ~scope:Eliom.Common.default_group_scope None (* Read & reset last_visit *) diff --git a/tools/gen_dune.ml b/tools/gen_dune.ml index 9a2d8f1..c1fb399 100644 --- a/tools/gen_dune.ml +++ b/tools/gen_dune.ml @@ -23,7 +23,33 @@ let handle_file_client nm = nm nm let () = - Array.concat (List.map Sys.readdir [".."; "../assets"]) + let root = Sys.readdir ".." in + let assets = Sys.readdir "../assets" in + (* The build directory mirrors the sources but also holds generated files, + which must not be enumerated or their client rule would be emitted twice: + - .pp.eliom/.pp.eliomi: preprocessing artifacts; + - the i18n modules produced from assets/*.tsv (the .tsv already emits the + rule) and the static config produced from *.eliom.in. *) + let generated_eliom = Hashtbl.create 16 in + Array.iter + (fun nm -> + if Filename.check_suffix nm ".tsv" + then Hashtbl.replace generated_eliom (Filename.chop_suffix nm ".tsv") ()) + assets; + Array.iter + (fun nm -> + if Filename.check_suffix nm ".eliom.in" + then + Hashtbl.replace generated_eliom (Filename.chop_suffix nm ".eliom.in") ()) + root; + let is_generated nm = + Filename.check_suffix nm ".pp.eliom" + || Filename.check_suffix nm ".pp.eliomi" + || (Filename.check_suffix nm ".eliom" + && Hashtbl.mem generated_eliom (Filename.chop_suffix nm ".eliom")) + in + Array.concat [root; assets] |> Array.to_list |> List.sort compare |> List.filter (fun nm -> nm.[0] <> '.') + |> List.filter (fun nm -> not (is_generated nm)) |> List.iter handle_file_client