0002-misc-use-Truncator-in-ellipsize-42744.patch
wcs/qommon/misc.py | ||
---|---|---|
39 | 39 |
from django.utils import six |
40 | 40 |
from django.utils.encoding import force_text |
41 | 41 |
from django.utils.html import strip_tags |
42 |
from django.template import engines, TemplateSyntaxError, VariableDoesNotExist
|
|
42 |
from django.template import TemplateSyntaxError, VariableDoesNotExist |
|
43 | 43 |
from django.utils.six.moves.html_parser import HTMLParser |
44 | 44 |
from django.utils.six.moves.urllib.parse import quote, urlencode |
45 | 45 |
from django.utils.six.moves.urllib import parse as urlparse |
46 |
from django.utils.text import Truncator |
|
46 | 47 | |
47 | 48 |
from quixote import get_publisher, get_response, get_request, redirect |
48 | 49 |
from quixote.html import htmltext |
... | ... | |
263 | 264 |
s = force_text(s, get_publisher().site_charset, errors='replace') |
264 | 265 |
if s and len(s) > length: |
265 | 266 |
if length > 3: |
266 |
s = s[:length-3] + '(…)'
|
|
267 |
s = Truncator(s).chars(length, truncate='(…)')
|
|
267 | 268 |
else: |
268 | 269 |
s = s[:length] |
269 | 270 |
return force_str(s) |
270 |
- |