edit form

This commit is contained in:
Stavros Polymenis 2016-09-26 21:06:54 +01:00
parent 3cc080031c
commit 8125c8159b
2 changed files with 21 additions and 11 deletions

View File

@ -32,12 +32,13 @@ let of_titled_files titles =
|> Format.asprintf "%a" (Tyxml.Html.pp ())
let form ymd =
let input_set t n =
let input_set title name value =
p [ label [
span [pcdata t];
input ~a:[a_name n] ()
span [pcdata title];
input ~a:[a_name name; a_value value] ()
]]
in
let open Ymd in
html (logarion_head "Compose")
(body [
header [ h1 [pcdata "Create new article"] ];
@ -48,14 +49,14 @@ let form ymd =
fieldset
~legend:(legend [pcdata "Create new article"])
[
input_set "Title" "title";
input_set "Author name" "author_name";
input_set "Author email" "author_email";
input_set "Topics" "topics";
input_set "Categories" "categories";
input_set "Keywords" "keywords";
input_set "Series" "series";
input_set "Abstract" "abstract";
input_set "Title" "title" ymd.meta.title;
input_set "Author name" "author_name" ymd.meta.author.name;
input_set "Author email" "author_email" ymd.meta.author.email;
input_set "Topics" "topics" (String.concat ", " ymd.meta.topics);
input_set "Categories" "categories" (String.concat ", " ymd.meta.categories);
input_set "Keywords" "keywords" (String.concat ", " ymd.meta.keywords);
input_set "Series" "series" (String.concat ", " ymd.meta.series);
input_set "Abstract" "abstract" ymd.meta.abstract;
p [
label [
span [pcdata"Text"];

View File

@ -40,6 +40,14 @@ let process_form =
`Html (Html.of_ymd ymd) |> respond'
end
let edit_form =
get "/:title/edit"
begin fun req ->
let filename = sanitised_path (param req "title") in
let filepath = "ymd/" ^ filename ^ ".ymd" in
`Html (Html.form (Logarion.of_file filepath)) |> respond'
end
let print_toc =
get "/" begin fun req -> `Html (Html.of_titled_files (Logarion.titled_files ())) |> respond' end
@ -47,6 +55,7 @@ let _ =
App.empty
|> print_ymd
|> print_form
|> edit_form
|> process_form
|> print_css
|> print_toc