<div class="comments">
<hr>
<h3>Comments</h3>
{% if comments is empty %}
<div class="border p-3 text-center">
<i>There are currently no comments here.</i>
</div>
{% endif %}
{% for comment in comments %}
<div class="row comment">
<div class="col-2 comment-author">
{% if comment.user is not empty %}
<img src="{{ comment.user.getAvatarURL() }}" width="80px" height="80px" loading='lazy' alt="User Avatar" />
{% else %}
<img src="https://www.gravatar.com/avatar/e1fe9118ba2d464f85c8c01845cb260b?s=80&r=g&d=mm" width="80px" height="80px" loading='lazy' />
{% endif %}
</div>
{% apply spaceless %}
<div class="col-10 comment-content">
<strong>
{% if comment.authorurl is not empty %}
<div><a href="{{comment.authorurl|external_link}}">{{comment.author}}</a></div>
{% else %}
<div>{{comment.author}}</div>
{% endif %}
{# if is_granted('IS_AUTHENTICATED_REMEMBERED') and (comment.author == app.user or app.user.isAdmin()) #}
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') and app.user.isAdmin() %}
<span class="float-right">
<a target="_blank" href="/admin/app/comment/{{comment.id}}/edit"><i class="fa fa-pencil"></i> Edit Comment</a>
</span>
{% endif %}
<div>{{ comment.createdat|date("F j, Y") }}</div>
</strong>
{#<div>{{ comment.commenttext|trim|raw }}</div>#}
<div>{{ comment.commenttext|trim }}</div>
</div>
{% endapply %}
</div>
{% endfor %}
<br>
<h3>Leave a Reply</h3>
{#
{{ form_start(form) }}
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
Logged in as {{ app.user.getDisplayname() }}.
{% else %}
{{ form_row(form.author) }}
{{ form_row(form.author_email) }}
{{ form_row(form.author_url) }}
{% endif %}
{{ form_row(form.comment_text) }}
<input type="submit" class="button" value="Submit Comment" />
{{ form_row(form._token) }}
{{ form_end(form, {'render_rest': false}) }}
#}
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
<form method="post" name="comment">
Logged in as {{ app.user.getDisplayname() }}.
<div class="form-row">
<label>Your Comment:</label>
<textarea class="form-control" name="comment-text" placeholder="The text of your comment..." required></textarea>
</div>
<input type="submit" class="button" value="Submit Comment" />
</form>
<script>
$('form[name=comment]').submit(function (e) {
$.ajax({
type: 'post',
data: $('form[name=comment]').serialize(),
success: function(){
location.reload()
}
});
e.preventDefault()
})
</script>
{% else %}
<div class="alert alert-warning row">
Commenting is only accessible to RCS users.
</div>
<div style="text-align:center">
<h3>Have an account? Login to leave a comment!</h3>
<br>
<a class="button text-white" href="/sign-in"><i class="fa fa-key"></i> Sign In</a>
</div>
{% endif %}
</div>