From: Tom Hughes Date: Sat, 13 Aug 2011 10:48:04 +0000 (+0100) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~5096^2~143 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/72e33046c80bddc0ca9b1336786dcb4b349137f7?hp=7c98b41cc89068d049a18f8738276f19cd47095e Merge branch 'master' into openstreetbugs Conflicts: app/views/browse/_map.html.erb app/views/site/index.html.erb --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 619ef981a..655017847 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,9 @@ class ApplicationController < ActionController::Base if STATUS == :database_readonly or STATUS == :database_offline session :off + + def self.cache_sweeper(*sweepers) + end end def authorize_web diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 0aeaf200d..45b5f80f9 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -446,7 +446,7 @@ private # eliminate empty changesets (where the bbox has not been set) # this should be applied to all changeset list displays def conditions_nonempty() - return ['min_lat IS NOT NULL'] + return ['num_changes > 0'] end end diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 73e9629e0..52ce742bf 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -10,7 +10,7 @@ class DiaryEntryController < ApplicationController caches_action :list, :view, :layout => false caches_action :rss, :layout => true - cache_sweeper :diary_sweeper, :only => [:new, :edit, :comment, :hide, :hidecomment], :unless => STATUS == :database_offline + cache_sweeper :diary_sweeper, :only => [:new, :edit, :comment, :hide, :hidecomment] def new @title = t 'diary_entry.new.title' diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 65029e4ef..21ef26bac 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -48,6 +48,18 @@ class SiteController < ApplicationController @lat = params['mlat'].to_f @zoom = params['zoom'].to_i + elsif params['bbox'] + bbox = params['bbox'].split(",") + + @lon = ( bbox[0].to_f + bbox[2].to_f ) / 2.0 + @lat = ( bbox[1].to_f + bbox[3].to_f ) / 2.0 + @zoom = 16 + + elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] + @lon = ( params['maxlon'].to_f + params['minlon'].to_f ) / 2.0 + @lat = ( params['maxlat'].to_f + params['minlat'].to_f ) / 2.0 + @zoom = 16 + elsif params['gpx'] @lon = Trace.find(params['gpx']).longitude @lat = Trace.find(params['gpx']).latitude diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 2cd3117dd..52392fddd 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -18,8 +18,8 @@ class TraceController < ApplicationController caches_action :list, :unless => :logged_in?, :layout => false caches_action :view, :layout => false caches_action :georss, :layout => true - cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete], :unless => STATUS == :database_offline - cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete], :unless => STATUS == :database_offline + cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete] + cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete] # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.). # target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index b337dc04c..70328f5a5 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -17,7 +17,7 @@ class UserController < ApplicationController filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation - cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => STATUS == :database_offline + cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete] def terms @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || DEFAULT_LEGALE diff --git a/app/models/changeset.rb b/app/models/changeset.rb index d13974fd9..8f9a1e69b 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -115,16 +115,21 @@ class Changeset < ActiveRecord::Base # nils, just use the bounding box update to write over them. @bbox = bbox.zip(array).collect { |a, b| a.nil? ? b : a } - # FIXME - this looks nasty and violates DRY... is there any prettier - # way to do this? - @bbox[0] = [-180 * GeoRecord::SCALE, array[0] + EXPAND * (@bbox[0] - @bbox[2])].max if array[0] < @bbox[0] - @bbox[1] = [ -90 * GeoRecord::SCALE, array[1] + EXPAND * (@bbox[1] - @bbox[3])].max if array[1] < @bbox[1] - @bbox[2] = [ 180 * GeoRecord::SCALE, array[2] + EXPAND * (@bbox[2] - @bbox[0])].min if array[2] > @bbox[2] - @bbox[3] = [ 90 * GeoRecord::SCALE, array[3] + EXPAND * (@bbox[3] - @bbox[1])].min if array[3] > @bbox[3] - - # update active record. rails 2.1's dirty handling should take care of - # whether this object needs saving or not. - self.min_lon, self.min_lat, self.max_lon, self.max_lat = @bbox + # only try to update the bbox if there is a value for every coordinate + # which there will be from the previous line as long as both array and + # bbox are all non-nil. + if has_valid_bbox? and array.all? + # FIXME - this looks nasty and violates DRY... is there any prettier + # way to do this? + @bbox[0] = [-180 * GeoRecord::SCALE, array[0] + EXPAND * (@bbox[0] - @bbox[2])].max if array[0] < @bbox[0] + @bbox[1] = [ -90 * GeoRecord::SCALE, array[1] + EXPAND * (@bbox[1] - @bbox[3])].max if array[1] < @bbox[1] + @bbox[2] = [ 180 * GeoRecord::SCALE, array[2] + EXPAND * (@bbox[2] - @bbox[0])].min if array[2] > @bbox[2] + @bbox[3] = [ 90 * GeoRecord::SCALE, array[3] + EXPAND * (@bbox[3] - @bbox[1])].min if array[3] > @bbox[3] + + # update active record. rails 2.1's dirty handling should take care of + # whether this object needs saving or not. + self.min_lon, self.min_lat, self.max_lon, self.max_lat = @bbox + end end ## diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index dd4ec74df..d2695ebe6 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -1,24 +1,71 @@ <%= javascript_include_tag '/openlayers/OpenLayers.js' %> <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %> <%= javascript_include_tag 'map.js' %> + + +
<% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
<%= t 'browse.map.loading' %> - + <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %> +
+ <%= link_to(t("browse.map.edit.area"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %> <% unless map.instance_of? Changeset %>
- + <%= link_to("", { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %> +
+ <%= link_to("", { :controller => :site, :action => :edit }, { :id => "object_edit", :class => "geolink object" }) %> <% end %> <% else %> <%= t 'browse.map.deleted' %> <% end %>
+ + + + + <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %> diff --git a/app/views/diary_entry/list.html.erb b/app/views/diary_entry/list.html.erb index 1be32fd21..a78b41a4f 100644 --- a/app/views/diary_entry/list.html.erb +++ b/app/views/diary_entry/list.html.erb @@ -1,5 +1,5 @@ <% if @this_user %> -<%= user_image @this_user, :style => "float: right" %> + <%= user_image @this_user %> <% end %>

<%= h(@title) %>

@@ -14,7 +14,6 @@ <% end %> <% end %> - <% if @entries.empty? %>

<%= t 'diary_entry.list.no_entries' %>

<% else %> diff --git a/app/views/diary_entry/view.html.erb b/app/views/diary_entry/view.html.erb index 1a8096d13..3bc9323e3 100644 --- a/app/views/diary_entry/view.html.erb +++ b/app/views/diary_entry/view.html.erb @@ -1,4 +1,4 @@ -<%= user_image @entry.user, :style => "float: right" %> +<%= user_image @entry.user %>

<%= link_to t('diary_entry.view.user_title', :user => h(@entry.user.display_name)), :action => :list %>

diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 6c22a9475..206905b94 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -6,6 +6,7 @@ <%= javascript_include_tag 'menu' %> <%= stylesheet_link_tag 'common' %> + <%= stylesheet_link_tag t('html.dir') %> <%= stylesheet_link_tag 'small', :media => "only screen and (max-width:641px)" %> <%= stylesheet_link_tag 'large', :media => "screen and (min-width: 642px)" %> diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index 7346802a9..9cb6d3df0 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -6,7 +6,7 @@ <%= link_to(image_tag("osm_logo.png", :size => "16x16", :border => 0, :alt => t('layouts.logo.alt_text')), :controller => 'site', :action => 'index') %>

<%= t 'layouts.project_name.h1' %>

-
+
<%= render :partial => "layouts/flash", :locals => { :flash => flash } %> <%= yield %> @@ -28,17 +28,18 @@
    <% - viewclass = '' - editclass = '' - historyclass = '' - exportclass = '' + viewclass = 'geolink llz layers' + editclass = 'geolink llz object minzoom13 disabled' + historyclass = 'geolink bbox minzoom11' + exportclass = 'geolink llz layers' traceclass = '' - viewclass = 'active' if params['controller'] == 'site' and params['action'] == 'index' - editclass = 'active' if params['controller'] == 'site' and params['action'] == 'edit' - historyclass = 'active' if params['controller'] == 'changeset' and params['action'] == 'list' - exportclass = 'active' if params['controller'] == 'site' and params['action'] == 'export' - traceclass = 'active' if params['controller'] == 'trace' - diaryclass = 'active' if params['controller'] == 'diary_entry' + diaryclass = '' + viewclass += ' active' if params['controller'] == 'site' and params['action'] == 'index' + editclass += ' active' if params['controller'] == 'site' and params['action'] == 'edit' + historyclass += ' active' if params['controller'] == 'changeset' and params['action'] == 'list' + exportclass += ' active' if params['controller'] == 'site' and params['action'] == 'export' + traceclass += ' active' if params['controller'] == 'trace' + diaryclass += ' active' if params['controller'] == 'diary_entry' %>
  • <%= link_to t('layouts.view'), {:controller => 'site', :action => 'index'}, {:id => 'viewanchor', :title => t('layouts.view_tooltip'), :class => viewclass} %>
  • <%= link_to t('layouts.edit') + ' ▾', {:controller => 'site', :action => 'edit'}, {:id => 'editanchor', :title => t('javascripts.site.edit_tooltip'), :class => editclass} %>
  • @@ -53,16 +54,16 @@
-
+
@@ -87,7 +88,8 @@

<%= t 'layouts.intro_3', - :ucl => link_to(t('layouts.intro_3_ucl'), "http://www.vr.ucl.ac.uk"), + :ucl => link_to(t('layouts.intro_3_ucl'), "http://www.vr.ucl.ac.uk"), + :ic => link_to(t('layouts.intro_3_ic'), "http://www.imperial.ac.uk/"), :bytemark => link_to(t('layouts.intro_3_bytemark'), "http://www.bytemark.co.uk"), :partners => link_to(t('layouts.intro_3_partners'), t('layouts.intro_3_partners_url')) %>

diff --git a/app/views/message/new.html.erb b/app/views/message/new.html.erb index 151cd2759..85de1e51b 100644 --- a/app/views/message/new.html.erb +++ b/app/views/message/new.html.erb @@ -5,15 +5,15 @@ <% form_for :message, :url => { :action => "new", :display_name => @to_user.display_name } do |f| %> - + - + - +
<%= t'message.new.subject' %><%= t'message.new.subject' %> <%= f.text_field :title, :size => 60, :value => @subject %>
<%= t'message.new.body' %><%= t'message.new.body' %> <%= f.text_area :body, :cols => 80, :value => @body %>
<%= submit_tag t('message.new.send_button') %>
diff --git a/app/views/message/read.html.erb b/app/views/message/read.html.erb index 576403170..6bad015cc 100644 --- a/app/views/message/read.html.erb +++ b/app/views/message/read.html.erb @@ -4,17 +4,17 @@ - + - + - + @@ -41,17 +41,17 @@
<%= t'message.read.from' %><%= t'message.read.from' %> <%= link_to h(@message.sender.display_name), :controller => 'user', :action => 'view', :display_name => @message.sender.display_name %> <%= user_thumbnail @message.sender %>
<%= t'message.read.subject' %><%= t'message.read.subject' %> <%= h(@message.title) %>
<%= t'message.read.date' %><%= t'message.read.date' %> <%= l @message.sent_on, :format => :friendly %>
- + - + - + diff --git a/app/views/oauth/oauthorize.html.erb b/app/views/oauth/oauthorize.html.erb index 844a86d52..28178a85c 100644 --- a/app/views/oauth/oauthorize.html.erb +++ b/app/views/oauth/oauthorize.html.erb @@ -1,5 +1,5 @@

Authorize access to your account

-

<%= t('oauth.oauthorize.request_access', :app_name => link_to(@token.client_application.name,@token.client_application.url)) %>

+

<%= t('oauth.oauthorize.request_access', :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(@user.display_name, :controller => :user, :action => :view, :display_name => @user.display_name)) %>

<% form_tag authorize_url do %> <%= hidden_field_tag "oauth_token", @token.token %> <%- if params[:oauth_callback] -%> diff --git a/app/views/site/_potlatch2.html.erb b/app/views/site/_potlatch2.html.erb index e648ed37c..c91a01984 100644 --- a/app/views/site/_potlatch2.html.erb +++ b/app/views/site/_potlatch2.html.erb @@ -41,6 +41,7 @@ fo.addVariable("api","<%= request.protocol + request.host_with_port %>/api/<%= API_VERSION %>/"); fo.addVariable("policy","<%= request.protocol + request.host_with_port %>/api/crossdomain.xml"); fo.addVariable("connection","XML"); + fo.addVariable("show_help","once"); <% if token %> fo.addVariable("oauth_token","<%= token.token %>"); fo.addVariable("oauth_token_secret","<%= token.secret %>"); diff --git a/app/views/site/_resize.html.erb b/app/views/site/_resize.html.erb new file mode 100644 index 000000000..a4975e14f --- /dev/null +++ b/app/views/site/_resize.html.erb @@ -0,0 +1,41 @@ + diff --git a/app/views/site/_sidebar.html.erb b/app/views/site/_sidebar.html.erb index 2dbcef432..f7e7229c8 100644 --- a/app/views/site/_sidebar.html.erb +++ b/app/views/site/_sidebar.html.erb @@ -1,8 +1,8 @@
<%= t'message.read.to' %><%= t'message.read.to' %> <%= link_to h(@message.recipient.display_name), :controller => 'user', :action => 'view', :display_name => @message.recipient.display_name %> <%= user_thumbnail @message.recipient %>
<%= t'message.read.subject' %><%= t'message.read.subject' %> <%= h(@message.title) %>
<%= t'message.read.date' %><%= t'message.read.date' %> <%= l @message.sent_on, :format => :friendly %>
- - + +