Projet

Général

Profil

0002-misc-use-Truncator-in-ellipsize-42744.patch

Lauréline Guérin, 28 août 2020 15:41

Télécharger (1,45 ko)

Voir les différences:

Subject: [PATCH 2/2] misc: use Truncator in ellipsize (#42744)

 wcs/qommon/misc.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
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
-