add post_form.eml.html
This commit is contained in:
parent
a6fc9b4346
commit
d090934183
7 changed files with 48 additions and 48 deletions
|
|
@ -25,30 +25,7 @@ let f request =
|
||||||
Click the map and make a new thread:
|
Click the map and make a new thread:
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
<div class="postForm">
|
<%s! Post_form.f None request %>
|
||||||
<%s! Dream.form_tag ~action:"/" ~enctype:`Multipart_form_data request %>
|
|
||||||
<input type="hidden" id="lat-input" name="lat-input">
|
|
||||||
<input type="hidden" id="lng-input" name="lng-input">
|
|
||||||
|
|
||||||
<label for="subject" id="subject-label" class="form-label">Subject</label>
|
|
||||||
<input name="subject" type="text" class="form-control" id="subject" aria-labelledby="subject-label" />
|
|
||||||
<br />
|
|
||||||
<label for="thread-comment" id="thread-comment-label" class="form-label">Comment</label>
|
|
||||||
<textarea name="thread-comment" type="text" class="form-control" id="thread-comment" aria-labelledby="thread-comment-label"></textarea>
|
|
||||||
<br />
|
|
||||||
<label for="tags" id="tags-label" class="form-label">Tags</label>
|
|
||||||
<%s! Format.asprintf "%a" Pp_babillard.pp_checkboxes () %>
|
|
||||||
<input name="tags" type="text" class="form-control" id="tags" aria-labelledby="tags-label" />
|
|
||||||
<br />
|
|
||||||
<label for="file" id="file-label" class="form-label">Picture:</label>
|
|
||||||
<input id="file" name="file" aria-describedby="file-label" type="file" accept="image/png,image/jpeg,image/webp,image/gif">
|
|
||||||
<br />
|
|
||||||
<label for="alt" id="alt-label" class="form-label off">Image description:</label>
|
|
||||||
<input name="alt" type="text" class="form-control off" id="alt" aria-labelledby="alt-label" />
|
|
||||||
<br />
|
|
||||||
<button type="submit" class="btn btn-primary" id="submit-new-thread-button" disabled>Make Thread</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
7
src/dune
7
src/dune
|
|
@ -13,6 +13,7 @@
|
||||||
emojid
|
emojid
|
||||||
login
|
login
|
||||||
permap
|
permap
|
||||||
|
post_form
|
||||||
pp_babillard
|
pp_babillard
|
||||||
register
|
register
|
||||||
report_page
|
report_page
|
||||||
|
|
@ -71,6 +72,12 @@
|
||||||
(action
|
(action
|
||||||
(run dream_eml %{deps} --workspace %{workspace_root})))
|
(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
|
(rule
|
||||||
(targets register.ml)
|
(targets register.ml)
|
||||||
(deps register.eml.html)
|
(deps register.eml.html)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ open Map
|
||||||
module Visibility = struct
|
module Visibility = struct
|
||||||
let new_thread_div = find_by_id "new-thread"
|
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"
|
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 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*)
|
(* set input lat/lng when clicked*)
|
||||||
let on_click_set_latlng e =
|
let on_click_set_latlng e =
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ let insert_quote el _event =
|
||||||
| None -> "no data-emojid on element"
|
| None -> "no data-emojid on element"
|
||||||
| Some emojid -> Jstr.to_string emojid
|
| Some emojid -> Jstr.to_string emojid
|
||||||
in
|
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 inner_html = El.Prop.jstr (Jstr.of_string "innerHTML") in
|
||||||
let content = Jstr.to_string @@ El.prop inner_html textarea in
|
let content = Jstr.to_string @@ El.prop inner_html textarea in
|
||||||
let new_content =
|
let new_content =
|
||||||
|
|
|
||||||
|
|
@ -286,21 +286,21 @@ let babillard_post request =
|
||||||
| `Ok
|
| `Ok
|
||||||
[ ("alt", [ (_, alt) ])
|
[ ("alt", [ (_, alt) ])
|
||||||
; ("category", categories)
|
; ("category", categories)
|
||||||
|
; ("comment", [ (_, comment) ])
|
||||||
; ("file", file)
|
; ("file", file)
|
||||||
; ("lat-input", [ (_, lat) ])
|
; ("lat-input", [ (_, lat) ])
|
||||||
; ("lng-input", [ (_, lng) ])
|
; ("lng-input", [ (_, lng) ])
|
||||||
; ("subject", [ (_, subject) ])
|
; ("subject", [ (_, subject) ])
|
||||||
; ("tags", [ (_, tags) ])
|
; ("tags", [ (_, tags) ])
|
||||||
; ("thread-comment", [ (_, comment) ])
|
|
||||||
]
|
]
|
||||||
| `Ok
|
| `Ok
|
||||||
( ("alt", [ (_, alt) ])
|
( ("alt", [ (_, alt) ])
|
||||||
|
:: ("comment", [ (_, comment) ])
|
||||||
:: ("file", file)
|
:: ("file", file)
|
||||||
:: ("lat-input", [ (_, lat) ])
|
:: ("lat-input", [ (_, lat) ])
|
||||||
:: ("lng-input", [ (_, lng) ])
|
:: ("lng-input", [ (_, lng) ])
|
||||||
:: ("subject", [ (_, subject) ])
|
:: ("subject", [ (_, subject) ])
|
||||||
:: ("tags", [ (_, tags) ])
|
:: ("tags", [ (_, tags) ])
|
||||||
:: ("thread-comment", [ (_, comment) ])
|
|
||||||
:: ([] as categories) ) -> (
|
:: ([] as categories) ) -> (
|
||||||
let categories = List.map snd categories in
|
let categories = List.map snd categories in
|
||||||
match (Float.of_string_opt lat, Float.of_string_opt lng) with
|
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
|
match%lwt Dream.multipart request with
|
||||||
| `Ok
|
| `Ok
|
||||||
[ ("alt", [ (_, alt) ])
|
[ ("alt", [ (_, alt) ])
|
||||||
|
; ("comment", [ (_, comment) ])
|
||||||
; ("file", file)
|
; ("file", file)
|
||||||
; ("reply-comment", [ (_, comment) ])
|
|
||||||
; ("tags", [ (_, tags) ])
|
; ("tags", [ (_, tags) ])
|
||||||
] -> (
|
] -> (
|
||||||
let parent_id = Dream.param request "thread_id" in
|
let parent_id = Dream.param request "thread_id" in
|
||||||
|
|
|
||||||
33
src/post_form.eml.html
Normal file
33
src/post_form.eml.html
Normal file
|
|
@ -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
|
||||||
|
<div class="post-form">
|
||||||
|
<%s! Dream.form_tag ~action ~enctype:`Multipart_form_data request %>
|
||||||
|
% begin if Option.is_none thread_id then
|
||||||
|
<input type="hidden" id="lat-input" name="lat-input">
|
||||||
|
<input type="hidden" id="lng-input" name="lng-input">
|
||||||
|
|
||||||
|
<label for="subject" id="subject-label" class="form-label">Subject</label>
|
||||||
|
<input name="subject" type="text" class="form-control" id="subject" aria-labelledby="subject-label" />
|
||||||
|
% end;
|
||||||
|
<label for="comment" id="comment-label" class="form-label">Comment</label>
|
||||||
|
<textarea name="comment" type="text" class="form-control" id="comment" aria-labelledby="comment-label"></textarea>
|
||||||
|
|
||||||
|
<label for="tags" id="tags-label" class="form-label">Tags</label>
|
||||||
|
<%s! checkboxes %>
|
||||||
|
<input name="tags" type="text" class="form-control" id="tags" aria-labelledby="tags-label" />
|
||||||
|
|
||||||
|
<label for="file" id="file-label" class="form-label">Picture:</label>
|
||||||
|
<input id="file" name="file" aria-describedby="file-label" type="file" accept="image/png,image/jpeg,image/webp,image/gif">
|
||||||
|
|
||||||
|
<label for="alt" id="alt-label" class="form-label off">Image description:</label>
|
||||||
|
<input name="alt" type="text" class="form-control off" id="alt" aria-labelledby="alt-label" />
|
||||||
|
% begin match thread_id with
|
||||||
|
% | None ->
|
||||||
|
<br />
|
||||||
|
<button type="submit" class="btn btn-primary" id="submit-button" disabled>Make Thread</button>
|
||||||
|
% | Some _id ->
|
||||||
|
<button type="submit" class="btn btn-primary" id="submit-button">Reply</button>
|
||||||
|
% end;
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
@ -7,24 +7,7 @@ let f thread_view thread_id request =
|
||||||
% let redirect = Dream.to_percent_encoded thread_url in
|
% let redirect = Dream.to_percent_encoded thread_url in
|
||||||
<a href="/login?redirect=<%s redirect%>">Login to reply!</a>
|
<a href="/login?redirect=<%s redirect%>">Login to reply!</a>
|
||||||
% | Some _ ->
|
% | Some _ ->
|
||||||
<div class="post-form">
|
<%s! Post_form.f (Some thread_id) request %>
|
||||||
<%s! Dream.form_tag ~action:( Format.sprintf "/thread/%s" thread_id)
|
|
||||||
~enctype:`Multipart_form_data request %>
|
|
||||||
|
|
||||||
<label for="reply-comment" id="reply-comment-label" class="form-label">Comment:</label>
|
|
||||||
<textarea name="reply-comment" type="text" class="form-control" id="reply-comment" aria-labelledby="reply-comment-label"></textarea>
|
|
||||||
|
|
||||||
<label for="tags" id="tags-label" class="form-label">Tags:</label>
|
|
||||||
<input name="tags" type="text" class="form-control" id="tags" aria-labelledby="tags-label"></input>
|
|
||||||
|
|
||||||
<label for="file" id="file-label" class="form-label">Picture:</label>
|
|
||||||
<input id="file" name="file" aria-describedby="file-label" type="file" accept="image/*">
|
|
||||||
|
|
||||||
<label for="alt" id="alt-label" class="form-label">Image description:</label>
|
|
||||||
<input name="alt" type="text" class="form-control" id="alt" aria-labelledby="alt-label"></input>
|
|
||||||
<button type="submit" class="btn btn-primary">Reply</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
% end;
|
% end;
|
||||||
% let feed_url = Format.sprintf "%s/feed" thread_url in
|
% let feed_url = Format.sprintf "%s/feed" thread_url in
|
||||||
<a type="application/atom+xml" href=<%s! feed_url %> >
|
<a type="application/atom+xml" href=<%s! feed_url %> >
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue