def _output_embed_to_dir(self, output_dir, version=""): file_name = "embed{0}.js".format(version) context = widget.add_offsite_js_files( {"current_site": Site.objects.get_current(), "MEDIA_URL": settings.MEDIA_URL} ) rendered = render_to_string("widget/{0}".format(file_name), context) with open(join(output_dir, file_name), "w") as f: f.write(rendered)
def _output_embed_to_dir(self, output_dir, version=''): file_name = 'embed{0}.js'.format(version) context = widget.add_offsite_js_files( {'site': Site.objects.get_current(), 'MEDIA_URL': settings.MEDIA_URL}) rendered = render_to_string( 'widget/{0}'.format(file_name), context) with open(join(output_dir, file_name), 'w') as f: f.write(rendered)
def embed(request, version_no=''): """ This is for serving embed when in development since the compilation with the media url hasn't taken place. Public clients will use the url : SITE_MEDIA/js/embed.js """ context = widget.add_offsite_js_files({}) if bool(version_no) is False: version_no = "" return render_to_response('widget/embed{0}.js'.format(version_no), context, context_instance=RequestContext(request), mimetype='text/javascript')
def xd_rpc(request, method_name, null=False): args = { 'request' : request } for k, v in request.POST.items(): if k[0:4] == 'xdp:': args[k[4:].encode('ascii')] = json.loads(v) rpc_module = null_rpc_views if null else rpc_views func = getattr(rpc_module, method_name) result = func(**args) params = { 'request_id' : request.POST['xdpe:request-id'], 'dummy_uri' : request.POST['xdpe:dummy-uri'], 'response_json' : json.dumps(result) } return render_to_response('widget/xd_rpc_response.html', widget.add_offsite_js_files(params), context_instance = RequestContext(request))
def embed(request, version_no=''): context = widget.add_offsite_js_files({}) return render_to_response('widget/embed{0}.js'.format(version_no), context, context_instance=RequestContext(request), mimetype='text/javascript')