Support monospace TextFields instead of Markdown
Drop markdown for monospace With markdown, we're only allowing about 1/10 of what is possible. This creates a false reality and expectation. Lets not suggest this. Nor do we have in-editor preview. So the user has to save, look at it, then go back and edit. And seeing a bunch of sanitized HTML or just missing sections isn't firendly. Monospace, what you type, is what you're going to get. It gives the presenter enough power to build a readable abstract, but not so much that they can break the page and it's CSS, nor the ability to confuse onselve through not getting what you expect. We keep bleach sanitation and we should probably run linkify on this in the long term. (Turn links into clickable links)
This commit is contained in:
parent
fb5eaea880
commit
a36ff64a82
7 changed files with 32 additions and 42 deletions
5
symposion/constants.py
Normal file
5
symposion/constants.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
TEXT_FIELD_MONOSPACE_NOTE=(
|
||||
"This field is rendered with the monospace font "
|
||||
"<a href=\"https://sourcefoundry.org/hack/\">Hack</a> with "
|
||||
"whitespace preserved")
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import logging
|
||||
|
||||
import bleach
|
||||
import markdown
|
||||
|
||||
|
||||
logger = logging.getLogger('MARKDOWN')
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
tags = bleach.sanitizer.ALLOWED_TAGS[:]
|
||||
tags.extend(['p', 'pre'])
|
||||
|
||||
|
||||
def parse(text):
|
||||
md = markdown.markdown(text, extensions=['extra'])
|
||||
text = bleach.clean(md, tags=tags)
|
||||
return text
|
|
@ -14,7 +14,8 @@ from django.core.exceptions import ValidationError
|
|||
from model_utils.managers import InheritanceManager
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from symposion.markdown_parser import parse
|
||||
from symposion import constants
|
||||
from symposion.text_parser import parse
|
||||
from symposion.conference.models import Section
|
||||
from symposion.speakers.models import Speaker
|
||||
|
||||
|
@ -84,9 +85,7 @@ class ProposalBase(models.Model):
|
|||
abstract = models.TextField(
|
||||
_("Abstract"),
|
||||
help_text=_("This will appear in the conference programme. Up to about "
|
||||
"500 words. Edit using <a "
|
||||
"href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>Markdown</a>.")
|
||||
"500 words. " + constants.TEXT_FIELD_MONOSPACE_NOTE)
|
||||
)
|
||||
abstract_html = models.TextField(blank=True)
|
||||
|
||||
|
@ -94,9 +93,8 @@ class ProposalBase(models.Model):
|
|||
_("Private Abstract"),
|
||||
help_text=_("This will only be shown to organisers and reviewers. You "
|
||||
"should provide any details about your proposal that you "
|
||||
"don't want to be public here. Edit using <a "
|
||||
"href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>Markdown</a>.")
|
||||
"don't want to be public here. " +
|
||||
constants.TEXT_FIELD_MONOSPACE_NOTE)
|
||||
)
|
||||
private_abstract_html = models.TextField(blank=True)
|
||||
|
||||
|
@ -107,10 +105,8 @@ class ProposalBase(models.Model):
|
|||
"projector, audio. If you require anything in addition, "
|
||||
"please list your technical requirements here. Such as: a "
|
||||
"static IP address, A/V equipment or will be demonstrating "
|
||||
"security-related techniques on the conference network. "
|
||||
"Edit using <a "
|
||||
"href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>Markdown</a>.")
|
||||
"security-related techniques on the conference network. " +
|
||||
constants.TEXT_FIELD_MONOSPACE_NOTE)
|
||||
)
|
||||
technical_requirements_html = models.TextField(blank=True)
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ from django.db.models.signals import post_save
|
|||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from symposion.markdown_parser import parse
|
||||
from symposion import constants
|
||||
from symposion.text_parser import parse
|
||||
from symposion.proposals.models import ProposalBase
|
||||
from symposion.schedule.models import Presentation
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.contrib.auth.models import User
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from symposion.markdown_parser import parse
|
||||
from symposion.text_parser import parse
|
||||
from symposion.proposals.models import ProposalBase
|
||||
from symposion.conference.models import Section
|
||||
from symposion.speakers.models import Speaker
|
||||
|
|
|
@ -6,7 +6,8 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from symposion.markdown_parser import parse
|
||||
from symposion import constants
|
||||
from symposion.text_parser import parse
|
||||
|
||||
|
||||
class Speaker(models.Model):
|
||||
|
@ -24,10 +25,8 @@ class Speaker(models.Model):
|
|||
blank=True,
|
||||
help_text=_("This will appear on the conference website and in the "
|
||||
"programme. Please write in the third person, eg 'Alice "
|
||||
"is a Moblin hacker...', 150-200 words. Edit using "
|
||||
"<a href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>"
|
||||
"Markdown</a>."),
|
||||
"is a Moblin hacker...', 150-200 words. " +
|
||||
constants.TEXT_FIELD_MONOSPACE_NOTE),
|
||||
verbose_name=_("Biography"),
|
||||
)
|
||||
biography_html = models.TextField(blank=True)
|
||||
|
@ -36,10 +35,8 @@ class Speaker(models.Model):
|
|||
help_text=_("Have you had any experience presenting elsewhere? If so, "
|
||||
"we'd like to know. Anything you put here will only be "
|
||||
"seen by the organisers and reviewers; use it to convince "
|
||||
"them why they should accept your proposal. Edit using "
|
||||
"<a href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>"
|
||||
"Markdown</a>."),
|
||||
"them why they should accept your proposal. " +
|
||||
constants.TEXT_FIELD_MONOSPACE_NOTE),
|
||||
verbose_name=_("Speaking experience"),
|
||||
)
|
||||
experience_html = models.TextField(blank=True)
|
||||
|
@ -62,9 +59,8 @@ class Speaker(models.Model):
|
|||
accessibility = models.TextField(
|
||||
blank=True,
|
||||
help_text=_("Please describe any special accessibility requirements "
|
||||
"that you may have. Edit using "
|
||||
"<a href='http://warpedvisions.org/projects/"
|
||||
"markdown-cheat-sheet/' target='_blank'>Markdown</a>."),
|
||||
"that you may have. " +
|
||||
constants.TEXT_FIELD_MONOSPACE_NOTE),
|
||||
verbose_name=_("Accessibility requirements"))
|
||||
accessibility_html = models.TextField(blank=True)
|
||||
travel_assistance = models.BooleanField(
|
||||
|
|
9
symposion/text_parser.py
Normal file
9
symposion/text_parser.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import bleach
|
||||
|
||||
tags = bleach.sanitizer.ALLOWED_TAGS[:]
|
||||
tags.extend(['p', 'pre'])
|
||||
|
||||
|
||||
def parse(text):
|
||||
scrubbed_text = bleach.clean(text, tags=tags)
|
||||
return scrubbed_text
|
Loading…
Reference in a new issue