From: Andy Allan Date: Wed, 28 Aug 2019 13:20:21 +0000 (+0200) Subject: Merge pull request #2266 from systemed/patch-2 X-Git-Tag: live~3208 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a7092491b069de43bb8d8c30d3526e7095c5cc98?hp=946deebf4c4799680fee76913752629f150d65f6 Merge pull request #2266 from systemed/patch-2 Add user_ class to diary entry div --- diff --git a/.gitignore b/.gitignore index 386f0513a..1328658c6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ node_modules public/assets public/attachments public/export +storage tmp diff --git a/.rubocop.yml b/.rubocop.yml index 7d2df0445..cbd62a052 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,8 @@ require: AllCops: TargetRubyVersion: 2.5 + Exclude: + - 'vendor/**/*' Rails: Enabled: true @@ -23,6 +25,10 @@ Metrics/BlockLength: Exclude: - 'config/routes.rb' +Metrics/ClassLength: + Exclude: + - 'test/**/*' + Naming/FileName: Exclude: - 'script/deliver-message' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 26b5aa64b..397215c03 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-06-05 09:04:25 +0100 using RuboCop version 0.71.0. +# on 2019-08-14 19:26:21 +0100 using RuboCop version 0.74.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 @@ -32,11 +32,11 @@ Lint/HandleExceptions: - 'app/controllers/api/amf_controller.rb' - 'app/controllers/users_controller.rb' -# Offense count: 703 +# Offense count: 699 Metrics/AbcSize: Max: 279 -# Offense count: 40 +# Offense count: 39 # Configuration parameters: CountComments, ExcludedMethods. # ExcludedMethods: refine Metrics/BlockLength: @@ -47,16 +47,16 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 5 -# Offense count: 68 +# Offense count: 25 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 1397 + Max: 645 # Offense count: 73 Metrics/CyclomaticComplexity: Max: 22 -# Offense count: 714 +# Offense count: 719 # Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: Max: 179 @@ -100,6 +100,14 @@ Naming/PredicateName: - 'app/models/user.rb' - 'lib/classic_pagination/pagination.rb' +# Offense count: 5 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'app/helpers/browse_tags_helper.rb' + - 'app/validators/characters_validator.rb' + - 'app/validators/whitespace_validator.rb' + # Offense count: 6 # Configuration parameters: Database, Include. # SupportedDatabases: mysql, postgresql @@ -165,11 +173,11 @@ Style/AsciiComments: Exclude: - 'test/models/message_test.rb' -# Offense count: 255 +# Offense count: 263 Style/Documentation: Enabled: false -# Offense count: 503 +# Offense count: 539 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, never @@ -182,15 +190,15 @@ Style/IfUnlessModifier: Exclude: - 'app/controllers/api/ways_controller.rb' -# Offense count: 74 +# Offense count: 70 # Cop supports --auto-correct. # Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 11 -# Offense count: 3320 +# Offense count: 3322 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 1073 + Max: 307 diff --git a/.travis.yml b/.travis.yml index 4d764d6ed..e4c81e4c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ before_script: - psql -U postgres -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/tmp/libpgosm', 'tile_for_point' LANGUAGE C STRICT" openstreetmap - psql -U postgres -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/tmp/libpgosm', 'xid_to_int4' LANGUAGE C STRICT" openstreetmap - cp config/travis.database.yml config/database.yml + - cp config/example.storage.yml config/storage.yml - touch config/settings.local.yml - bundle exec rake db:migrate - bundle exec rake i18n:js:export diff --git a/Gemfile b/Gemfile index f41ac015b..c2bb066b7 100644 --- a/Gemfile +++ b/Gemfile @@ -56,7 +56,6 @@ gem "http_accept_language", "~> 2.0.0" gem "i18n-js", ">= 3.0.0" gem "oauth-plugin", ">= 0.5.1" gem "openstreetmap-deadlock_retry", ">= 1.3.0", :require => "deadlock_retry" -gem "paperclip", "~> 5.2" gem "rack-cors" gem "rails-i18n", "~> 4.0.0" gem "record_tag_helper" @@ -126,6 +125,12 @@ gem "mimemagic" # Used for browser detection gem "browser" +# Used for S3 object storage +gem "aws-sdk-s3" + +# Used to resize user images +gem "mini_magick" + # Gems useful for development group :development do gem "annotate" diff --git a/Gemfile.lock b/Gemfile.lock index 80f946845..a4104c536 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,11 +60,27 @@ GEM ast (2.4.0) autoprefixer-rails (8.6.5) execjs + aws-eventstream (1.0.3) + aws-partitions (1.206.0) + aws-sdk-core (3.64.0) + aws-eventstream (~> 1.0, >= 1.0.2) + aws-partitions (~> 1.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-kms (1.24.0) + aws-sdk-core (~> 3, >= 3.61.1) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.46.0) + aws-sdk-core (~> 3, >= 3.61.1) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.1.0) + aws-eventstream (~> 1.0, >= 1.0.2) better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - better_html (1.0.13) + better_html (1.0.14) actionview (>= 4.0) activesupport (>= 4.0) ast (~> 2.0) @@ -77,12 +93,12 @@ GEM debug_inspector (>= 0.0.1) bootsnap (1.4.4) msgpack (~> 1.0) - browser (2.5.3) + browser (2.6.1) builder (3.2.3) bzip2-ffi (1.0.0) ffi (~> 1.0) cancancan (3.0.1) - canonical-rails (0.2.5) + canonical-rails (0.2.6) rails (>= 4.1, < 6.1) capybara (2.18.0) addressable @@ -91,7 +107,6 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (>= 2.0, < 4.0) - climate_control (0.2.0) cliver (0.3.2) coderay (1.1.2) coffee-rails (4.2.2) @@ -104,10 +119,10 @@ GEM composite_primary_keys (11.1.0) activerecord (~> 5.2.1) concurrent-ruby (1.1.5) - config (1.7.1) - activesupport (>= 3.0) - deep_merge (~> 1.2.1) - dry-validation (>= 0.12.2) + config (2.0.0) + activesupport (>= 4.2) + deep_merge (~> 1.2, >= 1.2.1) + dry-schema (~> 1.0) coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) @@ -120,42 +135,44 @@ GEM dalli (2.7.10) debug_inspector (0.0.3) deep_merge (1.2.1) - delayed_job (4.1.5) - activesupport (>= 3.0, < 5.3) - delayed_job_active_record (4.1.3) - activerecord (>= 3.0, < 5.3) + delayed_job (4.1.8) + activesupport (>= 3.0, < 6.1) + delayed_job_active_record (4.1.4) + activerecord (>= 3.0, < 6.1) delayed_job (>= 3.0, < 5) - docile (1.3.1) + docile (1.3.2) dry-configurable (0.8.3) concurrent-ruby (~> 1.0) dry-core (~> 0.4, >= 0.4.7) - dry-container (0.7.0) + dry-container (0.7.2) concurrent-ruby (~> 1.0) dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.7) + dry-core (0.4.9) concurrent-ruby (~> 1.0) dry-equalizer (0.2.2) dry-inflector (0.1.2) - dry-logic (0.6.1) + dry-initializer (3.0.1) + dry-logic (1.0.3) concurrent-ruby (~> 1.0) dry-core (~> 0.2) dry-equalizer (~> 0.2) - dry-types (0.14.1) + dry-schema (1.3.3) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.8, >= 0.8.3) + dry-core (~> 0.4) + dry-equalizer (~> 0.2) + dry-initializer (~> 3.0) + dry-logic (~> 1.0) + dry-types (~> 1.0) + dry-types (1.1.1) concurrent-ruby (~> 1.0) dry-container (~> 0.3) dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.2) + dry-equalizer (~> 0.2, >= 0.2.2) dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 0.5, >= 0.5) - dry-validation (0.13.3) - concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1, >= 0.1.3) - dry-core (~> 0.2, >= 0.2.1) - dry-equalizer (~> 0.2) - dry-logic (~> 0.5, >= 0.5.0) - dry-types (~> 0.14.0) + dry-logic (~> 1.0, >= 1.0.2) dynamic_form (1.1.4) - erb_lint (0.0.28) + erb_lint (0.0.29) activesupport better_html (~> 1.0.7) html_tokenizer @@ -174,37 +191,38 @@ GEM faraday (0.15.4) multipart-post (>= 1.2, < 3) ffi (1.11.1) - ffi-libarchive (0.4.6) + ffi-libarchive (0.4.10) ffi (~> 1.0) - fspath (3.1.1) + fspath (3.1.2) gd2-ffij (0.4.0) ffi (>= 1.0.0) geoip (1.6.4) globalid (0.4.2) activesupport (>= 4.2.0) - hashdiff (0.4.0) + hashdiff (1.0.0) hashie (3.6.0) html_tokenizer (0.0.7) htmlentities (4.3.4) http_accept_language (2.0.5) i18n (0.9.5) concurrent-ruby (~> 1.0) - i18n-js (3.2.3) + i18n-js (3.3.0) i18n (>= 0.6.6) - image_optim (0.26.4) + image_optim (0.26.5) exifr (~> 1.2, >= 1.2.2) fspath (~> 3.0) image_size (>= 1.5, < 3) in_threads (~> 1.3) progress (~> 3.0, >= 3.0.1) - image_optim_rails (0.4.2) + image_optim_rails (0.4.3) image_optim (~> 0.24) rails sprockets - image_size (2.0.1) - in_threads (1.5.2) - jaro_winkler (1.5.2) - jquery-rails (4.3.3) + image_size (2.0.2) + in_threads (1.5.3) + jaro_winkler (1.5.3) + jmespath (1.4.0) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -235,19 +253,17 @@ GEM marcel (0.3.3) mimemagic (~> 0.3.2) method_source (0.9.2) - mime-types (3.2.2) - mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) mimemagic (0.3.3) - mini_mime (1.0.1) + mini_magick (4.9.5) + mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.11.3) - msgpack (1.2.10) + msgpack (1.3.1) multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.1.1) - nio4r (2.3.1) - nokogiri (1.10.3) + nio4r (2.4.0) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) nokogumbo (2.0.1) nokogiri (~> 1.8, >= 1.8.4) @@ -271,10 +287,10 @@ GEM omniauth-github (1.3.0) omniauth (~> 1.5) omniauth-oauth2 (>= 1.4.0, < 2.0) - omniauth-google-oauth2 (0.7.0) + omniauth-google-oauth2 (0.8.0) jwt (>= 2.0) omniauth (>= 1.1.1) - omniauth-oauth2 (>= 1.5) + omniauth-oauth2 (>= 1.6) omniauth-mediawiki (0.0.4) jwt (~> 2.0) omniauth-oauth (~> 1.0) @@ -291,12 +307,6 @@ GEM multi_json (~> 1.12) omniauth-oauth2 (~> 1.4) openstreetmap-deadlock_retry (1.3.0) - paperclip (5.3.0) - activemodel (>= 4.2.0) - activesupport (>= 4.2.0) - mime-types - mimemagic (~> 0.3.0) - terrapin (~> 0.6.0) parallel (1.17.0) parser (2.6.3.0) ast (~> 2.4.0) @@ -305,9 +315,9 @@ GEM capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - progress (3.5.1) + progress (3.5.2) psych (3.1.0) - public_suffix (3.1.0) + public_suffix (3.1.1) puma (3.12.1) quad_tile (1.0.1) r2 (0.2.7) @@ -339,7 +349,7 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) + rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) rails-i18n (4.0.2) i18n (~> 0.6) @@ -351,7 +361,7 @@ GEM rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (12.3.2) + rake (12.3.3) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) @@ -360,20 +370,20 @@ GEM request_store (1.4.1) rack (>= 1.4) rinku (2.0.6) - rotp (5.0.0) + rotp (5.1.0) addressable (~> 2.5) - rubocop (0.71.0) + rubocop (0.74.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.6) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) - rubocop-performance (1.3.0) - rubocop (>= 0.68.0) - rubocop-rails (2.0.0) - rack (>= 2.0) - rubocop (>= 0.70.0) + rubocop-performance (1.4.1) + rubocop (>= 0.71.0) + rubocop-rails (2.3.1) + rack (>= 1.1) + rubocop (>= 0.72.0) ruby-openid (2.7.0) ruby-progressbar (1.10.1) ruby_dep (1.5.0) @@ -385,19 +395,19 @@ GEM sassc (2.0.1) ffi (~> 1.9) rake - sassc-rails (2.1.1) + sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) sprockets-rails tilt - secure_headers (6.1.0) + secure_headers (6.1.1) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - smart_properties (1.14.0) + smart_properties (1.15.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -405,16 +415,14 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - strong_migrations (0.4.0) + strong_migrations (0.4.1) activerecord (>= 5) term-ansicolor (1.7.1) tins (~> 1.0) - terrapin (0.6.0) - climate_control (>= 0.0.3, < 1.0) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.9) - tins (1.20.3) + tins (1.21.1) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.20) @@ -423,13 +431,13 @@ GEM validates_email_format_of (1.6.3) i18n vendorer (0.2.0) - webmock (3.6.0) + webmock (3.6.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.0) + websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.4) xpath (3.2.0) nokogiri (~> 1.8) @@ -444,6 +452,7 @@ DEPENDENCIES activerecord-import annotate autoprefixer-rails (~> 8.6.3) + aws-sdk-s3 better_errors bigdecimal (~> 1.1.0) binding_of_caller @@ -480,6 +489,7 @@ DEPENDENCIES listen logstasher mimemagic + mini_magick minitest (~> 5.1) oauth-plugin (>= 0.5.1) omniauth @@ -490,7 +500,6 @@ DEPENDENCIES omniauth-openid omniauth-windowslive openstreetmap-deadlock_retry (>= 1.3.0) - paperclip (~> 5.2) pg poltergeist psych diff --git a/INSTALL.md b/INSTALL.md index b03c97515..2b1b4b5de 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -24,14 +24,15 @@ of packages required before you can get the various gems installed. * Bundler * Javascript Runtime -These can be installed on Ubuntu 16.04 or later with: +These can be installed on Ubuntu 18.04 or later with: ``` -sudo apt-get install ruby2.5 libruby2.5 ruby2.5-dev \ +sudo apt-get update +sudo apt-get install ruby2.5 libruby2.5 ruby2.5-dev bundler \ libmagickwand-dev libxml2-dev libxslt1-dev nodejs \ - apache2 apache2-dev build-essential git-core \ + apache2 apache2-dev build-essential git-core phantomjs \ postgresql postgresql-contrib libpq-dev postgresql-server-dev-all \ - libsasl2-dev imagemagick libffi-dev + libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev sudo gem2.5 install bundler ``` @@ -46,7 +47,8 @@ sudo dnf install ruby ruby-devel rubygem-rdoc rubygem-bundler rubygems \ libxml2-devel js \ gcc gcc-c++ git \ postgresql postgresql-server postgresql-contrib postgresql-devel \ - perl-podlators ImageMagick libffi-devel nodejs-yarn + perl-podlators ImageMagick libffi-devel gd-devel libarchive-devel \ + bzip2-devel nodejs-yarn ``` If you didn't already have PostgreSQL installed then create a PostgreSQL instance and start the server: @@ -122,6 +124,15 @@ We use [Yarn](https://yarnpkg.com/) to manage the Node.js modules required for t bundle exec rake yarn:install ``` +## Storage setup + +The Rails port needs to be configured with an object storage facility - for +development and testing purposes you can use the example configuration: + +``` +cp config/example.storage.yml config/storage.yml +``` + ## Database setup The Rails Port uses three databases - one for development, one for testing, and one for production. The database-specific configuration @@ -207,7 +218,7 @@ Rails comes with a built-in webserver, so that you can test on your own machine bundle exec rails server ``` -You can now view the site in your favourite web-browser at `http://localhost:3000/` +You can now view the site in your favourite web-browser at [http://localhost:3000/](http://localhost:3000/) Note that the OSM map tiles you see aren't created from your local database - they are just the standard map tiles. diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 28380392d..c34f357a9 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -44,6 +44,7 @@ class Ability can [:account, :go_public, :make_friend, :remove_friend], User if user.moderator? + can [:hide, :hidecomment], DiaryEntry can [:index, :show, :resolve, :ignore, :reopen], Issue can :create, IssueComment can [:new, :create, :edit, :update, :destroy], Redaction @@ -51,7 +52,7 @@ class Ability end if user.administrator? - can [:hide, :unhide, :hidecomment, :unhidecomment], [DiaryEntry, DiaryComment] + can [:hide, :unhide, :hidecomment, :unhidecomment], DiaryEntry can [:index, :show, :resolve, :ignore, :reopen], Issue can :create, IssueComment can [:set_status, :delete, :index], User diff --git a/app/abilities/api_ability.rb b/app/abilities/api_ability.rb index 9fc3cdd9c..80245eeaa 100644 --- a/app/abilities/api_ability.rb +++ b/app/abilities/api_ability.rb @@ -9,6 +9,7 @@ class ApiAbility can :index, :map can :show, :permission can [:search_all, :search_nodes, :search_ways, :search_relations], :search + can :show, :version if Settings.status != "database_offline" can [:show, :download, :query], Changeset diff --git a/app/assets/images/users/images/large.png b/app/assets/images/avatar_large.png similarity index 100% rename from app/assets/images/users/images/large.png rename to app/assets/images/avatar_large.png diff --git a/app/assets/images/users/images/small.png b/app/assets/images/avatar_small.png similarity index 100% rename from app/assets/images/users/images/small.png rename to app/assets/images/avatar_small.png diff --git a/app/assets/images/users/images/user-icons.svg b/app/assets/images/avatars.svg similarity index 100% rename from app/assets/images/users/images/user-icons.svg rename to app/assets/images/avatars.svg diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4a310f22b..fbc76e4a8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,17 +17,16 @@ //= require richtext //= require querystring -var querystring = require("querystring-component"); - /* * Called as the user scrolls/zooms around to maniplate hrefs of the * view tab and various other links */ window.updateLinks = function (loc, zoom, layers, object) { $(".geolink").each(function (index, link) { - var href = link.href.split(/[?#]/)[0], - args = querystring.parse(link.search.substring(1)), - editlink = $(link).hasClass("editlink"); + var querystring = require("querystring-component"), + href = link.href.split(/[?#]/)[0], + args = querystring.parse(link.search.substring(1)), + editlink = $(link).hasClass("editlink"); delete args.node; delete args.way; diff --git a/app/assets/javascripts/edit/id.js.erb b/app/assets/javascripts/edit/id.js.erb index 2ce8974f5..23726519e 100644 --- a/app/assets/javascripts/edit/id.js.erb +++ b/app/assets/javascripts/edit/id.js.erb @@ -1,4 +1,7 @@ +//= require querystring + $(document).ready(function () { + var querystring = require("querystring-component"); var id = $("#id-embed"); if (id.data("key")) { @@ -20,14 +23,15 @@ $(document).ready(function () { if (hashParams.background) params.background = hashParams.background; if (hashParams.comment) params.comment = hashParams.comment; - if (hashParams.hashtags) params.hashtags = hashParams.hashtags; - if (hashParams.source) params.source = hashParams.source; if (hashParams.disable_features) params.disable_features = hashParams.disable_features; - if (hashParams.offset) params.offset = hashParams.offset; - if (hashParams.walkthrough) params.walkthrough = hashParams.walkthrough; + if (hashParams.hashtags) params.hashtags = hashParams.hashtags; if (hashParams.locale) params.locale = hashParams.locale; if (hashParams.maprules) params.maprules = hashParams.maprules; + if (hashParams.offset) params.offset = hashParams.offset; + if (hashParams.photo_overlay) params.photo_overlay = hashParams.photo_overlay; if (hashParams.presets) params.presets = hashParams.presets; + if (hashParams.source) params.source = hashParams.source; + if (hashParams.walkthrough) params.walkthrough = hashParams.walkthrough; if (id.data("gpx")) { params.gpx = id.data("gpx"); diff --git a/app/assets/javascripts/id.js b/app/assets/javascripts/id.js index 0aae749f7..ba16d9df2 100644 --- a/app/assets/javascripts/id.js +++ b/app/assets/javascripts/id.js @@ -27,8 +27,8 @@ document.addEventListener("DOMContentLoaded", function () { id.map().on("move.embed", parent.$.throttle(250, function () { if (id.inIntro()) return; var zoom = ~~id.map().zoom(), - center = id.map().center(), - llz = { lon: center[0], lat: center[1], zoom: zoom }; + center = id.map().center(), + llz = { lon: center[0], lat: center[1], zoom: zoom }; parent.updateLinks(llz, zoom); diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 6228b2376..2c7d70e11 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -21,8 +21,11 @@ //= require index/query //= require router //= require bowser +//= require querystring $(document).ready(function () { + var querystring = require("querystring-component"); + var loaderTimeout; var map = new L.OSM.Map("map", { @@ -32,6 +35,8 @@ $(document).ready(function () { }); OSM.loadSidebarContent = function (path, callback) { + var content_path = path; + map.setSidebarOverlaid(false); clearTimeout(loaderTimeout); @@ -42,17 +47,17 @@ $(document).ready(function () { // IE<10 doesn't respect Vary: X-Requested-With header, so // prevent caching the XHR response as a full-page URL. - if (path.indexOf("?") >= 0) { - path += "&xhr=1"; + if (content_path.indexOf("?") >= 0) { + content_path += "&xhr=1"; } else { - path += "?xhr=1"; + content_path += "?xhr=1"; } $("#sidebar_content") .empty(); $.ajax({ - url: path, + url: content_path, dataType: "html", complete: function (xhr) { clearTimeout(loaderTimeout); @@ -234,7 +239,7 @@ $(document).ready(function () { e.preventDefault(); var data = $(this).data(), - center = L.latLng(data.lat, data.lon); + center = L.latLng(data.lat, data.lon); map.setView(center, data.zoom); L.marker(center, { icon: OSM.getUserIcon() }).addTo(map); @@ -260,13 +265,13 @@ $(document).ready(function () { if (object) query.select = object.type + object.id; var iframe = $("