simple css support
This commit is contained in:
parent
4edbbad730
commit
7a4b7c9105
12
src/html.ml
12
src/html.ml
@ -2,8 +2,12 @@ let html_of ymd =
|
||||
let ymd_title = ymd.Logarion.meta.title in
|
||||
let ymd_body = Omd.to_html (Omd.of_string ymd.Logarion.text) in
|
||||
let open Tyxml.Html in
|
||||
let tyhtml = html
|
||||
(head (title (Unsafe.data ymd_title)) [])
|
||||
(body [Unsafe.data ymd_body])
|
||||
in
|
||||
let tyhtml =
|
||||
html
|
||||
(head
|
||||
(title (Unsafe.data ymd_title))
|
||||
[link ~rel:[`Stylesheet] ~href:"style.css" ();]
|
||||
)
|
||||
(body [Unsafe.data ymd_body])
|
||||
in
|
||||
Format.asprintf "%a" (Tyxml.Html.pp ()) tyhtml
|
||||
|
16
src/web.ml
16
src/web.ml
@ -1,11 +1,5 @@
|
||||
open Opium.Std
|
||||
|
||||
let test = "---
|
||||
title: Test
|
||||
author: orbifx
|
||||
---
|
||||
Hello _world_!"
|
||||
|
||||
let load_file f =
|
||||
let ic = open_in f in
|
||||
let n = in_channel_length ic in
|
||||
@ -13,14 +7,18 @@ let load_file f =
|
||||
really_input ic s 0 n;
|
||||
close_in ic;
|
||||
(s)
|
||||
|
||||
|
||||
let print_css =
|
||||
get "/style.css" begin fun req -> `String (load_file "ymd/style.css") |> respond' end
|
||||
|
||||
let print_ymd =
|
||||
get "/:title" begin fun req ->
|
||||
let file = (param req "title") ^ ".ymd" in
|
||||
let file = "ymd/" ^ (param req "title") ^ ".ymd" in
|
||||
`Html (Html.html_of (Logarion.ymd (load_file file))) |> respond'
|
||||
end
|
||||
|
||||
|
||||
let _ =
|
||||
App.empty
|
||||
|> print_ymd
|
||||
|> print_css
|
||||
|> App.run_command
|
||||
|
Loading…
x
Reference in New Issue
Block a user