diff --git a/Gemfile b/Gemfile index 0d31318b8dc..e70ab2d89f0 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,8 @@ gem "actionpack-page_caching" # Omniauth for authentication gem "omniauth" gem "omniauth-openid" -gem "openstreetmap-omniauth-google-oauth2", ">= 0.2.6.1", :require => "omniauth-google-oauth2" +gem "omniauth-google-oauth2" +#gem "openstreetmap-omniauth-google-oauth2", ">= 0.2.6.1", :require => "omniauth-google-oauth2" gem "omniauth-facebook" gem "omniauth-windowslive" @@ -85,6 +86,9 @@ gem "soap4r-ruby1.9" gem "dalli" gem "kgio" +# indexing city in algolia +gem "algoliasearch" + # Gems useful for development group :development do gem "vendorer" @@ -103,4 +107,5 @@ group :development, :test do gem "konacha" gem "poltergeist" gem "coveralls", :require => false + gem "pry-rails" end diff --git a/Gemfile.lock b/Gemfile.lock index a19d2e7fa60..b7d9229f9fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,10 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.3.8) + algoliasearch (1.6.1) + httpclient (~> 2.4) + json (>= 1.5.1) arel (6.0.0) ast (2.0.0) astrolabe (1.3.0) @@ -59,6 +63,7 @@ GEM cliver (0.3.2) cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) + coderay (1.1.0) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -127,6 +132,7 @@ GEM nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) + method_source (0.8.2) mime-types (2.6.1) mini_portile (0.6.2) minitest (5.7.0) @@ -155,6 +161,12 @@ GEM rack (~> 1.0) omniauth-facebook (2.0.1) omniauth-oauth2 (~> 1.2) + omniauth-google-oauth2 (0.2.8) + addressable (~> 2.3) + jwt (~> 1.0) + multi_json (~> 1.3) + omniauth (>= 1.1.1) + omniauth-oauth2 (>= 1.1.1) omniauth-oauth2 (1.3.0) oauth2 (~> 1.0) omniauth (~> 1.2) @@ -164,11 +176,6 @@ GEM omniauth-windowslive (0.0.9) multi_json (>= 1.0.3) omniauth-oauth2 (~> 1.0) - openstreetmap-omniauth-google-oauth2 (0.2.6.1) - jwt (~> 1.0) - multi_json (~> 1.3) - omniauth (>= 1.1.1) - omniauth-oauth2 (>= 1.1.1) paperclip (4.2.2) activemodel (>= 3.0.0) activesupport (>= 3.0.0) @@ -183,6 +190,12 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) powerpack (0.1.1) + pry (0.10.3) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-rails (0.3.4) + pry (>= 0.9.10) psych (2.0.13) r2 (0.2.5) rack (1.6.2) @@ -252,6 +265,7 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) + slop (3.6.0) soap4r-ruby1.9 (2.0.5) sprockets (2.12.3) hike (~> 1.2) @@ -295,6 +309,7 @@ PLATFORMS DEPENDENCIES SystemTimer (>= 1.1.3) actionpack-page_caching + algoliasearch autoprefixer-rails bigdecimal (~> 1.1.0) coffee-rails (~> 4.1.0) @@ -319,12 +334,13 @@ DEPENDENCIES oauth-plugin (>= 0.5.1) omniauth omniauth-facebook + omniauth-google-oauth2 omniauth-openid omniauth-windowslive - openstreetmap-omniauth-google-oauth2 (>= 0.2.6.1) paperclip (~> 4.0) pg poltergeist + pry-rails psych r2 rack-cors @@ -341,3 +357,6 @@ DEPENDENCIES uglifier (>= 1.3.0) validates_email_format_of (>= 1.5.1) vendorer + +BUNDLED WITH + 1.10.6 diff --git a/app/assets/images/pin.svg b/app/assets/images/pin.svg new file mode 100644 index 00000000000..43bd920409b --- /dev/null +++ b/app/assets/images/pin.svg @@ -0,0 +1,13 @@ + + + + diff --git a/app/assets/images/pin_disabled.svg b/app/assets/images/pin_disabled.svg new file mode 100644 index 00000000000..c24d9a33ca2 --- /dev/null +++ b/app/assets/images/pin_disabled.svg @@ -0,0 +1,13 @@ + + + + diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 5e437c6ec47..fbb4c9b0d35 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -8,6 +8,7 @@ //= require leaflet.polyline //= require leaflet.query //= require index/search +//= require index/search_algolia //= require index/browse //= require index/export //= require index/notes diff --git a/app/assets/javascripts/index/search_algolia.js b/app/assets/javascripts/index/search_algolia.js new file mode 100644 index 00000000000..01c8ce7a7ba --- /dev/null +++ b/app/assets/javascripts/index/search_algolia.js @@ -0,0 +1,128 @@ +// Component responsible for displaying the search results +var SearchResultComponent = function ( cities ){ + this.cities = cities; + this.container = $('#sidebar_content'); +} + +SearchResultComponent.prototype = { + + clear: function () { + this.container.html(""); + }, + + render: function ( cities ) { + + this.cities = cities; + this.container.css('display','block'); + this.clear(); + this.displayCities( this.cities ); + }, + + displayCity: function ( city ) { + + var country_code = city.country_code.toLowerCase(); + var search_result = $(" ") + search_result.attr( "href", "/#map=9/"+ city._geoloc.lat + "/" + city._geoloc.lng ); + flag = $("
"+ city._highlightResult.name.value +"
" + city.country + "
") + flag.appendTo(search_result); + block.appendTo(search_result); + search_result.on('click', function ( e ){ + $('.query_wrapper input').val(city.name); + }); + search_result.appendTo(this.container); + + }, + + displayCities: function ( cities ) { + if (cities.length == 0 ) { + this.displayNoResults(); + return; + } + + cities.forEach( function ( city ){ + this.displayCity( city ); + }.bind(this)) + }, + + displayNoResults: function (){ + this.container.html("