1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-23 00:30:05 +00:00

Spruce up comments.

This commit is contained in:
snowfag 2017-05-22 12:58:09 -04:00 committed by nyaadev
parent fee55c1792
commit aab3eaccaa
3 changed files with 52 additions and 35 deletions

View file

@ -394,7 +394,7 @@ class User(db.Model):
def gravatar_url(self): def gravatar_url(self):
# from http://en.gravatar.com/site/implement/images/python/ # from http://en.gravatar.com/site/implement/images/python/
size = 40 size = 120
# construct the url # construct the url
gravatar_url = 'https://www.gravatar.com/avatar/' + \ gravatar_url = 'https://www.gravatar.com/avatar/' + \
hashlib.md5(self.email.encode('utf-8').lower()).hexdigest() + '?' hashlib.md5(self.email.encode('utf-8').lower()).hexdigest() + '?'

View file

@ -218,3 +218,26 @@ table.torrent-list tbody tr td a:visited {
ul.nav-tabs#profileTabs { ul.nav-tabs#profileTabs {
margin-bottom: 15px; margin-bottom: 15px;
} }
.comments-panel {
width: 99%;
margin: 0 auto;
margin-top:10px;
margin-bottom:10px;
}
.comment-box {
width: 95%;
margin: 0 auto;
margin-top:30px;
margin-bottom:10px;
}
.delete-btn {
position: relative;
float: right;
}
.avatar {
max-width: 120px;
}

View file

@ -137,9 +137,8 @@
</h3> </h3>
</div> </div>
{% for comment in comments %} {% for comment in comments %}
<div class="panel panel-default"> <div class="panel panel-default comments-panel">
<div class="panel-body"> <div class="panel-body">
<div class="row">
<div class="col-md-2"> <div class="col-md-2">
<p> <p>
{% set user_url = torrent.user and url_for('view_user', user_name=comment.user.username) %} {% set user_url = torrent.user and url_for('view_user', user_name=comment.user.username) %}
@ -150,21 +149,17 @@
</p> </p>
<p>{{ comment.user.userlevel_str }}</p> <p>{{ comment.user.userlevel_str }}</p>
<p> <p>
<img style="max-width: 120px;" src="{{ comment.user.gravatar_url() }}"> <img class="avatar" src="{{ comment.user.gravatar_url() }}">
</p> </p>
{% if g.user.is_moderator or g.user.id == comment.user_id %}
<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>
<div class="col-md-10"> <div class="col-md-10">
<small>{{comment.created_time | timesince}}</small><br><br> <div class="row">
<small>{{comment.created_time | timesince}}</small>
{% if g.user.is_moderator or g.user.id == comment.user_id %}
<div class="btn btn-danger btn-sm delete-btn" title="Delete" onclick='location.href = "{{ url_for('delete_comment', comment_id=comment.id, torrent_id=torrent.id)}}";'>Delete</div>
{% endif %}
</div>
<div class="row">
{# Escape newlines into html entities because CF strips blank newlines #} {# Escape newlines into html entities because CF strips blank newlines #}
<div id="torrent-comment{{ comment.id }}">{{ comment.text }}</div> <div id="torrent-comment{{ comment.id }}">{{ comment.text }}</div>
</div> </div>
@ -180,15 +175,14 @@
target.innerHTML = writer.render(parsed); target.innerHTML = writer.render(parsed);
</script> </script>
{% endfor %} {% endfor %}
</div>
{% if g.user %} {% if g.user %}
<form method="POST"> <form method="POST" class="comment-box">
{{ form.csrf_token }} {{ form.csrf_token }}
{{ render_field(form.comment, class_='form-control') }} {{ render_field(form.comment, class_='form-control') }}
<input type="submit" value="Submit" class="btn btn-primary"> <input type="submit" value="Submit" class="btn btn-success btn-sm">
</form> </form>
{% endif %} {% endif %}
</div>
<script> <script>
var target = document.getElementById('torrent-description'); var target = document.getElementById('torrent-description');