summaryrefslogtreecommitdiff
path: root/news
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-07-06 20:16:10 -0500
committerDan McGee <dan@archlinux.org>2010-07-06 20:16:10 -0500
commitad162d74db6718b2ba7dd1ab2e1f21847a7c7744 (patch)
treeb67f56a8d113b88108ac6155fcccad2300d08de8 /news
parent5b2861f1f02d9bfbc189402f35687093c7322aa9 (diff)
Format all news items using markdown
Implements FS#13741. A preview function is also added so working with news items is easier to make sure you get the formatting right. This will result in some older news items looking a bit weird if they didn't put linebreaks in all the right places, we can fix a few of these as we notice them. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'news')
-rw-r--r--news/views.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/news/views.py b/news/views.py
index 0b7b379e..887fe1dc 100644
--- a/news/views.py
+++ b/news/views.py
@@ -1,10 +1,13 @@
from django import forms
from django.contrib.auth.decorators import permission_required
+from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.views.decorators.cache import never_cache
from django.views.generic import list_detail, create_update
+import markdown
+
from main.models import News
def view(request, newsid):
@@ -57,4 +60,13 @@ def edit(request, newsid):
form_class=NewsForm,
template_name="news/add.html")
+@permission_required('main.change_news')
+@never_cache
+def preview(request):
+ markup = ''
+ if request.POST:
+ data = request.POST.get('data', '')
+ markup = markdown.markdown(data)
+ return HttpResponse(markup)
+
# vim: set ts=4 sw=4 et: