diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-11-18 09:34:09 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-11-18 09:34:09 -0600 |
commit | 817066506d846d06d0489dfb42b8200b86f61153 (patch) | |
tree | 36578ed7e5b2b205c919fcfb8929c8fc33a79c3f /mediagoblin/tools/text.py | |
parent | 76c6c806caec7af20a3fe11c04bb783baacc3934 (diff) | |
parent | 3618a9ac5112c657fd095a0f9cbd346921a4e800 (diff) | |
download | mediagoblin-817066506d846d06d0489dfb42b8200b86f61153.tar.lz mediagoblin-817066506d846d06d0489dfb42b8200b86f61153.tar.xz mediagoblin-817066506d846d06d0489dfb42b8200b86f61153.zip |
Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin
Conflicts:
mediagoblin/templates/mediagoblin/user_pages/user.html
Diffstat (limited to 'mediagoblin/tools/text.py')
-rw-r--r-- | mediagoblin/tools/text.py | 7 |
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. |