-
Notifications
You must be signed in to change notification settings - Fork 27
/
canopy_config.ml
32 lines (26 loc) · 928 Bytes
/
canopy_config.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
open Canopy_utils
let decompose_git_url url =
match String.rindex url '#' with
| exception Not_found -> (url, None)
| i ->
let remote_url = String.sub url 0 i in
let branch = String.sub url (i + 1) (String.length url - i - 1) in
(remote_url, Some branch)
let remote_uri () = fst (decompose_git_url (Key_gen.remote ()))
let remote_branch () = snd (decompose_git_url (Key_gen.remote ()))
let port () = Key_gen.port ()
let tls_port () = Key_gen.tls_port ()
let push_hook_path () = Key_gen.push_hook ()
let entry name = [ ".config" ; name ]
let index_page cache =
match KeyMap.find_opt cache @@ entry "index_page" with
| Some (`Config p) -> p
| _ -> "Index"
let blog_name cache =
match KeyMap.find_opt cache @@ entry "blog_name" with
| Some (`Config n) -> n
| _ -> "Canopy"
let root cache =
match KeyMap.find_opt cache @@ entry "root" with
| Some (`Config r) -> r
| _ -> "http://localhost"