import wtforms
-from mediagoblin.util import convert_to_tag_list
-
class EditForm(wtforms.Form):
title = wtforms.TextField(
from string import split
from mediagoblin import messages
-from mediagoblin.util import render_to_response, redirect, clean_html, \
- TAGS_DELIMITER
+from mediagoblin.util import (
+ render_to_response, redirect, clean_html, TAGS_DELIMITER, \
+ convert_to_tag_list)
from mediagoblin.edit import forms
from mediagoblin.edit.lib import may_edit_media
from mediagoblin.decorators import require_active_login, get_user_media_entry
media['description']))
media['slug'] = request.POST['slug']
- media['tags'] = request.POST['tags'].split(TAGS_DELIMITER)
+ media['tags'] = convert_to_tag_list(request.POST['tags'])
media.save()
return redirect(request, "mediagoblin.user_pages.media_home",
import wtforms
-from mediagoblin.util import convert_to_tag_list
-
class SubmitStartForm(wtforms.Form):
title = wtforms.TextField(
[wtforms.validators.Length(min=0, max=500)])
description = wtforms.TextAreaField('Description of this work')
file = wtforms.FileField('File')
- tags = wtforms.TextField('Tags', filters=[convert_to_tag_list])
+ tags = wtforms.TextField('Tags')
from werkzeug.utils import secure_filename
from mediagoblin.util import (
- render_to_response, redirect, cleaned_markdown_conversion)
+ render_to_response, redirect, cleaned_markdown_conversion, \
+ convert_to_tag_list)
from mediagoblin.decorators import require_active_login
from mediagoblin.submit import forms as submit_forms, security
from mediagoblin.process_media import process_media_initial
entry['media_type'] = u'image' # heh
entry['uploader'] = request.user['_id']
- entry['tags'] = split(request.POST.get('tags'))
+ entry['tags'] = convert_to_tag_list(request.POST.get('tags'))
# Save, just so we can get the entry id for the sake of using
# it to generate the file path
user= media.uploader().username) }}">
{{- media.uploader().username }}</a>
</p>
-
- <p>
- {{ ' '.join(media.tags) }}
- </p>
<br />
<h3>Comments</h3>
</p>
{% endif %}
</p>
+ {% if media.tags %}
+ <p>
+ {{ ' '.join(media.tags) }}
+ </p>
+ {% endif %}
</div>
{% else %}
<p>Sorry, no such media found.<p/>
TAGS_DELIMITER = u' '
+TAGS_CASE_SENSITIVE = False
def convert_to_tag_list(tag_string):
"""
Strips trailing, leading, and internal whitespace, and also converts
the user input into an array of tags
"""
+ taglist = []
if tag_string:
- taglist = []
stripped_tag_string = u' '.join(tag_string.strip().split())
for tag in stripped_tag_string.split(TAGS_DELIMITER):
- if tag.strip(): taglist.append(tag.strip())
- return taglist
+ if tag.strip():
+ if TAGS_CASE_SENSITIVE:
+ taglist.append(tag.strip())
+ else:
+ taglist.append(tag.strip().lower())
+ return taglist
MARKDOWN_INSTANCE = markdown.Markdown(safe_mode='escape')