Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gem "rails-assets-js-md5"
gem "rails-assets-moment"
gem "underscore-rails"
gem "gmaps4rails"
gem "geocoder"

group :development, :test do
gem 'pry'
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GEM
execjs (2.2.2)
ffi (1.9.6)
ffi (1.9.6-x86-mingw32)
geocoder (1.2.6)
gmaps4rails (2.1.2)
haml (4.0.6)
tilt
Expand Down Expand Up @@ -214,6 +215,7 @@ DEPENDENCIES
capybara
coderay!
ember-middleman
geocoder
gmaps4rails
highline
listen
Expand All @@ -231,4 +233,4 @@ DEPENDENCIES
thin
tzinfo-data
underscore-rails
wdm (>= 0.1.0)
wdm (>= 0.1.0)
34 changes: 33 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

require "bundler/setup"
require 'yaml'
require 'geocoder'

def git_initialize(repository)
unless File.exist?(".git")
Expand Down Expand Up @@ -63,7 +64,6 @@ def generate_ember_docs
end

def generate_ember_data_docs
output_path = 'data_api.yml'
repo_path = ember_data_path
sha = ENV['EMBER_DATA_SHA']

Expand All @@ -89,6 +89,33 @@ def generate_ember_data_docs
puts "Built #{repo_path} with SHA #{sha}"
end

def geocode_meetups
output_path = 'meetups.yml'
puts "Geocoding records from #{output_path}... "

data = YAML.load_file(File.expand_path("./data/#{output_path}"))
meetups = data["locations"].values.flatten
meetups.each do |meetup|
coord = Geocoder.coordinates(meetup["location"])
if coord.nil?
puts "Unable to find coordinates for #{meetup["location"]}"
next
end
meetup["lat"] = coord[0]
meetup["lon"] = coord[1]
puts "Found coordinates for #{meetup["location"]}"
#throttle requests to API to avoid errors
sleep 0.1
end

File.open(File.expand_path("../source/data/meetup_locations.json", __FILE__),"w") do |f|
f.write(meetups.to_json)
end
# File.open(File.expand_path("../data/#{output_path}", __FILE__), "w") do |f|
# YAML.dump(data, f)
# end
end

def build
system "middleman build"
end
Expand Down Expand Up @@ -155,3 +182,8 @@ task :deploy do |t, args|
system "git push origin master" unless ENV['NODEPLOY']
end
end

