From: Adam Hoyle Date: Mon, 27 Sep 2021 18:30:25 +0000 (+0100) Subject: Merge branch 'master' into feature/add-communities-page X-Git-Tag: live~1970^2~33 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/06c2db433d63ebd0e5a83cb6b68a29a6ca1d5050?hp=a57bc158fd9b8a8287786f2ab01ebeb2bbf2447f Merge branch 'master' into feature/add-communities-page --- diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..44b38323d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..6313b56c5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 32514771c..90bfaa8f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-06-29 17:25:37 UTC using RuboCop version 1.18.0. +# on 2021-09-14 19:29:59 UTC using RuboCop version 1.21.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,13 +14,26 @@ require: - rubocop-rails - rubocop-rake -# Offense count: 510 +# Offense count: 524 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Layout/LineLength: Max: 270 +# Offense count: 62 +# Cop supports --auto-correct. +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'app/controllers/geocoder_controller.rb' + - 'app/models/user.rb' + - 'lib/bounding_box.rb' + - 'lib/osm.rb' + - 'lib/rich_text.rb' + - 'lib/short_link.rb' + - 'test/controllers/api/old_nodes_controller_test.rb' + - 'test/lib/short_link_test.rb' + # Offense count: 34 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: @@ -50,12 +63,12 @@ Lint/DuplicateBranch: - 'app/helpers/browse_tags_helper.rb' - 'lib/password_hash.rb' -# Offense count: 631 +# Offense count: 643 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: - Max: 235 + Max: 189 -# Offense count: 68 +# Offense count: 69 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. # IgnoredMethods: refine Metrics/BlockLength: @@ -69,14 +82,14 @@ Metrics/BlockNesting: # Offense count: 25 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 361 + Max: 337 -# Offense count: 56 +# Offense count: 58 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 25 -# Offense count: 703 +# Offense count: 716 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 179 @@ -86,37 +99,22 @@ Metrics/MethodLength: Metrics/ParameterLists: Max: 6 -# Offense count: 60 +# Offense count: 62 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 26 -# Offense count: 519 +# Offense count: 528 Minitest/MultipleAssertions: - Max: 88 + Max: 54 -# Offense count: 4 +# Offense count: 3 Naming/AccessorMethodName: Exclude: - 'app/controllers/application_controller.rb' - 'app/helpers/title_helper.rb' - 'lib/osm.rb' -# Offense count: 21 -# Configuration parameters: CheckIdentifiers, CheckConstants, CheckVariables, CheckStrings, CheckSymbols, CheckComments, CheckFilepaths, FlaggedTerms. -Naming/InclusiveLanguage: - Exclude: - - 'app/controllers/sessions_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/helpers/browse_tags_helper.rb' - - 'app/views/api/capabilities/show.builder' - - 'app/views/confirmations/_resend_success_flash.html.erb' - - 'app/views/users/suspended.html.erb' - - 'config/environments/production.rb' - - 'config/initializers/canonical_rails.rb' - - 'config/initializers/config.rb' - - 'config/initializers/doorkeeper.rb' - # Offense count: 8 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ @@ -200,7 +198,7 @@ Rake/Desc: - 'lib/tasks/subscribe_diary_authors.rake' - 'lib/tasks/subscribe_old_changesets.rake' -# Offense count: 597 +# Offense count: 602 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never diff --git a/Gemfile b/Gemfile index 918a49747..75cb1054b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" # Require rails -gem "rails", "6.1.4" +gem "rails", "6.1.4.1" # Require json for multi_json gem "json" @@ -145,7 +145,7 @@ group :test do gem "rubocop" gem "rubocop-minitest" gem "rubocop-performance" - gem "rubocop-rails" + gem "rubocop-rails", "~> 2.11.3" # Bug in 2.12.0, fixed in master after 2.12.2 gem "rubocop-rake" gem "selenium-webdriver" gem "simplecov", :require => false diff --git a/Gemfile.lock b/Gemfile.lock index 2fb65a668..2f8e120da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,66 +3,66 @@ GEM specs: aasm (5.2.0) concurrent-ruby (~> 1.0) - actioncable (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + actioncable (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actionmailbox (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (>= 2.7.1) - actionmailer (6.1.4) - actionpack (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activesupport (= 6.1.4) + actionmailer (6.1.4.1) + actionpack (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4) - actionview (= 6.1.4) - activesupport (= 6.1.4) + actionpack (6.1.4.1) + actionview (= 6.1.4.1) + activesupport (= 6.1.4.1) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actionpack-page_caching (1.2.4) actionpack (>= 4.0.0) - actiontext (6.1.4) - actionpack (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actiontext (6.1.4.1) + actionpack (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) nokogiri (>= 1.8.5) - actionview (6.1.4) - activesupport (= 6.1.4) + actionview (6.1.4.1) + activesupport (= 6.1.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (6.1.4) - activesupport (= 6.1.4) + activejob (6.1.4.1) + activesupport (= 6.1.4.1) globalid (>= 0.3.6) - activemodel (6.1.4) - activesupport (= 6.1.4) - activerecord (6.1.4) - activemodel (= 6.1.4) - activesupport (= 6.1.4) + activemodel (6.1.4.1) + activesupport (= 6.1.4.1) + activerecord (6.1.4.1) + activemodel (= 6.1.4.1) + activesupport (= 6.1.4.1) activerecord-import (1.2.0) activerecord (>= 3.2) - activestorage (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activesupport (= 6.1.4) + activestorage (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activesupport (= 6.1.4.1) marcel (~> 1.0.0) mini_mime (>= 1.1.0) - activesupport (6.1.4) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -74,23 +74,23 @@ GEM activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 14.0) ast (2.4.2) - autoprefixer-rails (10.3.1.0) + autoprefixer-rails (10.3.3.0) execjs (~> 2) - aws-eventstream (1.1.1) - aws-partitions (1.484.0) - aws-sdk-core (3.119.0) + aws-eventstream (1.2.0) + aws-partitions (1.503.0) + aws-sdk-core (3.121.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.46.0) - aws-sdk-core (~> 3, >= 3.119.0) + aws-sdk-kms (1.48.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.98.0) - aws-sdk-core (~> 3, >= 3.119.0) + aws-sdk-s3 (1.103.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.2.4) + aws-sigv4 (~> 1.4) + aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) better_errors (2.9.1) coderay (>= 1.0.0) @@ -106,7 +106,7 @@ GEM smart_properties binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bootsnap (1.7.7) + bootsnap (1.9.1) msgpack (~> 1.0) bootstrap (4.5.3) autoprefixer-rails (>= 9.1.0) @@ -121,7 +121,7 @@ GEM bzip2-ffi (1.1.0) ffi (~> 1.0) cancancan (3.3.0) - canonical-rails (0.2.11) + canonical-rails (0.2.12) rails (>= 4.1, < 6.2) capybara (3.35.3) addressable @@ -155,23 +155,22 @@ GEM railties (>= 5) doorkeeper-i18n (5.2.2) doorkeeper (>= 5.2) - dry-configurable (0.12.1) + dry-configurable (0.13.0) concurrent-ruby (~> 1.0) - dry-core (~> 0.5, >= 0.5.0) - dry-container (0.8.0) + dry-core (~> 0.6) + dry-container (0.9.0) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1, >= 0.1.3) + dry-configurable (~> 0.13, >= 0.13.0) dry-core (0.7.1) concurrent-ruby (~> 1.0) - dry-equalizer (0.3.0) dry-inflector (0.2.1) dry-initializer (3.0.4) dry-logic (1.2.0) concurrent-ruby (~> 1.0) dry-core (~> 0.5, >= 0.5) - dry-schema (1.7.0) + dry-schema (1.8.0) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.8, >= 0.8.3) + dry-configurable (~> 0.13, >= 0.13.0) dry-core (~> 0.5, >= 0.5) dry-initializer (~> 3.0) dry-logic (~> 1.0) @@ -182,13 +181,12 @@ GEM dry-core (~> 0.5, >= 0.5) dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 1.0, >= 1.0.2) - dry-validation (1.6.0) + dry-validation (1.7.0) concurrent-ruby (~> 1.0) dry-container (~> 0.7, >= 0.7.1) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) + dry-core (~> 0.5, >= 0.5) dry-initializer (~> 3.0) - dry-schema (~> 1.5, >= 1.5.2) + dry-schema (~> 1.8, >= 1.8.0) erb_lint (0.1.1) activesupport better_html (~> 1.0.7) @@ -205,7 +203,7 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faraday (1.7.0) + faraday (1.8.0) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -224,8 +222,8 @@ GEM faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) - ffi (1.15.3) - ffi-libarchive (1.0.17) + ffi (1.15.4) + ffi-libarchive (1.1.3) ffi (~> 1.0) fspath (3.1.2) gd2-ffij (0.4.0) @@ -254,7 +252,7 @@ GEM image_processing (1.12.1) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - image_size (2.1.1) + image_size (2.1.2) in_threads (1.5.4) jbuilder (2.11.2) activesupport (>= 5.0.0) @@ -269,22 +267,22 @@ GEM kramdown (2.3.1) rexml libxml-ruby (3.2.1) - listen (3.6.0) + listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logstasher (2.1.5) activesupport (>= 5.2) request_store - loofah (2.11.0) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (1.0.2) maxminddb (0.1.22) method_source (1.0.0) mini_magick (4.11.0) - mini_mime (1.1.0) + mini_mime (1.1.1) mini_portile2 (2.6.1) minitest (5.14.4) msgpack (1.4.2) @@ -292,7 +290,7 @@ GEM multi_xml (0.6.0) multipart-post (2.1.1) nio4r (2.5.8) - nokogiri (1.12.2) + nokogiri (1.12.4) mini_portile2 (~> 2.6.1) racc (~> 1.4) oauth (0.4.7) @@ -340,14 +338,14 @@ GEM multi_json (~> 1.12) omniauth-oauth2 (~> 1.4) openstreetmap-deadlock_retry (1.3.1) - parallel (1.20.1) + parallel (1.21.0) parser (3.0.2.0) ast (~> 2.4.1) pg (1.2.3) popper_js (1.16.0) progress (3.6.0) public_suffix (4.0.6) - puma (5.4.0) + puma (5.5.0) nio4r (~> 2.0) quad_tile (1.0.1) r2 (0.2.7) @@ -363,20 +361,20 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-uri_sanitizer (0.0.2) - rails (6.1.4) - actioncable (= 6.1.4) - actionmailbox (= 6.1.4) - actionmailer (= 6.1.4) - actionpack (= 6.1.4) - actiontext (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activemodel (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + rails (6.1.4.1) + actioncable (= 6.1.4.1) + actionmailbox (= 6.1.4.1) + actionmailer (= 6.1.4.1) + actionpack (= 6.1.4.1) + actiontext (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activemodel (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) bundler (>= 1.15.0) - railties (= 6.1.4) + railties (= 6.1.4.1) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -385,14 +383,14 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + railties (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) method_source rake (>= 0.13) thor (~> 1.0) @@ -407,20 +405,20 @@ GEM rexml (3.2.5) rinku (2.0.6) rotp (6.2.0) - rubocop (1.18.4) + rubocop (1.21.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.8.0, < 2.0) + rubocop-ast (>= 1.9.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.9.0) + rubocop-ast (1.11.0) parser (>= 3.0.1.1) rubocop-minitest (0.15.0) rubocop (>= 0.90, < 2.0) - rubocop-performance (1.11.4) + rubocop-performance (1.11.5) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.11.3) @@ -431,7 +429,7 @@ GEM rubocop (~> 1.0) ruby-openid (2.9.2) ruby-progressbar (1.11.0) - ruby-vips (2.1.2) + ruby-vips (2.1.3) ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -446,7 +444,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - secure_headers (6.3.2) + secure_headers (6.3.3) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) @@ -457,7 +455,7 @@ GEM simplecov-html (0.12.3) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.3) - smart_properties (1.15.0) + smart_properties (1.16.3) sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -467,13 +465,13 @@ GEM sprockets (>= 3.0.0) strong_migrations (0.7.8) activerecord (>= 5) - terser (1.1.5) + terser (1.1.6) execjs (>= 0.3.0, < 3) thor (1.1.0) tilt (2.0.10) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) validates_email_format_of (1.6.3) i18n vendorer (0.2.0) @@ -554,7 +552,7 @@ DEPENDENCIES r2 (~> 0.2.7) rack-cors rack-uri_sanitizer - rails (= 6.1.4) + rails (= 6.1.4.1) rails-controller-testing rails-i18n (~> 6.0.0) rinku (>= 2.0.6) @@ -562,7 +560,7 @@ DEPENDENCIES rubocop rubocop-minitest rubocop-performance - rubocop-rails + rubocop-rails (~> 2.11.3) rubocop-rake sanitize sassc-rails diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index ec32a4607..f33ce182d 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -42,6 +42,7 @@ class Ability can [:index, :new, :create, :show, :edit, :update, :destroy], :oauth2_application can [:index, :destroy], :oauth2_authorized_application can [:new, :show, :create, :destroy], :oauth2_authorization + can [:show], :dashboard can [:new, :create, :edit, :update, :comment, :subscribe, :unsubscribe], DiaryEntry can [:make_friend, :remove_friend], Friendship can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 0023286bf..e0eec7bda 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1096,47 +1096,11 @@ tr.turn:hover { /* Rules for the user profile page */ -#userinformation { - min-height: 100px; - .userinformation-inner { - float: left; - } - .user-description { - width: 100%; - clear: both; - } -} - -.admin-user-info small { - margin-bottom: $lineheight/2; - display: inline; - margin-right: $lineheight; -} - .contact-activity { margin-top: $lineheight; width: 100%; } -.activity-details p { - margin-left: 70px; - margin-bottom: 0; -} - -.users-show { - // Silly exception; remove when user page is redesigned. - .content-inner { - max-width: none; - } - p#no_home_location { - margin: $lineheight; - } - .user_thumbnail { - margin-top: $lineheight/4; - float: left; - } -} - /* Rules for the user map */ .content_map .leaflet-popup-content { @@ -1466,6 +1430,12 @@ img.user_image { margin-right: $lineheight; } +img.user_image_no_margins { + max-width: 100px; + max-height: 100px; + border: 1px solid $grey; +} + img.user_thumbnail { max-width: 50px; max-height: 50px; @@ -1473,6 +1443,12 @@ img.user_thumbnail { margin-right: $lineheight; } +img.user_thumbnail_no_margins { + max-width: 50px; + max-height: 50px; + border: 1px solid $grey; +} + img.user_thumbnail_tiny { width: auto; height: auto; @@ -1489,28 +1465,28 @@ abbr.geo { /* General styles for action lists / subnavs / pager navs */ -ul.secondary-actions { - font-style: normal; - margin-bottom: 0; - margin-left: 0; - padding: 0; - &.pager { - display: inline-block; - margin-right: 60px; - } - > li { - display: block; - float: left; - list-style: none; - border-left: 1px solid $grey; - padding-left: $lineheight/2; - margin-right: $lineheight/2; - &:first-child { - border-left: 0; - padding-left: 0; + +nav.secondary-actions { + margin-left: -11px; + overflow: hidden; + > ul { + display: flex; + flex-direction: row; + flex-wrap: wrap; + margin-bottom: 0; + margin-left: -1px; + padding: 0; + &.pager { + display: inline-block; + margin-right: 60px; } - &:last-child { - margin-right: 0px; + > li { + flex-basis: auto; + list-style: none; + border-left: 1px solid $grey; + padding-left: $lineheight/2; + margin-right: $lineheight/2; + margin-bottom: $lineheight/8; } } } @@ -1574,6 +1550,17 @@ div.secondary-actions { } } +/* Create a single-line dl */ + +dl.dl-inline { + dt, dd { + display: inline-block; + } + dd { + margin-right: 1em; + } +} + /* Customise the background colour of striped tables */ .table-striped > tbody > tr:nth-child(2n+1) > td, diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 34627a118..63fda31bd 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -11,6 +11,8 @@ module Api before_action :require_public_data, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe] before_action :check_api_writable, :only => [:create, :update, :upload, :subscribe, :unsubscribe] before_action :check_api_readable, :except => [:create, :update, :upload, :download, :query, :subscribe, :unsubscribe] + before_action :set_request_formats, :only => [:download] + around_action :api_call_handle_error around_action :api_call_timeout, :except => [:upload] @@ -122,35 +124,29 @@ module Api end end - # create changeset and user caches - changeset_cache = {} - user_display_name_cache = {} - - # create an osmChange document for the output - result = OSM::API.new.get_xml_doc - result.root.name = "osmChange" - # generate an output element for each operation. note: we avoid looking # at the history because it is simpler - but it would be more correct to # check these assertions. + @created = [] + @modified = [] + @deleted = [] + elements.each do |elt| - result.root << - if elt.version == 1 - # first version, so it must be newly-created. - created = XML::Node.new "create" - created << elt.to_xml_node(changeset_cache, user_display_name_cache) - elsif elt.visible - # must be a modify - modified = XML::Node.new "modify" - modified << elt.to_xml_node(changeset_cache, user_display_name_cache) - else - # if the element isn't visible then it must have been deleted - deleted = XML::Node.new "delete" - deleted << elt.to_xml_node(changeset_cache, user_display_name_cache) - end + if elt.version == 1 + # first version, so it must be newly-created. + @created << elt + elsif elt.visible + # must be a modify + @modified << elt + else + # if the element isn't visible then it must have been deleted + @deleted << elt + end end - render :xml => result.to_s + respond_to do |format| + format.xml + end end ## diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb index b4a2efc7c..a452cb930 100644 --- a/app/controllers/api/users_controller.rb +++ b/app/controllers/api/users_controller.rb @@ -1,6 +1,7 @@ module Api class UsersController < ApiController before_action :disable_terms_redirect, :only => [:details] + before_action :setup_user_auth, :only => [:show, :index] before_action :authorize, :only => [:details, :gpx_files] authorize_resource diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb new file mode 100644 index 000000000..540683d25 --- /dev/null +++ b/app/controllers/dashboards_controller.rb @@ -0,0 +1,14 @@ +class DashboardsController < ApplicationController + layout "site" + + before_action :authorize_web + before_action :set_locale + + authorize_resource :class => false + + before_action :check_database_readable + + def show + @user = current_user + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3d5173a7..42ac6ac11 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -277,15 +277,15 @@ class UsersController < ApplicationController name = auth_info[:info][:name] email = auth_info[:info][:email] - case provider - when "openid" - email_verified = uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) || + email_verified = case provider + when "openid" + uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) || uid.match(%r{https://me.yahoo.com/(.*)}) - when "google", "facebook" - email_verified = true - else - email_verified = false - end + when "google", "facebook" + true + else + false + end if settings = session.delete(:new_user_settings) current_user.auth_provider = provider diff --git a/app/helpers/open_graph_helper.rb b/app/helpers/open_graph_helper.rb index 99b8d00a3..a91457645 100644 --- a/app/helpers/open_graph_helper.rb +++ b/app/helpers/open_graph_helper.rb @@ -11,7 +11,7 @@ module OpenGraphHelper } safe_join(tags.map do |property, content| - tag(:meta, :property => property, :content => content) + tag.meta(:property => property, :content => content) end, "\n") end end diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 15231f4d0..c7516a51c 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -25,7 +25,7 @@ module UserRolesHelper end if image - svg_icon = tag("source", :srcset => image_path("#{image}.svg"), :type => "image/svg+xml") + svg_icon = tag.source(:srcset => image_path("#{image}.svg"), :type => "image/svg+xml") png_icon = image_tag("#{image}.png", :srcset => image_path("#{image}.svg"), :size => "20x20", :border => 0, :alt => alt, :title => title) icon = tag.picture(svg_icon + png_icon) icon = link_to(icon, url, :method => :post, :confirm => confirm) if url diff --git a/app/models/concerns/object_metadata.rb b/app/models/concerns/object_metadata.rb deleted file mode 100644 index dcfde889c..000000000 --- a/app/models/concerns/object_metadata.rb +++ /dev/null @@ -1,43 +0,0 @@ -module ObjectMetadata - extend ActiveSupport::Concern - - def add_metadata_to_xml_node(el, osm, changeset_cache, user_display_name_cache) - el["changeset"] = osm.changeset_id.to_s - el["redacted"] = osm.redaction.id.to_s if osm.redacted? - el["timestamp"] = osm.timestamp.xmlschema - el["version"] = osm.version.to_s - el["visible"] = osm.visible.to_s - - if changeset_cache.key?(osm.changeset_id) - # use the cache if available - else - changeset_cache[osm.changeset_id] = osm.changeset.user_id - end - - user_id = changeset_cache[osm.changeset_id] - - if user_display_name_cache.key?(user_id) - # use the cache if available - elsif osm.changeset.user.data_public? - user_display_name_cache[user_id] = osm.changeset.user.display_name - else - user_display_name_cache[user_id] = nil - end - - unless user_display_name_cache[user_id].nil? - el["user"] = user_display_name_cache[user_id] - el["uid"] = user_id.to_s - end - end - - def add_tags_to_xml_node(el, tags) - tags.each do |tag| - tag_el = XML::Node.new("tag") - - tag_el["k"] = tag.k - tag_el["v"] = tag.v - - el << tag_el - end - end -end diff --git a/app/models/node.rb b/app/models/node.rb index 5e799c8d9..8bfac993b 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -27,7 +27,6 @@ class Node < ApplicationRecord include GeoRecord include ConsistencyValidations include NotRedactable - include ObjectMetadata self.table_name = "current_nodes" diff --git a/app/models/old_node.rb b/app/models/old_node.rb index 620cc24d2..81d8e331f 100644 --- a/app/models/old_node.rb +++ b/app/models/old_node.rb @@ -27,7 +27,6 @@ class OldNode < ApplicationRecord include GeoRecord include ConsistencyValidations - include ObjectMetadata self.table_name = "nodes" self.primary_keys = "node_id", "version" @@ -69,28 +68,6 @@ class OldNode < ApplicationRecord old_node end - def to_xml - doc = OSM::API.new.get_xml_doc - doc.root << to_xml_node - doc - end - - def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new "node" - el["id"] = node_id.to_s - - add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) - - if visible? - el["lat"] = lat.to_s - el["lon"] = lon.to_s - end - - add_tags_to_xml_node(el, old_tags) - - el - end - def save_with_dependencies! save! diff --git a/app/models/old_relation.rb b/app/models/old_relation.rb index 51aeb9c4c..d0a03ac25 100644 --- a/app/models/old_relation.rb +++ b/app/models/old_relation.rb @@ -22,7 +22,6 @@ class OldRelation < ApplicationRecord include ConsistencyValidations - include ObjectMetadata self.table_name = "relations" self.primary_keys = "relation_id", "version" @@ -88,31 +87,6 @@ class OldRelation < ApplicationRecord attr_writer :members, :tags - def to_xml - doc = OSM::API.new.get_xml_doc - doc.root << to_xml_node - doc - end - - def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new "relation" - el["id"] = relation_id.to_s - - add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) - - old_members.each do |member| - member_el = XML::Node.new "member" - member_el["type"] = member.member_type.to_s.downcase - member_el["ref"] = member.member_id.to_s # "id" is considered uncool here as it should be unique in XML - member_el["role"] = member.member_role.to_s - el << member_el - end - - add_tags_to_xml_node(el, old_tags) - - el - end - # Temporary method to match interface to relations def relation_members old_members diff --git a/app/models/old_way.rb b/app/models/old_way.rb index 3260f2a1f..9acf8665d 100644 --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@ -22,7 +22,6 @@ class OldWay < ApplicationRecord include ConsistencyValidations - include ObjectMetadata self.table_name = "ways" self.primary_keys = "way_id", "version" @@ -86,23 +85,6 @@ class OldWay < ApplicationRecord attr_writer :nds, :tags - def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new "way" - el["id"] = way_id.to_s - - add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) - - old_nodes.each do |nd| # FIXME: need to make sure they come back in the right order - node_el = XML::Node.new "nd" - node_el["ref"] = nd.node_id.to_s - el << node_el - end - - add_tags_to_xml_node(el, old_tags) - - el - end - # Temporary method to match interface to ways def way_nodes old_nodes diff --git a/app/models/relation.rb b/app/models/relation.rb index 365ea533e..25564940b 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -22,7 +22,6 @@ class Relation < ApplicationRecord include ConsistencyValidations include NotRedactable - include ObjectMetadata self.table_name = "current_relations" diff --git a/app/models/way.rb b/app/models/way.rb index 7bb82b281..724965ddf 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -22,7 +22,6 @@ class Way < ApplicationRecord include ConsistencyValidations include NotRedactable - include ObjectMetadata self.table_name = "current_ways" diff --git a/app/views/api/changesets/download.xml.builder b/app/views/api/changesets/download.xml.builder new file mode 100644 index 000000000..1e400cd9f --- /dev/null +++ b/app/views/api/changesets/download.xml.builder @@ -0,0 +1,19 @@ +xml.instruct! :xml, :version => "1.0" + +xml.osmChange(OSM::API.new.xml_root_attributes) do |osm| + @created.each do |elt| + osm.create do |create| + create << render(elt) + end + end + @modified.each do |elt| + osm.modify do |modify| + modify << render(elt) + end + end + @deleted.each do |elt| + osm.delete do |delete| + delete << render(elt) + end + end +end diff --git a/app/views/api/users/_user.json.jbuilder b/app/views/api/users/_user.json.jbuilder index d89b42bef..8423353dd 100644 --- a/app/views/api/users/_user.json.jbuilder +++ b/app/views/api/users/_user.json.jbuilder @@ -4,7 +4,7 @@ json.user do json.account_created user.creation_time.xmlschema json.description user.description if user.description - if current_user && current_user == user + if current_user && current_user == user && can?(:details, User) json.contributor_terms do json.agreed user.terms_agreed.present? json.pd user.consider_pd @@ -45,7 +45,7 @@ json.user do end end - if current_user && current_user == user + if current_user && current_user == user && can?(:details, User) if user.home_lat && user.home_lon json.home do json.lat user.home_lat diff --git a/app/views/api/users/_user.xml.builder b/app/views/api/users/_user.xml.builder index d8c6c1c6e..9092f2c96 100644 --- a/app/views/api/users/_user.xml.builder +++ b/app/views/api/users/_user.xml.builder @@ -2,7 +2,7 @@ xml.tag! "user", :id => user.id, :display_name => user.display_name, :account_created => user.creation_time.xmlschema do xml.tag! "description", user.description if user.description - if current_user && current_user == user + if current_user && current_user == user && can?(:details, User) xml.tag! "contributor-terms", :agreed => user.terms_agreed.present?, :pd => user.consider_pd else @@ -24,7 +24,7 @@ xml.tag! "user", :id => user.id, :active => user.blocks_created.active.size end end - if current_user && current_user == user + if current_user && current_user == user && can?(:details, User) if user.home_lat && user.home_lon xml.tag! "home", :lat => user.home_lat, :lon => user.home_lon, diff --git a/app/views/application/_settings_menu.html.erb b/app/views/application/_settings_menu.html.erb new file mode 100644 index 000000000..03d8c74c2 --- /dev/null +++ b/app/views/application/_settings_menu.html.erb @@ -0,0 +1,18 @@ +<% content_for :heading_class, "pb-0" %> + +<% content_for :heading do %> + +<% end %> diff --git a/app/views/users/_contact.html.erb b/app/views/dashboards/_contact.html.erb similarity index 54% rename from app/views/users/_contact.html.erb rename to app/views/dashboards/_contact.html.erb index c7e10c060..7614c0c4d 100644 --- a/app/views/users/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -4,21 +4,23 @@ :icon => image_path(type == "friend" ? "marker-blue.png" : "marker-green.png"), :description => render(:partial => "popup", :object => contact, :locals => { :type => type }) } %> -<%= tag.div :class => "contact-activity clearfix", :data => { :user => user_data } do %> - <%= user_thumbnail contact %> -
-

