reimplemented static serving using opium's function

This commit is contained in:
Stavros Polymenis 2016-10-30 10:29:00 +00:00
parent 5c795a4628
commit 73f566124b

View File

@ -70,11 +70,11 @@ let () =
let form_of_ymd = Html.form ~header_tpl blog_url lgrn in
let list_of_ymds = Html.of_file_meta_pairs ~header_tpl ~listing_tpl blog_url lgrn in
App.empty
|> middleware @@ Middleware.static ~local_path:"./share" ~uri_prefix:"/share"
|> post "/post" (fun req -> ymd_of_req req >>= fun ymd -> L.to_file ymd >>= fun () -> html_response (page_of_ymd ymd))
|> get "/edit/:ttl" (fun r -> ret_param "ttl" r >>= ymdpath >|= ymd >|= form_of_ymd >>= html_response)
|> get "/new" (fun _ -> return Ymd.blank_ymd >|= form_of_ymd >>= html_response)
|> get "/text/:ttl" (fun req -> ret_param "ttl" req >>= ymdpath >|= ymd >|= page_of_ymd >>= html_response)
|> get "/!/:ttl" (fun req -> ret_param "ttl" req >|= L.latest_file_meta_pair >|= ymd_or_error >|= page_of_ymd >>= html_response)
|> get "/style.css" (fun _ -> return "ymd/style.css" >|= L.load_file >>= string_response)
|> get "/" (fun _ -> return (L.file_meta_pairs ()) >|= list_of_ymds >>= html_response)
|> App.run_command