desc "Find coordinates for meetup locations"
task :geocode do
geocode_meetups
end
1 change: 1 addition & 0 deletions source/data/meetup_locations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"location":"San Francisco, CA","url":"http://www.meetup.com/Ember-SF/","image":"07sanfrancisco.png","lat":37.7749295,"lon":-122.4194155},{"location":"New York, NY","url":"http://www.meetup.com/EmberJS-NYC/","image":"04newyork.png","lat":40.7127837,"lon":-74.0059413},{"location":"Chicago, IL","url":"http://www.meetup.com/Chicago-Ember-js/","image":"03chicago.png","lat":41.8781136,"lon":-87.6297982},{"location":"Boston, MA","url":"http://www.meetup.com/Boston-Ember-js/","image":"02boston.png","lat":42.3600825,"lon":-71.0588801},{"location":"Atlanta, GA","url":"http://www.meetup.com/Ember-Atlanta-Meetup/","image":"01atlanta.png","lat":33.7489954,"lon":-84.3879824},{"location":"Southern California, CA","url":"http://www.meetup.com/Ember-SC/","image":"05socal.png","lat":34.9592083,"lon":-116.419389},{"location":"Philadelphia, PA","url":"http://www.meetup.com/Emberjs-Philly/","image":"06philadelphia.png","lat":39.9525839,"lon":-75.1652215},{"location":"Seattle, WA","url":"http://www.meetup.com/Ember-js-Seattle-Meetup/","image":"08seattle.png","lat":47.6062095,"lon":-122.3320708},{"location":"St. Louis, MO","url":"http://www.meetup.com/STLEmber","lat":38.6270025,"lon":-90.19940419999999},{"location":"Austin, TX","url":"http://www.meetup.com/Ember-ATX/","image":"16austin.png","lat":30.267153,"lon":-97.7430608},{"location":"Washington, DC","url":"http://www.meetup.com/Ember-JS-DC/","image":"19washington.png","lat":38.9071923,"lon":-77.0368707},{"location":"Salt Lake City, UT","url":"http://www.meetup.com/EmberJS-SLC","lat":40.7607793,"lon":-111.8910474},{"location":"Cincinnati, OH","url":"http://www.meetup.com/Embernati","lat":39.1031182,"lon":-84.5120196},{"location":"Minneapolis / St. Paul, MN","url":"http://www.meetup.com/Ember-Twin-Cities","lat":44.9716692,"lon":-93.2806134},{"location":"Portland, OR","url":"http://www.meetup.com/Ember-PDX/","lat":45.5230622,"lon":-122.6764816},{"location":"Pittsburgh, PA","url":"http://www.meetup.com/Ember-js-Pittsburgh/","lat":40.44062479999999,"lon":-79.9958864},{"location":"Denver, CO","url":"http://www.meetup.com/Ember-js-Denver/","lat":39.7392358,"lon":-104.990251},{"location":"Dallas, TX","url":"http://www.meetup.com/Ember-Dallas","lat":32.7766642,"lon":-96.79698789999999},{"location":"Orlando, FL","url":"http://www.meetup.com/Ember-js-Orlando/","image":"01orlando.png","lat":28.5383355,"lon":-81.3792365},{"location":"Indianapolis, IN","url":"http://www.meetup.com/Ember-js-Indianapolis/","lat":39.768403,"lon":-86.158068},{"location":"Toronto, Canada","url":"http://www.meetup.com/Toronto-Ember-JS-Meetup/","image":"15toronto.png","lat":43.653226,"lon":-79.3831843},{"location":"Ottawa, Canada","url":"http://www.meetup.com/Ember-js-Ottawa/","image":"13ottawa.png","lat":45.4215296,"lon":-75.69719309999999},{"location":"Vancouver, Canada","url":"http://www.meetup.com/Vancouver-Ember-js/","lat":49.2827291,"lon":-123.1207375},{"location":"San Juan, Puerto Rico","url":"http://www.meetup.com/Ember-PR/","image":"21puertorico.png","lat":18.4663338,"lon":-66.1057217},{"location":"Calgary, Canada","url":"http://www.meetup.com/EmberJS-YYC/","image":"23calgary.png","lat":51.0486151,"lon":-114.0708459},{"location":"São Paulo, Brazil","url":"http://www.meetup.com/Ember-js-Sao-Paulo/","lat":-23.5505199,"lon":-46.63330939999999},{"location":"Belo Horizonte, Brazil","url":"http://www.meetup.com/Ember-BH/","lat":-19.9166813,"lon":-43.9344931},{"location":"Montevideo, Uruguay","url":"http://www.meetup.com/ember-montevideo/","lat":-34.9011127,"lon":-56.16453139999999},{"location":"Paris, France","url":"http://www.meetup.com/EmberJS-Paris/","image":"14paris.png","lat":48.856614,"lon":2.3522219},{"location":"London, UK","url":"http://emberlondon.com","image":"11london.png","lat":51.5073509,"lon":-0.1277583},{"location":"Dublin, Ireland","url":"http://www.meetup.com/emberjsdublin/","image":"10dublin.png","lat":53.3498053,"lon":-6.2603097},{"location":"Berlin, Germany","url":"http://www.meetup.com/Ember-js-Berlin/","image":"09berlin.png","lat":52.52000659999999,"lon":13.404954},{"location":"Munich, Germany","url":"http://www.meetup.com/Ember-js-Munich/","image":"12munich.png","lat":48.1351253,"lon":11.5819806},{"location":"Göteborg, Sweden","url":"http://www.meetup.com/ember-js-goteborg/","image":"17goteborg.png","lat":57.70887,"lon":11.97456},{"location":"Budapest, Hungary","url":"http://www.meetup.com/ember-bp/","lat":47.497912,"lon":19.040235},{"location":"Oslo, Norway","url":"http://www.meetup.com/Ember-js-Oslo/","lat":59.9138688,"lon":10.7522454},{"location":"Brussels, Belgium","url":"http://www.meetup.com/Ember-js-Brussels/","lat":50.8503396,"lon":4.3517103},{"location":"Barcelona, Spain","url":"http://www.meetup.com/Ember-js-Barcelona/","image":"22barcelona.png","lat":41.3850639,"lon":2.1734035},{"location":"Kyiv, Ukraine","url":"http://ember-club.kiev.ua","lat":50.4501,"lon":30.5234},{"location":"Zürich, Switzerland","url":"http://www.meetup.com/Ember-js-Zurich/","lat":47.3686498,"lon":8.539182499999999},{"location":"Amsterdam, the Netherlands","url":"http://www.meetup.com/Amsterdam-Ember-js/","lat":52.3702157,"lon":4.895167900000001},{"location":"Tel Aviv, Israel","url":"http://www.meetup.com/Ember-IL/","image":"20telaviv.png","lat":32.0852999,"lon":34.78176759999999},{"location":"Bangalore, India","url":"http://www.meetup.com/EmberJS-Bangalore/","lat":12.9715987,"lon":77.5945627},{"location":"Tokyo, Japan","url":"http://emberjs.doorkeeper.jp/","lat":35.7090259,"lon":139.7319925},{"location":"Adelaide, Australia","url":"http://www.meetup.com/Ember-js-Adelaide","lat":-34.92862119999999,"lon":138.5999594},{"location":"Melbourne, Australia","url":"http://www.meetup.com/Ember-Melb-JS/","image":"18melbourne.png","lat":-37.814107,"lon":144.96328},{"location":"Wellington, New Zealand","url":"http://www.meetup.com/ember-js-wellington/","lat":-41.2864603,"lon":174.776236}]
42 changes: 27 additions & 15 deletions source/javascripts/meetups.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@
var handler = Gmaps.build('Google'),
mapOptions = $('meta[name=mapOptions]').attr('content');

