From: Tom Hughes Date: Fri, 23 Aug 2013 16:41:09 +0000 (+0100) Subject: Merge remote-tracking branch 'osmlab/id-default' X-Git-Tag: live~4804 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/ae0177fbe61d7d02e3c6b441bd395fff6fd96a18?hp=fa339033e1f00f4f3e2b9c790c5100a863cf91ac Merge remote-tracking branch 'osmlab/id-default' --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0cd850cc6..aec612080 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -422,6 +422,24 @@ class ApplicationController < ActionController::Base request.body.rewind end + def preferred_editor + editor = if params[:editor] + params[:editor] + elsif @user and @user.preferred_editor + @user.preferred_editor + else + DEFAULT_EDITOR + end + + if request.env['HTTP_USER_AGENT'] =~ /MSIE/ and editor == 'id' + editor = 'potlatch2' + end + + editor + end + + helper_method :preferred_editor + private # extract authorisation credentials from headers, returns user = nil if none diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 7c8ee32b3..94cc64754 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -36,7 +36,7 @@ class SiteController < ApplicationController end def edit - editor = params[:editor] || @user.preferred_editor || DEFAULT_EDITOR + editor = preferred_editor if editor == "remote" render :action => :index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 160e25e35..4765cb35b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -57,16 +57,6 @@ module ApplicationHelper content_tag(tag, capture(&block), :class => "hide_unless_administrator") end - def preferred_editor - if params[:editor] - params[:editor] - elsif @user and @user.preferred_editor - @user.preferred_editor - else - DEFAULT_EDITOR - end - end - def scale_to_zoom(scale) Math.log(360.0 / (scale.to_f * 512.0)) / Math.log(2.0) end diff --git a/config/example.application.yml b/config/example.application.yml index 9a6d83aba..c6c15bb1d 100644 --- a/config/example.application.yml +++ b/config/example.application.yml @@ -73,7 +73,7 @@ defaults: &defaults # URL of Nominatim instance to use for geocoding nominatim_url: "http://nominatim.openstreetmap.org/" # Default editor - default_editor: "potlatch2" + default_editor: "id" # OAuth consumer key for Potlatch 2 #potlatch2_key: "" # OAuth consumer key for the web site