implements discussions

This commit is contained in:
zapashcanon 2022-03-31 01:43:59 +02:00
parent c46e401ef3
commit cf0ad20c79
No known key found for this signature in database
GPG key ID: 8981C3C62D1D28F1
6 changed files with 203 additions and 24 deletions

21
src/template_utils.ml Normal file
View file

@ -0,0 +1,21 @@
let get_title content =
let open Soup in
try
let soup = content |> parse in
soup $ "h1" |> R.leaf_text
with Failure _e -> "Permap"
let render ?title content request =
let title =
match title with None -> get_title content | Some title -> title
in
Dream.html
@@ Template.render_unsafe ~title:(Dream.html_escape title)
~content:(Dream.html_escape content)
request
let render_unsafe ?title content request =
let title =
match title with None -> get_title content | Some title -> title
in
Dream.html @@ Template.render_unsafe ~title ~content request