Skip to content

Commit 8f6a26b

Browse files
committed
Hack the format_history_text filter to be less weird, using the same
formatting for snippets and full text, also link up legacy ballot set events - Legacy-Id: 5209
1 parent d56c675 commit 8f6a26b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

ietf/idtracker/templatetags/ietf_filters.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from django import template
55
from django.conf import settings
66
from django.utils.html import escape, fix_ampersands
7-
from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter, urlize, truncatewords_html
7+
from django.utils.text import truncate_html_words
8+
from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter, urlize
89
from django.template import resolve_variable
910
from django.utils.safestring import mark_safe, SafeData
1011
from django.utils import simplejson
@@ -460,9 +461,14 @@ def ad_area(user):
460461
@register.filter
461462
def format_history_text(text):
462463
"""Run history text through some cleaning and add ellipsis if it's too long."""
463-
full = mark_safe(sanitize_html(keep_spacing(linebreaksbr(urlize(mark_safe(text))))))
464-
snippet = truncatewords_html(format_textarea(text), 25)
465-
if snippet[-3:] == "...":
464+
full = mark_safe(text)
465+
466+
if text.startswith("This was part of a ballot set with:"):
467+
full = urlize_ietf_docs(full)
468+
469+
full = mark_safe(sanitize_html(keep_spacing(linebreaksbr(urlize(full)))))
470+
snippet = truncate_html_words(full, 25)
471+
if snippet != full:
466472
return mark_safe(u'<div class="snippet">%s<span class="showAll">[show all]</span></div><div style="display:none" class="full">%s</div>' % (snippet, full))
467473
return full
468474

0 commit comments

Comments
 (0)