+<%= tag.div :class => "contact-activity clearfix row", :data => { :user => user_data } do %> +

+ <%= user_thumbnail contact, :class => "user_thumbnail_no_margins" %> +
+
+

<%= link_to contact.display_name, user_path(contact) %> <% if @user.home_lon and @user.home_lat and contact.home_lon and contact.home_lat %> <% distance = @user.distance(contact) %> <% if distance < 1 %> - (<%= t "users.show.m away", :count => (distance * 1000).round %>) + (<%= t ".m away", :count => (distance * 1000).round %>) <% else %> - (<%= t "users.show.km away", :count => distance.round %>) + (<%= t ".km away", :count => distance.round %>) <% end %> <% end %>

-

+

<% changeset = contact.changesets.first %> <% if changeset %> <%= t("users.show.latest edit", :ago => time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")) %> @@ -31,15 +33,17 @@ <% end %>

-
    -
  • <%= link_to t("users.show.send message"), new_message_path(contact) %>
  • -
  • - <% if current_user.is_friends_with?(contact) %> - <%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> - <% else %> - <%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> - <% end %> -
  • -
+
<% end %> diff --git a/app/views/users/_popup.html.erb b/app/views/dashboards/_popup.html.erb similarity index 100% rename from app/views/users/_popup.html.erb rename to app/views/dashboards/_popup.html.erb diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb new file mode 100644 index 000000000..9aa4abed4 --- /dev/null +++ b/app/views/dashboards/show.html.erb @@ -0,0 +1,65 @@ +<% content_for :heading do %> +

<%= t ".title" %>

+<% end %> + +
+ <% if current_user and @user.id == current_user.id %> +
+ <% if @user.home_lat.nil? or @user.home_lon.nil? %> +
+

<%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %>

+
+ <% else %> + <% content_for :head do %> + <%= javascript_include_tag "user" %> + <% end %> + <% user_data = { + :lon => current_user.home_lon, + :lat => current_user.home_lat, + :icon => image_path("marker-red.png"), + :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" }) + } %> + <%= tag.div "", :id => "map", :class => "content_map", :data => { :user => user_data } %> + <% end %> + + <% friends = @user.friends %> + <% nearby = @user.nearby - friends %> +
+ +
+

<%= t ".my friends" %>

+ + <% if friends.empty? %> + <%= t ".no friends" %> + <% else %> + +
+ <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %> +
+ <% end %> + +
+ +

<%= t ".nearby users" %>

+ + <% if nearby.empty? %> + <%= t ".no nearby users" %> + <% else %> + +
+ <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %> +
+ <% end %> +
+ <% end %> +
diff --git a/app/views/diary_entries/_diary_entry.html.erb b/app/views/diary_entries/_diary_entry.html.erb index 946c6ce17..4080b8f95 100644 --- a/app/views/diary_entries/_diary_entry.html.erb +++ b/app/views/diary_entries/_diary_entry.html.erb @@ -23,31 +23,33 @@ <%= render :partial => "location", :object => diary_entry %> <% end %> - +
diff --git a/app/views/diary_entries/index.html.erb b/app/views/diary_entries/index.html.erb index 80561cbbf..6803c761e 100644 --- a/app/views/diary_entries/index.html.erb +++ b/app/views/diary_entries/index.html.erb @@ -6,19 +6,21 @@ <% end %>

<%= @title %>

- + <% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index bd1c10c39..e9e88c1e0 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -94,6 +94,7 @@