Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model property/method for striptags|urlize|linebreaks'd values #151

Open
jogwen opened this issue Feb 11, 2013 · 4 comments
Open

Model property/method for striptags|urlize|linebreaks'd values #151

jogwen opened this issue Feb 11, 2013 · 4 comments

Comments

@jogwen
Copy link

jogwen commented Feb 11, 2013

Instead of doing this using template filters in each template where an object.description is shown, provide a model method or property to return the value ready to go into template. This will help us to not forget to striptags|urlize|linebreak description values in new templates as we add them by allowing us to put {{object.display_description}} instead of {[object.descripton|striptags|urlize|linebreaks}}. We could do one that returns striptags|urlize|linebreaks and one that does than plus truncatewords.

@KimSJ
Copy link
Contributor

KimSJ commented Feb 11, 2013

If I understand correctly, this also makes it easier to implement a
config option to allow markdown or whatever in the future?

On 11/02/2013 11:23, jogwen wrote:

Instead of doing this using template filters in each template where an
object.description is shown, provide a model method or property to
return the value ready to go into template. This will help us to not
forget to striptags|urlize|linebreak description values in new
templates as we add them by allowing us to put
{{object.display_description}} instead of
{[object.descripton|striptags|urlize|linebreaks}}. We could do one
that returns striptags|urlize|linebreaks and one that does than plus
truncatewords.


Reply to this email directly or view it on GitHub
#151..

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2013.0.2897 / Virus Database: 2639/6082 - Release Date: 02/04/13

@jogwen
Copy link
Author

jogwen commented Feb 11, 2013

I don't think so. Michele's fix strips html tags, converts any text that
looks like a urlhttps://docs.djangoproject.com/en/1.4/ref/templates/builtins/#urlizeinto
an anchor and then adds br tags to preserve linebreaks so eg.

abc google.com and
xyz http://urlwithunusualdomain
123 urlwithunusualdomain

will end up as

abc google.com and
xyz http://urlwithunusualdomain
123 urlwithunusualdomain

I doubt this can be extended with that much ease to allow for general
markdown.

On 11 February 2013 15:17, Kim SJ [email protected] wrote:

If I understand correctly, this also makes it easier to implement a
config option to allow markdown or whatever in the future?

On 11/02/2013 11:23, jogwen wrote:

Instead of doing this using template filters in each template where an
object.description is shown, provide a model method or property to
return the value ready to go into template. This will help us to not
forget to striptags|urlize|linebreak description values in new
templates as we add them by allowing us to put
{{object.display_description}} instead of
{[object.descripton|striptags|urlize|linebreaks}}. We could do one
that returns striptags|urlize|linebreaks and one that does than plus
truncatewords.


Reply to this email directly or view it on GitHub
#151..

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2013.0.2897 / Virus Database: 2639/6082 - Release Date: 02/04/13


Reply to this email directly or view it on GitHubhttps://github.com//issues/151#issuecomment-13384347..

@mattions
Copy link
Contributor

TBH, right now this is enough and we need to add the filter on the template.

Going down the way to support Markdown or rich Text is possible but
requires a lot of work more and opens a lot of other trouble (like h1 which
will compromise the structure and so forth.)

Let's keep it simple for now

On Mon, Feb 11, 2013 at 4:06 PM, jogwen [email protected] wrote:

I don't think so. Michele's fix strips html tags, converts any text that
looks like a url<
https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#urlize>into
an anchor and then adds br tags to preserve linebreaks so eg.

abc google.com and
xyz http://urlwithunusualdomain
123 urlwithunusualdomain

will end up as

abc google.com and
xyz http://urlwithunusualdomain
123 urlwithunusualdomain

I doubt this can be extended with that much ease to allow for general
markdown.

On 11 February 2013 15:17, Kim SJ [email protected] wrote:

If I understand correctly, this also makes it easier to implement a
config option to allow markdown or whatever in the future?

On 11/02/2013 11:23, jogwen wrote:

Instead of doing this using template filters in each template where an
object.description is shown, provide a model method or property to
return the value ready to go into template. This will help us to not
forget to striptags|urlize|linebreak description values in new
templates as we add them by allowing us to put
{{object.display_description}} instead of
{[object.descripton|striptags|urlize|linebreaks}}. We could do one
that returns striptags|urlize|linebreaks and one that does than plus
truncatewords.


Reply to this email directly or view it on GitHub
#151..

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2013.0.2897 / Virus Database: 2639/6082 - Release Date:
02/04/13


Reply to this email directly or view it on GitHub<
https://github.com/e-Luminate/eluminate_web/issues/151#issuecomment-13384347>..


Reply to this email directly or view it on GitHubhttps://github.com//issues/151#issuecomment-13387017..

Michele Mattioni, PhD
http://michelemattioni.me

@KimSJ
Copy link
Contributor

KimSJ commented Feb 11, 2013

Yes, def in the "wishlist" category!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants