diff --git a/Gemfile b/Gemfile index e035c3e414..b9879c4b5b 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 53a3369d04..d55b70f525 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -214,6 +215,7 @@ DEPENDENCIES capybara coderay! ember-middleman + geocoder gmaps4rails highline listen @@ -231,4 +233,4 @@ DEPENDENCIES thin tzinfo-data underscore-rails - wdm (>= 0.1.0) \ No newline at end of file + wdm (>= 0.1.0) diff --git a/Rakefile b/Rakefile index 466deaccb5..95405cc595 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,7 @@ require "bundler/setup" require 'yaml' +require 'geocoder' def git_initialize(repository) unless File.exist?(".git") @@ -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'] @@ -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 @@ -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 diff --git a/source/data/meetup_locations.json b/source/data/meetup_locations.json new file mode 100644 index 0000000000..959bd7a61b --- /dev/null +++ b/source/data/meetup_locations.json @@ -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}] \ No newline at end of file diff --git a/source/javascripts/meetups.js b/source/javascripts/meetups.js index 9bbb03e305..178f287404 100644 --- a/source/javascripts/meetups.js +++ b/source/javascripts/meetups.js @@ -2,23 +2,35 @@ var handler = Gmaps.build('Google'), mapOptions = $('meta[name=mapOptions]').attr('content'); + var infowindow_template = _.template("