Commit a5c62483 authored by Otto Naderer's avatar Otto Naderer

introduced mistune markdown parser for articles

tweaked media serving settings for devel server
parent 20757dc7
......@@ -3,6 +3,11 @@ from django.shortcuts import render, get_object_or_404
from django.template import RequestContext
from django import forms
import datetime
import mistune
class CustomRenderer(mistune.Renderer):
def image(self, src, title, alt_text):
return '<div id="textimg"><img src="' + src + '"/><br>Title: ' + title + '<br>Alt: ' + alt_text + '</div>'
class BlogCommentForm(forms.Form):
guestname = forms.CharField()
......@@ -16,6 +21,9 @@ def listall(request):
def detail(request, blogentry_id):
blogdetail = get_object_or_404(blogentry, pk=blogentry_id)
renderer = CustomRenderer()
md = mistune.Markdown(renderer = renderer, hard_wrap = True)
blogdetail.body = md(blogdetail.body)
form = BlogCommentForm()
context = {'blogentry': blogdetail, 'commentform': form}
......
No preview for this file type
......@@ -10,7 +10,7 @@ class BlogImageAdminForm(forms.ModelForm):
class BlogImageAdmin(admin.ModelAdmin):
form = BlogImageAdminForm
list_display = ('date', )
list_display = ('id', 'caption')
admin.site.register(BlogImage, BlogImageAdmin)
......@@ -128,3 +128,6 @@ STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = 'http://127.0.0.1:8000/media/'
......@@ -44,7 +44,7 @@ div#main{
padding-top: 1em;
}
img#intext{
div#textimg{
padding-top:1em;
display: block;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment