make things pretty

This commit is contained in:
zapashcanon 2022-02-18 02:39:25 +01:00
parent a5eeb32fbe
commit abb70caabd
No known key found for this signature in database
GPG key ID: 8981C3C62D1D28F1
4 changed files with 61 additions and 44 deletions

View file

@ -4,12 +4,12 @@ let f request =
<br /> <br />
<div class="row mb-3"> <div class="row mb-3">
<div class="col-md-6"> <div class="col-md-6">
% if Option.is_some @@ Dream.session "nick" request then begin
<a href="/babillard/new_thread" >[New Thread]</a>
% end;
<div id="map"></div> <div id="map"></div>
<br /> <br />
<button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button> <button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button>
% if Option.is_some @@ Dream.session "nick" request then begin
<a class="btn btn-primary" href="/babillard/new_thread">New Thread</a>
% end;
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div id="thread_preview_div"></div> <div id="thread_preview_div"></div>

View file

@ -1,39 +1,43 @@
let f request = let f request =
% begin match Dream.session "nick" request with % begin match Dream.session "nick" request with
% | None -> % | None ->
Login to make a new thread. <a href="/login">Login</a> to make a new thread.
% | Some _nick -> % | Some _nick ->
<script type="text/javascript" src="/assets/js/js_newthread.js" defer="defer"></script> <script type="text/javascript" src="/assets/js/js_newthread.js" defer="defer"></script>
<div id="newthread">Click the map to make a new thread:</div> <h1>New thread</h1>
<div class="row mb-3"> <div id="newthread">
Click the map to make a new thread:
</div>
<br />
<div class="row mb-3">
<div class="col-md-6"> <div class="col-md-6">
<div id="map"></div> <div id="map"></div>
<button onclick="geolocalize()">Geolocalize me</button> <br />
<button class="btn btn-primary" onclick="geolocalize()">Geolocalize me</button>
</div> </div>
<div class="col-md-6" id="newthread-form"> <div class="col-md-6" id="newthread-form">
<div class="postForm"> <div class="postForm">
<%s! Dream.form_tag ~action:"/babillard/new_thread" ~enctype:`Multipart_form_data request %> <%s! Dream.form_tag ~action:"/babillard/new_thread" ~enctype:`Multipart_form_data request %>
<input type="hidden" id="lat_input" name="lat_input"> <input type="hidden" id="lat_input" name="lat_input">
<input type="hidden" id="lng_input" name="lng_input"> <input type="hidden" id="lng_input" name="lng_input">
<label for="subject" id="subjectLabel" class="form-label">Subject</label> <label for="subject" id="subjectLabel" class="form-label">Subject</label>
<input name="subject" type="text" class="form-control" id="subject" aria-labelledby="subjectLabel"></input> <input name="subject" type="text" class="form-control" id="subject" aria-labelledby="subjectLabel"></input>
<label for="threadComment" id="threadCommentLabel" class="form-label">Comment</label> <label for="threadComment" id="threadCommentLabel" class="form-label">Comment</label>
<textarea name="threadComment" type="text" class="form-control" id="threadComment" aria-labelledby="threadCommentLabel"></textarea> <textarea name="threadComment" type="text" class="form-control" id="threadComment" aria-labelledby="threadCommentLabel"></textarea>
<label for="tags" id="tagsLabel" class="form-label">Tags</label> <label for="tags" id="tagsLabel" class="form-label">Tags</label>
<input name="tags" type="text" class="form-control" id="tags" aria-labelledby="tagsLabel"></input> <input name="tags" type="text" class="form-control" id="tags" aria-labelledby="tagsLabel"></input>
<label for="file" id="fileLabel" class="form-label">Picture:</label> <label for="file" id="fileLabel" class="form-label">Picture:</label>
<input id="file" name="file" aria-describedby="fileLabel" type="file" accept="image/*"> <input id="file" name="file" aria-describedby="fileLabel" type="file" accept="image/*">
<label for="alt" id="altLabel" class="form-label">Image description:</label> <label for="alt" id="altLabel" class="form-label">Image description:</label>
<input name="alt" type="text" class="form-control" id="alt" aria-labelledby="altLabel"></input> <input name="alt" type="text" class="form-control" id="alt" aria-labelledby="altLabel"></input>
<button type="submit" class="btn btn-primary">Make Thread</button> <button type="submit" class="btn btn-primary">Make Thread</button>
</form> </form>
</div>
</div> </div>
</div> </div>
</div>
% end; % end;

View file

@ -129,8 +129,18 @@ let public_profile request =
let^? nick, _password, _email, (bio, _) = Db.find_opt Q.get_user nick in let^? nick, _password, _email, (bio, _) = Db.find_opt Q.get_user nick in
let user_info = let user_info =
Format.sprintf Format.sprintf
{|nick = `%s`; bio = '%s'; {|
<img src="/user/%s/avatar" class="img-thumbnail" alt="Your avatar picture">|} <h1>%s</h1>
<br />
<div class="row">
<div class="col-md-6">
<blockquote>%s</blockquote>
</div>
<div class="col-md-6">
<img src="/user/%s/avatar" class="img-thumbnail" alt="Your avatar picture">
</div>
</div>
|}
nick (Dream.html_escape bio) nick nick (Dream.html_escape bio) nick
in in
Ok user_info Ok user_info

View file

@ -1,16 +1,19 @@
let f nick bio request = let f nick bio request =
<%s Format.sprintf "Hello %s !" nick %> <h1><%s Format.sprintf "Hello %s !" nick %></h1>
<%s! Dream.form_tag ~action:"/profile" request %> <%s! Dream.form_tag ~action:"/profile" request %>
<div class="mb-3"> <div class="mb-3">
<label for="bio" class="form-label">Bio</label> <label for="bio" class="form-label">Bio</label>
<textarea name="bio" type="text" class="form-control" id="bio" aria-describedby="bioHelp"><%s bio %></textarea> <textarea name="bio" type="text" class="form-control" id="bio" aria-describedby="bioHelp"><%s bio %></textarea>
<div id="bioHelp" class="form-text">Who are you?</div> <div id="bioHelp" class="form-text">Who are you?</div>
</div> </div>
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary">Save</button>
</form> </form>
<br />
<img src="/user/<%s nick %>/avatar" class="img-thumbnail" alt="Your avatar picture"> <img src="/user/<%s nick %>/avatar" class="img-thumbnail" alt="Your avatar picture" />
<%s! Dream.form_tag ~action:"/profile" ~enctype:`Multipart_form_data request %> <br />
<input name="file" type="file"> <br />
<button>Submit!</button> <%s! Dream.form_tag ~action:"/profile" ~enctype:`Multipart_form_data request %>
</form> <input name="file" type="file"><br />
<br />
<button class="btn btn-primary">Submit picture!</button>
</form>