added example web interface
This commit is contained in:
parent
d602bf54ac
commit
f8c4109cde
9
Makefile
9
Makefile
@ -1,5 +1,8 @@
|
||||
|
||||
all: foo
|
||||
all: web
|
||||
|
||||
foo: src/logarion.ml
|
||||
ocamlfind ocamlopt -o logarion -linkpkg -package omd,Str src/logarion.ml
|
||||
web: logarion.cmx src/web.ml
|
||||
ocamlfind ocamlopt -o logarion-web -linkpkg -package opium.unix,omd,Str logarion.cmx src/web.ml
|
||||
|
||||
logarion.cmx: src/logarion.ml
|
||||
ocamlfind ocamlopt -c -o logarion.cmx -linkpkg -package omd src/logarion.ml
|
||||
|
@ -44,17 +44,11 @@ let ymd s =
|
||||
let md_str = List.nth segments 1 in
|
||||
Printf.printf "%s" yaml_str;
|
||||
let meta = log_meta yaml_str in
|
||||
print_endline meta.title;
|
||||
Printf.printf "%s" md_str
|
||||
(meta, md_str)
|
||||
|
||||
let html_of string =
|
||||
let html_of (meta, md) =
|
||||
let open Omd in
|
||||
to_html (of_string string)
|
||||
|
||||
let test = "---
|
||||
title: Test
|
||||
author: orbifx
|
||||
---
|
||||
Hello _world_!"
|
||||
|
||||
let () = ymd test
|
||||
let body = to_html (of_string md) in
|
||||
"<!DOCTYPE html><html><head><title>" ^ meta.title ^ "</title></head><body>"
|
||||
^ body
|
||||
^ "</body></html>"
|
||||
|
18
src/web.ml
Normal file
18
src/web.ml
Normal file
@ -0,0 +1,18 @@
|
||||
open Opium.Std
|
||||
|
||||
let test = "---
|
||||
title: Test
|
||||
author: orbifx
|
||||
---
|
||||
Hello _world_!"
|
||||
|
||||
let print_ymd =
|
||||
let open Logarion in
|
||||
get "/" begin fun req ->
|
||||
`Html (html_of (ymd test)) |> respond'
|
||||
end
|
||||
|
||||
let _ =
|
||||
App.empty
|
||||
|> print_ymd
|
||||
|> App.run_command
|
Loading…
x
Reference in New Issue
Block a user