From: Tom Hughes Date: Sun, 14 Jul 2024 14:56:20 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/4929' X-Git-Tag: live~375 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/26f6fdf82c93b0fd3198bb8929d5f20a4723bfe8?hp=51d2a846ece990db7c4109ecf923ad9201c6f8e6 Merge remote-tracking branch 'upstream/pull/4929' --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fdc7c35a5..6fe5b2e57 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -24,7 +24,7 @@ FactoryBot/ExcessiveCreateList: # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: - Max: 248 + Max: 266 # Offense count: 29 # This cop supports unsafe autocorrection (--autocorrect-all). diff --git a/Gemfile b/Gemfile index 5a21c7f7a..fcf2ceb4d 100644 --- a/Gemfile +++ b/Gemfile @@ -65,7 +65,7 @@ gem "rack-cors" gem "rails-i18n", "~> 7.0.0" gem "rails_param" gem "rinku", ">= 2.0.6", :require => "rails_rinku" -gem "strong_migrations" +gem "strong_migrations", "< 2.0.0" gem "validates_email_format_of", ">= 1.5.1" # Native OSM extensions diff --git a/Gemfile.lock b/Gemfile.lock index 21488bc99..284e97adc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,19 +95,19 @@ GEM autoprefixer-rails (10.4.16.0) execjs (~> 2) aws-eventstream (1.3.0) - aws-partitions (1.947.0) - aws-sdk-core (3.198.0) + aws-partitions (1.954.0) + aws-sdk-core (3.201.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.86.0) - aws-sdk-core (~> 3, >= 3.198.0) - aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.153.0) - aws-sdk-core (~> 3, >= 3.198.0) + aws-sdk-kms (1.88.0) + aws-sdk-core (~> 3, >= 3.201.0) + aws-sigv4 (~> 1.5) + aws-sdk-s3 (1.156.0) + aws-sdk-core (~> 3, >= 3.201.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.8) + aws-sigv4 (~> 1.5) aws-sigv4 (1.8.0) aws-eventstream (~> 1, >= 1.0.2) base64 (0.2.0) @@ -186,13 +186,13 @@ GEM doorkeeper (>= 5.5, < 5.8) jwt (>= 2.5) drb (2.2.1) - dry-configurable (1.1.0) + dry-configurable (1.2.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) dry-core (1.0.1) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) - dry-inflector (1.0.0) + dry-inflector (1.1.0) dry-initializer (3.1.1) dry-logic (1.5.0) concurrent-ruby (~> 1.0) @@ -234,8 +234,9 @@ GEM factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) - faraday (2.9.2) + faraday (2.10.0) faraday-net_http (>= 2.0, < 3.2) + logger faraday-net_http (3.1.0) net-http ffi (1.17.0) @@ -245,7 +246,7 @@ GEM ffi-libarchive (1.1.14) ffi (~> 1.0) file_exists (0.2.0) - frozen_record (0.27.1) + frozen_record (0.27.2) activemodel fspath (3.1.2) gd2-ffij (0.4.0) @@ -288,7 +289,7 @@ GEM image_size (3.4.0) in_threads (1.6.0) io-console (0.7.2) - irb (1.13.2) + irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.12.0) @@ -326,12 +327,12 @@ GEM marcel (1.0.4) matrix (0.4.2) maxminddb (0.1.22) - mini_magick (4.13.1) + mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.7) mini_racer (0.9.0) libv8-node (~> 18.19.0.0) - minitest (5.24.0) + minitest (5.24.1) minitest-focus (1.4.0) minitest (>= 4, < 6) msgpack (1.7.2) @@ -402,7 +403,7 @@ GEM omniauth (~> 2.0) openstreetmap-deadlock_retry (1.3.1) parallel (1.25.1) - parser (3.3.3.0) + parser (3.3.4.0) ast (~> 2.4.1) racc pg (1.5.6) @@ -490,13 +491,13 @@ GEM rouge (4.3.0) rtlcss (0.2.1) mini_racer (>= 0.6.3) - rubocop (1.64.1) + rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) @@ -513,7 +514,7 @@ GEM rubocop-performance (1.21.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.25.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -568,7 +569,7 @@ GEM terser (1.2.3) execjs (>= 0.3.0, < 3) thor (1.3.1) - tilt (2.3.0) + tilt (2.4.0) timeout (0.4.1) turbo-rails (2.0.5) actionpack (>= 6.0.0) @@ -588,7 +589,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.8.1) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -693,7 +694,7 @@ DEPENDENCIES simplecov simplecov-lcov sprockets-exporters_pack - strong_migrations + strong_migrations (< 2.0.0) terser turbo-rails unicode-display_width diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index c0b2f3982..a0eea302f 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -42,7 +42,8 @@ class Ability can [:new, :show, :create, :destroy], :oauth2_authorization can [:edit, :update, :destroy], :account can [:show], :dashboard - can [:new, :create, :edit, :update, :comment, :subscribe, :unsubscribe], DiaryEntry + can [:new, :create, :edit, :update, :subscribe, :unsubscribe], DiaryEntry + can [:create], DiaryComment can [:make_friend, :remove_friend], Friendship can [:new, :create, :reply, :show, :inbox, :outbox, :muted, :mark, :unmute, :destroy], Message can [:close, :reopen], Note diff --git a/app/assets/images/banners/StateoftheMapEurope_2024.png b/app/assets/images/banners/StateoftheMapEurope_2024.png index d0d1cee62..2f35f7b98 100644 Binary files a/app/assets/images/banners/StateoftheMapEurope_2024.png and b/app/assets/images/banners/StateoftheMapEurope_2024.png differ diff --git a/app/assets/images/closed_note_marker.svg b/app/assets/images/closed_note_marker.svg index d16b5707e..84e1048a4 100644 --- a/app/assets/images/closed_note_marker.svg +++ b/app/assets/images/closed_note_marker.svg @@ -9,32 +9,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/assets/images/confirm-illustration.png b/app/assets/images/confirm-illustration.png deleted file mode 100644 index 08a954a45..000000000 Binary files a/app/assets/images/confirm-illustration.png and /dev/null differ diff --git a/app/assets/images/confirm-illustration.svg b/app/assets/images/confirm-illustration.svg index 9bb5715b8..999ac6c16 100644 --- a/app/assets/images/confirm-illustration.svg +++ b/app/assets/images/confirm-illustration.svg @@ -1,1255 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010000011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - + diff --git a/app/assets/images/new.png b/app/assets/images/new.png deleted file mode 100644 index 4a9fa8b36..000000000 Binary files a/app/assets/images/new.png and /dev/null differ diff --git a/app/assets/images/new.svg b/app/assets/images/new.svg deleted file mode 100644 index ef65650f7..000000000 --- a/app/assets/images/new.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/app/assets/images/new_note_marker.svg b/app/assets/images/new_note_marker.svg index efa538b72..c84444b5b 100644 --- a/app/assets/images/new_note_marker.svg +++ b/app/assets/images/new_note_marker.svg @@ -1,12 +1,4 @@ - - - - - - - - diff --git a/app/assets/images/open_note_marker.svg b/app/assets/images/open_note_marker.svg index 8dc07b71a..a1b4381c6 100644 --- a/app/assets/images/open_note_marker.svg +++ b/app/assets/images/open_note_marker.svg @@ -9,32 +9,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/assets/images/sign-up-illustration.png b/app/assets/images/sign-up-illustration.png deleted file mode 100644 index e785ec602..000000000 Binary files a/app/assets/images/sign-up-illustration.png and /dev/null differ diff --git a/app/assets/images/sign-up-illustration.svg b/app/assets/images/sign-up-illustration.svg index 7f3a3338f..ffa41b9f7 100644 --- a/app/assets/images/sign-up-illustration.svg +++ b/app/assets/images/sign-up-illustration.svg @@ -1,1359 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010000011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - + diff --git a/app/assets/images/terms-illustration.png b/app/assets/images/terms-illustration.png deleted file mode 100644 index 7c32f4f30..000000000 Binary files a/app/assets/images/terms-illustration.png and /dev/null differ diff --git a/app/assets/images/terms-illustration.svg b/app/assets/images/terms-illustration.svg index 2bb1aaf99..762c44b6b 100644 --- a/app/assets/images/terms-illustration.svg +++ b/app/assets/images/terms-illustration.svg @@ -1,1620 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010000011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - 101010101010100011100010101010011010101010101001010110010111010101011010000101010000110001101010110010101101101010111010101011 - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/assets/javascripts/auth_providers.js b/app/assets/javascripts/auth_providers.js index 975c57a9b..38a7287a0 100644 --- a/app/assets/javascripts/auth_providers.js +++ b/app/assets/javascripts/auth_providers.js @@ -9,15 +9,12 @@ $(document).ready(function () { }); // Add click handler to show OpenID field - $("#openid_open_url").click(function (e) { - e.preventDefault(); + $("#openid_open_url").click(function () { $("#openid_url").val("http://"); - $("#login_auth_buttons").hide().removeClass("d-flex"); - $("#login_openid_url").show(); - $("#openid_login_button").show(); + $("#login_auth_buttons").hide(); + $("#openid_login_form").show(); }); // Hide OpenID field for now - $("#login_openid_url").hide(); - $("#openid_login_button").hide(); + $("#openid_login_form").hide(); }); diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index 4ebb89da9..9a0ec07d3 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -5,13 +5,13 @@ //= require i18n //= require i18n/embed -window.onload = function () { - if (navigator.languages) { - I18n.locale = navigator.languages[0]; - } else if (navigator.language) { - I18n.locale = navigator.language; - } +if (navigator.languages) { + I18n.locale = navigator.languages[0]; +} else if (navigator.language) { + I18n.locale = navigator.language; +} +window.onload = function () { var query = (window.location.search || '?').slice(1), args = {}; diff --git a/app/assets/javascripts/index/contextmenu.js b/app/assets/javascripts/index/contextmenu.js index cac5e6fbf..ffc0eadb7 100644 --- a/app/assets/javascripts/index/contextmenu.js +++ b/app/assets/javascripts/index/contextmenu.js @@ -51,7 +51,7 @@ OSM.initializeContextMenu = function (map) { lat = latlng.lat.toFixed(precision), lng = latlng.lng.toFixed(precision); - OSM.router.route("/search?whereami=1&query=" + encodeURIComponent(lat + "," + lng)); + OSM.router.route("/search?lat=" + encodeURIComponent(lat) + "&lon=" + encodeURIComponent(lng)); } }); diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 94bb52a1b..2f3882e3a 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -33,10 +33,11 @@ OSM.Search = function (map) { $(".describe_location").on("click", function (e) { e.preventDefault(); var center = map.getCenter().wrap(), - precision = OSM.zoomPrecision(map.getZoom()); - OSM.router.route("/search?whereami=1&query=" + encodeURIComponent( - center.lat.toFixed(precision) + "," + center.lng.toFixed(precision) - )); + precision = OSM.zoomPrecision(map.getZoom()), + lat = center.lat.toFixed(precision), + lng = center.lng.toFixed(precision); + + OSM.router.route("/search?lat=" + encodeURIComponent(lat) + "&lon=" + encodeURIComponent(lng)); }); $("#sidebar_content") diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 0b868d2ca..b92d70796 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -8,6 +8,7 @@ L.OSM.share = function (options) { control.onAddPane = function (map, button, $ui) { // Link / Embed + $("#content").addClass("overlay-right-sidebar"); var $linkSection = $("
") .attr("class", "share-link p-3 border-bottom border-secondary-subtle") diff --git a/app/assets/javascripts/leaflet.sidebar.js b/app/assets/javascripts/leaflet.sidebar.js index 7e72278e3..9573c839d 100644 --- a/app/assets/javascripts/leaflet.sidebar.js +++ b/app/assets/javascripts/leaflet.sidebar.js @@ -31,9 +31,11 @@ L.OSM.sidebar = function (selector) { map.panBy([-paneWidth, 0], { animate: false }); } $(sidebar).hide(); + $("#content").addClass("overlay-right-sidebar"); current = currentButton = $(); } else { $(sidebar).show(); + $("#content").removeClass("overlay-right-sidebar"); current = pane; currentButton = button || $(); if ($("html").attr("dir") === "rtl") { diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 4cc31d611..a1734682e 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -395,7 +395,7 @@ body.small-nav { overflow-y: scroll; } - .overlay-sidebar { + .overlay-sidebar.overlay-right-sidebar { #sidebar { position: absolute; width: 350px; @@ -403,7 +403,7 @@ body.small-nav { overflow: hidden; } - #map, #map-ui { + #map { height: 100%; } } @@ -677,10 +677,16 @@ tr.turn { padding: $lineheight; } -/* Overrides for pages that use new layout conventions */ +/* Rules for login and signup pages */ + +.sessions-new, .users-new, .users-create { + #content .content-inner { + max-width: 760px; + } +} .header-illustration { - background-position: 0 0; + background-position: right; background-repeat: no-repeat; position: relative; min-height: 200px; @@ -689,16 +695,16 @@ tr.turn { bottom: 0; &.new-user-main { - background-image: image-url("sign-up-illustration.png"); - background-position-x: 50px; + background-image: image-url("sign-up-illustration.svg"); + background-position-x: 70px; } &.confirm-main { - background-image: image-url("confirm-illustration.png"); + background-image: image-url("confirm-illustration.svg"); } &.new-user-terms { - background-image: image-url("terms-illustration.png"); + background-image: image-url("terms-illustration.svg"); } } @@ -895,10 +901,6 @@ div.secondary-actions { } } -.auth-container { - max-width: 600px; -} - /* Rules for tabs inside secondary background sections */ .bg-body-secondary .nav-tabs { diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index ff7f694c5..ae1bc8755 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -112,6 +112,7 @@ class ApiController < ApplicationController # self.current_user setup by OAuth else report_error t("application.oauth_10a_disabled", :link => t("application.auth_disabled_link")), :forbidden + self.current_user = nil end else username, passwd = auth_data # parse from headers diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 05fa76658..c6223fb9d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base # TODO: some sort of escaping of problem characters in the message response.headers["Error"] = message - if request.headers["X-Error-Format"]&.casecmp("xml")&.zero? + if request.headers["X-Error-Format"]&.casecmp?("xml") result = OSM::API.new.xml_doc result.root.name = "osmError" result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}") diff --git a/app/controllers/changeset_comments_controller.rb b/app/controllers/changeset_comments_controller.rb index 0b5f6059a..637ac7be6 100644 --- a/app/controllers/changeset_comments_controller.rb +++ b/app/controllers/changeset_comments_controller.rb @@ -18,7 +18,7 @@ class ChangesetCommentsController < ApplicationController changeset = Changeset.find(id) # Return comments for this changeset only - @comments = changeset.comments.includes(:author, :changeset).limit(comments_limit) + @comments = changeset.comments.includes(:author, :changeset).reverse_order.limit(comments_limit) else # Return comments @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC").limit(comments_limit).preload(:changeset) diff --git a/app/controllers/diary_comments_controller.rb b/app/controllers/diary_comments_controller.rb index 8abf2071b..a9a7a2641 100644 --- a/app/controllers/diary_comments_controller.rb +++ b/app/controllers/diary_comments_controller.rb @@ -11,7 +11,7 @@ class DiaryCommentsController < ApplicationController authorize_resource before_action :lookup_user, :only => :index - before_action :check_database_writable, :only => [:hide, :unhide] + before_action :check_database_writable, :only => [:create, :hide, :unhide] allow_thirdparty_images :only => :index @@ -26,6 +26,29 @@ class DiaryCommentsController < ApplicationController @comments, @newer_comments_id, @older_comments_id = get_page_items(comments, :includes => [:user]) end + def create + @entry = DiaryEntry.find(params[:id]) + @comments = @entry.visible_comments + @diary_comment = @entry.comments.build(comment_params) + @diary_comment.user = current_user + if @diary_comment.save + + # Notify current subscribers of the new comment + @entry.subscribers.visible.each do |user| + UserMailer.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user + end + + # Add the commenter to the subscribers if necessary + @entry.subscriptions.create(:user => current_user) unless @entry.subscribers.exists?(current_user.id) + + redirect_to diary_entry_path(@entry.user, @entry) + else + render :action => "new" + end + rescue ActiveRecord::RecordNotFound + render "diary_entries/no_such_entry", :status => :not_found + end + def hide comment = DiaryComment.find(params[:comment]) comment.update(:visible => false) @@ -37,4 +60,12 @@ class DiaryCommentsController < ApplicationController comment.update(:visible => true) redirect_to diary_entry_path(comment.diary_entry.user, comment.diary_entry) end + + private + + ## + # return permitted diary comment parameters + def comment_params + params.require(:diary_comment).permit(:body) + end end diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index bf6e8d0b1..1a888547d 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -11,7 +11,7 @@ class DiaryEntriesController < ApplicationController authorize_resource before_action :lookup_user, :only => :show - before_action :check_database_writable, :only => [:new, :create, :edit, :update, :comment, :hide, :unhide, :subscribe, :unsubscribe] + before_action :check_database_writable, :only => [:new, :create, :edit, :update, :hide, :unhide, :subscribe, :unsubscribe] allow_thirdparty_images :only => [:new, :create, :edit, :update, :index, :show] @@ -136,29 +136,6 @@ class DiaryEntriesController < ApplicationController render :action => "no_such_entry", :status => :not_found end - def comment - @entry = DiaryEntry.find(params[:id]) - @comments = @entry.visible_comments - @diary_comment = @entry.comments.build(comment_params) - @diary_comment.user = current_user - if @diary_comment.save - - # Notify current subscribers of the new comment - @entry.subscribers.visible.each do |user| - UserMailer.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user - end - - # Add the commenter to the subscribers if necessary - @entry.subscriptions.create(:user => current_user) unless @entry.subscribers.exists?(current_user.id) - - redirect_to diary_entry_path(@entry.user, @entry) - else - render :action => "show" - end - rescue ActiveRecord::RecordNotFound - render :action => "no_such_entry", :status => :not_found - end - def subscribe @diary_entry = DiaryEntry.find(params[:id]) @@ -239,12 +216,6 @@ class DiaryEntriesController < ApplicationController ActionController::Parameters.new.permit(:title, :body, :language_code, :latitude, :longitude) end - ## - # return permitted diary comment parameters - def comment_params - params.require(:diary_comment).permit(:body) - end - ## # decide on a location for the diary entry map def set_map_location diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 4a593f86a..43f276efa 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -35,15 +35,15 @@ class GeocoderController < ApplicationController @results = [] if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180 - @results.push(:lat => lat, :lon => lon, + @results.push(:lat => params[:lat], :lon => params[:lon], :zoom => params[:zoom], - :name => "#{lat}, #{lon}") + :name => "#{params[:lat]}, #{params[:lon]}") end if lon >= -90 && lon <= 90 && lat >= -180 && lat <= 180 - @results.push(:lat => lon, :lon => lat, + @results.push(:lat => params[:lon], :lon => params[:lat], :zoom => params[:zoom], - :name => "#{lon}, #{lat}") + :name => "#{params[:lon]}, #{params[:lat]}") end if @results.empty? @@ -61,9 +61,9 @@ class GeocoderController < ApplicationController @error = "Longitude #{lon} out of range" render :action => "error" else - @results = [{ :lat => lat, :lon => lon, + @results = [{ :lat => params[:lat], :lon => params[:lon], :zoom => params[:zoom], - :name => "#{lat}, #{lon}" }] + :name => "#{params[:lat]}, #{params[:lon]}" }] render :action => "results" end @@ -206,61 +206,42 @@ class GeocoderController < ApplicationController if query = params[:query] query.strip! - if latlon = query.match(/^([NS])\s*(\d{1,3}(\.\d*)?)\W*([EW])\s*(\d{1,3}(\.\d*)?)$/).try(:captures) || # [NSEW] decimal degrees - query.match(/^(\d{1,3}(\.\d*)?)\s*([NS])\W*(\d{1,3}(\.\d*)?)\s*([EW])$/).try(:captures) # decimal degrees [NSEW] - params.merge!(nsew_to_decdeg(latlon)).delete(:query) + if latlon = query.match(/^(?[NS])\s*#{dms_regexp('ns')}\W*(?[EW])\s*#{dms_regexp('ew')}$/) || + query.match(/^#{dms_regexp('ns')}\s*(?[NS])\W*#{dms_regexp('ew')}\s*(?[EW])$/) + params.merge!(to_decdeg(latlon.named_captures.compact)).delete(:query) - elsif latlon = query.match(/^([NS])\s*(\d{1,3})°?(?:\s*(\d{1,3}(\.\d*)?)?['′]?)?\W*([EW])\s*(\d{1,3})°?(?:\s*(\d{1,3}(\.\d*)?)?['′]?)?$/).try(:captures) || # [NSEW] degrees, decimal minutes - query.match(/^(\d{1,3})°?(?:\s*(\d{1,3}(\.\d*)?)?['′]?)?\s*([NS])\W*(\d{1,3})°?(?:\s*(\d{1,3}(\.\d*)?)?['′]?)?\s*([EW])$/).try(:captures) # degrees, decimal minutes [NSEW] - params.merge!(ddm_to_decdeg(latlon)).delete(:query) + elsif latlon = query.match(%r{^(?[+-]?\d+(?:\.\d+)?)(?:\s+|\s*[,/]\s*)(?[+-]?\d+(?:\.\d+)?)$}) + params.merge!(:lat => latlon["lat"], :lon => latlon["lon"]).delete(:query) - elsif latlon = query.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?$/).try(:captures) || # [NSEW] degrees, minutes, decimal seconds - query.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?(?:\s*(\d{1,3}(\.\d*)?)?["″]?)?\s*([EW])$/).try(:captures) # degrees, minutes, decimal seconds [NSEW] - params.merge!(dms_to_decdeg(latlon)).delete(:query) - - elsif latlon = query.match(/^([+-]?\d+(\.\d*)?)(?:\s+|\s*,\s*)([+-]?\d+(\.\d*)?)$/) - params.merge!(:lat => latlon[1].to_f, :lon => latlon[3].to_f).delete(:query) - - params[:latlon_digits] = true unless params[:whereami] + params[:latlon_digits] = true end end params.permit(:query, :lat, :lon, :latlon_digits, :zoom, :minlat, :minlon, :maxlat, :maxlon) end - def nsew_to_decdeg(captures) - begin - Float(captures[0]) - lat = captures[2].casecmp("s").zero? ? -captures[0].to_f : captures[0].to_f - lon = captures[5].casecmp("w").zero? ? -captures[3].to_f : captures[3].to_f - rescue StandardError - lat = captures[0].casecmp("s").zero? ? -captures[1].to_f : captures[1].to_f - lon = captures[3].casecmp("w").zero? ? -captures[4].to_f : captures[4].to_f - end - { :lat => lat, :lon => lon } + def dms_regexp(name_prefix) + / + (?: (?<#{name_prefix}d>\d{1,3}(?:\.\d+)?)°? ) | + (?: (?<#{name_prefix}d>\d{1,3})°?\s*(?<#{name_prefix}m>\d{1,2}(?:\.\d+)?)['′]? ) | + (?: (?<#{name_prefix}d>\d{1,3})°?\s*(?<#{name_prefix}m>\d{1,2})['′]?\s*(?<#{name_prefix}s>\d{1,2}(?:\.\d+)?)["″]? ) + /x end - def ddm_to_decdeg(captures) - begin - Float(captures[0]) - lat = captures[3].casecmp("s").zero? ? -(captures[0].to_f + (captures[1].to_f / 60)) : captures[0].to_f + (captures[1].to_f / 60) - lon = captures[7].casecmp("w").zero? ? -(captures[4].to_f + (captures[5].to_f / 60)) : captures[4].to_f + (captures[5].to_f / 60) - rescue StandardError - lat = captures[0].casecmp("s").zero? ? -(captures[1].to_f + (captures[2].to_f / 60)) : captures[1].to_f + (captures[2].to_f / 60) - lon = captures[4].casecmp("w").zero? ? -(captures[5].to_f + (captures[6].to_f / 60)) : captures[5].to_f + (captures[6].to_f / 60) - end - { :lat => lat, :lon => lon } - end + def to_decdeg(captures) + ns = captures.fetch("ns").casecmp?("s") ? -1 : 1 + nsd = BigDecimal(captures.fetch("nsd", "0")) + nsm = BigDecimal(captures.fetch("nsm", "0")) + nss = BigDecimal(captures.fetch("nss", "0")) - def dms_to_decdeg(captures) - begin - Float(captures[0]) - lat = captures[4].casecmp("s").zero? ? -(captures[0].to_f + ((captures[1].to_f + (captures[2].to_f / 60)) / 60)) : captures[0].to_f + ((captures[1].to_f + (captures[2].to_f / 60)) / 60) - lon = captures[9].casecmp("w").zero? ? -(captures[5].to_f + ((captures[6].to_f + (captures[7].to_f / 60)) / 60)) : captures[5].to_f + ((captures[6].to_f + (captures[7].to_f / 60)) / 60) - rescue StandardError - lat = captures[0].casecmp("s").zero? ? -(captures[1].to_f + ((captures[2].to_f + (captures[3].to_f / 60)) / 60)) : captures[1].to_f + ((captures[2].to_f + (captures[3].to_f / 60)) / 60) - lon = captures[5].casecmp("w").zero? ? -(captures[6].to_f + ((captures[7].to_f + (captures[8].to_f / 60)) / 60)) : captures[6].to_f + ((captures[7].to_f + (captures[8].to_f / 60)) / 60) - end - { :lat => lat, :lon => lon } + ew = captures.fetch("ew").casecmp?("w") ? -1 : 1 + ewd = BigDecimal(captures.fetch("ewd", "0")) + ewm = BigDecimal(captures.fetch("ewm", "0")) + ews = BigDecimal(captures.fetch("ews", "0")) + + lat = ns * (nsd + (nsm / 60) + (nss / 3600)) + lon = ew * (ewd + (ewm / 60) + (ews / 3600)) + + { :lat => lat.round(6).to_s("F"), :lon => lon.round(6).to_s("F") } end end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 779174e25..e4d6c70d9 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -117,7 +117,7 @@ class MessagesController < ApplicationController # Set the message as being read or unread. def mark - @message = Message.where(:recipient => current_user).or(Message.where(:sender => current_user)).find(params[:message_id]) + @message = current_user.messages.find(params[:message_id]) if params[:mark] == "unread" message_read = false notice = t ".as_unread" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b7c156bd9..0830e51d4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -262,40 +262,38 @@ class UsersController < ApplicationController private def save_new_user(email_hmac, referer = nil) - if check_signup_allowed(current_user.email) - current_user.data_public = true - current_user.description = "" if current_user.description.nil? - current_user.creation_ip = request.remote_ip - current_user.languages = http_accept_language.user_preferred_languages - current_user.terms_agreed = Time.now.utc - current_user.tou_agreed = Time.now.utc - current_user.terms_seen = true - - if current_user.auth_uid.blank? - current_user.auth_provider = nil - current_user.auth_uid = nil - elsif email_hmac && ActiveSupport::SecurityUtils.secure_compare(email_hmac, UsersController.message_hmac(current_user.email)) - current_user.activate - end + current_user.data_public = true + current_user.description = "" if current_user.description.nil? + current_user.creation_ip = request.remote_ip + current_user.languages = http_accept_language.user_preferred_languages + current_user.terms_agreed = Time.now.utc + current_user.tou_agreed = Time.now.utc + current_user.terms_seen = true + + if current_user.auth_uid.blank? + current_user.auth_provider = nil + current_user.auth_uid = nil + elsif email_hmac && ActiveSupport::SecurityUtils.secure_compare(email_hmac, UsersController.message_hmac(current_user.email)) + current_user.activate + end - if current_user.save - SIGNUP_IP_LIMITER&.update(request.remote_ip) - SIGNUP_EMAIL_LIMITER&.update(canonical_email(current_user.email)) + if current_user.save + SIGNUP_IP_LIMITER&.update(request.remote_ip) + SIGNUP_EMAIL_LIMITER&.update(canonical_email(current_user.email)) - flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo) + flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo) - referer = welcome_path(welcome_options(referer)) + referer = welcome_path(welcome_options(referer)) - if current_user.status == "active" - successful_login(current_user, referer) - else - session[:pending_user] = current_user.id - UserMailer.signup_confirm(current_user, current_user.generate_token_for(:new_user), referer).deliver_later - redirect_to :controller => :confirmations, :action => :confirm, :display_name => current_user.display_name - end + if current_user.status == "active" + successful_login(current_user, referer) else - render :action => "new", :referer => params[:referer] + session[:pending_user] = current_user.id + UserMailer.signup_confirm(current_user, current_user.generate_token_for(:new_user), referer).deliver_later + redirect_to :controller => :confirmations, :action => :confirm, :display_name => current_user.display_name end + else + render :action => "new", :referer => params[:referer] end end diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index d767cb887..734a266db 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -52,10 +52,6 @@ module UserHelper # External authentication support - def openid_logo - image_tag "openid.svg", :size => "36", :alt => t("application.auth_providers.openid_logo_alt"), :class => "align-text-bottom" - end - def auth_button(name, provider, options = {}) link_to( image_tag("#{name}.svg", @@ -64,7 +60,7 @@ module UserHelper :size => "36"), auth_path(options.merge(:provider => provider)), :method => :post, - :class => "auth_button btn btn-light mx-1 p-2 d-block", + :class => "auth_button btn btn-light p-2", :title => t("application.auth_providers.#{name}.title") ) end @@ -77,7 +73,7 @@ module UserHelper :size => "36") + t("application.auth_providers.#{name}.title"), auth_path(options.merge(:provider => provider)), :method => :post, - :class => "auth_button btn btn-outline-secondary fs-6 border rounded py-2 px-4 d-flex justify-content-center align-items-center", + :class => "auth_button btn btn-outline-secondary border py-2 px-4 d-flex justify-content-center align-items-center", :title => t("application.auth_providers.#{name}.title") ) end diff --git a/app/models/request_token.rb b/app/models/request_token.rb index adeabb184..ec38f7421 100644 --- a/app/models/request_token.rb +++ b/app/models/request_token.rb @@ -73,7 +73,7 @@ class RequestToken < OauthToken end def oob? - callback_url.nil? || callback_url.casecmp("oob").zero? + callback_url.nil? || callback_url.casecmp?("oob") end def oauth10? diff --git a/app/views/api/map/index.json.jbuilder b/app/views/api/map/index.json.jbuilder index 7cc983aef..756884539 100644 --- a/app/views/api/map/index.json.jbuilder +++ b/app/views/api/map/index.json.jbuilder @@ -2,8 +2,8 @@ json.partial! "root_attributes" json.partial! "bounds" -all = @nodes + @ways + @relations - -json.elements(all) do |obj| - json.partial! obj +json.elements do + json.array! @nodes, :partial => "/api/nodes/node", :as => :node + json.array! @ways, :partial => "/api/ways/way", :as => :way + json.array! @relations, :partial => "/api/relations/relation", :as => :relation end diff --git a/app/views/api/nodes/index.json.jbuilder b/app/views/api/nodes/index.json.jbuilder index 3e3ceb4cc..7708a3498 100644 --- a/app/views/api/nodes/index.json.jbuilder +++ b/app/views/api/nodes/index.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@nodes) do |node| - json.partial! node +json.elements do + json.array! @nodes, :partial => "node", :as => :node end diff --git a/app/views/api/nodes/show.json.jbuilder b/app/views/api/nodes/show.json.jbuilder index 9974da82f..bcbd29b5e 100644 --- a/app/views/api/nodes/show.json.jbuilder +++ b/app/views/api/nodes/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@node]) do |node| - json.partial! node +json.elements do + json.array! [@node], :partial => "node", :as => :node end diff --git a/app/views/api/old_nodes/history.json.jbuilder b/app/views/api/old_nodes/history.json.jbuilder index 96e8cca2d..3a800d07d 100644 --- a/app/views/api/old_nodes/history.json.jbuilder +++ b/app/views/api/old_nodes/history.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@elems) do |old_node| - json.partial! old_node +json.elements do + json.array! @elems, :partial => "old_node", :as => :old_node end diff --git a/app/views/api/old_nodes/show.json.jbuilder b/app/views/api/old_nodes/show.json.jbuilder index f63e07d43..c6929ea82 100644 --- a/app/views/api/old_nodes/show.json.jbuilder +++ b/app/views/api/old_nodes/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@old_element]) do |old_node| - json.partial! old_node +json.elements do + json.array! [@old_element], :partial => "old_node", :as => :old_node end diff --git a/app/views/api/old_relations/history.json.jbuilder b/app/views/api/old_relations/history.json.jbuilder index 311a80a86..944bed023 100644 --- a/app/views/api/old_relations/history.json.jbuilder +++ b/app/views/api/old_relations/history.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@elems) do |old_relation| - json.partial! old_relation +json.elements do + json.array! @elems, :partial => "old_relation", :as => :old_relation end diff --git a/app/views/api/old_relations/show.json.jbuilder b/app/views/api/old_relations/show.json.jbuilder index 5b33e4b85..bd767b3df 100644 --- a/app/views/api/old_relations/show.json.jbuilder +++ b/app/views/api/old_relations/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@old_element]) do |old_relation| - json.partial! old_relation +json.elements do + json.array! [@old_element], :partial => "old_relation", :as => :old_relation end diff --git a/app/views/api/old_ways/history.json.jbuilder b/app/views/api/old_ways/history.json.jbuilder index b5cf80d09..9e98901f5 100644 --- a/app/views/api/old_ways/history.json.jbuilder +++ b/app/views/api/old_ways/history.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@elems) do |old_way| - json.partial! old_way +json.elements do + json.array! @elems, :partial => "old_way", :as => :old_way end diff --git a/app/views/api/old_ways/show.json.jbuilder b/app/views/api/old_ways/show.json.jbuilder index c66488526..ee21d0f41 100644 --- a/app/views/api/old_ways/show.json.jbuilder +++ b/app/views/api/old_ways/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@old_element]) do |old_way| - json.partial! old_way +json.elements do + json.array! [@old_element], :partial => "old_way", :as => :old_way end diff --git a/app/views/api/relations/full.json.jbuilder b/app/views/api/relations/full.json.jbuilder index 98cbbfc40..16331a89e 100644 --- a/app/views/api/relations/full.json.jbuilder +++ b/app/views/api/relations/full.json.jbuilder @@ -1,7 +1,7 @@ json.partial! "api/root_attributes" -all = @nodes + @ways + @relations - -json.elements(all) do |obj| - json.partial! obj +json.elements do + json.array! @nodes, :partial => "/api/nodes/node", :as => :node + json.array! @ways, :partial => "/api/ways/way", :as => :way + json.array! @relations, :partial => "/api/relations/relation", :as => :relation end diff --git a/app/views/api/relations/index.json.jbuilder b/app/views/api/relations/index.json.jbuilder index f170cb150..9b0f65bf1 100644 --- a/app/views/api/relations/index.json.jbuilder +++ b/app/views/api/relations/index.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@relations) do |relation| - json.partial! relation +json.elements do + json.array! @relations, :partial => "relation", :as => :relation end diff --git a/app/views/api/relations/relations_for_node.json.jbuilder b/app/views/api/relations/relations_for_node.json.jbuilder index f170cb150..9b0f65bf1 100644 --- a/app/views/api/relations/relations_for_node.json.jbuilder +++ b/app/views/api/relations/relations_for_node.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@relations) do |relation| - json.partial! relation +json.elements do + json.array! @relations, :partial => "relation", :as => :relation end diff --git a/app/views/api/relations/relations_for_relation.json.jbuilder b/app/views/api/relations/relations_for_relation.json.jbuilder index f170cb150..9b0f65bf1 100644 --- a/app/views/api/relations/relations_for_relation.json.jbuilder +++ b/app/views/api/relations/relations_for_relation.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@relations) do |relation| - json.partial! relation +json.elements do + json.array! @relations, :partial => "relation", :as => :relation end diff --git a/app/views/api/relations/relations_for_way.json.jbuilder b/app/views/api/relations/relations_for_way.json.jbuilder index f170cb150..9b0f65bf1 100644 --- a/app/views/api/relations/relations_for_way.json.jbuilder +++ b/app/views/api/relations/relations_for_way.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@relations) do |relation| - json.partial! relation +json.elements do + json.array! @relations, :partial => "relation", :as => :relation end diff --git a/app/views/api/relations/show.json.jbuilder b/app/views/api/relations/show.json.jbuilder index 7f85d0f25..e5da7cd3f 100644 --- a/app/views/api/relations/show.json.jbuilder +++ b/app/views/api/relations/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@relation]) do |relation| - json.partial! relation +json.elements do + json.array! [@relation], :partial => "relation", :as => :relation end diff --git a/app/views/api/ways/full.json.jbuilder b/app/views/api/ways/full.json.jbuilder index bebad5e9f..1bd127dac 100644 --- a/app/views/api/ways/full.json.jbuilder +++ b/app/views/api/ways/full.json.jbuilder @@ -1,7 +1,6 @@ json.partial! "api/root_attributes" -all = @nodes + [@way] - -json.elements(all) do |obj| - json.partial! obj +json.elements do + json.array! @nodes, :partial => "/api/nodes/node", :as => :node + json.array! [@way], :partial => "/api/ways/way", :as => :way end diff --git a/app/views/api/ways/index.json.jbuilder b/app/views/api/ways/index.json.jbuilder index 19e59cfb8..7b8de5f1c 100644 --- a/app/views/api/ways/index.json.jbuilder +++ b/app/views/api/ways/index.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@ways) do |way| - json.partial! way +json.elements do + json.array! @ways, :partial => "way", :as => :way end diff --git a/app/views/api/ways/show.json.jbuilder b/app/views/api/ways/show.json.jbuilder index acb93c1e7..92e570d86 100644 --- a/app/views/api/ways/show.json.jbuilder +++ b/app/views/api/ways/show.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements([@way]) do |way| - json.partial! way +json.elements do + json.array! [@way], :partial => "way", :as => :way end diff --git a/app/views/api/ways/ways_for_node.json.jbuilder b/app/views/api/ways/ways_for_node.json.jbuilder index 19e59cfb8..7b8de5f1c 100644 --- a/app/views/api/ways/ways_for_node.json.jbuilder +++ b/app/views/api/ways/ways_for_node.json.jbuilder @@ -1,5 +1,5 @@ json.partial! "api/root_attributes" -json.elements(@ways) do |way| - json.partial! way +json.elements do + json.array! @ways, :partial => "way", :as => :way end diff --git a/app/views/application/_auth_providers.html.erb b/app/views/application/_auth_providers.html.erb index be921ee9c..96a20fd85 100644 --- a/app/views/application/_auth_providers.html.erb +++ b/app/views/application/_auth_providers.html.erb @@ -1,17 +1,18 @@ -
-
+<% prefered_auth_button_available = false %> +<% %w[google facebook microsoft github wikipedia].each do |provider| %> + <% if Settings.key?("#{provider}_auth_id".to_sym) -%> + <% if @preferred_auth_provider == provider %> + <% prefered_auth_button_available = true %> + <% end %> + <% end -%> +<% end -%> - <% prefered_auth_button_available = false %> - <% %w[google facebook microsoft github wikipedia].each do |provider| %> - <% if Settings.key?("#{provider}_auth_id".to_sym) -%> - <% if @preferred_auth_provider == provider %> - <% prefered_auth_button_available = true %> - <% end %> - <% end -%> - <% end -%> +
+ <%= tag.div :id => "login_auth_buttons", + :class => ["row row-cols-1", { "row-cols-sm-2" => prefered_auth_button_available }, "g-2 mb-3"] do %> <% if prefered_auth_button_available %> -
+
<% %w[google facebook microsoft github wikipedia].each do |provider| %> <% if Settings.key?("#{provider}_auth_id".to_sym) -%> <% if @preferred_auth_provider == provider %> @@ -20,18 +21,16 @@ <% end -%> <% end -%>
-
- <% else %> -
<% end %> - <%= link_to image_tag("openid.svg", - :alt => t("application.auth_providers.openid.title"), - :size => "36"), - "#", - :id => "openid_open_url", - :title => t("application.auth_providers.openid.title"), - :class => "btn btn-light mx-1 p-2 d-block" %> +
+ <%= button_tag image_tag("openid.svg", + :alt => t(".openid.alt"), + :size => "36"), + :type => "button", + :id => "openid_open_url", + :title => t(".openid.title"), + :class => "btn btn-light p-2" %> <% %w[google facebook microsoft github wikipedia].each do |provider| %> <% unless @preferred_auth_provider == provider %> @@ -41,17 +40,20 @@ <% end %> <% end -%>
-
+ <% end %> <%# :tabindex starts high to allow rendering at the bottom of the template %> <%= form_tag(auth_path(:provider => "openid"), :id => "openid_login_form") do %> -
- +
+ <%= hidden_field_tag("referer", params[:referer], :autocomplete => "off") %> - <%= text_field_tag("openid_url", "", :tabindex => 20, :autocomplete => "on", :class => "openid_url form-control") %> + <%= text_field_tag("openid_url", "", :tabindex => 20, :autocomplete => "on", :class => "form-control") %> (" target="_new"><%= t "accounts.edit.openid.link text" %>)
- <%= submit_tag t(".openid_login_button"), :tabindex => 21, :id => "openid_login_button", :class => "btn btn-primary" %> + <%= submit_tag t(".openid_login_button"), :tabindex => 21, :class => "btn btn-primary" %> <% end %>
diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb index d3e6dbcb3..a65597fef 100644 --- a/app/views/dashboards/show.html.erb +++ b/app/views/dashboards/show.html.erb @@ -19,7 +19,7 @@ :icon => image_path("marker-red.png"), :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" }) } %> - <%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded", :data => { :user => user_data } %> + <%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %> <% end %> <% friends = @user.friends %> diff --git a/app/views/diary_comments/new.html.erb b/app/views/diary_comments/new.html.erb new file mode 100644 index 000000000..91e646944 --- /dev/null +++ b/app/views/diary_comments/new.html.erb @@ -0,0 +1,12 @@ +<% content_for :heading do %> +

<%= t ".heading" %>

+<% end %> + +<%= render :partial => "diary_entries/diary_entry_heading", :object => @entry, :as => "diary_entry" %> + +

<%= t "diary_entries.show.leave_a_comment" %>

+ +<%= bootstrap_form_for @diary_comment, :url => comment_diary_entry_path(@entry.user, @entry) do |f| %> + <%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %> + <%= f.primary %> +<% end %> diff --git a/app/views/diary_entries/_form.html.erb b/app/views/diary_entries/_form.html.erb index 291e8e33b..a449b0d39 100644 --- a/app/views/diary_entries/_form.html.erb +++ b/app/views/diary_entries/_form.html.erb @@ -5,7 +5,7 @@
<%= t ".location" -%> - <%= tag.div "", :id => "map", :class => "border border-secondary-subtle rounded mb-3", :data => { :lat => @lat, :lon => @lon, :zoom => @zoom } %> + <%= tag.div "", :id => "map", :class => "border border-secondary-subtle rounded mb-3 z-0", :data => { :lat => @lat, :lon => @lon, :zoom => @zoom } %>
<%= f.text_field :latitude, :wrapper_class => "col-sm-4 d-flex flex-column", :class => "mt-auto", :id => "latitude" %> diff --git a/app/views/diary_entries/index.html.erb b/app/views/diary_entries/index.html.erb index a0ab0264a..15be9e964 100644 --- a/app/views/diary_entries/index.html.erb +++ b/app/views/diary_entries/index.html.erb @@ -25,7 +25,14 @@ <% end %> <% if @user && @user == current_user || !@user && current_user %> -
  • <%= link_to image_tag("new.png") + t(".new"), new_diary_entry_path, :class => "icon-link", :title => t(".new_title") %>
  • +
  • + <%= link_to new_diary_entry_path, :class => "icon-link", :title => t(".new_title") do %> + + + + <%= t(".new") %> + <% end %> +
  • <% end %> diff --git a/app/views/diary_entries/show.html.erb b/app/views/diary_entries/show.html.erb index 1830c9ced..cfed1c46d 100644 --- a/app/views/diary_entries/show.html.erb +++ b/app/views/diary_entries/show.html.erb @@ -34,7 +34,7 @@ <% if current_user %>

    <%= t ".leave_a_comment" %>

    - <%= bootstrap_form_for @entry.comments.new, :url => { :action => "comment" } do |f| %> + <%= bootstrap_form_for @entry.comments.new, :url => comment_diary_entry_path(@entry.user, @entry) do |f| %> <%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %> <%= f.primary %> <% end %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb index fea15eb2f..ac76b4d2d 100644 --- a/app/views/profiles/edit.html.erb +++ b/app/views/profiles/edit.html.erb @@ -56,7 +56,7 @@ checked <% end %> id="updatehome" />
    - <%= tag.div "", :id => "map", :class => "content_map set_location border border-secondary-subtle rounded" %> + <%= tag.div "", :id => "map", :class => "content_map set_location border border-secondary-subtle rounded z-0" %>
    <%= f.primary t(".save") %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 70839d160..9d05d4af8 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -3,14 +3,14 @@ <%= javascript_include_tag "auth_providers" %> <% end %> -<% content_for :heading_class, "p-0 mw-100" %> +<% content_for :heading_class, "pb-0" %> <% content_for :heading do %> <% if @client_app_name %>

    <%= t(".login_to_authorize_html", :client_app_name => @client_app_name) %>

    <% end %> -
    +
    <% end %> -
    - <% if @preferred_auth_provider %> - <%= render :partial => "auth_providers" %> -
    -
    -
    <%= t ".or" %>
    -
    -
    - <% end %> +<% if @preferred_auth_provider %> + <%= render :partial => "auth_providers" %> + <%= render :partial => "shared/section_divider", :locals => { :text => t(".or") } %> +<% end %> - <%= bootstrap_form_tag(:action => "login", :html => { :id => "login_form" }) do |f| %> - <%= hidden_field_tag("referer", h(params[:referer]), :autocomplete => "off") %> +<%= bootstrap_form_tag(:action => "login", :html => { :id => "login_form" }) do |f| %> + <%= hidden_field_tag("referer", h(params[:referer]), :autocomplete => "off") %> - <%= f.text_field :username, :label => t(".email or username"), :autofocus => true, :tabindex => 1, :value => params[:username] %> + <%= f.text_field :username, :label => t(".email or username"), :autofocus => true, :tabindex => 1, :value => params[:username] %> -
    -
    - <%= f.label :password, t(".password"), :class => "form-label" %> -
    -
    - <%= link_to(t(".lost password link"), user_forgot_password_path) %> -
    -
    - +
    + <%= f.label :password, t(".password") %> + <%= link_to(t(".lost password link"), user_forgot_password_path) %> +
    - <%= f.form_group do %> - <%= f.check_box :remember_me, { :label => t(".remember"), :tabindex => 3, :checked => (params[:remember_me] == "yes") }, "yes" %> - <% end %> + <%= f.password_field :password, :autocomplete => "on", :tabindex => 2, :value => "", :skip_label => true %> -
    - <%= f.primary t(".login_button"), :tabindex => 4 %> -
    + <%= f.form_group do %> + <%= f.check_box :remember_me, { :label => t(".remember"), :tabindex => 3, :checked => (params[:remember_me] == "yes") }, "yes" %> <% end %> - <% unless @preferred_auth_provider %> -
    -
    -
    <%= t ".with external" %>
    -
    -
    - <%= render :partial => "auth_providers" %> - <% end %> -
    +
    + <%= f.primary t(".login_button"), :tabindex => 4 %> +
    +<% end %> + +<% unless @preferred_auth_provider %> + <%= render :partial => "shared/section_divider", :locals => { :text => t(".with external") } %> + <%= render :partial => "auth_providers" %> +<% end %> diff --git a/app/views/shared/_section_divider.html.erb b/app/views/shared/_section_divider.html.erb new file mode 100644 index 000000000..ad6bffd9d --- /dev/null +++ b/app/views/shared/_section_divider.html.erb @@ -0,0 +1,5 @@ +
    + + <%= text %> + +
    diff --git a/app/views/users/blocked.html.erb b/app/views/users/blocked.html.erb index a97d9ba8d..a5fb08a34 100644 --- a/app/views/users/blocked.html.erb +++ b/app/views/users/blocked.html.erb @@ -1,7 +1,7 @@ -<% content_for :heading_class, "p-0 mw-100" %> +<% content_for :heading_class, "pb-0" %> <% content_for :heading do %> -
    -