diff comments/views.py @ 1094:110bbc78a482

GCalendar V3 conversion in progress.
author Brian Neal <bgneal@gmail.com>
date Sun, 29 May 2016 23:09:23 -0500
parents e932f2ecd4a7
children
line wrap: on
line diff
--- a/comments/views.py	Wed May 11 22:00:44 2016 -0500
+++ b/comments/views.py	Sun May 29 23:09:23 2016 -0500
@@ -140,7 +140,7 @@
     function for a javascript editor such as markItUp.
     """
     if not request.user.is_authenticated():
-        return HttpResponseForbidden('This service is only available to logged in users.')
+        return HttpResponseForbidden('This service is only available to logged-in users.')
 
     data = request.POST.get('data', None)
     if data is None:
@@ -156,3 +156,20 @@
     return render(request, 'comments/markdown_preview.html', {
         'data': html,
         })
+
+
+@require_POST
+def markdown_preview_v3(request):
+    if not request.user.is_authenticated():
+        return HttpResponseForbidden(
+                'This service is only available to logged-in users.')
+
+    data = request.POST.get('data', None)
+    html = site_markup(data) if data else ''
+    if html:
+        try:
+            image_check(html)
+        except ImageCheckError as ex:
+            html = PREVIEW_UNAVAILABLE.format(ex)
+
+    return HttpResponse(html)