comparison 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
comparison
equal deleted inserted replaced
1093:1ac847818aea 1094:110bbc78a482
138 from the POST parameters and returns a rendered HTML page from the data, which 138 from the POST parameters and returns a rendered HTML page from the data, which
139 is assumed to be in markdown format. The HTML page is suitable for the preview 139 is assumed to be in markdown format. The HTML page is suitable for the preview
140 function for a javascript editor such as markItUp. 140 function for a javascript editor such as markItUp.
141 """ 141 """
142 if not request.user.is_authenticated(): 142 if not request.user.is_authenticated():
143 return HttpResponseForbidden('This service is only available to logged in users.') 143 return HttpResponseForbidden('This service is only available to logged-in users.')
144 144
145 data = request.POST.get('data', None) 145 data = request.POST.get('data', None)
146 if data is None: 146 if data is None:
147 return HttpResponseBadRequest('No data') 147 return HttpResponseBadRequest('No data')
148 148
154 html = PREVIEW_UNAVAILABLE.format(ex) 154 html = PREVIEW_UNAVAILABLE.format(ex)
155 155
156 return render(request, 'comments/markdown_preview.html', { 156 return render(request, 'comments/markdown_preview.html', {
157 'data': html, 157 'data': html,
158 }) 158 })
159
160
161 @require_POST
162 def markdown_preview_v3(request):
163 if not request.user.is_authenticated():
164 return HttpResponseForbidden(
165 'This service is only available to logged-in users.')
166
167 data = request.POST.get('data', None)
168 html = site_markup(data) if data else ''
169 if html:
170 try:
171 image_check(html)
172 except ImageCheckError as ex:
173 html = PREVIEW_UNAVAILABLE.format(ex)
174
175 return HttpResponse(html)