From: Tom Hughes Date: Wed, 9 Aug 2023 18:20:54 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/4132' X-Git-Tag: live~709 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/eedf8a55e4e14d8721b209201b2bdd96d5b6738e?hp=b4256ae6a389cad58a8dee903269f47d2e43a194 Merge remote-tracking branch 'upstream/pull/4132' --- diff --git a/Gemfile.lock b/Gemfile.lock index 2cb6bf177..dc2bb6080 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,7 +74,7 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) @@ -86,8 +86,8 @@ GEM autoprefixer-rails (10.4.13.0) execjs (~> 2) aws-eventstream (1.2.0) - aws-partitions (1.795.0) - aws-sdk-core (3.180.1) + aws-partitions (1.799.0) + aws-sdk-core (3.180.2) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -168,7 +168,7 @@ GEM dry-configurable (1.1.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-core (1.0.0) + dry-core (1.0.1) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) dry-inflector (1.0.0) @@ -298,7 +298,7 @@ GEM maxminddb (0.1.22) method_source (1.0.0) mini_magick (4.12.0) - mini_mime (1.1.2) + mini_mime (1.1.5) mini_portile2 (2.8.4) minitest (5.19.0) msgpack (1.7.2) @@ -382,8 +382,8 @@ GEM rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-protection (3.0.6) - rack + rack-protection (3.1.0) + rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) rack-uri_sanitizer (0.0.2) @@ -405,7 +405,7 @@ GEM actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.1.1) + rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -531,7 +531,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.10) + zeitwerk (2.6.11) PLATFORMS ruby diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 38c498169..783c4da8d 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -192,11 +192,11 @@ $(document).ready(function () { }); if (Cookies.get("_osm_welcome") !== "hide") { - $(".welcome").addClass("visible"); + $(".welcome").removeAttr("hidden"); } $(".welcome .btn-close").on("click", function () { - $(".welcome").removeClass("visible"); + $(".welcome").hide(); Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/", samesite: "lax" }); }); diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 14da8f300..964f187f9 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -54,7 +54,7 @@ $(document).ready(function () { precision = OSM.zoomPrecision(zoom), location = e.latlng.wrap(); - $("#homerow").removeClass(); + $("#home_message").hide(); $("#home_lat").val(location.lat.toFixed(precision)); $("#home_lon").val(location.lng.toFixed(precision)); diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index f68ba9eee..779fbbe35 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -317,7 +317,7 @@ body.small-nav { display: inline-block; } - .overlay-sidebar #sidebar .welcome.visible { + .overlay-sidebar #sidebar .welcome { display: none; } @@ -436,11 +436,7 @@ body.small-nav { } .welcome { - display: none; - - &.visible { - display: block; - } + display: block; } #sidebar_content { @@ -1127,32 +1123,6 @@ tr.turn:hover { } } -/* Rules for the account settings page */ - -#accountForm .user_image { - margin-bottom: 0; -} - -#accountForm #user_image { - margin-left: 20px; -} - -#accountForm ul.accountImage-options { - margin-left: 120px; -} - -.nohome .location { - display: none; -} - -#homerow .message { - display: none; -} - -.nohome .message { - display: inline !important; -} - /* Rules for the oauth authorization page */ .oauth-authorize ul { @@ -1212,44 +1182,6 @@ tr.turn:hover { display: none; } -/* Rules for highlighting fields with rails validation errors */ - -.formError { - display: inline-block; - padding: 5px 10px; - margin-top: 5px; - border-radius: 4px; - font-size: 12px; - color: #fff; - background-color: #ff7070; -} - -/* Rules for rails validation error boxes */ - -#errorExplanation { - width: 400px; - border: 2px solid #ff7070; - padding: 0 $lineheight/2; - margin-bottom: $lineheight; - background-color: #f0f0f0; - - h2 { - margin: 0 -10px 10px -10px; - padding: $lineheight/4 $lineheight/4 $lineheight/4 15px; - font-weight: bold; - font-size: 12px; - background-color: #c00; - color: #fff; - text-align: left; - } - - p { - color: #333; - margin-bottom: 0px; - padding: $lineheight/4; - } -} - .search_form { background-color: $lightgrey; diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index a08edff53..0dffd4de2 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -19,9 +19,6 @@ module Api # Helper methods for checking consistency include ConsistencyValidations - DEFAULT_QUERY_LIMIT = 100 - MAX_QUERY_LIMIT = 100 - ## # Return XML giving the basic info about the changeset. Does not # return anything about the nodes, ways and relations in the changeset. @@ -391,13 +388,13 @@ module Api # Get the maximum number of results to return def result_limit if params[:limit] - if params[:limit].to_i.positive? && params[:limit].to_i <= MAX_QUERY_LIMIT + if params[:limit].to_i.positive? && params[:limit].to_i <= Settings.max_changeset_query_limit params[:limit].to_i else - raise OSM::APIBadUserInput, "Changeset limit must be between 1 and #{MAX_QUERY_LIMIT}" + raise OSM::APIBadUserInput, "Changeset limit must be between 1 and #{Settings.max_changeset_query_limit}" end else - DEFAULT_QUERY_LIMIT + Settings.default_changeset_query_limit end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d22a031d4..5dcfee07c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base def authorize_web if session[:user] - self.current_user = User.where(:id => session[:user]).where("status IN ('active', 'confirmed', 'suspended')").first + self.current_user = User.where(:id => session[:user], :status => %w[active confirmed suspended]).first if session[:fingerprint] && session[:fingerprint] != current_user.fingerprint diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 6e7378bf3..ea9aacb21 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -17,7 +17,7 @@ class DiaryEntriesController < ApplicationController if @user @title = t ".user_title", :user => @user.display_name - @entries = @user.diary_entries + entries = @user.diary_entries else render_unknown_user params[:display_name] return @@ -25,7 +25,7 @@ class DiaryEntriesController < ApplicationController elsif params[:friends] if current_user @title = t ".title_friends" - @entries = DiaryEntry.where(:user_id => current_user.friends) + entries = DiaryEntry.where(:user_id => current_user.friends) else require_user return @@ -33,32 +33,40 @@ class DiaryEntriesController < ApplicationController elsif params[:nearby] if current_user @title = t ".title_nearby" - @entries = DiaryEntry.where(:user_id => current_user.nearby) + entries = DiaryEntry.where(:user_id => current_user.nearby) else require_user return end else - @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] }) + entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] }) if params[:language] @title = t ".in_language_title", :language => Language.find(params[:language]).english_name - @entries = @entries.where(:language_code => params[:language]) + entries = entries.where(:language_code => params[:language]) else @title = t ".title" end end + entries = entries.visible unless can? :unhide, DiaryEntry + @params = params.permit(:display_name, :friends, :nearby, :language) - @page = (params[:page] || 1).to_i - @page_size = 20 + @entries = if params[:before] + entries.where("diary_entries.id < ?", params[:before]).order(:id => :desc) + elsif params[:after] + entries.where("diary_entries.id > ?", params[:after]).order(:id => :asc) + else + entries.order(:id => :desc) + end - @entries = @entries.visible unless can? :unhide, DiaryEntry - @entries = @entries.order("created_at DESC") - @entries = @entries.offset((@page - 1) * @page_size) - @entries = @entries.limit(@page_size) + @entries = @entries.limit(20) @entries = @entries.includes(:user, :language) + @entries = @entries.sort.reverse + + @newer_entries = @entries.count.positive? && entries.exists?(["diary_entries.id > ?", @entries.first.id]) + @older_entries = @entries.count.positive? && entries.exists?(["diary_entries.id < ?", @entries.last.id]) end def show diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index fc8b3a60b..912247c9c 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -88,10 +88,7 @@ class GeocoderController < ApplicationController response = fetch_xml("#{Settings.nominatim_url}search?format=xml&extratags=1&q=#{escape_query(query)}#{viewbox}#{exclude}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}") # extract the results from the response - results = response.elements["searchresults"] - - # extract parameters from more_url - more_url_params = CGI.parse(URI.parse(results.attributes["more_url"]).query) + results = response.elements["searchresults"] # create result array @results = [] @@ -99,7 +96,7 @@ class GeocoderController < ApplicationController # create parameter hash for "more results" link @more_params = params .permit(:query, :minlon, :minlat, :maxlon, :maxlat, :exclude) - .merge(:exclude => more_url_params["exclude_place_ids"].first) + .merge(:exclude => results.attributes["exclude_place_ids"]) # parse the response results.elements.each("place") do |place| diff --git a/app/models/trace.rb b/app/models/trace.rb index 0b9877225..35fee0bf4 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -35,7 +35,7 @@ class Trace < ApplicationRecord has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace scope :visible, -> { where(:visible => true) } - scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) } + scope :visible_to, ->(u) { visible.where(:visibility => %w[public identifiable]).or(visible.where(:user => u)) } scope :visible_to_all, -> { where(:visibility => %w[public identifiable]) } scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) } diff --git a/app/views/api/capabilities/show.builder b/app/views/api/capabilities/show.builder index b6a38723d..1258601bb 100644 --- a/app/views/api/capabilities/show.builder +++ b/app/views/api/capabilities/show.builder @@ -7,7 +7,9 @@ xml.osm(OSM::API.new.xml_root_attributes) do |osm| api.tracepoints(:per_page => Settings.tracepoints_per_page) api.waynodes(:maximum => Settings.max_number_of_way_nodes) api.relationmembers(:maximum => Settings.max_number_of_relation_members) - api.changesets(:maximum_elements => Changeset::MAX_ELEMENTS) + api.changesets(:maximum_elements => Changeset::MAX_ELEMENTS, + :default_query_limit => Settings.default_changeset_query_limit, + :maximum_query_limit => Settings.max_changeset_query_limit) api.timeout(:seconds => Settings.api_timeout) api.status(:database => @database_status, :api => @api_status, diff --git a/app/views/diary_entries/index.html.erb b/app/views/diary_entries/index.html.erb index 9c0112cd0..4a8beab37 100644 --- a/app/views/diary_entries/index.html.erb +++ b/app/views/diary_entries/index.html.erb @@ -38,9 +38,9 @@