email_debug_mode = boolean(default=True)
email_sender_address = string(default="notice@mediagoblin.example.org")
+# tag parsing
+tags_delimiter = string(default=",")
+tags_case_sensitive = boolean(default=False)
+tags_max_length = integer(default=50)
+
# By default not set, but you might want something like:
# "%(here)s/user_dev/templates/"
local_templates = string()
from string import split
from mediagoblin import messages
+from mediagoblin import mg_globals
from mediagoblin.util import (
- render_to_response, redirect, clean_html, TAGS_DELIMITER, \
- convert_to_tag_list)
+ render_to_response, redirect, clean_html, 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
title = media['title'],
slug = media['slug'],
description = media['description'],
- tags = TAGS_DELIMITER.join(media['tags']))
+ tags = mg_globals.app_config['tags_delimiter'].join(media['tags']))
if request.method == 'POST' and form.validate():
# Make sure there isn't already a MediaEntry with such a slug
return HTML_CLEANER.clean_html(html)
-TAGS_DELIMITER = u' '
-TAGS_CASE_SENSITIVE = False
-TAGS_MAX_LENGTH = 50
-
def convert_to_tag_list(tag_string):
"""
Filter input from incoming string containing user tags,
stripped_tag_string = u' '.join(tag_string.strip().split())
# Split the tag string into a list of tags
- for tag in stripped_tag_string.split(TAGS_DELIMITER):
+ for tag in stripped_tag_string.split(
+ mg_globals.app_config['tags_delimiter']):
# Do not permit duplicate tags
if tag.strip() and tag not in taglist:
- if TAGS_CASE_SENSITIVE:
+ if mg_globals.app_config['tags_case_sensitive']:
taglist.append(tag.strip())
else:
taglist.append(tag.strip().lower())
tags = convert_to_tag_list(field.data)
too_long_tags = [
tag for tag in tags
- if len(tag) > TAGS_MAX_LENGTH]
+ if len(tag) > mg_globals.app_config['tags_max_length']]
if too_long_tags:
raise wtforms.ValidationError(
- TOO_LONG_TAG_WARNING % (
- TAGS_MAX_LENGTH, ', '.join(too_long_tags)))
+ TOO_LONG_TAG_WARNING % (mg_globals.app_config['tags_max_length'], \
+ ', '.join(too_long_tags)))
MARKDOWN_INSTANCE = markdown.Markdown(safe_mode='escape')