mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 20:19:59 +00:00
only allow logged in users to comment
This commit is contained in:
parent
c3a637c8eb
commit
9bd71af1b2
|
@ -136,48 +136,59 @@
|
||||||
Comments - {{ comment_count }}
|
Comments - {{ comment_count }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-collapse">
|
{% for comment in comments %}
|
||||||
<table class="table table-bordered table-striped">
|
<div class="panel panel-default">
|
||||||
<thead>
|
<div class="panel-body" >
|
||||||
{% if g.user.is_admin %}
|
<div class="row">
|
||||||
<th style="width:auto;">Delete</th>
|
<div class="col-md-2">
|
||||||
{% endif %}
|
<p>
|
||||||
<th style="width:auto;">Date</th>
|
{% set user_url = torrent.user and url_for('view_user', user_name=comment.user.username) %}
|
||||||
<th style="width:auto;">User</th>
|
<a href="{{ user_url }}">{{ comment.user.username }}</a>
|
||||||
<th style="width:100%;">Comment</th>
|
{% if comment.user.id == torrent.uploader_id and not torrent.anonymous %}
|
||||||
</thead>
|
(uploader)
|
||||||
<tbody>
|
|
||||||
{% for comment in comments %}
|
|
||||||
<tr>
|
|
||||||
{% if g.user.is_admin %}
|
|
||||||
<td class="col-md-1">
|
|
||||||
<a href="{{ url_for('delete_comment', torrent_id=torrent.id, comment_id=comment.id )}}"><i class="fa fa-ban"></i></a>
|
|
||||||
</td>
|
|
||||||
{% endif %}
|
|
||||||
<td class="col-md-1">
|
|
||||||
{% if comment.user %}
|
|
||||||
<a href="{{ url_for('view_user', user_name=comment.user.username) }}">
|
|
||||||
{{ comment.user.username }}
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
<span>Anonymous</span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</p>
|
||||||
<td class="col-md-1" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</td>
|
<p>{{ comment.user.userlevel_str }}</p>
|
||||||
<td class="col-md-9">{{ comment.text }}</td>
|
<p>
|
||||||
</tr>
|
<img style="max-width: 120px;" src="{{ comment.user.gravatar_url() }}">
|
||||||
{% endfor %}
|
</p>
|
||||||
<tbody>
|
{% if g.user.is_moderator or g.user.id == comment.user_id %}
|
||||||
</table>
|
<div class="row form-group">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="btn btn-default" title="Delete">
|
||||||
|
<a href="{{ url_for('delete_comment', comment_id=comment.id, torrent_id=torrent.id)}}">Delete</a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<small>{{comment.created_time | timesince}}</small><br><br>
|
||||||
|
{# Escape newlines into html entities because CF strips blank newlines #}
|
||||||
|
<div id="torrent-comment{{ comment.id }}">{{ comment.text }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
var target = document.getElementById('torrent-comment{{ comment.id }}');
|
||||||
|
var text = target.innerHTML;
|
||||||
|
var reader = new commonmark.Parser({safe: true});
|
||||||
|
var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '<br />'});
|
||||||
|
var parsed = reader.parse(text.trim());
|
||||||
|
target.innerHTML = writer.render(parsed);
|
||||||
|
</script>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="POST" action="{{ request.url }}/submit_comment">
|
{% if g.user %}
|
||||||
|
<form method="POST">
|
||||||
{{ form.csrf_token }}
|
{{ form.csrf_token }}
|
||||||
{{ render_field(form.comment, class_='form-control') }}
|
{{ render_field(form.comment, class_='form-control') }}
|
||||||
{{ render_field(form.is_anonymous) }}
|
|
||||||
<input type="submit" value="Submit" class="btn btn-primary">
|
<input type="submit" value="Submit" class="btn btn-primary">
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var target = document.getElementById('torrent-description');
|
var target = document.getElementById('torrent-description');
|
||||||
|
|
Loading…
Reference in a new issue