diff --git a/pyweb/mumble/templatetags/mumble_extras.py b/pyweb/mumble/templatetags/mumble_extras.py index f5afdd0..64f8567 100644 --- a/pyweb/mumble/templatetags/mumble_extras.py +++ b/pyweb/mumble/templatetags/mumble_extras.py @@ -28,4 +28,10 @@ def mrange( value ): register.filter( 'mrange', mrange ); +### FILTER: trunc -- converts "a very very extaordinary long text" to "a very very extra..." +def trunc( string, maxlen = 50 ): + if len(string) < maxlen: + return string; + return string[:(maxlen - 3)] + "..."; +register.filter( 'trunc', trunc ); diff --git a/template/mumble/content.htm b/template/mumble/content.htm index 3aed433..7cbe061 100644 --- a/template/mumble/content.htm +++ b/template/mumble/content.htm @@ -26,14 +26,14 @@ {% endspaceless %} {% if item.1.is_player %} player - {{ item.1.name }} + {{ item.1.name|trunc:30 }} {% else %} {% if item.1.linked %} linked channel {% else %} channel {% endif %} - {{ item.1.name }} + {{ item.1.name|trunc:30 }} {% endif %}