[Django] #19496: truncatechars_html

65 views
Skip to first unread message

Django

unread,
Dec 19, 2012, 5:21:39 PM12/19/12
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+--------------------------
Reporter: esevece | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.4
Severity: Normal | Keywords: truncatchars
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------
Hi,
why don't have something like truncatewords_html for chars?
I don't have experience with the Django's source code, so I don't have a
patch. But I can try if you want.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 19, 2012, 10:28:17 PM12/19/12
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------

Reporter: esevece | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by russellm):

* needs_better_patch: => 0
* needs_docs: => 0
* easy: 0 => 1
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

Sure; we've added truncatedchars; makes sense that there would be a HTML-
sensitive equivalent.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:1>

Django

unread,
Jan 10, 2013, 10:18:12 AM1/10/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: slurms
Type: New feature | Status: assigned

Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by slurms):

* owner: nobody => slurms
* status: new => assigned
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:2>

Django

unread,
Jan 10, 2013, 10:39:41 AM1/10/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: slurms
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by slurms):

Used truncatewords_html as a guideline, added docs & tests. All tests pass
under sqlite. Pull request here: https://github.com/django/django/pull/633

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:3>

Django

unread,
Feb 23, 2013, 8:06:05 AM2/23/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: slurms
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by DHessing):

* needs_better_patch: 0 => 1


Comment:

{{{
>>> truncatechars_html('<h1>test</h1>', 5)
u'<h1>t ...</h1>'
}}}
Should return u'<h1>te...</h1>'. Truncatewords adds an extra space in
front of the ellipsis but truncatechars doesn't.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:4>

Django

unread,
May 18, 2013, 9:15:34 AM5/18/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+----------------------------------------
Reporter: esevece | Owner: martmatwarne

Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by martmatwarne):

* owner: slurms => martmatwarne


--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:5>

Django

unread,
May 18, 2013, 11:09:56 AM5/18/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+----------------------------------------
Reporter: esevece | Owner: martmatwarne
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+----------------------------------------

Comment (by martmatwarne):

The above issue should now be fixed. It also appears to have broken
truncatechars which I've now fixed

https://github.com/django/django/pull/1126

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:6>

Django

unread,
May 18, 2013, 11:35:44 AM5/18/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+----------------------------------------
Reporter: esevece | Owner: martmatwarne
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+----------------------------------------

Comment (by martmatwarne):

Actually there still appears to be issues when using html with only one
tag pair in it

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:7>

Django

unread,
May 28, 2013, 2:22:43 PM5/28/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+----------------------------------------
Reporter: esevece | Owner: martmatwarne
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+----------------------------------------

Comment (by EvilDMP):

I have marked this ticket as suitable for a first-time committer attending
a [https://dont-be-afraid-to-commit.readthedocs.org/ Don't be afraid to
commit workshop].

The next planned session will be hosted by
[http://www.cardiffdevworkshop.com Cardiff Dev Workshop] on Saturday 8th
June.

If you want to tackle this ticket before then, or at any time in fact,
please '''don't''' let the fact that it's assigned to me stop you. Feel
free to re-assign it to yourself and do whatever you like to it.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:8>

Django

unread,
May 28, 2013, 2:22:48 PM5/28/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: EvilDMP

Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by EvilDMP):

* owner: martmatwarne => EvilDMP


--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:9>

Django

unread,
Sep 29, 2013, 12:46:40 PM9/29/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: EvilDMP
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by saturn5971):

truncatechars_html was incorrectly adding the '...' to text that was under
the truncate length but only by 3 or fewer characters:

{{{
>>> truncatechars_html('abcd', 4)
u'a...'
}}}

I've provided an updated patch here, including an addition to the test:

[https://github.com/django/django/pull/1689]

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:10>

Django

unread,
Oct 7, 2013, 6:41:34 PM10/7/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: EvilDMP
Type: New feature | Status: assigned
Component: Template system | Version: master

Severity: Normal | Resolution:
Keywords: truncatchars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timo):

* version: 1.4 => master
* easy: 1 => 0


Comment:

I've left some comments on the PR for improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:11>

Django

unread,
Nov 14, 2013, 1:17:27 AM11/14/13
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: EvilDMP
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: truncatechars | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by saturn5971):

* cc: saturn5971 (added)
* keywords: truncatchars => truncatechars


Comment:

Thanks! I updated my pull request in accord with Timo's suggestions.

[https://github.com/django/django/pull/1689]

To eliminate redundant code between _html_chars and _html_words, I've
collapsed them into a single function, _truncate_html. I made the
requested documentation changes as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:12>

Django

unread,
Feb 13, 2014, 10:29:50 AM2/13/14
to django-...@googlegroups.com
#19496: truncatechars_html
---------------------------------+------------------------------------
Reporter: esevece | Owner: EvilDMP
Type: New feature | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: truncatechars | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f94f466cd3461527fb76a3e8951039a3c2388829"]:
{{{
#!CommitTicketReference repository=""
revision="f94f466cd3461527fb76a3e8951039a3c2388829"
Fixed #19496 -- Added truncatechars_html filter.

Thanks esevece for the suggestion and Nick Sandford and Martin Warne
for the inital work on the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:13>

Reply all
Reply to author
Forward
0 new messages