ocaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

rudimentary 'forester export' command

+57 -2
+19 -1
bin/forester/main.ml
··· 31 31 let@ dir_to_copy = List.iter @~ dirs_to_copy in 32 32 Forester.copy_contents_of_dir ~env @@ path_of_dir ~env dir_to_copy 33 33 34 + let export ~env config_filename = 35 + let config = Forester_frontend.Config.parse_forest_config_file config_filename in 36 + let tree_dirs = paths_of_dirs ~env config.trees in 37 + let asset_dirs = paths_of_dirs ~env config.assets in 38 + Forester.plant_forest_from_dirs ~env ~host: config.host ~dev: false ~tree_dirs ~asset_dirs; 39 + let host = 40 + match config.host with 41 + | Some host -> host 42 + | None -> Reporter.fatalf Configuration_error "To export a forest, you must first fill in the `host' field in %s" config_filename 43 + in 44 + Forester.export ~env ~host ~asset_dirs 45 + 34 46 let new_tree ~env config_filename dest_dir prefix template random = 35 47 let@ () = Reporter.silence in 36 48 let config = Forester_frontend.Config.parse_forest_config_file config_filename in ··· 169 181 $ arg_no_theme 170 182 ) 171 183 184 + let export_cmd ~env = 185 + let doc = "Export your forest to an archive that can be planted elsewhere" in 186 + let man = [] in 187 + let info = Cmd.info "export" ~version ~doc ~man in 188 + Cmd.v info Term.(const (export ~env) $ arg_config) 189 + 172 190 let new_tree_cmd ~env = 173 191 let arg_prefix = 174 192 let doc = "The namespace prefix for the created tree." in ··· 252 270 ] 253 271 in 254 272 let info = Cmd.info "forester" ~version ~doc ~man in 255 - Cmd.group info [build_cmd ~env; new_tree_cmd ~env; complete_cmd ~env; init_cmd ~env; query_cmd ~env] 273 + Cmd.group info [build_cmd ~env; new_tree_cmd ~env; complete_cmd ~env; init_cmd ~env; query_cmd ~env; export_cmd ~env] 256 274 257 275 let () = 258 276 Random.self_init ();
+1
lib/forest/Forester_forest.ml
··· 5 5 module Plain_text_client = Plain_text_client 6 6 7 7 module Json_manifest_client = Json_manifest_client 8 + module Json_client = Json_client
+11
lib/forest/Json_client.ml
··· 1 + open Forester_core 2 + module T = Xml_tree 3 + 4 + type t = { 5 + host: string; 6 + articles: T.content T.article list 7 + } 8 + [@@deriving repr] 9 + 10 + let render_trees ~host articles = 11 + Repr.to_json_string t { host; articles }
+6
lib/forest/Json_client.mli
··· 1 + open Forester_core 2 + 3 + val render_trees : 4 + host: string -> 5 + Xml_tree.content Xml_tree.article list -> 6 + string
+1 -1
lib/forest/dune
··· 2 2 (name Forester_forest) 3 3 (public_name forester.forest) 4 4 (preprocess 5 - (pps ppx_deriving.show)) 5 + (pps ppx_deriving.show ppx_repr)) 6 6 (libraries 7 7 forester.prelude 8 8 forester.xml_names
+13
lib/frontend/Forester.ml
··· 167 167 let@ writer = Eio.Buf_write.with_flow flow in 168 168 Client.pp_xml ~stylesheet (Eio.Buf_write.make_formatter writer) article 169 169 end 170 + 171 + let export ~env ~host ~asset_dirs : unit = 172 + let@ () = Reporter.profile "Export forest" in 173 + let cwd = Eio.Stdenv.cwd env in 174 + let trees = FU.get_all_articles () in 175 + let result = Json_client.render_trees ~host trees in 176 + let dir = Eio.Path.(cwd / "export" / host) in 177 + Eio.Path.mkdirs ~exists_ok: true ~perm: 0o755 dir; 178 + Eio.Path.save ~create: (`Or_truncate 0o644) Eio.Path.(dir / "forest.json") result; 179 + let@ dir_to_copy = List.iter @~ asset_dirs in 180 + let source = EP.native_exn dir_to_copy in 181 + let dest_dir = EP.native_exn dir in 182 + Eio_util.copy_to_dir ~env ~cwd ~source ~dest_dir
+6
lib/frontend/Forester.mli
··· 19 19 stylesheet: string -> 20 20 unit 21 21 22 + val export : 23 + env: env -> 24 + host: string -> 25 + asset_dirs: dir list -> 26 + unit 27 + 22 28 val copy_contents_of_dir : 23 29 env: env -> 24 30 dir ->