aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/text.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-11-13 20:23:26 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-11-13 20:23:26 -0600
commitee91c2b88d1a42b9d15d34d2c081cd8394649041 (patch)
tree01a75b958b2814763a0b219145bbe284d1d04931 /mediagoblin/tools/text.py
parent4671fda345394dad9ca4278b1cf7b2cdf7d2b4ee (diff)
parent285ffeddf3542201b83072d3be544c85e9c487c2 (diff)
downloadmediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.lz
mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.xz
mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.zip
Merge remote-tracking branch 'remotes/nyergler/pep8-ification'
Conflicts: mediagoblin/db/migrations.py mediagoblin/db/models.py mediagoblin/user_pages/views.py mediagoblin/util.py
Diffstat (limited to 'mediagoblin/tools/text.py')
-rw-r--r--mediagoblin/tools/text.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mediagoblin/tools/text.py b/mediagoblin/tools/text.py
index de4bb281..be1adb00 100644
--- a/mediagoblin/tools/text.py
+++ b/mediagoblin/tools/text.py
@@ -21,6 +21,7 @@ from lxml.html.clean import Cleaner
from mediagoblin import mg_globals
from mediagoblin.tools import url
+
# A super strict version of the lxml.html cleaner class
HTML_CLEANER = Cleaner(
scripts=True,
@@ -42,6 +43,7 @@ HTML_CLEANER = Cleaner(
host_whitelist=(),
whitelist_tags=set([]))
+
def clean_html(html):
# clean_html barfs on an empty string
if not html:
@@ -49,6 +51,7 @@ def clean_html(html):
return HTML_CLEANER.clean_html(html)
+
def convert_to_tag_list_of_dicts(tag_string):
"""
Filter input from incoming string containing user tags,
@@ -73,6 +76,7 @@ def convert_to_tag_list_of_dicts(tag_string):
'slug': url.slugify(tag.strip())})
return taglist
+
def media_tags_as_string(media_entry_tags):
"""
Generate a string from a media item's tags, stored as a list of dicts
@@ -85,9 +89,11 @@ def media_tags_as_string(media_entry_tags):
[tag['name'] for tag in media_entry_tags])
return media_tag_string
+
TOO_LONG_TAG_WARNING = \
u'Tags must be shorter than %s characters. Tags that are too long: %s'
+
def tag_length_validator(form, field):
"""
Make sure tags do not exceed the maximum tag length.
@@ -105,6 +111,7 @@ def tag_length_validator(form, field):
MARKDOWN_INSTANCE = markdown.Markdown(safe_mode='escape')
+
def cleaned_markdown_conversion(text):
"""
Take a block of text, run it through MarkDown, and clean its HTML.