def oembed(request): if not request.GET.get("url"): return HttpResponse('{"error":"No Url Provided."}') url_parts = urlparse(request.GET.get("url")) keys = url_parts.path.split("/") for i in range(len(keys)): if len(keys[i]) and keys[i][-1] == "+": # stats keys[i] = keys[i][:-1] chart = Chart.get_by_id(pretty_decode(keys[1])) chart.counter += 1 chart.put() if len(keys) > 3: version = ChartDataSet.get(keys[2]) perma = reverse("chart-detail-version", args=(pretty_decocde(keys[1]), keys[2])) else: version = chart.data perma = reverse("chart-detail", args=(pretty_decode(keys[1]),)) graph_url, graph = get_graph(version, _cht[chart.chart_type], 600, 480) oembed = { "version": str(version.version), "type": "photo", "width": 600, "height": 480, "title": chart.name, "url": graph_url, "author": chart.user.email(), "provider_name": "Permachart", "provier_url": "http://permachart.appengine.com", } return HttpResponse(json.dumps(oembed, sort_keys=True, indent=4), mimetype="application/javascript")
def chart_detail(request, hash): chart = Chart.get_by_id(pretty_decode(hash)) if chart.data: graph_url, graph = get_graph(chart.data, _cht[chart.chart_type]) else: graph_url, graph = None, None return render_to_response( "charter/detail.html", {"chart": chart, "graph": graph, "graph_url": graph_url, "version": chart.data, "user": request.g_app_user}, )
def small_chart(self, data=None): if not data: data = self.data try: return get_graph(data, _cht[self.chart_type], 180, 144, 2) except ValueError: # no data return '' except: # everything else return ''
def chart_detail_version(request, hash, version_key): chart = Chart.get_by_id(pretty_decode(hash)) version = ChartDataSet.get(version_key) graph_url, graph = get_graph(version, _cht[chart.chart_type]) return render_to_response( "charter/detail.html", { "chart": chart, "graph": graph, "graph_url": graph_url, "version": version, "version_specific": True, "user": request.g_app_user, }, )