Permalink
Browse files

first stab at a simplified profile page which can show a 'baseball ca…

…rd' sort of view of a census geography, instead of so many numbers. will probably add a map, some flot charts, etc.
  • Loading branch information...
1 parent 2abc2eb commit 39eca14da544769cc9adf5e4054eee30f2413a47 @JoeGermuska JoeGermuska committed Sep 3, 2011
Showing with 56 additions and 0 deletions.
  1. +20 −0 censusweb/api/templates/profile.html
  2. +1 −0 censusweb/api/urls.py
  3. +35 −0 censusweb/media/js/profile.js
@@ -0,0 +1,20 @@
+{% extends 'base.html' %}
+{% load helpertags %}
+{% load humanize %}
+{% block title %}Census Map {% endblock title %}
+{% block content %}
+<link rel="stylesheet" href="{{ MEDIA_URL }}leaflet/leaflet.css" type="text/css" charset="utf-8">
+<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+<script type="text/javascript" src="{{ MEDIA_URL }}leaflet/leaflet.js"></script>
+<script type="text/javascript" src="{{ MEDIA_URL }}js/profile.js"></script>
+<script id="basic-info" type="text/x-js-template">
+ <h1><%= metadata.NAME %></h1>
+ <dl>
+ <dt>Population</dt>
+ <dd><%= data['2010'].P1.P001001 %></dd>
+ </dl>
+</script>
+<div id="profile">
+
+</div>
+{% endblock %}
View
@@ -21,6 +21,7 @@
url(r'^map/$', views.generic_view, { "template": "map.html" }, name="map"),
url(r'^map/(?P<geoids>[,\d]+)\.html$', views.generic_view, { "template": "map.html" }, name="map"),
url(r'^map/contains$', views.map_contains, name="map_contains"),
+ url(r'^profile/(?P<geoid>[\d]+)\.html$', views.generic_view, { "template": "profile.html" }, name="profile"),
url(r'^docs/json.html$', views.generic_view, { "template": "docs/json.html" }, name="json-doc"),
url(r'^docs/boundary.html$', views.generic_view, { "template": "docs/boundary.html" }, name="boundary-documentation"),
url(r'^util/create_table/(?P<aggregate>(all_files|all_tables))\.sql$', views.generate_sql, name="generate_sql"), # order matters. keep this first to catch only numbers before tables
@@ -0,0 +1,35 @@
+$(function(){
+ var basic_info_template = _.template($('#basic-info').html());
+ window.parseGeoid = function() {
+ // Get url without hashbang
+ var target = _.last(window.location.pathname.split("/"));
+
+ // Ditch the .html
+ target = _.first(target.split("."));
+
+ // Split the list
+ geoids = target.split(",");
+
+ return geoids[0];
+ }
+
+ function display_sf1_data(data) {
+ console.log("in display_sf1_data");
+ window.sf1 = data;
+ $("#profile").append(basic_info_template(data));
+ }
+
+ function display_geodata(geodata) {
+ console.log("in display_geodata");
+ window.geodata = geodata;
+ if (geodata.objects) {
+ console.log("display_geodata: " + geodata.objects[0].external_id);
+ }
+ }
+
+ $(document).ready(function(){
+ var geoid = window.parseGeoid();
+ ire_census.do_with_sf1_data(geoid,display_sf1_data);
+ ire_census.do_with_geodata(geoid,display_geodata);
+ });
+});

0 comments on commit 39eca14

Please sign in to comment.