Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mjibson/nycnow
base: fa98bb6156
...
head fork: mjibson/nycnow
compare: 32553e5f1a
  • 5 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
1  .gitignore
@@ -1,2 +1,3 @@
*.pyc
+*.swp
settings.py
View
2  main.py
@@ -113,7 +113,7 @@ def get(self):
for e in j['data']:
events.append(Event(
e[8],
- e[18],
+ e[18].strip().title() + ', ' + e[19],
e[9],
0,
'street events',
View
3  static/css/site.css
@@ -0,0 +1,3 @@
+.highlight {
+ background-color: #DDD;
+}
View
36 static/js/site.js
@@ -0,0 +1,36 @@
+function findEvent(n) {
+ var p = $(n);
+ while(!p.hasClass('event'))
+ p = p.parent();
+ return p;
+}
+
+var HIGHLIGHT = 'highlight';
+var map = {};
+
+$(function() {
+ var DEL = '<a href="#" class="del"><i class="icon-remove"></i></a>';
+ $('.title').each(function() {
+ var d = $(DEL);
+ var label = $(this).html();
+ d.data('del', label);
+
+ d.hover(function() {
+ $(map[label]).addClass(HIGHLIGHT);
+ }, function() {
+ $(map[label]).removeClass(HIGHLIGHT);
+ });
+
+ $(this).append(d);
+
+ if(!$(map).attr(label))
+ map[label] = new Array();
+
+ map[label].push(findEvent(this)[0]);
+ });
+
+ $('.del').on("click", function() {
+ var d = $(this).data('del');
+ $(map[d]).remove();
+ });
+});
View
2  templates/base.html
@@ -3,6 +3,8 @@
<head>
<title>NYC Now</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/static/css/site.css" rel="stylesheet">
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<div class="navbar">
View
10 templates/index.html
@@ -3,18 +3,20 @@
{% block content %}
{% for e in events %}
- <div class="row">
+ <div class="row event">
<div class="span2">
- <h4>{{ e.category }}</h4>
+ <h4 class="title">{{ e.category }}</h4>
</div>
<div class="span8">
- <h2>{% if e.url %}<a href="{{ e.url }}">{{ e.name }}</a>{% else %}{{ e.name }}{% endif %}</h2>
+ <h2 class="title">{% if e.url %}<a href="{{ e.url }}">{{ e.name }}</a>{% else %}{{ e.name }}{% endif %}</h2>
{{ e.address }}
</div>
- <div class="span2">
+ <div class="span2 title">
{{ e.source }}
</div>
</div>
{% endfor %}
+<script src="/static/js/site.js"></script>
+
{% endblock %}
View
10 utils.py
@@ -9,6 +9,10 @@
env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
+DISTANCE_METERS = 1000
+DISTANCE_MILES = DISTANCE_METERS * 0.000621371192
+LIMIT = 10
+
def render(_template, context):
return env.get_template(_template).render(**context)
@@ -28,7 +32,7 @@ def foursquare_url(api, **kwargs):
return FOURSQUARE_ENDPOINT + api + '?' + urllib.urlencode(params)
def foursquare_trending(pos):
- return fetch(foursquare_url(FOURSQUARE_TRENDING, ll=pos, limit=5))
+ return fetch(foursquare_url(FOURSQUARE_TRENDING, ll=pos, limit=LIMIT, radius=DISTANCE_METERS))
NYT_ENDPOINT = 'http://api.nytimes.com/'
NYT_EVENTS = 'svc/events/v2/listings.json'
@@ -40,7 +44,7 @@ def nyt_url(api, **kwargs):
return NYT_ENDPOINT + api + '?' + urllib.urlencode(params)
def nyt_events(pos):
- return fetch(nyt_url(NYT_EVENTS, ll=pos, limit=5))
+ return fetch(nyt_url(NYT_EVENTS, ll=pos, limit=LIMIT, radius=DISTANCE_METERS))
YIPIT_ENDPOINT = 'http://api.yipit.com/v1/'
YIPIT_DEALS = 'deals/'
@@ -52,7 +56,7 @@ def yipit_url(api, **kwargs):
return YIPIT_ENDPOINT + api + '?' + urllib.urlencode(params)
def yipit_deals(pos):
- return fetch(yipit_url(YIPIT_DEALS, lat=pos.lat, lon=pos.lng, division='new-york', radius=0.5, limit=5))
+ return fetch(yipit_url(YIPIT_DEALS, lat=pos.lat, lon=pos.lng, division='new-york', radius=DISTANCE_MILES, limit=LIMIT))
SOCRATA_ENDPOINT = 'http://nycopendata.socrata.com/api/views/'
SOCRATA_STREET_ACTIVITIES = 'xenu-5qjw'

No commit comments for this range

Something went wrong with that request. Please try again.