Skip to content

Commit

Permalink
Make Canopy_config.config.(name, push) command-line arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaker committed Mar 11, 2016
1 parent 4c901a4 commit 0e1ddf6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions canopy_config.ml
@@ -1,6 +1,6 @@
type t = {
remote_uri : string;
name : string;
blog_name : string;
index_page : string;
port : int;
push_hook_path: string;
Expand All @@ -9,7 +9,7 @@ type t = {
let config () = {
remote_uri = Key_gen.remote ();
index_page = Key_gen.index ();
name = "Canopy";
blog_name = Key_gen.name ();
port = Key_gen.port ();
push_hook_path = "push";
}
2 changes: 1 addition & 1 deletion canopy_main.ml
Expand Up @@ -56,7 +56,7 @@ module Main (C: CONSOLE) (RES: Resolver_lwt.S) (CON: Conduit_mirage.S) (S:Cohtt
new_task () >>= fun t ->
Store.list (t "Reading posts") [] >>= fun keys ->
let index = config.index_page in
let name = config.name in
let name = config.blog_name in
let body = Canopy_templates.template_main ~index ~content ~name ~title ~keys in
S.respond_string ~status ~body () in

Expand Down
25 changes: 20 additions & 5 deletions config.ml
Expand Up @@ -4,25 +4,40 @@ let stack console = socket_stackv4 console [Ipaddr.V4.any]

let disk = crunch "./disk"

let remote_k =
let doc = Key.Arg.info ~doc:"Remote repository to fetch content." ["r"; "remote"] in
Key.(create "remote" Arg.(opt string "https://github.com/Engil/__blog.git" doc))

let index_k =
let doc = Key.Arg.info ~doc:"Index file name in remote." ["i"; "index"] in
Key.(create "index" Arg.(opt string "Index" doc))

let name_k =
let doc = Key.Arg.info ~doc:"Blog name." ["n"; "name"] in
Key.(create "name" Arg.(opt string "Canopy" doc))

let port_k =
let doc = Key.Arg.info ~doc:"Socket port." ["p"; "port"] in
Key.(create "port" Arg.(opt int 8080 doc))

let push_hook_k =
let doc = Key.Arg.info ~doc:"GitHub push hook." ["hook"] in
Key.(create "push_hook" Arg.(opt string "push" doc))

let remote_k =
let doc = Key.Arg.info ~doc:"Remote repository to fetch content." ["r"; "remote"] in
Key.(create "remote" Arg.(opt string "https://github.com/Engil/__blog.git" doc))

let main =
let libraries = ["irmin.git"; "cow"; "mirage-http"; "irmin.mirage";"tls.mirage";] in
let libraries = if get_mode () = `Xen then libraries else "irmin.unix" :: libraries in
let keys = Key.([
abstract index_k;
abstract name_k;
abstract port_k;
abstract push_hook_k;
abstract remote_k
]) in
foreign
~libraries
~deps:[abstract nocrypto]
~keys:Key.([abstract remote_k; abstract index_k; abstract port_k])
~keys:keys
~packages:["irmin"; "mirage-http"; "mirage-flow"; "tls"; "cow";
"mirage-types-lwt"; "channel"; "git"; "mirage-git"; "git-unix"; "re"; "cohttp"]
"Canopy_main.Main" (console @-> resolver @-> conduit @-> http @-> kv_ro @-> job)
Expand Down

0 comments on commit 0e1ddf6

Please sign in to comment.