Skip to content

Commit

Permalink
Commenting in new template
Browse files Browse the repository at this point in the history
  • Loading branch information
symkat committed Nov 29, 2021
1 parent 2ce90ca commit b7e170a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 42 deletions.
33 changes: 33 additions & 0 deletions Web/templates/simple/blog/_comment.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- Begin simple/blog/_comment.tx -->
<div class="card my-4">
<div class="card-body">
<div class="">
<a href="#">u/[% $comment.author.username %]</a>
<small><span title="[% $comment.created_at %]">[% $comment.time_ago %]</span></small>
</div>
<div class="pt-4">
%% $comment.content
</div>
<br />
<a class="card-link" data-bs-toggle="collapse" href="#replyForm[% $comment.id %]" role="button" aria-expanded="false" aria-controls="replyForm[% $comment.id %]">[Reply]</a>
<a href="#" class="card-link">[Permlink]</a>
<div id="replyForm[% $comment.id %]" class="row mx-2 my-4 collapse">
<form method="POST" action="[% $c.url_for( 'do_blog_comment' ) %]">
<input type="hidden" name="parent_id" value="[% $comment.id %]" />
<input type="hidden" name="blog_id" value="[% $blog.id %]" />
<div class="mb-3">
<label for="message" class="form-label">Post a Reply</label>
<textarea class="form-control" name="message" id="message" rows="3"></textarea>
</div>

<button type="submit" class="btn btn-primary float-end">Post Message</button>
</form>
</div>
</div>
%% for $comment.get_children -> $child_comment {
<div style="margin-left: 2em">
%% include "/default/blog/_comment.tx" { comment => $child_comment };
</div>
%% }
</div>
<!-- End simple/blog/_comment.tx -->
76 changes: 34 additions & 42 deletions Web/templates/simple/blog/item.html.tx
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,39 @@



<!-- Comments section-->
<section class="mb-5">
<div class="card bg-light">
<div class="card-body">
<!-- Comment form-->
<form class="mb-4"><textarea class="form-control" rows="3" placeholder="Join the discussion and leave a comment!"></textarea></form>
<!-- Comment with nested comments-->
<div class="d-flex mb-4">
<!-- Parent comment-->
<div class="flex-shrink-0"><img class="rounded-circle" src="https://dummyimage.com/50x50/ced4da/6c757d.jpg" alt="..." /></div>
<div class="ms-3">
<div class="fw-bold">Commenter Name</div>
If you're going to lead a space frontier, it has to be government; it'll never be private enterprise. Because the space frontier is dangerous, and it's expensive, and it has unquantified risks.
<!-- Child comment 1-->
<div class="d-flex mt-4">
<div class="flex-shrink-0"><img class="rounded-circle" src="https://dummyimage.com/50x50/ced4da/6c757d.jpg" alt="..." /></div>
<div class="ms-3">
<div class="fw-bold">Commenter Name</div>
And under those conditions, you cannot establish a capital-market evaluation of that enterprise. You can't get investors.
</div>
</div>
<!-- Child comment 2-->
<div class="d-flex mt-4">
<div class="flex-shrink-0"><img class="rounded-circle" src="https://dummyimage.com/50x50/ced4da/6c757d.jpg" alt="..." /></div>
<div class="ms-3">
<div class="fw-bold">Commenter Name</div>
When you put money directly to a problem, it makes a good headline.
</div>
</div>
</div>
</div>
<!-- Single comment-->
<div class="d-flex">
<div class="flex-shrink-0"><img class="rounded-circle" src="https://dummyimage.com/50x50/ced4da/6c757d.jpg" alt="..." /></div>
<div class="ms-3">
<div class="fw-bold">Commenter Name</div>
When I look at the universe and all the ways the universe wants to kill us, I find it hard to reconcile that with statements of beneficence.
</div>
</div>
</div>
</div>
</section>
<!-- Start Comments / Review section-->
<section class="mb-5">
<div class="card bg-light">
<div class="card-body">
<!-- Begin Review / Root Comment Form-->
<div class="row">
<form method="post" action="[% $c.url_for( 'do_blog_comment' ) %]">
<input type="hidden" name="blog_id" value="[% $blog.id %]">

<textarea class="form-control" id="message" name="message" rows="4" placeholder="What do you think of [% $blog.title %]?">[% $form_message %]</textarea>

<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" value="1" name="rev_pos" id="rev_pos" [% $form_rev_pos ? " checked " : "" %]>
<label class="form-check-label" for="rev_pos">This is a positive review. I recommend this blog.</label>
</div>

<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" value="1" name="rev_neg" id="rev_neg" [% $form_rev_neg ? " checked " : "" %]>
<label class="form-check-label" for="rev_neg">This is a negative review. I dislike this blog.</label>
</div>

<button type="submit" class="btn btn-primary float-end">Post Review</button>
</form>
</div>
<!-- End Review / Root Comment Form-->
<div class="row">
%% for $blog.get_comments -> $comment {
%% include "/simple/blog/_comment.tx" { comment => $comment };
%% }
</div>
</div>
</div>
</section>
<!-- End Comments / Review section-->

%% }

0 comments on commit b7e170a

Please sign in to comment.