Generate config.toml in .logarion/ instead of copying it

This commit is contained in:
Stavros Polymenis 2017-11-02 21:52:53 +00:00
parent 39b68e947d
commit 82a493bd82
2 changed files with 26 additions and 7 deletions

View File

@ -13,7 +13,7 @@ module Configuration = struct
let of_config config =
let open Confix in
let open Confix.Config in
let str k = ConfixToml.(string config ("general" / k)) in
let str k = ConfixToml.(string config ("archive" / k)) in
try
Ok {
repository =

View File

@ -38,14 +38,33 @@ let init force =
".logarion/html-templates", "templates";
]
in
let copies = [
"config.toml", ".logarion/";
"share/static", ".logarion/";
"share/html_templates", ".logarion/";
]
let toml_data =
Random.self_init();
let open Toml in
let open TomlTypes in
of_key_values [
key "archive",
TTable (
of_key_values [
key "title", TString "";
key "owner", TString (Bos.OS.Env.opt_var "USER" "");
key "email", TString (Bos.OS.Env.opt_var "EMAIL" "");
key "uuid", TString (Meta.Id.(generate () |> to_string));
]);
key "web",
TTable (
of_key_values [
key "url", TString "http://localhost:3666";
key "stylesheets", TArray ( NodeString ["main.css"] );
key "static_dir", TString "share/static";
]);
key "templates", TTable (of_key_values []);
]
in
create_dirs dirs;
make_copies copies
let config_file = open_out ".logarion/config.toml" in
output_bytes config_file (Toml.Printer.string_of_table toml_data);
close_out config_file
let init_term =
let force =