new file mode 100644
@@ -0,0 +1,10 @@
+from django import template
+register = template.Library()
+
+@register.filter
+def truncate(text, chars):
+ """Truncates the given text after the given number of chars."""
+ if len(text) > chars:
+ return text[:chars] + "..."
+ else:
+ return text
@@ -3,9 +3,10 @@
{% load syntax %}
{% load person %}
{% load patch %}
+{% load truncate %}
{% block title %}{{patch.name}}{% endblock %}
-{% block heading %}{{patch.name}}{%endblock%}
+{% block heading %}{{patch.name|truncate:70}}{%endblock%}
{% block body %}
<script language="JavaScript" type="text/javascript">
@@ -33,6 +34,10 @@ function toggle_headers(link_id, headers_id)
<td>{{ patch.submitter|personify }}</td></tr>
</tr>
<tr>
+ <th>Subject</th>
+ <td>{{ patch.name }}</td></tr>
+ </tr>
+ <tr>
<th>Date</th>
<td>{{ patch.date }}</td>
</tr>
If we don't do this they may span multiple lines, causing the top-bar to expand and look awful. Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> --- An example of a patch which has a name too long: http://patchwork.ozlabs.org/patch/99869/ Oh, the 70-chars length was chosen because with that added to the other (fixed) elements of the heading it still fits in one line on a 1280px wide screen. Feel free to tweak it to a smaller number if you'd like it to fit on a 1024px wide screen. apps/patchwork/templatetags/truncate.py | 10 ++++++++++ templates/patchwork/patch.html | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletions(-) create mode 100644 apps/patchwork/templatetags/truncate.py