From: Tom Hughes Date: Sun, 25 Feb 2024 09:28:48 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/4463' X-Git-Tag: live~1257 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/746bfd0a4838268eaf745e85e0e27b5acf9cf64a?hp=2d03d738dab3ffa1f73566fd85d6f4a8c92f6d56 Merge remote-tracking branch 'upstream/pull/4463' --- diff --git a/Gemfile.lock b/Gemfile.lock index 32ac9e418..24beeb4d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,35 +3,35 @@ GEM specs: aasm (5.5.0) concurrent-ruby (~> 1.0) - actioncable (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.3) - actionpack (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activesupport (= 7.1.3) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.3) - actionview (= 7.1.3) - activesupport (= 7.1.3) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -41,39 +41,39 @@ GEM rails-html-sanitizer (~> 1.6) actionpack-page_caching (1.2.4) actionpack (>= 4.0.0) - actiontext (7.1.3) - actionpack (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3) - activesupport (= 7.1.3) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (7.1.3) - activesupport (= 7.1.3) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.1.3) - activesupport (= 7.1.3) - activerecord (7.1.3) - activemodel (= 7.1.3) - activesupport (= 7.1.3) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) timeout (>= 0.4.0) activerecord-import (1.5.1) activerecord (>= 4.2) - activestorage (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activesupport (= 7.1.3) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - activesupport (7.1.3) + activesupport (7.1.3.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -95,11 +95,12 @@ GEM autoprefixer-rails (10.4.16.0) execjs (~> 2) aws-eventstream (1.3.0) - aws-partitions (1.887.0) - aws-sdk-core (3.191.0) + aws-partitions (1.894.0) + aws-sdk-core (3.191.2) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) + base64 jmespath (~> 1, >= 1.6.1) aws-sdk-kms (1.77.0) aws-sdk-core (~> 3, >= 3.191.0) @@ -157,12 +158,11 @@ GEM deep_merge (~> 1.2, >= 1.2.1) dry-validation (~> 1.0, >= 1.0.0) connection_pool (2.4.1) - crack (0.4.6) + crack (1.0.0) bigdecimal rexml crass (1.0.6) - dalli (3.2.7) - base64 + dalli (3.2.8) dartsass-ruby (3.0.2) sass-embedded (~> 1.54, < 1.67) dartsass-sprockets (3.0.0) @@ -180,7 +180,7 @@ GEM activerecord (>= 3.0, < 8.0) delayed_job (>= 3.0, < 5) docile (1.4.0) - doorkeeper (5.6.8) + doorkeeper (5.6.9) railties (>= 5) doorkeeper-i18n (5.2.7) doorkeeper (>= 5.2) @@ -248,14 +248,14 @@ GEM ffi-libarchive (1.1.14) ffi (~> 1.0) file_exists (0.2.0) - frozen_record (0.27.0) + frozen_record (0.27.1) activemodel fspath (3.1.2) gd2-ffij (0.4.0) ffi (>= 1.0.0) globalid (1.2.1) activesupport (>= 6.1) - google-protobuf (3.25.2) + google-protobuf (3.25.3) hashdiff (1.1.0) hashie (5.0.0) highline (3.0.1) @@ -292,7 +292,7 @@ GEM image_size (3.4.0) in_threads (1.6.0) io-console (0.7.2) - irb (1.11.1) + irb (1.11.2) rdoc reline (>= 0.4.2) jbuilder (2.11.5) @@ -304,7 +304,8 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.7.1) - jwt (2.7.1) + jwt (2.8.0) + base64 kgio (2.11.4) kramdown (2.4.0) rexml @@ -333,7 +334,7 @@ GEM mini_portile2 (2.8.5) mini_racer (0.8.0) libv8-node (~> 18.16.0.0) - minitest (5.22.0) + minitest (5.22.2) minitest-focus (1.4.0) minitest (>= 4, < 6) msgpack (1.7.2) @@ -406,7 +407,7 @@ GEM parser (3.3.0.5) ast (~> 2.4.1) racc - pg (1.5.4) + pg (1.5.5) popper_js (2.11.8) progress (3.6.0) psych (5.1.2) @@ -416,7 +417,7 @@ GEM nio4r (~> 2.0) quad_tile (1.0.1) racc (1.7.3) - rack (2.2.8) + rack (2.2.8.1) rack-cors (2.0.1) rack (>= 2.0.0) rack-openid (1.4.2) @@ -433,20 +434,20 @@ GEM rackup (1.0.0) rack (< 3) webrick - rails (7.1.3) - actioncable (= 7.1.3) - actionmailbox (= 7.1.3) - actionmailer (= 7.1.3) - actionpack (= 7.1.3) - actiontext (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activemodel (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.1.3) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -461,9 +462,9 @@ GEM rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -479,7 +480,7 @@ GEM regexp_parser (2.9.0) reline (0.4.2) io-console (~> 0.5) - request_store (1.5.1) + request_store (1.6.0) rack (>= 1.4) rexml (3.2.6) rinku (2.0.6) @@ -530,7 +531,7 @@ GEM google-protobuf (~> 3.23) rake (>= 13.0.0) secure_headers (6.5.0) - selenium-webdriver (4.17.0) + selenium-webdriver (4.18.1) base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) @@ -574,7 +575,7 @@ GEM i18n vendorer (0.2.0) version_gem (1.1.3) - webmock (3.19.1) + webmock (3.21.2) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/app/assets/stylesheets/browse.scss b/app/assets/stylesheets/browse.scss index 7c6f4b365..fe398bc5a 100644 --- a/app/assets/stylesheets/browse.scss +++ b/app/assets/stylesheets/browse.scss @@ -14,10 +14,6 @@ margin-left: 25px; } - /* Deleted objects */ - - .deleted { text-decoration: line-through; } - /* Nodes (and ways as areas) */ .aeroway.aerodrome::before { content: image-url('browse/aerodrome.p.16.png'); } diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 18eab1316..1f7c45db5 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -822,14 +822,11 @@ tr.turn:hover { height: 400px; display: none; } - .comments { - max-width: 740px; + .diary-comment .col-auto { + width: 62px; } - .diary-comment { - border-top: 1px dashed $grey; - &:first-child { - border-top: 1px solid $grey; - } + .diary-comment .col { + max-width: 690px; } } diff --git a/app/controllers/api/traces_controller.rb b/app/controllers/api/traces_controller.rb index b66aead38..956bcde6e 100644 --- a/app/controllers/api/traces_controller.rb +++ b/app/controllers/api/traces_controller.rb @@ -35,7 +35,7 @@ module Api trace = do_create(params[:file], tags, description, visibility) if trace.id - TraceImporterJob.perform_later(trace) + trace.schedule_import render :plain => trace.id.to_s elsif trace.valid? head :internal_server_error @@ -66,7 +66,7 @@ module Api if trace.user == current_user trace.visible = false trace.save! - TraceDestroyerJob.perform_later(trace) + trace.schedule_destruction head :ok else diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 1f9574b9c..1a3d648f4 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -157,21 +157,25 @@ class DiaryEntriesController < ApplicationController end def subscribe - diary_entry = DiaryEntry.find(params[:id]) + @diary_entry = DiaryEntry.find(params[:id]) - diary_entry.subscriptions.create(:user => current_user) unless diary_entry.subscribers.exists?(current_user.id) + if request.post? + @diary_entry.subscriptions.create(:user => current_user) unless @diary_entry.subscribers.exists?(current_user.id) - redirect_to diary_entry_path(diary_entry.user, diary_entry) + redirect_to diary_entry_path(@diary_entry.user, @diary_entry) + end rescue ActiveRecord::RecordNotFound render :action => "no_such_entry", :status => :not_found end def unsubscribe - diary_entry = DiaryEntry.find(params[:id]) + @diary_entry = DiaryEntry.find(params[:id]) - diary_entry.subscriptions.where(:user => current_user).delete_all if diary_entry.subscribers.exists?(current_user.id) + if request.post? + @diary_entry.subscriptions.where(:user => current_user).delete_all if @diary_entry.subscribers.exists?(current_user.id) - redirect_to diary_entry_path(diary_entry.user, diary_entry) + redirect_to diary_entry_path(@diary_entry.user, @diary_entry) + end rescue ActiveRecord::RecordNotFound render :action => "no_such_entry", :status => :not_found end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ba2858ce4..3c2084a5b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -20,7 +20,7 @@ class SessionsController < ApplicationController def create session[:remember_me] ||= params[:remember_me] session[:referer] = safe_referer(params[:referer]) if params[:referer] - password_authentication(params[:username], params[:password]) + password_authentication(params[:username].strip, params[:password]) end def destroy diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index 242f8113c..df6337147 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -126,7 +126,7 @@ class TracesController < ApplicationController flash[:notice] = t ".trace_uploaded" flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4 - TraceImporterJob.perform_later(@trace) + @trace.schedule_import redirect_to :action => :index, :display_name => current_user.display_name else flash[:error] = t(".upload_failed") if @trace.valid? @@ -176,7 +176,7 @@ class TracesController < ApplicationController trace.visible = false trace.save flash[:notice] = t ".scheduled_for_deletion" - TraceDestroyerJob.perform_later(trace) + trace.schedule_destruction redirect_to :action => :index, :display_name => trace.user.display_name end rescue ActiveRecord::RecordNotFound diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 0f533770b..7aa6e4754 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,12 +1,25 @@ module BrowseHelper - def printable_name(object, version: false) + def element_single_current_link(type, object, url) + link_to url, { :class => element_class(type, object), :title => element_title(object), :rel => (link_follow(object) if type == "node") } do + element_strikethrough object do + printable_element_name object + end + end + end + + def element_list_item(type, object, &block) + tag.li :class => element_class(type, object), :title => element_title(object) do + element_strikethrough object, &block + end + end + + def printable_element_name(object) id = if object.id.is_a?(Array) object.id[0] else object.id end - name = t "printable_name.with_id", :id => id.to_s - name = t "printable_name.with_version", :id => name, :version => object.version.to_s if version + name = id.to_s # don't look at object tags if redacted, so as to avoid giving # away redacted version tag information. @@ -27,20 +40,25 @@ module BrowseHelper name end - def link_class(type, object) - classes = [type] + def printable_element_version(object) + t "printable_name.version", :version => object.version + end - if object.redacted? - classes << "deleted" + def element_strikethrough(object, &block) + if object.redacted? || !object.visible? + tag.s(&block) else - classes += icon_tags(object).flatten.map { |t| h(t) } - classes << "deleted" unless object.visible? + yield end + end + def element_class(type, object) + classes = [type] + classes += icon_tags(object).flatten.map { |t| h(t) } unless object.redacted? classes.join(" ") end - def link_title(object) + def element_title(object) if object.redacted? "" else diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index d1ad60b2c..0894b972d 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -97,6 +97,7 @@ class UserMailer < ApplicationMailer @readurl = diary_entry_url(comment.diary_entry.user, comment.diary_entry, :anchor => "comment#{comment.id}") @commenturl = diary_entry_url(comment.diary_entry.user, comment.diary_entry, :anchor => "newcomment") @replyurl = new_message_url(comment.user, :message => { :title => "Re: #{comment.diary_entry.title}" }) + @unsubscribeurl = diary_entry_unsubscribe_url(comment.diary_entry.user, comment.diary_entry) @author = @from_user attach_user_avatar(comment.user) diff --git a/app/models/trace.rb b/app/models/trace.rb index 2411fb9b7..1e8f25a83 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -267,6 +267,14 @@ class Trace < ApplicationRecord end end + def schedule_import + TraceImporterJob.new(self).enqueue(:priority => user.traces.where(:inserted => false).count) + end + + def schedule_destruction + TraceDestroyerJob.perform_later(self) + end + private def content_type(file) diff --git a/app/views/browse/_containing_relation.html.erb b/app/views/browse/_containing_relation.html.erb index 06220a97d..2547ff7aa 100644 --- a/app/views/browse/_containing_relation.html.erb +++ b/app/views/browse/_containing_relation.html.erb @@ -1,4 +1,4 @@ -
  • <%= linked_name = link_to printable_name(containing_relation.relation), :action => "relation", :id => containing_relation.relation.id.to_s +
  • <%= linked_name = link_to printable_element_name(containing_relation.relation), :action => "relation", :id => containing_relation.relation.id.to_s if containing_relation.member_role.blank? t ".entry_html", :relation_name => linked_name else diff --git a/app/views/browse/_node.html.erb b/app/views/browse/_node.html.erb index cc8597292..6c6c1fdf3 100644 --- a/app/views/browse/_node.html.erb +++ b/app/views/browse/_node.html.erb @@ -17,7 +17,7 @@ <%= t "browse.part_of_ways", :count => node.ways.uniq.count %> diff --git a/app/views/browse/_relation_member.html.erb b/app/views/browse/_relation_member.html.erb index 5e52c04e8..16842f569 100644 --- a/app/views/browse/_relation_member.html.erb +++ b/app/views/browse/_relation_member.html.erb @@ -1,10 +1,9 @@ -<% member_class = link_class(relation_member.member_type.downcase, relation_member.member) - linked_name = link_to printable_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :title => link_title(relation_member.member), :rel => link_follow(relation_member.member) } +<% linked_name = link_to printable_element_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :rel => link_follow(relation_member.member) } type_str = t ".type.#{relation_member.member_type.downcase}" %> -
  • +<%= element_list_item relation_member.member_type.downcase, relation_member.member do %> <%= if relation_member.member_role.blank? t ".entry_html", :type => type_str, :name => linked_name else t ".entry_role_html", :type => type_str, :name => linked_name, :role => relation_member.member_role end %> -
  • +<% end %> diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index 26403f3fd..7197298ac 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -27,10 +27,12 @@