From 8dc16bd8dbd362a0e823f8abd989d871ce5de32f Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 15 Aug 2013 16:36:08 -0700 Subject: [PATCH] Make iD default editor Make iD the default editor for all users that have not specified a preferred editor, except fall back to P2 on IE. --- app/controllers/application_controller.rb | 18 ++++++++++++++++++ app/controllers/site_controller.rb | 2 +- app/helpers/application_helper.rb | 10 ---------- config/example.application.yml | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) 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 b2212645c..69ce8f8b1 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -52,7 +52,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 -- 2.43.2