var infowindow_template = _.template("<div class='map-marker'><h2><%=location%></h2>" +
"<div class='view'><a href='<%=url%>' target='_blank'>Go to meetup page</a></div></div>");

mapOptions = JSON.parse(mapOptions);
mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL;

handler.buildMap(mapOptions, function(){
var markers = handler.addMarkers([
{
"lat": 33.7677129,
"lng": -84.420604,
"picture": {
"url": "/images/meetups/map-pin.png",
"width": 20,
"height": 28
},
"infowindow": "<div class='map-marker'><h2>Atlanta, GA</h2><div class='organizer'><img src='http://photos3.meetupstatic.com/photos/member/d/c/7/0/highres_179096432.jpeg' class='profile'><strong>William Metz</strong><br>Organizer</div><div class='organizer'><img src='http://photos2.meetupstatic.com/photos/member/a/5/3/4/member_238302292.jpeg' class='profile'><strong>Chris McCuller</strong><br>Organizer</div><div class='organizer'><img src='http://photos4.meetupstatic.com/photos/member/b/d/4/e/member_214428462.jpeg' class='profile'><strong>Shane Ballman</strong><br>Organizer</div><div class='view'><a href='#' target='_blank'>Go to meetup page</a></div></div>"
},
]);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
$.getJSON("/data/meetup_locations.json", function( meetups ) {
handler.buildMap(mapOptions, function(){
var marker_data = _.map(meetups, function(meetup){
return {
"lat": meetup["lat"],
"lng": meetup["lon"],
"infowindow": infowindow_template(meetup)
};
});
var markers = handler.addMarkers(marker_data);
handler.bounds.extendWith(markers);

if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
handler.map.centerOn(pos);
handler.map.serviceObject.setZoom(8);
}, handler.fitMapToBounds.bind(handler));
}
else {
handler.fitMapToBounds();
}
});
});
})();
1 change: 0 additions & 1 deletion source/meetups.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ title: "Meetups"
</div>

<script src="/javascripts/meetups.js"></script>