예제 #1
0
def update_text(request, template_name):
	save_id = request.POST.get('id')

	save_data = request.POST.get('value') 

	converter = Converter(template_name, 'index.html')

	success = converter.update_text(save_id, save_data)

	if success:
		converter.commit_template()

	return HttpResponse('got ' + save_id + ' ' + save_data)
예제 #2
0
def convert(request, template_name):

	converter = Converter(template_name, 'index.html')
	
	converter.run_edit_engine() 

	converted_html_string = converter.get_converted_html()

	template = Template(converted_html_string)

	context = Context(request)

	return HttpResponse(template.render(context)) 
예제 #3
0
def update_image(request, template_name):
	save_id = request.POST.get('id')

	if not request.FILES or not save_id:
		return HttpResponseBadRequest

	for f in request.FILES.getlist('file'):
		success = upload_image(template_name, f)

		if not success:
			return HttpResponseNotModified

		converter = Converter(template_name, 'index.html')
		
		location = converter.replace_image(save_id, f.name)

		if location is not None:
			converter.commit_template()
			return HttpResponse(location)

		break

	return HttpResponseNotModified
예제 #4
0
def upload(request, template_name): 
	converter = Converter(template_name, 'index.html')
	converter.run_upload_engine()

	return HttpResponse(template_name + ' uploaded')