From: Andy Allan Date: Wed, 27 Sep 2023 14:33:58 +0000 (+0100) Subject: Merge pull request #4249 from AntonKhorev/no-traces-nav-empty-li X-Git-Tag: live~552 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/a569343e0158ccb23e9329b9a2c856da6beb729b?hp=ed99c62874c049fcf502173e3c1d02888e8d2d85 Merge pull request #4249 from AntonKhorev/no-traces-nav-empty-li Change traces feed and upload button alignment --- diff --git a/.rubocop.yml b/.rubocop.yml index f8060f948..dc2a33a35 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,11 +17,6 @@ AllCops: Rails: Enabled: true -# Config can be removed after https://github.com/rubocop/rubocop-factory_bot/issues/53 -FactoryBot/AssociationStyle: - Include: - - 'test/factories/**/*' - Layout/ExtraSpacing: AllowForAlignment: true diff --git a/Gemfile.lock b/Gemfile.lock index 5f36ab055..d224d95ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,8 +86,8 @@ GEM autoprefixer-rails (10.4.15.0) execjs (~> 2) aws-eventstream (1.2.0) - aws-partitions (1.820.0) - aws-sdk-core (3.181.0) + aws-partitions (1.828.0) + aws-sdk-core (3.183.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -95,7 +95,7 @@ GEM aws-sdk-kms (1.71.0) aws-sdk-core (~> 3, >= 3.177.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.134.0) + aws-sdk-s3 (1.135.0) aws-sdk-core (~> 3, >= 3.181.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.6) @@ -121,9 +121,9 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 2.9.3, < 3) sassc-rails (>= 2.0.0) - bootstrap_form (5.2.3) - actionpack (>= 6.0) - activemodel (>= 6.0) + bootstrap_form (5.3.2) + actionpack (>= 6.1) + activemodel (>= 6.1) brakeman (6.0.1) brotli (0.4.0) browser (5.3.1) @@ -152,7 +152,7 @@ GEM crack (0.4.5) rexml crass (1.0.6) - dalli (3.2.5) + dalli (3.2.6) date (3.3.3) debug_inspector (1.1.0) deep_merge (1.2.2) @@ -206,7 +206,7 @@ GEM rubocop smart_properties erubi (1.12.0) - execjs (2.9.0) + execjs (2.9.1) exifr (1.4.0) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -218,11 +218,11 @@ GEM faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.2) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake - ffi-libarchive (1.1.3) + ffi-libarchive (1.1.13) ffi (~> 1.0) frozen_record (0.27.0) activemodel @@ -313,7 +313,7 @@ GEM net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.5.9) nokogiri (1.15.4) @@ -450,16 +450,16 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) - rubocop-factory_bot (2.23.1) + rubocop-factory_bot (2.24.0) rubocop (~> 1.33) - rubocop-minitest (0.31.1) + rubocop-minitest (0.32.1) rubocop (>= 1.39, < 2.0) - rubocop-performance (1.19.0) + rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.21.0) + rubocop-rails (2.21.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -471,7 +471,7 @@ GEM ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (2.3.2) - sanitize (6.0.2) + sanitize (6.1.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) sassc (2.4.0) @@ -483,7 +483,7 @@ GEM sprockets-rails tilt secure_headers (6.5.0) - selenium-webdriver (4.12.0) + selenium-webdriver (4.13.1) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -508,14 +508,14 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - strong_migrations (1.6.1) + strong_migrations (1.6.3) activerecord (>= 5.2) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) terser (1.1.18) execjs (>= 0.3.0, < 3) thor (1.2.2) - tilt (2.2.0) + tilt (2.3.0) timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -528,13 +528,13 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS ruby diff --git a/Vendorfile b/Vendorfile index 680ed2225..4c6a80839 100644 --- a/Vendorfile +++ b/Vendorfile @@ -15,7 +15,7 @@ folder 'vendor/assets' do folder 'img', 'src/img' end - from 'https://github.com/jfirebaugh/leaflet-osm.git' do + from 'https://github.com/openstreetmap/leaflet-osm.git' do file 'leaflet.osm.js', 'leaflet-osm.js' end diff --git a/app/abilities/api_ability.rb b/app/abilities/api_ability.rb index 9b274ec84..fe39f5eb5 100644 --- a/app/abilities/api_ability.rb +++ b/app/abilities/api_ability.rb @@ -21,6 +21,7 @@ class ApiAbility can [:history, :version], OldNode can [:history, :version], OldWay can [:history, :version], OldRelation + can [:show], UserBlock end if user&.active? diff --git a/app/assets/images/banners/StateoftheMapEurope_2023.png b/app/assets/images/banners/StateoftheMapEurope_2023.png new file mode 100644 index 000000000..33e9db907 Binary files /dev/null and b/app/assets/images/banners/StateoftheMapEurope_2023.png differ diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 7bd0891a3..c86c8ad02 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -268,7 +268,8 @@ OSM.Directions = function (map) { I18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + "."); } - var turnByTurnTable = $(""); + var turnByTurnTable = $("
") + .append($("")); var directionsCloseButton = $(""); - row.append(" "); - row.append(" "); + row.append("
" + instruction); + row.append("
" + instruction); row.append("" + dist); row.on("click", function () { diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index 6e61100f2..e1e0e64fd 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -51,6 +51,13 @@ L.OSM.Map = L.Map.extend({ }).prop("outerHTML"); var thunderforest = I18n.t("javascripts.map.thunderforest_credit", { thunderforest_link: thunderforest_link }); + var tracestrack_link = $("", { + href: "https://www.tracestrack.com/", + target: "_blank", + text: I18n.t("javascripts.map.tracestrack") + }).prop("outerHTML"); + var tracestrack = I18n.t("javascripts.map.tracestrack_credit", { tracestrack_link: tracestrack_link }); + var memomaps_link = $("", { href: "https://memomaps.de/", target: "_blank", @@ -99,6 +106,16 @@ L.OSM.Map = L.Map.extend({ })); } + if (OSM.TRACESTRACK_KEY) { + this.baseLayers.push(new L.OSM.TracestrackTopo({ + attribution: copyright + ". " + tracestrack + ". " + terms, + apikey: OSM.TRACESTRACK_KEY, + code: "P", + keyid: "tracestracktopo", + name: I18n.t("javascripts.map.base.tracestracktop_topo") + })); + } + this.baseLayers.push(new L.OSM.OPNVKarte({ attribution: copyright + ". " + memomaps + ". " + terms, code: "O", diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 0ffd35e2c..0a0f5c67a 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -25,6 +25,10 @@ OSM = { THUNDERFOREST_KEY: <%= Settings.thunderforest_key.to_json %>, <% end %> +<% if Settings.key?(:tracestrack_key) %> + TRACESTRACK_KEY: <%= Settings.tracestrack_key.to_json %>, +<% end %> + MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, MARKER_RED: <%= image_path("marker-red.png").to_json %>, diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 2cd357845..b95d1fcd6 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -23,7 +23,7 @@ small, aside { .small_icon { vertical-align: middle; - margin-right: $lineheight/4; + margin-right: $lineheight * 0.25; } [dir=rtl] { /* no-r2 */ text-align: right; } @@ -102,7 +102,7 @@ header { > * { height: 100%; - padding: $lineheight/2; + padding: $lineheight * 0.5; } h1, nav.primary { @@ -698,11 +698,6 @@ div.direction { div.direction.i#{$i} { background-position: #{($i)*-20}px 0px; } } -td.instruction, td.distance { - padding-top: $lineheight/5; - padding-bottom: $lineheight/5; - border-bottom: 1px solid $grey; -} td.distance { color: $darkgrey; text-align: right; @@ -809,15 +804,6 @@ tr.turn:hover { } } - .note-comments li, .changeset-comments li { - margin: $lineheight/2 0; - - p { - margin: 10px 6px 0 6px; - line-height: 1.5; - } - } - .subscribe-buttons input { font-size: 90%; line-height: 15px; @@ -891,18 +877,6 @@ tr.turn:hover { } #minlat { margin-bottom: -1px; } } - - .export_bound { - margin: $lineheight/4; - } - - dl { - padding-left: $lineheight/2; - dd { - margin-left: 0; - margin-bottom: 10px; - } - } } /* Rules for edit pages */ @@ -1002,7 +976,7 @@ tr.turn:hover { /* Rules for the user map */ .content_map .leaflet-popup-content { - margin: $lineheight/2; + margin: $spacer; min-height: 50px; } @@ -1038,20 +1012,6 @@ tr.turn:hover { &:first-child { border-top: 1px solid $grey; } - p { - margin-bottom: $lineheight/2; - } - } -} - -/* Rules for the log in page */ - -#login_auth_buttons { - margin-bottom: 0; - - li { - float: left; - padding: $lineheight/4 $lineheight/2; } } @@ -1142,9 +1102,9 @@ nav.secondary-actions { flex-basis: auto; list-style: none; border-left: 1px solid $grey; - padding-left: $lineheight/2; - margin-right: $lineheight/2; - margin-bottom: $lineheight/8; + padding-left: $lineheight * 0.5; + margin-right: $lineheight * 0.5; + margin-bottom: $lineheight * 0.125; } } } diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 71fdf3978..a4afdf576 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -1,30 +1,58 @@ +html { + height: 100%; +} + +body { + height: 100%; + margin: 0; +} + +#content { + height: 100%; +} + header, -#sidebar, -#permalink, .leaflet-control { display: none; } -html { - height: 100%; +.map-layout .overlay-sidebar #sidebar { + display: none; +} + +.map-layout #sidebar { + page-break-after: always; + + & > * { + display: none; + } + #sidebar_content { + display: unset; + } + + button, + input, + textarea, + .secondary-actions { + display: none; + } +} + +#map-ui { + display: none !important; } #map { - position: absolute !important; - top: 0; - bottom: 40px; - left: 0; - right: 0; + position: relative; + height: calc(100% - 40px); + box-sizing: border-box; border: 1px solid black; } /* Rules for attribution text under the main map shown on printouts */ #attribution { - position: absolute !important; - bottom: 0; - left: 0; - right: 0; + page-break-inside: avoid; height: 40px; font-size: 12px; text-align: center; diff --git a/app/controllers/api/user_blocks_controller.rb b/app/controllers/api/user_blocks_controller.rb new file mode 100644 index 000000000..19fd4b400 --- /dev/null +++ b/app/controllers/api/user_blocks_controller.rb @@ -0,0 +1,18 @@ +module Api + class UserBlocksController < ApiController + before_action :check_api_readable + + authorize_resource + + around_action :api_call_handle_error, :api_call_timeout + before_action :set_request_formats + + def show + raise OSM::APIBadUserInput, "No id was given" unless params[:id] + + @user_block = UserBlock.find(params[:id]) + rescue ActiveRecord::RecordNotFound + raise OSM::APINotFoundError + end + end +end diff --git a/app/helpers/banner_helper.rb b/app/helpers/banner_helper.rb index 17c6eace3..9048d4840 100644 --- a/app/helpers/banner_helper.rb +++ b/app/helpers/banner_helper.rb @@ -1,13 +1,19 @@ module BannerHelper def active_banners BANNERS.reject do |_k, v| - enddate = v[:enddate] begin - parsed = enddate && Date.parse(enddate) + startdate = v[:startdate] && Date.parse(v[:startdate]) rescue StandardError - parsed = nil + startdate = nil end - !parsed.is_a?(Date) || (parsed.is_a?(Date) && parsed.past?) + + begin + enddate = v[:enddate] && Date.parse(v[:enddate]) + rescue StandardError + enddate = nil + end + + startdate&.future? || enddate&.past? end end diff --git a/app/views/api/user_blocks/_user_block.json.jbuilder b/app/views/api/user_blocks/_user_block.json.jbuilder new file mode 100644 index 000000000..3288dd6ad --- /dev/null +++ b/app/views/api/user_blocks/_user_block.json.jbuilder @@ -0,0 +1,13 @@ +json.user_block do + json.id user_block.id + json.created_at user_block.created_at.xmlschema + json.updated_at user_block.updated_at.xmlschema + json.ends_at user_block.ends_at.xmlschema + json.needs_view user_block.needs_view + + json.user :uid => user_block.user_id, :user => user_block.user.display_name + json.creator :uid => user_block.creator_id, :user => user_block.creator.display_name + json.revoker :uid => user_block.revoker_id, :user => user_block.revoker.display_name if user_block.revoker + + json.reason user_block.reason +end diff --git a/app/views/api/user_blocks/_user_block.xml.builder b/app/views/api/user_blocks/_user_block.xml.builder new file mode 100644 index 000000000..a41dc56d7 --- /dev/null +++ b/app/views/api/user_blocks/_user_block.xml.builder @@ -0,0 +1,14 @@ +attrs = { + "id" => user_block.id, + "created_at" => user_block.created_at.xmlschema, + "updated_at" => user_block.updated_at.xmlschema, + "ends_at" => user_block.ends_at.xmlschema, + "needs_view" => user_block.needs_view +} + +xml.user_block(attrs) do + xml.user :uid => user_block.user_id, :user => user_block.user.display_name + xml.creator :uid => user_block.creator_id, :user => user_block.creator.display_name + xml.revoker :uid => user_block.revoker_id, :user => user_block.revoker.display_name if user_block.revoker + xml.reason user_block.reason +end diff --git a/app/views/api/user_blocks/show.json.jbuilder b/app/views/api/user_blocks/show.json.jbuilder new file mode 100644 index 000000000..6cfc0ded5 --- /dev/null +++ b/app/views/api/user_blocks/show.json.jbuilder @@ -0,0 +1,3 @@ +json.partial! "api/root_attributes" + +json.partial! @user_block diff --git a/app/views/api/user_blocks/show.xml.builder b/app/views/api/user_blocks/show.xml.builder new file mode 100644 index 000000000..eff666ba7 --- /dev/null +++ b/app/views/api/user_blocks/show.xml.builder @@ -0,0 +1,5 @@ +xml.instruct! + +xml.osm(OSM::API.new.xml_root_attributes) do |osm| + osm << (render(@user_block) || "") +end diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb index b5c360a03..9acbd05ae 100644 --- a/app/views/browse/changeset.html.erb +++ b/app/views/browse/changeset.html.erb @@ -46,7 +46,9 @@ — <%= t("javascripts.changesets.show.hide_comment") %> <% end %> - <%= comment.body.to_html %> +
+ <%= comment.body.to_html %> +
<% elsif current_user and current_user.moderator? %>
  • @@ -57,7 +59,9 @@ :user => link_to(comment.author.display_name, user_path(comment.author))) %> — <%= t("javascripts.changesets.show.unhide_comment") %> - <%= comment.body.to_html %> +
    + <%= comment.body.to_html %> +
  • <% end %> <% end %> diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 2378d8c2e..3bb97b484 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -34,7 +34,9 @@ <% @note_comments.drop(1).each do |comment| %>
  • <%= note_event(comment.event, comment.created_at, comment.author) %> - <%= comment.body.to_html %> +
    + <%= comment.body.to_html %> +
  • <% end %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index dea65f768..03755730b 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -27,22 +27,12 @@
    -