Skip to content

Commit a6160c6

Browse files
committed
Initial Commit
0 parents  commit a6160c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1343
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.bundle
2+
db/*.sqlite3
3+
log/*.log
4+
tmp/
5+
.sass-cache/
6+
.idea

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--colour

Gemfile

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
source 'http://rubygems.org'
2+
3+
gem 'rails', '3.1.1'
4+
5+
gem 'mongoid'
6+
gem 'bson_ext'
7+
gem 'decent_exposure'
8+
gem 'eventmachine'
9+
gem 'em-http-request'
10+
gem "execjs"
11+
gem 'haml-rails'
12+
gem 'kaminari'
13+
gem "therubyracer"
14+
15+
# Gems used only for assets and not required
16+
# in production environments by default.
17+
group :assets do
18+
gem 'sass-rails', '~> 3.1.4'
19+
gem 'coffee-rails', '~> 3.1.1'
20+
gem 'uglifier', '>= 1.0.3'
21+
end
22+
23+
gem 'jquery-rails'
24+
25+
# To use ActiveModel has_secure_password
26+
# gem 'bcrypt-ruby', '~> 3.0.0'
27+
28+
# Use unicorn as the web server
29+
# gem 'unicorn'
30+
31+
# Deploy with Capistrano
32+
# gem 'capistrano'
33+
34+
# To use debugger
35+
# gem 'ruby-debug19', :require => 'ruby-debug'
36+
37+
group :development, :test do
38+
gem 'rspec'
39+
gem 'rspec-rails'
40+
end
41+
42+
group :test do
43+
# Pretty printed test output
44+
gem 'turn', :require => false
45+
end

Gemfile.lock

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
actionmailer (3.1.1)
5+
actionpack (= 3.1.1)
6+
mail (~> 2.3.0)
7+
actionpack (3.1.1)
8+
activemodel (= 3.1.1)
9+
activesupport (= 3.1.1)
10+
builder (~> 3.0.0)
11+
erubis (~> 2.7.0)
12+
i18n (~> 0.6)
13+
rack (~> 1.3.2)
14+
rack-cache (~> 1.1)
15+
rack-mount (~> 0.8.2)
16+
rack-test (~> 0.6.1)
17+
sprockets (~> 2.0.2)
18+
activemodel (3.1.1)
19+
activesupport (= 3.1.1)
20+
builder (~> 3.0.0)
21+
i18n (~> 0.6)
22+
activerecord (3.1.1)
23+
activemodel (= 3.1.1)
24+
activesupport (= 3.1.1)
25+
arel (~> 2.2.1)
26+
tzinfo (~> 0.3.29)
27+
activeresource (3.1.1)
28+
activemodel (= 3.1.1)
29+
activesupport (= 3.1.1)
30+
activesupport (3.1.1)
31+
multi_json (~> 1.0)
32+
addressable (2.2.6)
33+
ansi (1.4.1)
34+
arel (2.2.1)
35+
bson (1.4.0)
36+
bson_ext (1.4.0)
37+
builder (3.0.0)
38+
coffee-rails (3.1.1)
39+
coffee-script (>= 2.2.0)
40+
railties (~> 3.1.0)
41+
coffee-script (2.2.0)
42+
coffee-script-source
43+
execjs
44+
coffee-script-source (1.1.3)
45+
decent_exposure (1.0.1)
46+
diff-lcs (1.1.3)
47+
em-http-request (0.3.0)
48+
addressable (>= 2.0.0)
49+
escape_utils
50+
eventmachine (>= 0.12.9)
51+
erubis (2.7.0)
52+
escape_utils (0.2.4)
53+
eventmachine (0.12.10)
54+
execjs (1.2.9)
55+
multi_json (~> 1.0)
56+
haml (3.1.3)
57+
haml-rails (0.3.4)
58+
actionpack (~> 3.0)
59+
activesupport (~> 3.0)
60+
haml (~> 3.0)
61+
railties (~> 3.0)
62+
hike (1.2.1)
63+
i18n (0.6.0)
64+
jquery-rails (1.0.18)
65+
railties (~> 3.0)
66+
thor (~> 0.14)
67+
json (1.6.1)
68+
kaminari (0.12.4)
69+
rails (>= 3.0.0)
70+
libv8 (3.3.10.4)
71+
mail (2.3.0)
72+
i18n (>= 0.4.0)
73+
mime-types (~> 1.16)
74+
treetop (~> 1.4.8)
75+
mime-types (1.17.2)
76+
mongo (1.4.0)
77+
bson (= 1.4.0)
78+
mongoid (2.3.3)
79+
activemodel (~> 3.1)
80+
mongo (~> 1.3)
81+
tzinfo (~> 0.3.22)
82+
multi_json (1.0.3)
83+
polyglot (0.3.3)
84+
rack (1.3.5)
85+
rack-cache (1.1)
86+
rack (>= 0.4)
87+
rack-mount (0.8.3)
88+
rack (>= 1.0.0)
89+
rack-ssl (1.3.2)
90+
rack
91+
rack-test (0.6.1)
92+
rack (>= 1.0)
93+
rails (3.1.1)
94+
actionmailer (= 3.1.1)
95+
actionpack (= 3.1.1)
96+
activerecord (= 3.1.1)
97+
activeresource (= 3.1.1)
98+
activesupport (= 3.1.1)
99+
bundler (~> 1.0)
100+
railties (= 3.1.1)
101+
railties (3.1.1)
102+
actionpack (= 3.1.1)
103+
activesupport (= 3.1.1)
104+
rack-ssl (~> 1.3.2)
105+
rake (>= 0.8.7)
106+
rdoc (~> 3.4)
107+
thor (~> 0.14.6)
108+
rake (0.9.2.2)
109+
rdoc (3.11)
110+
json (~> 1.4)
111+
rspec (2.7.0)
112+
rspec-core (~> 2.7.0)
113+
rspec-expectations (~> 2.7.0)
114+
rspec-mocks (~> 2.7.0)
115+
rspec-core (2.7.1)
116+
rspec-expectations (2.7.0)
117+
diff-lcs (~> 1.1.2)
118+
rspec-mocks (2.7.0)
119+
rspec-rails (2.7.0)
120+
actionpack (~> 3.0)
121+
activesupport (~> 3.0)
122+
railties (~> 3.0)
123+
rspec (~> 2.7.0)
124+
sass (3.1.10)
125+
sass-rails (3.1.5)
126+
actionpack (~> 3.1.0)
127+
railties (~> 3.1.0)
128+
sass (~> 3.1.10)
129+
tilt (~> 1.3.2)
130+
sprockets (2.0.3)
131+
hike (~> 1.2)
132+
rack (~> 1.0)
133+
tilt (~> 1.1, != 1.3.0)
134+
therubyracer (0.9.9)
135+
libv8 (~> 3.3.10)
136+
thor (0.14.6)
137+
tilt (1.3.3)
138+
treetop (1.4.10)
139+
polyglot
140+
polyglot (>= 0.3.1)
141+
turn (0.8.3)
142+
ansi
143+
tzinfo (0.3.31)
144+
uglifier (1.1.0)
145+
execjs (>= 0.3.0)
146+
multi_json (>= 1.0.2)
147+
148+
PLATFORMS
149+
ruby
150+
151+
DEPENDENCIES
152+
bson_ext
153+
coffee-rails (~> 3.1.1)
154+
decent_exposure
155+
em-http-request
156+
eventmachine
157+
execjs
158+
haml-rails
159+
jquery-rails
160+
kaminari
161+
mongoid
162+
rails (= 3.1.1)
163+
rspec
164+
rspec-rails
165+
sass-rails (~> 3.1.4)
166+
therubyracer
167+
turn
168+
uglifier (>= 1.0.3)

README

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
== Twitter Geolocation Demo
2+
3+
This application demonstrates streaming twitter statuses into a mongodb capped collection in order
4+
to view the top 50 tweets nearest a particular latitude/longitude coordinate.
5+
6+
In order to start streaming the data, use:
7+
8+
rake twitter:stream CREDENTIALS=twitter_username,twitter_password
9+
10+
You must have set up your twitter account per the streaming API documents.
11+
12+
To run tests, just run: rspec spec. It is not necessary to rake test:db:prepare.
13+
14+
To use, enter Latitude and Longitude coordinates and click search. You can click on both map markers and
15+
screen name links to open a window showing the corresponding tweet on the map.

Rakefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env rake
2+
# Add your own tasks in files placed in lib/tasks ending in .rake,
3+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4+
5+
require File.expand_path('../config/application', __FILE__)
6+
7+
GeolocationDemo::Application.load_tasks

app/assets/images/rails.png

6.49 KB
Loading

app/assets/javascripts/application.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This is a manifest file that'll be compiled into including all the files listed below.
2+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3+
// be included in the compiled file accessible from http://example.com/assets/application.js
4+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5+
// the compiled file.
6+
//
7+
//= require jquery
8+
//= require jquery_ujs
9+
//= require_tree .
10+
//=require map
11+
12+
$(function() {
13+
14+
var enable_search = function() {
15+
if ($("#coordinate_search_longitude").val() && $("#coordinate_search_latitude").val()) {
16+
$("#coordinate_search").removeAttr("disabled");
17+
} else {
18+
$("#coordinate_search").attr("disabled", "disabled");
19+
};
20+
};
21+
22+
enable_search();
23+
24+
$(".coordinate").keyup(function() {
25+
enable_search();
26+
});
27+
});

app/assets/javascripts/map.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
$(document).ready(function() {
2+
if ($("#coordinate_search_longitude").val() && $("#coordinate_search_latitude").val()) {
3+
var long = $("#coordinate_search_longitude").val();
4+
var lat = $("#coordinate_search_latitude").val();
5+
6+
// Creating a LatLng object containing the coordinate for the center of the map
7+
var latlng = new google.maps.LatLng(lat, long);
8+
9+
// Creating an object literal containing the properties we want to pass to the map
10+
var options = {
11+
zoom: 3,
12+
center: latlng,
13+
mapTypeId: google.maps.MapTypeId.ROADMAP };
14+
15+
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
16+
17+
var createInfo = function(screen_name, tweet) {
18+
return '<div class="infowindow"><strong>' + screen_name + ' </strong>' + tweet + '</div>';
19+
};
20+
21+
var openInfoWindows = [];
22+
23+
$("tr").each(function() {
24+
var row = $(this);
25+
var coords = eval(row.find(".location")[0].innerHTML);
26+
var link = row.find(".screen_name")[0]
27+
var screen_name = link.innerHTML;
28+
var tweet = row.find(".tweet")[0].innerHTML;
29+
30+
// Add Marker
31+
var marker1 = new google.maps.Marker({
32+
position: new google.maps.LatLng(coords[0], coords[1])
33+
});
34+
35+
marker1.setMap(map);
36+
37+
// Add information window
38+
var infowindow1 = new google.maps.InfoWindow({
39+
content: createInfo(screen_name, tweet)
40+
});
41+
42+
function showWindow() {
43+
while (openInfoWindows.length > 0) {
44+
openInfoWindows.pop().close();
45+
}
46+
infowindow1.open(map, marker1);
47+
openInfoWindows.push(infowindow1);
48+
}
49+
50+
// Add listener for a click on the pin
51+
google.maps.event.addListener(marker1, 'click', function() {
52+
showWindow();
53+
});
54+
55+
// Add listener for a click screen name
56+
$(link).click(function() {
57+
showWindow();
58+
});
59+
});
60+
}
61+
});
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
3+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4+
* the top of the compiled file, but it's generally better to create a new file per style scope.
5+
*= require_self
6+
*= require_tree .
7+
*/

0 commit comments

Comments
 (0)