diff --git a/pastebin/apps/dpaste/templates/dpaste/snippet_details.html b/pastebin/apps/dpaste/templates/dpaste/snippet_details.html index 1916dfc..1f2ceb0 100644 --- a/pastebin/apps/dpaste/templates/dpaste/snippet_details.html +++ b/pastebin/apps/dpaste/templates/dpaste/snippet_details.html @@ -1,6 +1,7 @@ {% extends "dpaste/base.html" %} {% load mptt_tags %} {% load i18n %} +{% load dpaste_tags %} {% block extrahead %} {% if request.session.userprefs %} @@ -24,7 +25,6 @@ {{ snippet.published|date:_("DATETIME_FORMAT") }} ({% trans "UTC" %}) {% endblock %} -{% load dpaste_tags %} {% block content %}
diff --git a/pastebin/apps/dpaste/templates/dpaste/snippet_list.html b/pastebin/apps/dpaste/templates/dpaste/snippet_list.html index 658b522..4b01def 100644 --- a/pastebin/apps/dpaste/templates/dpaste/snippet_list.html +++ b/pastebin/apps/dpaste/templates/dpaste/snippet_list.html @@ -1,7 +1,8 @@ {% extends "dpaste/base.html" %} {% load i18n %} +{% load dpaste_tags %} -{% block title %}{% trans "Snippet" %} #{{ snippet.pk }}{% endblock %} +{% block title %}{% trans "Snippet List" %}{% endblock %} {% block headline %}{{ snippet.content|truncatewords:40 }}
- {% endfor %} + +{% for l in lines %}{{ forloop.counter }}{% endfor %} |
+ {% for line in snippet|highlight:5 %} | + |
---|
{% trans "No snippets available." %}
{% endif %} diff --git a/pastebin/apps/dpaste/templatetags/dpaste_tags.py b/pastebin/apps/dpaste/templatetags/dpaste_tags.py index 1b5279f..d545929 100644 --- a/pastebin/apps/dpaste/templatetags/dpaste_tags.py +++ b/pastebin/apps/dpaste/templatetags/dpaste_tags.py @@ -10,8 +10,12 @@ def in_list(value,arg): return value in arg @register.filter -def highlight(snippet): +def highlight(snippet, maxlines=None): h = pygmentize(snippet.content, snippet.lexer) if not h: - return snippet.content.splitlines() - return h.splitlines() \ No newline at end of file + s = snippet.content.splitlines() + s = h.splitlines() + + if maxlines: + return s[:maxlines] + return s \ No newline at end of file