From: Aaron Williamson Date: Mon, 11 Jul 2011 02:28:48 +0000 (-0400) Subject: Markdown-enable user bio (Feature 410) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4c465852d198a1d8e8562a1e25b23fa7c9b4d2b4;p=mediagoblin.git Markdown-enable user bio (Feature 410) --- diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 279cb9f2..8e07e738 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -47,7 +47,8 @@ class User(Document): 'verification_key': unicode, 'is_admin': bool, 'url' : unicode, - 'bio' : unicode + 'bio' : unicode, # May contain markdown + 'bio_html': unicode, # May contain plaintext, or HTML } required_fields = ['username', 'created', 'pw_hash', 'email'] diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index 3bcf788b..fac1f41d 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -101,6 +101,10 @@ def edit_profile(request): if request.method == 'POST' and form.validate(): user['url'] = request.POST['url'] user['bio'] = request.POST['bio'] + + md = markdown.Markdown(safe_mode = 'escape') + user['bio_html'] = clean_html(md.convert(user['bio'])) + user.save() messages.add_message(request, diff --git a/mediagoblin/templates/mediagoblin/utils/profile.html b/mediagoblin/templates/mediagoblin/utils/profile.html index f44defa5..d9b121f6 100644 --- a/mediagoblin/templates/mediagoblin/utils/profile.html +++ b/mediagoblin/templates/mediagoblin/utils/profile.html @@ -18,9 +18,9 @@ {% block profile_content -%} {% if user.bio %} -

- {{ user.bio }} -

+ {% autoescape False %} +

{{ user.bio_html }}

+ {% endautoescape %} {% endif %} {% if user.url %}