From 87ff896c42ea8ce55ee42da85db8c0d7a5562abf Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 10 Jul 2016 18:52:36 -0700 Subject: [PATCH] Fix for geolocation --- app/assets/stylesheets/_application.scss | 2 +- app/controllers/conferences_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +++--- app/mailers/user_mailer.rb | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index f2c4f9d..86f0e59 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -2156,7 +2156,7 @@ body { } button, .button { - margin: 0 0.25em; + margin: 0 0.25em 0.5em; } .message { diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 3364a8b..974cecd 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -558,7 +558,7 @@ class ConferencesController < ApplicationController @errors[:name] = :empty end - if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location])).present? + if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], params: { language: 'en' })).present? corrected = view_context.location(l.first) if corrected.present? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 67d5d3d..7a916db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -443,13 +443,13 @@ module ApplicationHelper end def get_remote_location - Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, ''))).first + Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, '')), params: { language: 'en' }).first end def lookup_ip_location begin if is_test? && ApplicationController::get_location.present? - Geocoder.search(ApplicationController::get_location).first + Geocoder.search(ApplicationController::get_location, params: { language: 'en' }).first elsif request.remote_ip == '127.0.0.1' || request.remote_ip == '::1' get_remote_location else @@ -546,7 +546,7 @@ module ApplicationHelper $panoramios ||= Hash.new $panoramios[location] ||= 0 $panoramios[location] += 1 - result = Geocoder.search(location).first + result = Geocoder.search(location, params: { language: 'en' }).first if result points = Geocoder::Calculations.bounding_box([result.latitude, result.longitude], 5, { :unit => :km }) options = {:set => :public, :size => :original, :from => 0, :to => 20, :mapfilter => false, :miny => points[0], :minx => points[1], :maxy => points[2], :maxx => points[3]} diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index a51ffee..f00cb0d 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -149,6 +149,7 @@ class UserMailer < ActionMailer::Base def contact(from, subject, message, email_list) @message = message + @subject = subject @from = from.is_a?(Integer) ? User.find(from) : from mail to: email_list.join(', '), subject: @subject, reply_to: from.is_a?(User) ? from.named_email : from @@ -156,6 +157,7 @@ class UserMailer < ActionMailer::Base def contact_details(from, subject, message, request, params) @message = message + @subject = subject @from = from.is_a?(Integer) ? User.find(from) : from @request = request @params = params