···124124 | exception exn ->
125125 if ignore_malformed then None else raise exn
126126127127-let plant_raw_forest_from_dirs ~env ~host ~dev ~tree_dirs ~asset_dirs ~foreign_dirs : unit =
127127+let plant_raw_forest_from_dirs ~env ~host ~dev ~tree_dirs ~asset_dirs ~foreign_paths : unit =
128128+ begin
129129+ let@ path = List.iter @~ foreign_paths in
130130+ let path_str = EP.native_exn path in
131131+ let@ () = Reporter.profile @@ Format.sprintf "Implant foreign forest from `%s'" path_str in
132132+ let blob = try EP.load path with _ -> Reporter.fatalf IO_error "Could not read foreign forest blob at `%s`" path_str in
133133+ match Repr.of_json_string (T.forest_t T.content_t) blob with
134134+ | Ok forest ->
135135+ List.iter F.plant_resource forest
136136+ | Error (`Msg err) ->
137137+ Reporter.fatalf Parse_error "Could not parse foreign forest blob: %s" err
138138+ | exception (Iri.Error err) ->
139139+ Reporter.fatalf Parse_error "Encountered error while decoding foreign forest blob: %s" (Iri.string_of_error err)
140140+ | exception exn ->
141141+ Reporter.fatalf Parse_error "Encountered unknown error while decoding foreign forest blob: %s" (Printexc.to_string exn)
142142+ end;
128143 let parsed_trees = parse_trees_in_dirs ~dev tree_dirs in
129144 begin
130145 let@ () = Reporter.profile "Read assets" in
···142157 F.plant_resource @@ T.Article article
143158 end;
144159 begin
145145- let@ _foreign_dir = List.iter @~ foreign_dirs in
160160+ let@ _foreign_dir = List.iter @~ foreign_paths in
146161 (* TODO: plant the trees & assets from the foreign directory *)
147162 ()
148163 end
···202217 | _ -> false
203218 in
204219 let cwd = Eio.Stdenv.cwd env in
205205- let result = Json_client.render ~host @@ List.of_seq local_resources in
206206- let dir = Eio.Path.(cwd / "export" / host) in
220220+ let result = Repr.to_json_string ~minify: true (T.forest_t T.content_t) @@ List.of_seq local_resources in
221221+ let dir = Eio.Path.(cwd / "export") in
222222+ let filename = host ^ ".json" in
207223 Eio.Path.mkdirs ~exists_ok: true ~perm: 0o755 dir;
208208- Eio.Path.save ~create: (`Or_truncate 0o644) Eio.Path.(dir / "forest.json") result
224224+ Eio.Path.save ~create: (`Or_truncate 0o644) Eio.Path.(dir / filename) result
+1-1
lib/frontend/Forester.mli
···99 dev: bool ->
1010 tree_dirs: dir list ->
1111 asset_dirs: dir list ->
1212- foreign_dirs: dir list ->
1212+ foreign_paths: dir list ->
1313 unit
14141515val render_forest :