# HG changeset patch # User neko259 # Date 2013-11-16 17:16:00 # Node ID 3930783499f660d6f8e996e6fe8f1af0b6fac2d1 # Parent 6bb724cd4a07d4fe80a19acd64106c1d237e14ee Truncate posts in reflink popups diff --git a/boards/static/js/refpopup.js b/boards/static/js/refpopup.js --- a/boards/static/js/refpopup.js +++ b/boards/static/js/refpopup.js @@ -57,7 +57,7 @@ function showPostPreview(e) { }; - cln.innerHTML = gettext('Loading...'); + cln.innerHTML = "
" + gettext('Loading...') + "
"; //если пост найден в дереве. if($('div[id='+pNum+']').length > 0) { @@ -72,7 +72,7 @@ function showPostPreview(e) { //ajax api else { $.ajax({ - url: '/api/post/' + pNum + '/' + url: '/api/post/' + pNum + '/?truncated' }) .success(function(data) { // TODO get a json, not post itself @@ -83,7 +83,8 @@ function showPostPreview(e) { }) .error(function() { - cln.innerHTML = gettext('Post not found'); + cln.innerHTML = "
" + + gettext('Post not found') + "
"; }); } diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -39,7 +39,11 @@ {% endif %} {% autoescape off %} - {{ post.text.rendered }} + {% if truncated %} + {{ post.text.rendered|truncatewords_html:50 }} + {% else %} + {{ post.text.rendered }} + {% endif %} {% endautoescape %} {% if post.is_referenced %}
diff --git a/boards/views.py b/boards/views.py --- a/boards/views.py +++ b/boards/views.py @@ -449,6 +449,8 @@ def get_post(request, post_id): context = RequestContext(request) context["post"] = post context["can_bump"] = thread.can_bump() + if "truncated" in request.GET: + context["truncated"] = True return render(request, 'boards/post.html', context)