Fix for geolocation

This commit is contained in:
Godwin 2016-07-10 18:52:36 -07:00
parent c56ecc0c7f
commit 87ff896c42
4 changed files with 7 additions and 5 deletions

View File

@ -2156,7 +2156,7 @@ body {
} }
button, .button { button, .button {
margin: 0 0.25em; margin: 0 0.25em 0.5em;
} }
.message { .message {

View File

@ -558,7 +558,7 @@ class ConferencesController < ApplicationController
@errors[:name] = :empty @errors[:name] = :empty
end 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) corrected = view_context.location(l.first)
if corrected.present? if corrected.present?

View File

@ -443,13 +443,13 @@ module ApplicationHelper
end end
def get_remote_location 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 end
def lookup_ip_location def lookup_ip_location
begin begin
if is_test? && ApplicationController::get_location.present? 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' elsif request.remote_ip == '127.0.0.1' || request.remote_ip == '::1'
get_remote_location get_remote_location
else else
@ -546,7 +546,7 @@ module ApplicationHelper
$panoramios ||= Hash.new $panoramios ||= Hash.new
$panoramios[location] ||= 0 $panoramios[location] ||= 0
$panoramios[location] += 1 $panoramios[location] += 1
result = Geocoder.search(location).first result = Geocoder.search(location, params: { language: 'en' }).first
if result if result
points = Geocoder::Calculations.bounding_box([result.latitude, result.longitude], 5, { :unit => :km }) 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]} options = {:set => :public, :size => :original, :from => 0, :to => 20, :mapfilter => false, :miny => points[0], :minx => points[1], :maxy => points[2], :maxx => points[3]}

View File

@ -149,6 +149,7 @@ class UserMailer < ActionMailer::Base
def contact(from, subject, message, email_list) def contact(from, subject, message, email_list)
@message = message @message = message
@subject = subject
@from = from.is_a?(Integer) ? User.find(from) : from @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 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) def contact_details(from, subject, message, request, params)
@message = message @message = message
@subject = subject
@from = from.is_a?(Integer) ? User.find(from) : from @from = from.is_a?(Integer) ? User.find(from) : from
@request = request @request = request
@params = params @params = params