diff --git a/snipts/templates/snipts/snipt-list.html b/snipts/templates/snipts/snipt-list.html index b151483..ca06a38 100644 --- a/snipts/templates/snipts/snipt-list.html +++ b/snipts/templates/snipts/snipt-list.html @@ -1,4 +1,4 @@ -{% load humanize snipt_tags %} +{% load humanize snipt_tags truncate_lines %} {% snipt_is_favorited_by_user as 'is_favorited' %} @@ -57,7 +57,26 @@ {% else %} - {{ snipt.stylized|safe }} + {% if snipt.line_count > 300 and not detail %} + + + + + + + +
+
+

+                                          
+
+
+
{{ snipt.code|truncate_lines }}
+
+
+ {% else %} + {{ snipt.stylized|safe }} + {% endif %} {% endif %} {% endif %} {% if snipt.line_count > 8 and not detail and 'snipt-expand' not in snipt.tags_list %} diff --git a/utils/templatetags/truncate_lines.py b/utils/templatetags/truncate_lines.py new file mode 100644 index 0000000..1678993 --- /dev/null +++ b/utils/templatetags/truncate_lines.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.filter +def truncate_lines(text): + return '\n'.join(text.split('\n')[:300])