Added Markdown rendering for media_entry
This commit is contained in:
parent
d07713d0b0
commit
44e2da2fe6
@ -73,7 +73,8 @@ class MediaEntry(Document):
|
||||
'title': unicode,
|
||||
'slug': unicode,
|
||||
'created': datetime.datetime,
|
||||
'description': unicode,
|
||||
'description': unicode, # May contain markdown/up
|
||||
'description_html': unicode, # May contain plaintext, or HTML
|
||||
'media_type': unicode,
|
||||
'media_data': dict, # extra data relevant to this media_type
|
||||
'plugin_data': dict, # plugins can dump stuff here.
|
||||
|
@ -47,7 +47,14 @@ def edit_media(request, media):
|
||||
u'An entry with that slug already exists for this user.')
|
||||
else:
|
||||
media['title'] = request.POST['title']
|
||||
media['description'] = request.POST['description']
|
||||
media['description'] = request.POST.get('description')
|
||||
|
||||
import markdown
|
||||
md = markdown.Markdown(
|
||||
safe_mode = 'escape')
|
||||
media['description_html'] = md.convert(
|
||||
media['description'])
|
||||
|
||||
media['slug'] = request.POST['slug']
|
||||
media.save()
|
||||
|
||||
|
@ -48,6 +48,13 @@ def submit_start(request):
|
||||
entry = request.db.MediaEntry()
|
||||
entry['title'] = request.POST['title'] or unicode(splitext(filename)[0])
|
||||
entry['description'] = request.POST.get('description')
|
||||
|
||||
import markdown
|
||||
md = markdown.Markdown(
|
||||
safe_mode = 'escape')
|
||||
entry['description_html'] = md.convert(
|
||||
entry['description'])
|
||||
|
||||
entry['media_type'] = u'image' # heh
|
||||
entry['uploader'] = request.user['_id']
|
||||
|
||||
|
@ -25,7 +25,9 @@
|
||||
</h1>
|
||||
<img class="media_image" src="{{ request.app.public_store.file_url(
|
||||
media.media_files.main) }}" />
|
||||
<p>{{ media.description }}</p>
|
||||
{% autoescape False %}
|
||||
<p>{{ media.description_html }}</p>
|
||||
{% endautoescape %}
|
||||
<p>Uploaded on
|
||||
{{ "%4d-%02d-%02d"|format(media.created.year,
|
||||
media.created.month, media.created.day) }}
|
||||
|
@ -81,10 +81,10 @@ def atom_feed(request):
|
||||
feed = AtomFeed(request.matchdict['user'],
|
||||
feed_url=request.url,
|
||||
url=request.host_url)
|
||||
|
||||
|
||||
for entry in cursor:
|
||||
feed.add(entry.get('title'),
|
||||
entry.get('description'),
|
||||
entry.get('description_html'),
|
||||
content_type='html',
|
||||
author=request.matchdict['user'],
|
||||
updated=entry.get('created'),
|
||||
|
@ -34,7 +34,6 @@ from webob import Response, exc
|
||||
from mediagoblin import globals as mgoblin_globals
|
||||
from mediagoblin.db.util import ObjectId
|
||||
|
||||
|
||||
TESTS_ENABLED = False
|
||||
def _activate_testing():
|
||||
"""
|
||||
@ -99,7 +98,7 @@ def get_jinja_env(template_loader, locale):
|
||||
|
||||
template_env = jinja2.Environment(
|
||||
loader=template_loader, autoescape=True,
|
||||
extensions=['jinja2.ext.i18n'])
|
||||
extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'])
|
||||
|
||||
template_env.install_gettext_callables(
|
||||
mgoblin_globals.translations.gettext,
|
||||
|
Loading…
x
Reference in New Issue
Block a user