diff --git a/src/babillard_page.eml.html b/src/babillard_page.eml.html
index a17e0f0..933113d 100644
--- a/src/babillard_page.eml.html
+++ b/src/babillard_page.eml.html
@@ -25,30 +25,7 @@ let f request =
Click the map and make a new thread:
-
-<%s! Dream.form_tag ~action:"/" ~enctype:`Multipart_form_data request %>
-
-
-
- Subject
-
-
-
-
-
- Tags
- <%s! Format.asprintf "%a" Pp_babillard.pp_checkboxes () %>
-
-
- Picture:
-
-
- Image description:
-
-
- Make Thread
-
-
+ <%s! Post_form.f None request %>
diff --git a/src/dune b/src/dune
index 02f188d..5302120 100644
--- a/src/dune
+++ b/src/dune
@@ -13,6 +13,7 @@
emojid
login
permap
+ post_form
pp_babillard
register
report_page
@@ -71,6 +72,12 @@
(action
(run dream_eml %{deps} --workspace %{workspace_root})))
+(rule
+ (targets post_form.ml)
+ (deps post_form.eml.html)
+ (action
+ (run dream_eml %{deps} --workspace %{workspace_root})))
+
(rule
(targets register.ml)
(deps register.eml.html)
diff --git a/src/js/babillard.ml b/src/js/babillard.ml
index 80e1c40..7d36a27 100644
--- a/src/js/babillard.ml
+++ b/src/js/babillard.ml
@@ -5,7 +5,7 @@ open Map
module Visibility = struct
let new_thread_div = find_by_id "new-thread"
- let thread_comment = find_by_id "thread-comment"
+ let thread_comment = find_by_id "comment"
let thread_preview_div = find_by_id "thread-preview"
@@ -99,7 +99,7 @@ let lat_input = find_by_id "lat-input"
let lng_input = find_by_id "lng-input"
-let button = find_by_id "submit-new-thread-button"
+let button = find_by_id "submit-button"
(* set input lat/lng when clicked*)
let on_click_set_latlng e =
diff --git a/src/js/post_form.ml b/src/js/post_form.ml
index 295721f..d7e9c3d 100644
--- a/src/js/post_form.ml
+++ b/src/js/post_form.ml
@@ -10,7 +10,7 @@ let insert_quote el _event =
| None -> "no data-emojid on element"
| Some emojid -> Jstr.to_string emojid
in
- let textarea = find_by_id "reply-comment" in
+ let textarea = find_by_id "comment" in
let inner_html = El.Prop.jstr (Jstr.of_string "innerHTML") in
let content = Jstr.to_string @@ El.prop inner_html textarea in
let new_content =
diff --git a/src/permap.ml b/src/permap.ml
index dd16617..fd9a251 100644
--- a/src/permap.ml
+++ b/src/permap.ml
@@ -286,21 +286,21 @@ let babillard_post request =
| `Ok
[ ("alt", [ (_, alt) ])
; ("category", categories)
+ ; ("comment", [ (_, comment) ])
; ("file", file)
; ("lat-input", [ (_, lat) ])
; ("lng-input", [ (_, lng) ])
; ("subject", [ (_, subject) ])
; ("tags", [ (_, tags) ])
- ; ("thread-comment", [ (_, comment) ])
]
| `Ok
( ("alt", [ (_, alt) ])
+ :: ("comment", [ (_, comment) ])
:: ("file", file)
:: ("lat-input", [ (_, lat) ])
:: ("lng-input", [ (_, lng) ])
:: ("subject", [ (_, subject) ])
:: ("tags", [ (_, tags) ])
- :: ("thread-comment", [ (_, comment) ])
:: ([] as categories) ) -> (
let categories = List.map snd categories in
match (Float.of_string_opt lat, Float.of_string_opt lng) with
@@ -348,8 +348,8 @@ let reply_post request =
match%lwt Dream.multipart request with
| `Ok
[ ("alt", [ (_, alt) ])
+ ; ("comment", [ (_, comment) ])
; ("file", file)
- ; ("reply-comment", [ (_, comment) ])
; ("tags", [ (_, tags) ])
] -> (
let parent_id = Dream.param request "thread_id" in
diff --git a/src/post_form.eml.html b/src/post_form.eml.html
new file mode 100644
index 0000000..3b5fb36
--- /dev/null
+++ b/src/post_form.eml.html
@@ -0,0 +1,33 @@
+let f thread_id request =
+% let action = match thread_id with |None -> "/" | Some id -> Format.sprintf "/thread/%s" id in
+% let checkboxes = match thread_id with |None -> Format.asprintf "%a" Pp_babillard.pp_checkboxes () | Some _id -> "" in
+
+<%s! Dream.form_tag ~action ~enctype:`Multipart_form_data request %>
+% begin if Option.is_none thread_id then
+
+
+
+ Subject
+
+% end;
+
+
+
+ Tags
+ <%s! checkboxes %>
+
+
+ Picture:
+
+
+ Image description:
+
+% begin match thread_id with
+% | None ->
+
+ Make Thread
+% | Some _id ->
+ Reply
+% end;
+
+
diff --git a/src/thread_page.eml.html b/src/thread_page.eml.html
index 177ed2e..94a03a0 100644
--- a/src/thread_page.eml.html
+++ b/src/thread_page.eml.html
@@ -7,24 +7,7 @@ let f thread_view thread_id request =
% let redirect = Dream.to_percent_encoded thread_url in
Login to reply!
% | Some _ ->
-
- <%s! Dream.form_tag ~action:( Format.sprintf "/thread/%s" thread_id)
- ~enctype:`Multipart_form_data request %>
-
-
-
-
- Tags:
-
-
- Picture:
-
-
- Image description:
-
- Reply
-
-
+<%s! Post_form.f (Some thread_id) request %>
% end;
% let feed_url = Format.sprintf "%s/feed" thread_url in
>