]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2175'
authorTom Hughes <tom@compton.nu>
Tue, 26 Mar 2019 19:14:04 +0000 (19:14 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 26 Mar 2019 19:14:04 +0000 (19:14 +0000)
133 files changed:
.gitignore
.travis.yml
CONFIGURE.md
Gemfile
Gemfile.lock
INSTALL.md
app/abilities/ability.rb
app/abilities/capability.rb
app/assets/images/banners/saveyourinternet.png [new file with mode: 0644]
app/assets/javascripts/embed.js.erb
app/assets/javascripts/osm.js.erb
app/controllers/api/amf_controller.rb
app/controllers/api/capabilities_controller.rb
app/controllers/api/changes_controller.rb
app/controllers/api/changeset_comments_controller.rb
app/controllers/api/changesets_controller.rb
app/controllers/api/map_controller.rb
app/controllers/api/nodes_controller.rb
app/controllers/api/notes_controller.rb
app/controllers/api/old_controller.rb
app/controllers/api/permissions_controller.rb
app/controllers/api/relations_controller.rb
app/controllers/api/search_controller.rb
app/controllers/api/swf_controller.rb
app/controllers/api/tracepoints_controller.rb
app/controllers/api/traces_controller.rb
app/controllers/api/user_preferences_controller.rb
app/controllers/api/users_controller.rb
app/controllers/api/ways_controller.rb
app/controllers/api_controller.rb [new file with mode: 0644]
app/controllers/application_controller.rb
app/controllers/browse_controller.rb
app/controllers/changeset_comments_controller.rb
app/controllers/changesets_controller.rb
app/controllers/diary_entries_controller.rb
app/controllers/geocoder_controller.rb
app/controllers/messages_controller.rb
app/controllers/oauth_controller.rb
app/controllers/site_controller.rb
app/controllers/traces_controller.rb
app/controllers/users_controller.rb
app/helpers/notifier_helper.rb
app/jobs/trace_destroyer_job.rb
app/jobs/trace_importer_job.rb
app/mailers/notifier.rb
app/models/changeset.rb
app/models/client_application.rb
app/models/request_token.rb
app/models/trace.rb
app/models/user.rb
app/models/user_block.rb
app/models/way.rb
app/views/api/capabilities/show.builder
app/views/api/changesets/_changeset.builder [new file with mode: 0644]
app/views/api/changesets/changeset.builder [new file with mode: 0644]
app/views/api/changesets/changesets.builder [new file with mode: 0644]
app/views/layouts/_head.html.erb
app/views/layouts/_header.html.erb
app/views/notifier/email_confirm.html.erb
app/views/notifier/email_confirm.text.erb
app/views/notifier/signup_confirm.html.erb
app/views/notifier/signup_confirm.text.erb
app/views/site/_id.html.erb
app/views/site/_potlatch2.html.erb
app/views/site/copyright.html.erb
app/views/site/edit.html.erb
app/views/site/id.html.erb
app/views/site/offline.html.erb
app/views/traces/_trace.html.erb
app/views/traces/show.html.erb
app/views/users/account.html.erb
app/views/users/blocked.html.erb
app/views/users/login.html.erb
app/views/users/suspended.html.erb
config/.gitignore
config/application.rb
config/banners.yml
config/environments/development.rb
config/environments/production.rb
config/example.application.yml [deleted file]
config/initializers/action_mailer.rb
config/initializers/canonical_rails.rb
config/initializers/config.rb [new file with mode: 0644]
config/initializers/omniauth.rb
config/initializers/paperclip.rb
config/initializers/secure_headers.rb
config/initializers/session_store.rb
config/locales/ar.yml
config/locales/arz.yml
config/locales/br.yml
config/locales/cs.yml
config/locales/de.yml
config/locales/diq.yml
config/locales/en.yml
config/locales/eo.yml
config/locales/es.yml
config/locales/eu.yml
config/locales/fa.yml
config/locales/fr.yml
config/locales/gl.yml
config/locales/ja.yml
config/locales/mk.yml
config/locales/nb.yml
config/locales/pt-BR.yml
config/locales/pt-PT.yml
config/locales/ro.yml
config/locales/ru.yml
config/locales/sr.yml
config/locales/tr.yml
config/locales/zh-TW.yml
config/preinitializer.rb [deleted file]
config/settings.yml [new file with mode: 0644]
config/settings/development.yml [new file with mode: 0644]
config/settings/production.yml [new file with mode: 0644]
config/settings/test.yml [new file with mode: 0644]
lib/auth.rb
lib/bounding_box.rb
lib/gpx.rb
lib/osm.rb
test/controllers/api/capabilities_controller_test.rb
test/controllers/api/changes_controller_test.rb
test/controllers/api/changesets_controller_test.rb
test/controllers/api/map_controller_test.rb
test/controllers/api/relations_controller_test.rb
test/controllers/api/tracepoints_controller_test.rb
test/controllers/api/traces_controller_test.rb
test/controllers/messages_controller_test.rb
test/controllers/site_controller_test.rb
test/controllers/traces_controller_test.rb
test/integration/user_blocks_test.rb
test/integration/user_terms_seen_test.rb
test/models/trace_test.rb
test/models/way_test.rb

index 1a2d35c6a28cc056de2646690384138a52a03caf..5ba4bc764093feadbe0fe7ac4219e1f6089c1321 100644 (file)
@@ -1,15 +1,18 @@
-log
-config/piwik.yml
+*~
+.DS_Store
+.idea
+.ruby-gemset
+.ruby-version
+.vagrant
 app/assets/javascripts/i18n
+config/environments/*.local.yml
+config/piwik.yml
+config/settings.local.yml
+config/settings/*.local.yml
+coverage
+doc
+log
 public/assets
 public/attachments
 public/export
 tmp
-.DS_Store
-*~
-doc
-.vagrant
-.ruby-gemset
-.ruby-version
-.idea
-coverage
index 9438622cda03b43284816b7cc50779a30804266f..1b99a514375447cc93ad5b9606f3d0063a67c593 100644 (file)
@@ -14,7 +14,6 @@ env:
   global:
     - OSM_MEMCACHE_SERVERS="127.0.0.1"
 before_script:
-  - cp config/example.application.yml config/application.yml
   - psql -U postgres -c "CREATE DATABASE openstreetmap"
   - psql -U postgres -c "CREATE EXTENSION btree_gist" openstreetmap
   - make -C db/functions libpgosm.so
@@ -23,6 +22,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
+  - touch config/settings.local.yml
   - bundle exec rake db:migrate
   - bundle exec rake i18n:js:export
 script:
index c6444ffa9efe773c5edda6b735148f4d502b6c81..91a64119ed33cb5d7ccf057ba266a6684f323bce 100644 (file)
@@ -2,6 +2,10 @@
 
 After [installing](INSTALL.md) this software, you may need to carry out some of these configuration steps, depending on your tasks.
 
+## Application configuration
+
+Many settings are available in `config/settings.yml`. You can customize your installation of The Rails Port by overriding these values using `config/settings.local.yml`
+
 ## Populating the database
 
 Your installation comes with no geographic data loaded. You can either create new data using one of the editors (Potlatch 2, iD, JOSM etc) or by loading an OSM extract.
@@ -71,11 +75,11 @@ Do the following:
 * Everything else can be left with the default blank values.
 * Click the "Register" button
 * On the next page, copy the "consumer key"
-* Edit config/application.yml in your rails tree
-* Uncomment and change the "potlatch2_key" configuration value
+* Edit config/settings.local.yml in your rails tree
+* Add the "potlatch2_key" configuration key and the consumer key as the value
 * Restart your rails server
 
-An example excerpt from application.yml:
+An example excerpt from settings.local.yml:
 
 ```
 # Default editor
@@ -86,8 +90,6 @@ potlatch2_key: "8lFmZPsagHV4l3rkAHq0hWY5vV3Ctl3oEFY1aXth"
 
 Follow the same process for registering and configuring iD (`id_key`) and the website/Notes (`oauth_key`), or to save time, simply reuse the same consumer key for each.
 
-**NOTE:** If you forget to set up OAuth, then you will get an error message similar to `uninitialized constant ActionView::CompiledTemplates::ID_KEY`.
-
 ## Troubleshooting
 
 Rails has its own log.  To inspect the log, do this:
diff --git a/Gemfile b/Gemfile
index 275388666e961410fc0c18f4a1ccbb1053acc31c..83f298101fcd38c2459a8ce25087333864c376d7 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
 source "https://rubygems.org"
 
 # Require rails
-gem "rails", "5.2.2"
+gem "rails", "5.2.2.1"
 
 # Require things which have moved to gems in ruby 1.9
 gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19
@@ -46,8 +46,10 @@ gem "image_optim_rails"
 # Load rails plugins
 gem "actionpack-page_caching"
 gem "active_record_union"
+gem "activerecord-import"
 gem "cancancan"
 gem "composite_primary_keys", "~> 11.1.0"
+gem "config"
 gem "delayed_job_active_record"
 gem "dynamic_form"
 gem "http_accept_language", "~> 2.0.0"
index 0dd07a95e03c4d403e6c052a2d98892ab3a8c7fd..57feba1fd0c4623ab2f34d99ed4f3f4c5d2ea0e3 100644 (file)
@@ -2,49 +2,51 @@ GEM
   remote: https://rubygems.org/
   specs:
     SystemTimer (1.2.3)
-    aasm (5.0.1)
+    aasm (5.0.2)
       concurrent-ruby (~> 1.0)
-    actioncable (5.2.2)
-      actionpack (= 5.2.2)
+    actioncable (5.2.2.1)
+      actionpack (= 5.2.2.1)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
-    actionmailer (5.2.2)
-      actionpack (= 5.2.2)
-      actionview (= 5.2.2)
-      activejob (= 5.2.2)
+    actionmailer (5.2.2.1)
+      actionpack (= 5.2.2.1)
+      actionview (= 5.2.2.1)
+      activejob (= 5.2.2.1)
       mail (~> 2.5, >= 2.5.4)
       rails-dom-testing (~> 2.0)
-    actionpack (5.2.2)
-      actionview (= 5.2.2)
-      activesupport (= 5.2.2)
+    actionpack (5.2.2.1)
+      actionview (= 5.2.2.1)
+      activesupport (= 5.2.2.1)
       rack (~> 2.0)
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.0, >= 1.0.2)
     actionpack-page_caching (1.1.1)
       actionpack (>= 4.0.0, < 6)
-    actionview (5.2.2)
-      activesupport (= 5.2.2)
+    actionview (5.2.2.1)
+      activesupport (= 5.2.2.1)
       builder (~> 3.1)
       erubi (~> 1.4)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.0, >= 1.0.3)
     active_record_union (1.3.0)
       activerecord (>= 4.0)
-    activejob (5.2.2)
-      activesupport (= 5.2.2)
+    activejob (5.2.2.1)
+      activesupport (= 5.2.2.1)
       globalid (>= 0.3.6)
-    activemodel (5.2.2)
-      activesupport (= 5.2.2)
-    activerecord (5.2.2)
-      activemodel (= 5.2.2)
-      activesupport (= 5.2.2)
+    activemodel (5.2.2.1)
+      activesupport (= 5.2.2.1)
+    activerecord (5.2.2.1)
+      activemodel (= 5.2.2.1)
+      activesupport (= 5.2.2.1)
       arel (>= 9.0)
-    activestorage (5.2.2)
-      actionpack (= 5.2.2)
-      activerecord (= 5.2.2)
+    activerecord-import (0.28.1)
+      activerecord (>= 3.2)
+    activestorage (5.2.2.1)
+      actionpack (= 5.2.2.1)
+      activerecord (= 5.2.2.1)
       marcel (~> 0.3.1)
-    activesupport (5.2.2)
+    activesupport (5.2.2.1)
       concurrent-ruby (~> 1.0, >= 1.0.2)
       i18n (>= 0.7, < 2)
       minitest (~> 5.1)
@@ -65,7 +67,7 @@ GEM
     bigdecimal (1.1.0)
     binding_of_caller (0.8.0)
       debug_inspector (>= 0.0.1)
-    bootsnap (1.4.0)
+    bootsnap (1.4.1)
       msgpack (~> 1.0)
     browser (2.5.3)
     builder (3.2.3)
@@ -91,7 +93,11 @@ GEM
     coffee-script-source (1.12.2)
     composite_primary_keys (11.1.0)
       activerecord (~> 5.2.1)
-    concurrent-ruby (1.1.4)
+    concurrent-ruby (1.1.5)
+    config (1.7.1)
+      activesupport (>= 3.0)
+      deep_merge (~> 1.2.1)
+      dry-validation (>= 0.12.2)
     coveralls (0.8.22)
       json (>= 1.8, < 3)
       simplecov (~> 0.16.1)
@@ -103,25 +109,54 @@ GEM
     crass (1.0.4)
     dalli (2.7.9)
     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 (>= 3.0, < 5)
     docile (1.3.1)
+    dry-configurable (0.8.2)
+      concurrent-ruby (~> 1.0)
+      dry-core (~> 0.4, >= 0.4.7)
+    dry-container (0.7.0)
+      concurrent-ruby (~> 1.0)
+      dry-configurable (~> 0.1, >= 0.1.3)
+    dry-core (0.4.7)
+      concurrent-ruby (~> 1.0)
+    dry-equalizer (0.2.2)
+    dry-inflector (0.1.2)
+    dry-logic (0.5.0)
+      dry-container (~> 0.2, >= 0.2.6)
+      dry-core (~> 0.2)
+      dry-equalizer (~> 0.2)
+    dry-types (0.14.0)
+      concurrent-ruby (~> 1.0)
+      dry-container (~> 0.3)
+      dry-core (~> 0.4, >= 0.4.4)
+      dry-equalizer (~> 0.2)
+      dry-inflector (~> 0.1, >= 0.1.2)
+      dry-logic (~> 0.5, >= 0.5)
+    dry-validation (0.13.0)
+      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.14)
     dynamic_form (1.1.4)
     erubi (1.8.0)
     execjs (2.7.0)
     exifr (1.3.6)
-    factory_bot (5.0.0)
+    factory_bot (5.0.2)
       activesupport (>= 4.2.0)
     factory_bot_rails (5.0.1)
       factory_bot (~> 5.0.0)
       railties (>= 4.2.0)
-    fakefs (0.19.1)
+    fakefs (0.20.0)
     faraday (0.15.4)
       multipart-post (>= 1.2, < 3)
-    ffi (1.9.25)
+    ffi (1.10.0)
     fspath (3.1.0)
     gd2-ffij (0.3.0)
       ffi (>= 1.0.0)
@@ -157,7 +192,7 @@ GEM
       execjs (>= 1.4.0)
       multi_json (~> 1.0)
       therubyracer (~> 0.12.1)
-    json (2.1.0)
+    json (2.2.0)
     jsonify (0.3.1)
       multi_json (~> 1.0)
     jsonify-rails (0.3.2)
@@ -192,7 +227,7 @@ GEM
     mini_mime (1.0.1)
     mini_portile2 (2.4.0)
     minitest (5.11.3)
-    msgpack (1.2.6)
+    msgpack (1.2.9)
     multi_json (1.13.1)
     multi_xml (0.6.0)
     multipart-post (2.0.0)
@@ -221,7 +256,7 @@ GEM
     omniauth-github (1.3.0)
       omniauth (~> 1.5)
       omniauth-oauth2 (>= 1.4.0, < 2.0)
-    omniauth-google-oauth2 (0.6.0)
+    omniauth-google-oauth2 (0.6.1)
       jwt (>= 2.0)
       omniauth (>= 1.1.1)
       omniauth-oauth2 (>= 1.5)
@@ -247,7 +282,7 @@ GEM
       mime-types
       mimemagic (~> 0.3.0)
       terrapin (~> 0.6.0)
-    parallel (1.13.0)
+    parallel (1.14.0)
     parser (2.6.0.0)
       ast (~> 2.4.0)
     pg (0.21.0)
@@ -270,18 +305,18 @@ GEM
     rack-test (1.1.0)
       rack (>= 1.0, < 3)
     rack-uri_sanitizer (0.0.2)
-    rails (5.2.2)
-      actioncable (= 5.2.2)
-      actionmailer (= 5.2.2)
-      actionpack (= 5.2.2)
-      actionview (= 5.2.2)
-      activejob (= 5.2.2)
-      activemodel (= 5.2.2)
-      activerecord (= 5.2.2)
-      activestorage (= 5.2.2)
-      activesupport (= 5.2.2)
+    rails (5.2.2.1)
+      actioncable (= 5.2.2.1)
+      actionmailer (= 5.2.2.1)
+      actionpack (= 5.2.2.1)
+      actionview (= 5.2.2.1)
+      activejob (= 5.2.2.1)
+      activemodel (= 5.2.2.1)
+      activerecord (= 5.2.2.1)
+      activestorage (= 5.2.2.1)
+      activesupport (= 5.2.2.1)
       bundler (>= 1.3.0)
-      railties (= 5.2.2)
+      railties (= 5.2.2.1)
       sprockets-rails (>= 2.0.0)
     rails-controller-testing (1.0.4)
       actionpack (>= 5.0.1.x)
@@ -295,9 +330,9 @@ GEM
     rails-i18n (4.0.2)
       i18n (~> 0.6)
       rails (>= 4.0)
-    railties (5.2.2)
-      actionpack (= 5.2.2)
-      activesupport (= 5.2.2)
+    railties (5.2.2.1)
+      actionpack (= 5.2.2.1)
+      activesupport (= 5.2.2.1)
       method_source
       rake (>= 0.8.7)
       thor (>= 0.19.0, < 2.0)
@@ -312,26 +347,27 @@ GEM
     request_store (1.4.1)
       rack (>= 1.4)
     rinku (2.0.4)
-    rotp (4.0.2)
+    rotp (4.1.0)
       addressable (~> 2.5)
-    rubocop (0.64.0)
+    rubocop (0.65.0)
       jaro_winkler (~> 1.5.1)
       parallel (~> 1.10)
       parser (>= 2.5, != 2.5.1.1)
       powerpack (~> 0.1)
+      psych (>= 3.1.0)
       rainbow (>= 2.2.2, < 4.0)
       ruby-progressbar (~> 1.7)
       unicode-display_width (~> 1.4.0)
     ruby-openid (2.7.0)
     ruby-progressbar (1.10.0)
     ruby_dep (1.5.0)
-    safe_yaml (1.0.4)
+    safe_yaml (1.0.5)
     sanitize (5.0.0)
       crass (~> 1.0.2)
       nokogiri (>= 1.8.0)
       nokogumbo (~> 2.0)
-    sassc (2.0.0)
-      ffi (~> 1.9.6)
+    sassc (2.0.1)
+      ffi (~> 1.9)
       rake
     sassc-rails (2.1.0)
       railties (>= 4.0.0)
@@ -339,7 +375,7 @@ GEM
       sprockets (> 3.0)
       sprockets-rails
       tilt
-    secure_headers (6.0.0)
+    secure_headers (6.1.0)
     simplecov (0.16.1)
       docile (~> 1.1)
       json (>= 1.8, < 3)
@@ -389,6 +425,7 @@ DEPENDENCIES
   aasm
   actionpack-page_caching
   active_record_union
+  activerecord-import
   annotate
   autoprefixer-rails (~> 8.6.3)
   better_errors
@@ -401,6 +438,7 @@ DEPENDENCIES
   capybara (~> 2.13)
   coffee-rails (~> 4.2)
   composite_primary_keys (~> 11.1.0)
+  config
   coveralls
   dalli
   delayed_job_active_record
@@ -442,7 +480,7 @@ DEPENDENCIES
   r2 (~> 0.2.7)
   rack-cors
   rack-uri_sanitizer
-  rails (= 5.2.2)
+  rails (= 5.2.2.1)
   rails-controller-testing
   rails-i18n (~> 4.0.0)
   record_tag_helper
index b1fb1eafb822ab0a3a8a453c616d276da76e2e39..5b2652c3e0cc4dc114b5bd692f01f375c7e6eac3 100644 (file)
@@ -114,16 +114,6 @@ cd openstreetmap-website
 bundle install
 ```
 
-## Application setup
-
-We need to create the `config/application.yml` file from the example template. This contains various configuration options.
-
-```
-cp config/example.application.yml config/application.yml
-```
-
-You can customize your installation of The Rails Port by changing the values in `config/application.yml`
-
 ## Database setup
 
 The Rails Port uses three databases -  one for development, one for testing, and one for production. The database-specific configuration
index 5e8ef997fb8523e19f72800b027b43ef452d0933..7e8e921a29f4d0c35b69c4a2d1a45331d41147cf 100644 (file)
@@ -8,72 +8,79 @@ class Ability
          :changeset, :note, :new_note, :query], :browse
     can :show, :capability
     can :index, :change
-    can [:index, :feed, :show, :download, :query], Changeset
-    can :index, ChangesetComment
     can :search, :direction
     can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :preview, :copyright, :key, :id], :site
-    can [:index, :rss, :show, :comments], DiaryEntry
     can [:finish, :embed], :export
     can [:search, :search_latlon, :search_ca_postcode, :search_osm_nominatim,
          :search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
     can :index, :map
-    can [:index, :create, :comment, :feed, :show, :search, :mine], Note
     can [:token, :request_token, :access_token, :test_request], :oauth
     can :show, :permission
-    can [:index, :show], Redaction
     can [:search_all, :search_nodes, :search_ways, :search_relations], :search
     can [:trackpoints], :swf
-    can [:index, :show, :data, :georss, :picture, :icon], Trace
-    can :index, Tracepoint
-    can [:terms, :api_users, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :api_read, :auth_success, :auth_failure], User
-    can [:index, :show, :blocks_on, :blocks_by], UserBlock
-    can [:index, :show], Node
-    can [:index, :show, :full, :ways_for_node], Way
-    can [:index, :show, :full, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
-    can [:history, :version], OldNode
-    can [:history, :version], OldWay
-    can [:history, :version], OldRelation
+
+    if Settings.status != "database_offline"
+      can [:index, :feed, :show, :download, :query], Changeset
+      can :index, ChangesetComment
+      can [:index, :rss, :show, :comments], DiaryEntry
+      can [:index, :create, :comment, :feed, :show, :search, :mine], Note
+      can [:index, :show], Redaction
+      can [:index, :show, :data, :georss, :picture, :icon], Trace
+      can :index, Tracepoint
+      can [:terms, :api_users, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :api_read, :auth_success, :auth_failure], User
+      can [:index, :show, :blocks_on, :blocks_by], UserBlock
+      can [:index, :show], Node
+      can [:index, :show, :full, :ways_for_node], Way
+      can [:index, :show, :full, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
+      can [:history, :version], OldNode
+      can [:history, :version], OldWay
+      can [:history, :version], OldRelation
+    end
 
     if user
       can :welcome, :site
-      can [:index, :new, :create, :show, :edit, :update, :destroy], ClientApplication
-      can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
-      can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
-      can [:close, :reopen], Note
       can [:revoke, :authorize], :oauth
-      can [:new, :create], Report
-      can [:mine, :new, :create, :edit, :update, :delete, :api_create, :api_read, :api_update, :api_delete, :api_data], Trace
-      can [:account, :go_public, :make_friend, :remove_friend, :api_details, :api_gpx_files], User
-      can [:read, :read_one, :update, :update_one, :delete_one], UserPreference
 
-      if user.terms_agreed?
-        can [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox], Changeset
-        can :create, ChangesetComment
-        can [:create, :update, :delete], Node
-        can [:create, :update, :delete], Way
-        can [:create, :update, :delete], Relation
-      end
+      if Settings.status != "database_offline"
+        can [:index, :new, :create, :show, :edit, :update, :destroy], ClientApplication
+        can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
+        can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
+        can [:close, :reopen], Note
+        can [:new, :create], Report
+        can [:mine, :new, :create, :edit, :update, :delete, :api_create, :api_read, :api_update, :api_delete, :api_data], Trace
+        can [:account, :go_public, :make_friend, :remove_friend, :api_details, :api_gpx_files], User
+        can [:read, :read_one, :update, :update_one, :delete_one], UserPreference
 
-      if user.moderator?
-        can [:destroy, :restore], ChangesetComment
-        can [:index, :show, :resolve, :ignore, :reopen], Issue
-        can :create, IssueComment
-        can :destroy, Note
-        can [:new, :create, :edit, :update, :destroy], Redaction
-        can [:new, :edit, :create, :update, :revoke], UserBlock
         if user.terms_agreed?
-          can :redact, OldNode
-          can :redact, OldWay
-          can :redact, OldRelation
+          can [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox], Changeset
+          can :create, ChangesetComment
+          can [:create, :update, :delete], Node
+          can [:create, :update, :delete], Way
+          can [:create, :update, :delete], Relation
         end
-      end
 
-      if user.administrator?
-        can [:hide, :hidecomment], [DiaryEntry, DiaryComment]
-        can [:index, :show, :resolve, :ignore, :reopen], Issue
-        can :create, IssueComment
-        can [:set_status, :delete, :index], User
-        can [:grant, :revoke], UserRole
+        if user.moderator?
+          can [:destroy, :restore], ChangesetComment
+          can [:index, :show, :resolve, :ignore, :reopen], Issue
+          can :create, IssueComment
+          can :destroy, Note
+          can [:new, :create, :edit, :update, :destroy], Redaction
+          can [:new, :edit, :create, :update, :revoke], UserBlock
+
+          if user.terms_agreed?
+            can :redact, OldNode
+            can :redact, OldWay
+            can :redact, OldRelation
+          end
+        end
+
+        if user.administrator?
+          can [:hide, :hidecomment], [DiaryEntry, DiaryComment]
+          can [:index, :show, :resolve, :ignore, :reopen], Issue
+          can :create, IssueComment
+          can [:set_status, :delete, :index], User
+          can [:grant, :revoke], UserRole
+        end
       end
     end
 
index d8f51eefea7562e723fb5a3ac47005a994d77f8a..f4c24e97d7ffd24122888ee1d069294f567c7a4c 100644 (file)
@@ -4,29 +4,31 @@ class Capability
   include CanCan::Ability
 
   def initialize(token)
-    can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
-    can [:api_read, :api_data], Trace if capability?(token, :allow_read_gpx)
-    can [:api_create, :api_update, :api_delete], Trace if capability?(token, :allow_write_gpx)
-    can [:api_details], User if capability?(token, :allow_read_prefs)
-    can [:api_gpx_files], User if capability?(token, :allow_read_gpx)
-    can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
-    can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
+    if Settings.status != "database_offline"
+      can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
+      can [:api_read, :api_data], Trace if capability?(token, :allow_read_gpx)
+      can [:api_create, :api_update, :api_delete], Trace if capability?(token, :allow_write_gpx)
+      can [:api_details], User if capability?(token, :allow_read_prefs)
+      can [:api_gpx_files], User if capability?(token, :allow_read_gpx)
+      can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
+      can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
 
-    if token&.user&.terms_agreed?
-      can [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox], Changeset if capability?(token, :allow_write_api)
-      can :create, ChangesetComment if capability?(token, :allow_write_api)
-      can [:create, :update, :delete], Node if capability?(token, :allow_write_api)
-      can [:create, :update, :delete], Way if capability?(token, :allow_write_api)
-      can [:create, :update, :delete], Relation if capability?(token, :allow_write_api)
-    end
-
-    if token&.user&.moderator?
-      can [:destroy, :restore], ChangesetComment if capability?(token, :allow_write_api)
-      can :destroy, Note if capability?(token, :allow_write_notes)
       if token&.user&.terms_agreed?
-        can :redact, OldNode if capability?(token, :allow_write_api)
-        can :redact, OldWay if capability?(token, :allow_write_api)
-        can :redact, OldRelation if capability?(token, :allow_write_api)
+        can [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox], Changeset if capability?(token, :allow_write_api)
+        can :create, ChangesetComment if capability?(token, :allow_write_api)
+        can [:create, :update, :delete], Node if capability?(token, :allow_write_api)
+        can [:create, :update, :delete], Way if capability?(token, :allow_write_api)
+        can [:create, :update, :delete], Relation if capability?(token, :allow_write_api)
+      end
+
+      if token&.user&.moderator?
+        can [:destroy, :restore], ChangesetComment if capability?(token, :allow_write_api)
+        can :destroy, Note if capability?(token, :allow_write_notes)
+        if token&.user&.terms_agreed?
+          can :redact, OldNode if capability?(token, :allow_write_api)
+          can :redact, OldWay if capability?(token, :allow_write_api)
+          can :redact, OldRelation if capability?(token, :allow_write_api)
+        end
       end
     end
   end
diff --git a/app/assets/images/banners/saveyourinternet.png b/app/assets/images/banners/saveyourinternet.png
new file mode 100644 (file)
index 0000000..4263396
Binary files /dev/null and b/app/assets/images/banners/saveyourinternet.png differ
index 36b23666a92f8ebe61481ba8d508d014a76b60bf..ceb488f987681871e05c87476e5a464de126c79d 100644 (file)
@@ -20,8 +20,8 @@ window.onload = function () {
   }
 
   var thunderforestOptions = {
-<% if defined?(THUNDERFOREST_KEY) %>
-    apikey: <%= THUNDERFOREST_KEY.to_json %>
+<% if Settings.key?(:thunderforest_key) %>
+    apikey: <%= Settings.thunderforest_key.to_json %>
 <% end %>
   };
 
index a9e1a475ec15d8daf302e4cc9faeb2355adb3859..205dae0d145358f4f621f8cd9881bb4a76370ab4 100644 (file)
@@ -1,24 +1,25 @@
-//= depend_on application.yml
+//= depend_on settings.yml
+//= depend_on settings.local.yml
 
 OSM = {
 <% if defined?(PIWIK) %>
   PIWIK:                   <%= PIWIK.to_json %>,
 <% end %>
 
-  MAX_REQUEST_AREA:        <%= MAX_REQUEST_AREA.to_json %>,
-  SERVER_PROTOCOL:         <%= SERVER_PROTOCOL.to_json %>,
-  SERVER_URL:              <%= SERVER_URL.to_json %>,
-  API_VERSION:             <%= API_VERSION.to_json %>,
-  STATUS:                  <%= STATUS.to_json %>,
-  MAX_NOTE_REQUEST_AREA:   <%= MAX_NOTE_REQUEST_AREA.to_json %>,
-  OVERPASS_URL:            <%= OVERPASS_URL.to_json %>,
-  NOMINATIM_URL:           <%= NOMINATIM_URL.to_json %>,
-  GRAPHHOPPER_URL:         <%= GRAPHHOPPER_URL.to_json %>,
-  FOSSGIS_OSRM_URL:        <%= FOSSGIS_OSRM_URL.to_json %>,
+  MAX_REQUEST_AREA:        <%= Settings.max_request_area.to_json %>,
+  SERVER_PROTOCOL:         <%= Settings.server_protocol.to_json %>,
+  SERVER_URL:              <%= Settings.server_url.to_json %>,
+  API_VERSION:             <%= Settings.api_version.to_json %>,
+  STATUS:                  <%= Settings.status.to_json %>,
+  MAX_NOTE_REQUEST_AREA:   <%= Settings.max_note_request_area.to_json %>,
+  OVERPASS_URL:            <%= Settings.overpass_url.to_json %>,
+  NOMINATIM_URL:           <%= Settings.nominatim_url.to_json %>,
+  GRAPHHOPPER_URL:         <%= Settings.graphhopper_url.to_json %>,
+  FOSSGIS_OSRM_URL:        <%= Settings.fossgis_osrm_url.to_json %>,
   DEFAULT_LOCALE:          <%= I18n.default_locale.to_json %>,
 
-<% if defined?(THUNDERFOREST_KEY) %>
-  THUNDERFOREST_KEY:       <%= THUNDERFOREST_KEY.to_json %>,
+<% if Settings.key?(:thunderforest_key) %>
+  THUNDERFOREST_KEY:       <%= Settings.thunderforest_key.to_json %>,
 <% end %>
 
   MARKER_GREEN:            <%= image_path("marker-green.png").to_json %>,
@@ -212,7 +213,7 @@ OSM = {
 
     return 6372795 * 2 * Math.asin(
       Math.sqrt(
-        Math.pow(Math.sin(latdiff / 2), 2) + 
+        Math.pow(Math.sin(latdiff / 2), 2) +
         Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(lngdiff / 2), 2)
       ));
   }
index 2a878d248930265490c5bbbd64b91870f0678785..0cf511d76333cb7ba9d0975c9019fd3fabbc91b3 100644 (file)
 # * version conflict when POIs and ways are reverted
 
 module Api
-  class AmfController < ApplicationController
+  class AmfController < ApiController
     include Potlatch
 
-    skip_before_action :verify_authenticity_token
     before_action :check_api_writable
 
     # AMF Controller implements its own authentication and authorization checks
@@ -131,7 +130,7 @@ module Api
 
     def amf_handle_error_with_timeout(call, rootobj, rootid)
       amf_handle_error(call, rootobj, rootid) do
-        OSM::Timer.timeout(API_TIMEOUT, OSM::APITimeoutError) do
+        OSM::Timer.timeout(Settings.api_timeout, OSM::APITimeoutError) do
           yield
         end
       end
index 8337bc8091ee6d1229f5727fca88cb42cc41f54e..7f91557f85849b74bf749daf590dbe77aa3f582d 100644 (file)
@@ -1,8 +1,5 @@
 module Api
-  class CapabilitiesController < ApplicationController
-    skip_before_action :verify_authenticity_token
-    before_action :api_deny_access_handler
-
+  class CapabilitiesController < ApiController
     authorize_resource :class => false
 
     around_action :api_call_handle_error, :api_call_timeout
index c9195e1d9b97f6335a34a82f6f00d16e4724deca..7170e15622468037a6c2a210d7cdce6e7091e36c 100644 (file)
@@ -1,8 +1,5 @@
 module Api
-  class ChangesController < ApplicationController
-    skip_before_action :verify_authenticity_token
-    before_action :api_deny_access_handler
-
+  class ChangesController < ApiController
     authorize_resource :class => false
 
     before_action :check_api_readable
index 6093f529e6039e92b10b3b330e785de4de4baba7..21c854139c9bf9d684183461650be60af8c9ee12 100644 (file)
@@ -1,8 +1,6 @@
 module Api
-  class ChangesetCommentsController < ApplicationController
-    skip_before_action :verify_authenticity_token
+  class ChangesetCommentsController < ApiController
     before_action :authorize
-    before_action :api_deny_access_handler
 
     authorize_resource
 
@@ -41,7 +39,8 @@ module Api
       changeset.subscribers << current_user unless changeset.subscribers.exists?(current_user.id)
 
       # Return a copy of the updated changeset
-      render :xml => changeset.to_xml.to_s
+      @changeset = changeset
+      render "api/changesets/changeset"
     end
 
     ##
@@ -60,7 +59,8 @@ module Api
       comment.update(:visible => false)
 
       # Return a copy of the updated changeset
-      render :xml => comment.changeset.to_xml.to_s
+      @changeset = comment.changeset
+      render "api/changesets/changeset"
     end
 
     ##
@@ -79,7 +79,8 @@ module Api
       comment.update(:visible => true)
 
       # Return a copy of the updated changeset
-      render :xml => comment.changeset.to_xml.to_s
+      @changeset = comment.changeset
+      render "api/changesets/changeset"
     end
   end
 end
index 853ee389f087a24a2ef8fdde3ddd1c38662344c9..fb6523f4e0065a1dd9c508fc2c9e490e68cbfaaa 100644 (file)
@@ -1,20 +1,17 @@
 # The ChangesetController is the RESTful interface to Changeset objects
 
 module Api
-  class ChangesetsController < ApplicationController
+  class ChangesetsController < ApiController
     layout "site"
     require "xml/libxml"
 
-    skip_before_action :verify_authenticity_token
     before_action :authorize, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe]
-    before_action :api_deny_access_handler, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox]
 
     authorize_resource
 
     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(:only => [:index, :feed]) { |c| c.check_database_readable(true) }
     around_action :api_call_handle_error
     around_action :api_call_timeout, :except => [:upload]
 
@@ -41,9 +38,9 @@ module Api
     # Return XML giving the basic info about the changeset. Does not
     # return anything about the nodes, ways and relations in the changeset.
     def show
-      changeset = Changeset.find(params[:id])
-
-      render :xml => changeset.to_xml(params[:include_discussion].presence).to_s
+      @changeset = Changeset.find(params[:id])
+      @include_discussion = params[:include_discussion].presence
+      render "changeset"
     end
 
     ##
@@ -104,7 +101,8 @@ module Api
       # save the larger bounding box and return the changeset, which
       # will include the bigger bounding box.
       cs.save!
-      render :xml => cs.to_xml.to_s
+      @changeset = cs
+      render "changeset"
     end
 
     ##
@@ -219,18 +217,9 @@ module Api
       # sort and limit the changesets
       changesets = changesets.order("created_at DESC").limit(100)
 
-      # preload users, tags and comments
-      changesets = changesets.preload(:user, :changeset_tags, :comments)
-
-      # create the results document
-      results = OSM::API.new.get_xml_doc
-
-      # add all matching changesets to the XML results document
-      changesets.order("created_at DESC").limit(100).each do |cs|
-        results.root << cs.to_xml_node
-      end
-
-      render :xml => results.to_s
+      # preload users, tags and comments, and render result
+      @changesets = changesets.preload(:user, :changeset_tags, :comments)
+      render "changesets"
     end
 
     ##
@@ -245,12 +234,12 @@ module Api
       # request *must* be a PUT.
       assert_method :put
 
-      changeset = Changeset.find(params[:id])
+      @changeset = Changeset.find(params[:id])
       new_changeset = Changeset.from_xml(request.raw_post)
 
-      check_changeset_consistency(changeset, current_user)
-      changeset.update_from(new_changeset, current_user)
-      render :xml => changeset.to_xml.to_s
+      check_changeset_consistency(@changeset, current_user)
+      @changeset.update_from(new_changeset, current_user)
+      render "changeset"
     end
 
     ##
@@ -270,7 +259,8 @@ module Api
       changeset.subscribers << current_user
 
       # Return a copy of the updated changeset
-      render :xml => changeset.to_xml.to_s
+      @changeset = changeset
+      render "changeset"
     end
 
     ##
@@ -290,7 +280,8 @@ module Api
       changeset.subscribers.delete(current_user)
 
       # Return a copy of the updated changeset
-      render :xml => changeset.to_xml.to_s
+      @changeset = changeset
+      render "changeset"
     end
 
     private
index 47c0aeb36af38295cd88e5b63ece3a47556457d9..27d6f3667410b13504851e0298e1eb67257c4154 100644 (file)
@@ -1,8 +1,5 @@
 module Api
-  class MapController < ApplicationController
-    skip_before_action :verify_authenticity_token
-    before_action :api_deny_access_handler
-
+  class MapController < ApiController
     authorize_resource :class => false
 
     before_action :check_api_readable
@@ -30,11 +27,11 @@ module Api
         return
       end
 
-      nodes = Node.bbox(bbox).where(:visible => true).includes(:node_tags).limit(MAX_NUMBER_OF_NODES + 1)
+      nodes = Node.bbox(bbox).where(:visible => true).includes(:node_tags).limit(Settings.max_number_of_nodes + 1)
 
       node_ids = nodes.collect(&:id)
-      if node_ids.length > MAX_NUMBER_OF_NODES
-        report_error("You requested too many nodes (limit is #{MAX_NUMBER_OF_NODES}). Either request a smaller area, or use planet.osm")
+      if node_ids.length > Settings.max_number_of_nodes
+        report_error("You requested too many nodes (limit is #{Settings.max_number_of_nodes}). Either request a smaller area, or use planet.osm")
         return
       end
 
index 4e46b38d56461c94f50f162169623f1f2ff8a05a..5218159c16097f61b921e07d63d0ea7cee1ff601 100644 (file)
@@ -1,12 +1,10 @@
 # The NodeController is the RESTful interface to Node objects
 
 module Api
-  class NodesController < ApplicationController
+  class NodesController < ApiController
     require "xml/libxml"
 
-    skip_before_action :verify_authenticity_token
     before_action :authorize, :only => [:create, :update, :delete]
-    before_action :api_deny_access_handler
 
     authorize_resource
 
index d4ebef5d4fb58e2b8e741c5f5dce1e2b3e481d88..20a24ce997bbe10a6aaf546d2f0131b91a4abb47 100644 (file)
@@ -1,12 +1,10 @@
 module Api
-  class NotesController < ApplicationController
+  class NotesController < ApiController
     layout "site", :only => [:mine]
 
-    skip_before_action :verify_authenticity_token
     before_action :check_api_readable
     before_action :setup_user_auth, :only => [:create, :comment, :show]
     before_action :authorize, :only => [:close, :reopen, :destroy]
-    before_action :api_deny_access_handler
 
     authorize_resource
 
@@ -37,7 +35,7 @@ module Api
       bbox.check_boundaries
 
       # Check the the bounding box is not too big
-      bbox.check_size(MAX_NOTE_REQUEST_AREA)
+      bbox.check_size(Settings.max_note_request_area)
 
       # Find the notes we want to return
       @notes = notes.bbox(bbox).order("updated_at DESC").limit(result_limit).preload(:comments)
@@ -190,7 +188,7 @@ module Api
         bbox = BoundingBox.from_bbox_params(params)
 
         bbox.check_boundaries
-        bbox.check_size(MAX_NOTE_REQUEST_AREA)
+        bbox.check_size(Settings.max_note_request_area)
 
         notes = notes.bbox(bbox)
       end
index 9a86bded590ea8c143634480a01023514f1d2be5..fa2b5814e49a400a5b22fd95d5d287812bb4fb29 100644 (file)
@@ -2,12 +2,10 @@
 # into one place. as it turns out, the API methods for historical
 # nodes, ways and relations are basically identical.
 module Api
-  class OldController < ApplicationController
+  class OldController < ApiController
     require "xml/libxml"
 
-    skip_before_action :verify_authenticity_token
     before_action :setup_user_auth, :only => [:history, :version]
-    before_action :api_deny_access_handler
     before_action :authorize, :only => [:redact]
 
     authorize_resource
index b24aca776dcfef6afeb0d0c476aaaea6bd46d5b4..9b168e04b568e5c1f880f0f2a035a11f1dc74c44 100644 (file)
@@ -1,8 +1,5 @@
 module Api
-  class PermissionsController < ApplicationController
-    skip_before_action :verify_authenticity_token
-    before_action :api_deny_access_handler
-
+  class PermissionsController < ApiController
     authorize_resource :class => false
 
     before_action :check_api_readable
index a0740b382819f720d59013a3b70157834428c758..b7d990c3d3570321d21614afc1ef94293d39055b 100644 (file)
@@ -1,10 +1,8 @@
 module Api
-  class RelationsController < ApplicationController
+  class RelationsController < ApiController
     require "xml/libxml"
 
-    skip_before_action :verify_authenticity_token
     before_action :authorize, :only => [:create, :update, :delete]
-    before_action :api_deny_access_handler
 
     authorize_resource
 
index 0afbbf8e2a40990947c8bf9eeb88b883bd98f721..feb487ac0e4d44369a7d49b5296b28afd93aa548 100644 (file)
@@ -1,9 +1,8 @@
 module Api
-  class SearchController < ApplicationController
+  class SearchController < ApiController
     # Support searching for nodes, ways, or all
     # Can search by tag k, v, or both (type->k,value->v)
     # Can search by name (k=name,v=....)
-    skip_before_action :verify_authenticity_token
     authorize_resource :class => false
 
     def search_all
index d48731b7023404cf72c7c388a6affd988502e718..2f8a5392da459274b423468d52664db6ad51b270 100644 (file)
@@ -1,6 +1,5 @@
 module Api
-  class SwfController < ApplicationController
-    skip_before_action :verify_authenticity_token
+  class SwfController < ApiController
     before_action :check_api_readable
     authorize_resource :class => false
 
index 56cd36138b737435afcd3ea0ea3f9179e559b046..b22bcfaeaff994508a4a7d2272035157e0867473 100644 (file)
@@ -1,8 +1,5 @@
 module Api
-  class TracepointsController < ApplicationController
-    skip_before_action :verify_authenticity_token
-    before_action :api_deny_access_handler
-
+  class TracepointsController < ApiController
     authorize_resource
 
     before_action :check_api_readable
@@ -19,7 +16,7 @@ module Api
         return
       end
 
-      offset = page * TRACEPOINTS_PER_PAGE
+      offset = page * Settings.tracepoints_per_page
 
       # Figure out the bbox
       # check boundary is sane and area within defined
@@ -36,7 +33,7 @@ module Api
       # get all the points
       ordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[trackable identifiable] }).order("gpx_id DESC, trackid ASC, timestamp ASC")
       unordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[public private] }).order("gps_points.latitude", "gps_points.longitude", "gps_points.timestamp")
-      points = ordered_points.union_all(unordered_points).offset(offset).limit(TRACEPOINTS_PER_PAGE)
+      points = ordered_points.union_all(unordered_points).offset(offset).limit(Settings.tracepoints_per_page)
 
       doc = XML::Document.new
       doc.encoding = XML::Encoding::UTF_8
index 8401e78ae039cfe9774535b946c4d16432e0ad86..47dd152a3fa6bc53bb38e8929865789fc37074a4 100644 (file)
@@ -1,12 +1,10 @@
 module Api
-  class TracesController < ApplicationController
+  class TracesController < ApiController
     layout "site", :except => :georss
 
-    skip_before_action :verify_authenticity_token
     before_action :authorize_web
     before_action :set_locale
     before_action :authorize
-    before_action :api_deny_access_handler
 
     authorize_resource
 
@@ -163,7 +161,7 @@ module Api
     end
 
     def offline_redirect
-      redirect_to :action => :offline if STATUS == :gpx_offline
+      redirect_to :action => :offline if Settings.status == "gpx_offline"
     end
   end
 end
index 82f6c6a4d78255d6fdc8b17087888679f54ed4f6..39e0dff300d83078e3fffcb54b5b4d04d29a74cf 100644 (file)
@@ -1,7 +1,6 @@
 # Update and read user preferences, which are arbitrayr key/val pairs
 module Api
-  class UserPreferencesController < ApplicationController
-    skip_before_action :verify_authenticity_token
+  class UserPreferencesController < ApiController
     before_action :authorize
 
     authorize_resource
index 70ad93f65e4862c33f73bd40d8a52f302f7317c6..f24d50cf101d2525c8054a642cf6b8e5d68df858 100644 (file)
@@ -1,11 +1,9 @@
 module Api
-  class UsersController < ApplicationController
+  class UsersController < ApiController
     layout "site", :except => [:api_details]
 
-    skip_before_action :verify_authenticity_token
     before_action :disable_terms_redirect, :only => [:api_details]
     before_action :authorize, :only => [:api_details, :api_gpx_files]
-    before_action :api_deny_access_handler
 
     authorize_resource
 
index 8684c5cfb13a9ea3575af5838b6c89df3887aeae..5e3e5e11ab1d511dea0882b5c455fa59c520f25b 100644 (file)
@@ -1,10 +1,8 @@
 module Api
-  class WaysController < ApplicationController
+  class WaysController < ApiController
     require "xml/libxml"
 
-    skip_before_action :verify_authenticity_token
     before_action :authorize, :only => [:create, :update, :delete]
-    before_action :api_deny_access_handler
 
     authorize_resource
 
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
new file mode 100644 (file)
index 0000000..579af27
--- /dev/null
@@ -0,0 +1,79 @@
+class ApiController < ApplicationController
+  skip_before_action :verify_authenticity_token
+
+  private
+
+  def authorize(realm = "Web Password", errormessage = "Couldn't authenticate you")
+    # make the current_user object from any auth sources we have
+    setup_user_auth
+
+    # handle authenticate pass/fail
+    unless current_user
+      # no auth, the user does not exist or the password was wrong
+      response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
+      render :plain => errormessage, :status => :unauthorized
+      return false
+    end
+  end
+
+  def deny_access(_exception)
+    if current_token
+      set_locale
+      report_error t("oauth.permissions.missing"), :forbidden
+    elsif current_user
+      head :forbidden
+    else
+      realm = "Web Password"
+      errormessage = "Couldn't authenticate you"
+      response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
+      render :plain => errormessage, :status => :unauthorized
+    end
+  end
+
+  def gpx_status
+    status = database_status
+    status = "offline" if status == "online" && Settings.status == "gpx_offline"
+    status
+  end
+
+  ##
+  # sets up the current_user for use by other methods. this is mostly called
+  # from the authorize method, but can be called elsewhere if authorisation
+  # is optional.
+  def setup_user_auth
+    # try and setup using OAuth
+    unless Authenticator.new(self, [:token]).allow?
+      username, passwd = get_auth_data # parse from headers
+      # authenticate per-scheme
+      self.current_user = if username.nil?
+                            nil # no authentication provided - perhaps first connect (client should retry after 401)
+                          elsif username == "token"
+                            User.authenticate(:token => passwd) # preferred - random token for user from db, passed in basic auth
+                          else
+                            User.authenticate(:username => username, :password => passwd) # basic auth
+                          end
+    end
+
+    # have we identified the user?
+    if current_user
+      # check if the user has been banned
+      user_block = current_user.blocks.active.take
+      unless user_block.nil?
+        set_locale
+        if user_block.zero_hour?
+          report_error t("application.setup_user_auth.blocked_zero_hour"), :forbidden
+        else
+          report_error t("application.setup_user_auth.blocked"), :forbidden
+        end
+      end
+
+      # if the user hasn't seen the contributor terms then don't
+      # allow editing - they have to go to the web site and see
+      # (but can decline) the CTs to continue.
+      if !current_user.terms_seen && flash[:skip_terms].nil?
+        set_locale
+        report_error t("application.setup_user_auth.need_to_see_terms"), :forbidden
+      end
+    end
+  end
+end
index 227e5198f5de115b9dc90d97acbf069cbfb2c581..3ab09b63d805bc67899c6e54dabeac86f7d5fa69 100644 (file)
@@ -12,6 +12,8 @@ class ApplicationController < ActionController::Base
   attr_accessor :current_user
   helper_method :current_user
 
+  private
+
   def authorize_web
     if session[:user]
       self.current_user = User.where(:id => session[:user]).where("status IN ('active', 'confirmed', 'suspended')").first
@@ -52,7 +54,7 @@ class ApplicationController < ActionController::Base
   end
 
   def require_oauth
-    @oauth = current_user.access_token(OAUTH_KEY) if current_user && defined? OAUTH_KEY
+    @oauth = current_user.access_token(Settings.oauth_key) if current_user && Settings.key?(:oauth_key)
   end
 
   ##
@@ -71,62 +73,8 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  ##
-  # sets up the current_user for use by other methods. this is mostly called
-  # from the authorize method, but can be called elsewhere if authorisation
-  # is optional.
-  def setup_user_auth
-    # try and setup using OAuth
-    unless Authenticator.new(self, [:token]).allow?
-      username, passwd = get_auth_data # parse from headers
-      # authenticate per-scheme
-      self.current_user = if username.nil?
-                            nil # no authentication provided - perhaps first connect (client should retry after 401)
-                          elsif username == "token"
-                            User.authenticate(:token => passwd) # preferred - random token for user from db, passed in basic auth
-                          else
-                            User.authenticate(:username => username, :password => passwd) # basic auth
-                          end
-    end
-
-    # have we identified the user?
-    if current_user
-      # check if the user has been banned
-      user_block = current_user.blocks.active.take
-      unless user_block.nil?
-        set_locale
-        if user_block.zero_hour?
-          report_error t("application.setup_user_auth.blocked_zero_hour"), :forbidden
-        else
-          report_error t("application.setup_user_auth.blocked"), :forbidden
-        end
-      end
-
-      # if the user hasn't seen the contributor terms then don't
-      # allow editing - they have to go to the web site and see
-      # (but can decline) the CTs to continue.
-      if !current_user.terms_seen && flash[:skip_terms].nil?
-        set_locale
-        report_error t("application.setup_user_auth.need_to_see_terms"), :forbidden
-      end
-    end
-  end
-
-  def authorize(realm = "Web Password", errormessage = "Couldn't authenticate you")
-    # make the current_user object from any auth sources we have
-    setup_user_auth
-
-    # handle authenticate pass/fail
-    unless current_user
-      # no auth, the user does not exist or the password was wrong
-      response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
-      render :plain => errormessage, :status => :unauthorized
-      return false
-    end
-  end
-
   def check_database_readable(need_api = false)
-    if STATUS == :database_offline || (need_api && STATUS == :api_offline)
+    if Settings.status == "database_offline" || (need_api && Settings.status == "api_offline")
       if request.xhr?
         report_error "Database offline for maintenance", :service_unavailable
       else
@@ -136,8 +84,8 @@ class ApplicationController < ActionController::Base
   end
 
   def check_database_writable(need_api = false)
-    if STATUS == :database_offline || STATUS == :database_readonly ||
-       (need_api && (STATUS == :api_offline || STATUS == :api_readonly))
+    if Settings.status == "database_offline" || Settings.status == "database_readonly" ||
+       (need_api && (Settings.status == "api_offline" || Settings.status == "api_readonly"))
       if request.xhr?
         report_error "Database offline for maintenance", :service_unavailable
       else
@@ -147,47 +95,41 @@ class ApplicationController < ActionController::Base
   end
 
   def check_api_readable
-    if api_status == :offline
+    if api_status == "offline"
       report_error "Database offline for maintenance", :service_unavailable
       false
     end
   end
 
   def check_api_writable
-    unless api_status == :online
+    unless api_status == "online"
       report_error "Database offline for maintenance", :service_unavailable
       false
     end
   end
 
   def database_status
-    if STATUS == :database_offline
-      :offline
-    elsif STATUS == :database_readonly
-      :readonly
+    if Settings.status == "database_offline"
+      "offline"
+    elsif Settings.status == "database_readonly"
+      "readonly"
     else
-      :online
+      "online"
     end
   end
 
   def api_status
     status = database_status
-    if status == :online
-      if STATUS == :api_offline
-        status = :offline
-      elsif STATUS == :api_readonly
-        status = :readonly
+    if status == "online"
+      if Settings.status == "api_offline"
+        status = "offline"
+      elsif Settings.status == "api_readonly"
+        status = "readonly"
       end
     end
     status
   end
 
-  def gpx_status
-    status = database_status
-    status = :offline if status == :online && STATUS == :gpx_offline
-    status
-  end
-
   def require_public_data
     unless current_user.data_public?
       report_error "You must make your edits public to upload new data", :forbidden
@@ -272,7 +214,7 @@ class ApplicationController < ActionController::Base
   ##
   # wrap an api call in a timeout
   def api_call_timeout
-    OSM::Timer.timeout(API_TIMEOUT, Timeout::Error) do
+    OSM::Timer.timeout(Settings.api_timeout, Timeout::Error) do
       yield
     end
   rescue Timeout::Error
@@ -282,7 +224,7 @@ class ApplicationController < ActionController::Base
   ##
   # wrap a web page in a timeout
   def web_timeout
-    OSM::Timer.timeout(WEB_TIMEOUT, Timeout::Error) do
+    OSM::Timer.timeout(Settings.web_timeout, Timeout::Error) do
       yield
     end
   rescue ActionView::Template::Error => ex
@@ -333,14 +275,14 @@ class ApplicationController < ActionController::Base
     append_content_security_policy_directives(
       :child_src => %w[http://127.0.0.1:8111 https://127.0.0.1:8112],
       :frame_src => %w[http://127.0.0.1:8111 https://127.0.0.1:8112],
-      :connect_src => [NOMINATIM_URL, OVERPASS_URL, FOSSGIS_OSRM_URL, GRAPHHOPPER_URL],
+      :connect_src => [Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url],
       :form_action => %w[render.openstreetmap.org],
       :style_src => %w['unsafe-inline']
     )
 
-    if STATUS == :database_offline || STATUS == :api_offline
+    if Settings.status == "database_offline" || Settings.status == "api_offline"
       flash.now[:warning] = t("layouts.osm_offline")
-    elsif STATUS == :database_readonly || STATUS == :api_readonly
+    elsif Settings.status == "database_readonly" || Settings.status == "api_readonly"
       flash.now[:warning] = t("layouts.osm_read_only")
     end
 
@@ -357,7 +299,7 @@ class ApplicationController < ActionController::Base
              elsif current_user&.preferred_editor
                current_user.preferred_editor
              else
-               DEFAULT_EDITOR
+               Settings.default_editor
              end
 
     editor
@@ -366,9 +308,9 @@ class ApplicationController < ActionController::Base
   helper_method :preferred_editor
 
   def update_totp
-    if defined?(TOTP_KEY)
+    if Settings.key?(:totp_key)
       cookies["_osm_totp_token"] = {
-        :value => ROTP::TOTP.new(TOTP_KEY, :interval => 3600).now,
+        :value => ROTP::TOTP.new(Settings.totp_key, :interval => 3600).now,
         :domain => "openstreetmap.org",
         :expires => 1.hour.from_now
       }
@@ -395,15 +337,7 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def deny_access(exception)
-    if @api_deny_access_handling
-      api_deny_access(exception)
-    else
-      web_deny_access(exception)
-    end
-  end
-
-  def web_deny_access(_exception)
+  def deny_access(_exception)
     if current_token
       set_locale
       report_error t("oauth.permissions.missing"), :forbidden
@@ -423,28 +357,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def api_deny_access(_exception)
-    if current_token
-      set_locale
-      report_error t("oauth.permissions.missing"), :forbidden
-    elsif current_user
-      head :forbidden
-    else
-      realm = "Web Password"
-      errormessage = "Couldn't authenticate you"
-      response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
-      render :plain => errormessage, :status => :unauthorized
-    end
-  end
-
-  attr_accessor :api_access_handling
-
-  def api_deny_access_handler
-    @api_deny_access_handling = true
-  end
-
-  private
-
   # extract authorisation credentials from headers, returns user = nil if none
   def get_auth_data
     if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it
index 0fccbb506bb2a19dae6db4087853a64b8f0933cf..ebdd2cd80fbbb2dfc812ae155477639215069e01 100644 (file)
@@ -3,7 +3,7 @@ class BrowseController < ApplicationController
 
   before_action :authorize_web
   before_action :set_locale
-  before_action(:except => [:query]) { |c| c.check_database_readable(true) }
+  before_action -> { check_database_readable(true) }
   before_action :require_oauth
   around_action :web_timeout
   authorize_resource :class => false
index 05b28eacf01c9806759bcafa8138f33b5958ce44..4abffb90efafac72a7a1d662c5b06fd1d97eb78a 100644 (file)
@@ -4,7 +4,7 @@ class ChangesetCommentsController < ApplicationController
 
   authorize_resource
 
-  before_action(:only => [:index]) { |c| c.check_database_readable(true) }
+  before_action -> { check_database_readable(true) }
   around_action :web_timeout
 
   ##
index a69d0d57b7daaa14b9e78459a87f71de8187bc45..32d9fd73314f53e731717081af5c383550298f8b 100644 (file)
@@ -7,10 +7,10 @@ class ChangesetsController < ApplicationController
   skip_before_action :verify_authenticity_token, :except => [:index]
   before_action :authorize_web
   before_action :set_locale
+  before_action -> { check_database_readable(true) }, :only => [:index, :feed]
 
   authorize_resource
 
-  before_action(:only => [:index, :feed]) { |c| c.check_database_readable(true) }
   around_action :web_timeout
 
   # Helper methods for checking consistency
index 4a1da178a163b558f1775a18b99527ab7519f196..fb1e7b702a6aa92250f24eb914be3633c4ca4cfc 100644 (file)
@@ -3,11 +3,11 @@ class DiaryEntriesController < ApplicationController
 
   before_action :authorize_web
   before_action :set_locale
+  before_action :check_database_readable
 
   authorize_resource
 
   before_action :lookup_user, :only => [:show, :comments]
-  before_action :check_database_readable
   before_action :check_database_writable, :only => [:new, :edit, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
   before_action :allow_thirdparty_images, :only => [:new, :edit, :index, :show, :comments]
 
@@ -158,7 +158,7 @@ class DiaryEntriesController < ApplicationController
         @entries = user.diary_entries
         @title = t("diary_entries.feed.user.title", :user => user.display_name)
         @description = t("diary_entries.feed.user.description", :user => user.display_name)
-        @link = url_for :action => "index", :display_name => user.display_name, :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+        @link = url_for :action => "index", :display_name => user.display_name, :host => Settings.server_url, :protocol => Settings.server_protocol
       else
         head :not_found
         return
@@ -170,11 +170,11 @@ class DiaryEntriesController < ApplicationController
         @entries = @entries.where(:language_code => params[:language])
         @title = t("diary_entries.feed.language.title", :language_name => Language.find(params[:language]).english_name)
         @description = t("diary_entries.feed.language.description", :language_name => Language.find(params[:language]).english_name)
-        @link = url_for :action => "index", :language => params[:language], :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+        @link = url_for :action => "index", :language => params[:language], :host => Settings.server_url, :protocol => Settings.server_protocol
       else
         @title = t("diary_entries.feed.all.title")
         @description = t("diary_entries.feed.all.description")
-        @link = url_for :action => "index", :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+        @link = url_for :action => "index", :host => Settings.server_url, :protocol => Settings.server_protocol
       end
     end
 
index d9b56147f46a6a1a2f82e3154fbdf04d278836e3..4a8f7765065ab11c7f6db3caa668f37826f2fc4e 100644 (file)
@@ -15,7 +15,7 @@ class GeocoderController < ApplicationController
     if @params[:lat] && @params[:lon]
       @sources.push "latlon"
       @sources.push "osm_nominatim_reverse"
-      @sources.push "geonames_reverse" if defined?(GEONAMES_USERNAME)
+      @sources.push "geonames_reverse" if Settings.key?(:geonames_username)
     elsif @params[:query]
       if @params[:query].match?(/^\d{5}(-\d{4})?$/)
         @sources.push "osm_nominatim"
@@ -26,7 +26,7 @@ class GeocoderController < ApplicationController
         @sources.push "osm_nominatim"
       else
         @sources.push "osm_nominatim"
-        @sources.push "geonames" if defined?(GEONAMES_USERNAME)
+        @sources.push "geonames" if Settings.key?(:geonames_username)
       end
     end
 
@@ -93,7 +93,7 @@ class GeocoderController < ApplicationController
     if response.get_elements("geodata/error").empty?
       @results.push(:lat => response.text("geodata/latt"),
                     :lon => response.text("geodata/longt"),
-                    :zoom => POSTCODE_ZOOM,
+                    :zoom => Settings.postcode_zoom,
                     :name => query.upcase)
     end
 
@@ -118,7 +118,7 @@ class GeocoderController < ApplicationController
     exclude = "&exclude_place_ids=#{params[:exclude]}" if params[:exclude]
 
     # ask nominatim
-    response = fetch_xml("#{NOMINATIM_URL}search?format=xml&extratags=1&q=#{escape_query(query)}#{viewbox}#{exclude}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}")
+    response = fetch_xml("#{Settings.nominatim_url}search?format=xml&extratags=1&q=#{escape_query(query)}#{viewbox}#{exclude}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}")
 
     # extract the results from the response
     results =  response.elements["searchresults"]
@@ -182,7 +182,7 @@ class GeocoderController < ApplicationController
     @results = []
 
     # ask geonames.org
-    response = fetch_xml("http://api.geonames.org/search?q=#{escape_query(query)}&lang=#{lang}&maxRows=20&username=#{GEONAMES_USERNAME}")
+    response = fetch_xml("http://api.geonames.org/search?q=#{escape_query(query)}&lang=#{lang}&maxRows=20&username=#{Settings.geonames_username}")
 
     # parse the response
     response.elements.each("geonames/geoname") do |geoname|
@@ -192,7 +192,7 @@ class GeocoderController < ApplicationController
       country = geoname.text("countryName")
 
       @results.push(:lat => lat, :lon => lon,
-                    :zoom => GEONAMES_ZOOM,
+                    :zoom => Settings.geonames_zoom,
                     :name => name,
                     :suffix => ", #{country}")
     end
@@ -213,7 +213,7 @@ class GeocoderController < ApplicationController
     @results = []
 
     # ask nominatim
-    response = fetch_xml("#{NOMINATIM_URL}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}")
+    response = fetch_xml("#{Settings.nominatim_url}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{http_accept_language.user_preferred_languages.join(',')}")
 
     # parse the response
     response.elements.each("reversegeocode/result") do |result|
@@ -247,7 +247,7 @@ class GeocoderController < ApplicationController
     @results = []
 
     # ask geonames.org
-    response = fetch_xml("http://api.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}&lang=#{lang}&username=#{GEONAMES_USERNAME}")
+    response = fetch_xml("http://api.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}&lang=#{lang}&username=#{Settings.geonames_username}")
 
     # parse the response
     response.elements.each("geonames/countrySubdivision") do |geoname|
@@ -255,7 +255,7 @@ class GeocoderController < ApplicationController
       country = geoname.text("countryName")
 
       @results.push(:lat => lat, :lon => lon,
-                    :zoom => GEONAMES_ZOOM,
+                    :zoom => Settings.geonames_zoom,
                     :name => name,
                     :suffix => ", #{country}")
     end
index dce0099e5b68caeceb12f1f5fa41865d4c3db0b9..5aa5aba709e33c2bf8f15a3e8442b928de548afc 100644 (file)
@@ -26,7 +26,7 @@ class MessagesController < ApplicationController
     @message.sender = current_user
     @message.sent_on = Time.now.getutc
 
-    if current_user.sent_messages.where("sent_on >= ?", Time.now.getutc - 1.hour).count >= MAX_MESSAGES_PER_HOUR
+    if current_user.sent_messages.where("sent_on >= ?", Time.now.getutc - 1.hour).count >= Settings.max_messages_per_hour
       flash[:error] = t ".limit_exceeded"
       render :action => "new"
     elsif @message.save
index 225fc0677a39b3fcd7951c7e7d8b5be56fabb62f..babd27c536ffd4eaf4d813e2fce559678a2fbadc 100644 (file)
@@ -39,7 +39,7 @@ class OauthController < ApplicationController
   end
 
   def oauth1_authorize
-    override_content_security_policy_directives(:form_action => []) if CSP_ENFORCE || defined?(CSP_REPORT_URL)
+    override_content_security_policy_directives(:form_action => []) if Settings.csp_enforce || Settings.key?(:csp_report_url)
 
     if @token.invalidated?
       @message = t "oauth.authorize_failure.invalid"
index 5833a1e045b01cd55ab69a8e746d040bd090ae72..471e9f3c5636d75d54765fc2854919e9a4da11e1 100644 (file)
@@ -12,7 +12,7 @@ class SiteController < ApplicationController
   authorize_resource :class => false
 
   def index
-    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless STATUS == :database_readonly || STATUS == :database_offline
+    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless Settings.status == "database_readonly" || Settings.status == "database_offline"
   end
 
   def permalink
index b488d717aefcefc736d01568889c3b48a8ae8257..334aa2aa654fecbd13a3453e1fd53c076154ce57 100644 (file)
@@ -3,10 +3,10 @@ class TracesController < ApplicationController
 
   before_action :authorize_web
   before_action :set_locale
+  before_action :check_database_readable
 
   authorize_resource
 
-  before_action :check_database_readable
   before_action :check_database_writable, :only => [:new, :create, :edit, :delete]
   before_action :offline_warning, :only => [:mine, :show]
   before_action :offline_redirect, :only => [:new, :create, :edit, :delete, :data]
@@ -121,7 +121,7 @@ class TracesController < ApplicationController
         flash[:notice] = t ".trace_uploaded"
         flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4
 
-        TraceImporterJob.perform_later(@trace) if TRACE_USE_JOB_QUEUE
+        TraceImporterJob.perform_later(@trace) if Settings.trace_use_job_queue
         redirect_to :action => :index, :display_name => current_user.display_name
       else
         flash[:error] = t("traces.create.upload_failed") if @trace.valid?
@@ -205,7 +205,7 @@ class TracesController < ApplicationController
       trace.visible = false
       trace.save
       flash[:notice] = t ".scheduled_for_deletion"
-      TraceDestroyerJob.perform_later(trace) if TRACE_USE_JOB_QUEUE
+      TraceDestroyerJob.perform_later(trace) if Settings.trace_use_job_queue
       redirect_to :action => :index, :display_name => trace.user.display_name
     end
   rescue ActiveRecord::RecordNotFound
@@ -323,11 +323,11 @@ class TracesController < ApplicationController
   end
 
   def offline_warning
-    flash.now[:warning] = t "traces.offline_warning.message" if STATUS == :gpx_offline
+    flash.now[:warning] = t "traces.offline_warning.message" if Settings.status == "gpx_offline"
   end
 
   def offline_redirect
-    redirect_to :action => :offline if STATUS == :gpx_offline
+    redirect_to :action => :offline if Settings.status == "gpx_offline"
   end
 
   def default_visibility
index fa5b22a98951479efea3f00a4e3bb28a36a767b5..9b97fa0a1f08af46d9d5657c12c75ad070acc052 100644 (file)
@@ -5,18 +5,18 @@ class UsersController < ApplicationController
   before_action :disable_terms_redirect, :only => [:terms, :save, :logout]
   before_action :authorize_web
   before_action :set_locale
+  before_action :check_database_readable
 
   authorize_resource
 
   before_action :require_self, :only => [:account]
-  before_action :check_database_readable, :except => [:login]
   before_action :check_database_writable, :only => [:new, :account, :confirm, :confirm_email, :lost_password, :reset_password, :go_public, :make_friend, :remove_friend]
   before_action :require_cookies, :only => [:new, :login, :confirm]
   before_action :lookup_user_by_name, :only => [:set_status, :delete]
   before_action :allow_thirdparty_images, :only => [:show, :account]
 
   def terms
-    @legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || DEFAULT_LEGALE
+    @legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || Settings.default_legale
     @text = OSM.legal_text_for_country(@legale)
 
     if request.xhr?
@@ -332,7 +332,7 @@ class UsersController < ApplicationController
       flash[:error] = t "users.confirm_resend.failure", :name => params[:display_name]
     else
       Notifier.signup_confirm(user, user.tokens.create).deliver_later
-      flash[:notice] = t("users.confirm_resend.success", :email => user.email, :sender => SUPPORT_EMAIL).html_safe
+      flash[:notice] = t("users.confirm_resend.success", :email => user.email, :sender => Settings.support_email).html_safe
     end
 
     redirect_to :action => "login"
@@ -521,7 +521,7 @@ class UsersController < ApplicationController
         when "active", "confirmed" then
           successful_login(user, request.env["omniauth.params"]["referer"])
         when "suspended" then
-          failed_login t("users.login.account is suspended", :webmaster => "mailto:#{SUPPORT_EMAIL}").html_safe
+          failed_login t("users.login.account is suspended", :webmaster => "mailto:#{Settings.support_email}").html_safe
         else
           failed_login t("users.login.auth failure")
         end
@@ -549,7 +549,7 @@ class UsersController < ApplicationController
     elsif user = User.authenticate(:username => username, :password => password, :pending => true)
       unconfirmed_login(user)
     elsif User.authenticate(:username => username, :password => password, :suspended => true)
-      failed_login t("users.login.account is suspended", :webmaster => "mailto:#{SUPPORT_EMAIL}").html_safe, username
+      failed_login t("users.login.account is suspended", :webmaster => "mailto:#{Settings.support_email}").html_safe, username
     else
       failed_login t("users.login.auth failure"), username
     end
index a696a3d9cd79a38394877192b06226189d3b3888..1c2e5e65437b18370f9d05f9a79313d846f4dd50 100644 (file)
@@ -12,7 +12,7 @@ module NotifierHelper
         # the <a> but Outlook only on the <strong>
         :style => "text-decoration: none"
       ),
-      user_url(display_name, :host => SERVER_URL),
+      user_url(display_name, :host => Settings.server_url),
       :target => "_blank",
       :rel => "noopener",
       :style => "text-decoration: none; color: #222"
index e2a05028854470a504412428d4f8e82caaf631ed..66b777b2c3cb7dd19d2b61730edd2e7c3cf7ee8b 100644 (file)
@@ -1,5 +1,5 @@
 class TraceDestroyerJob < ApplicationJob
-  queue_as :default
+  queue_as :traces
 
   def perform(trace)
     trace.destroy
index d41de5836969bbd5cd8592de3bb57f4150521b45..6b8943aa20f2dc5dca20dfdd979429f6f0096bbc 100644 (file)
@@ -1,5 +1,5 @@
 class TraceImporterJob < ApplicationJob
-  queue_as :default
+  queue_as :traces
 
   def perform(trace)
     gpx = trace.import
index 4b53c66f6825f1b38d5fdbde69653002762e9896..e705efb006756f09a6f5ff21ea8b7665689725cc 100644 (file)
@@ -1,6 +1,6 @@
 class Notifier < ActionMailer::Base
-  default :from => EMAIL_FROM,
-          :return_path => EMAIL_RETURN_PATH,
+  default :from => Settings.email_from,
+          :return_path => Settings.email_return_path,
           :auto_submitted => "auto-generated"
   helper :application
   before_action :set_shared_template_vars
@@ -196,14 +196,14 @@ class Notifier < ActionMailer::Base
   end
 
   def from_address(name, type, id, digest, user_id = nil)
-    if Object.const_defined?(:MESSAGES_DOMAIN) && domain = MESSAGES_DOMAIN
+    if Settings.key?(:messages_domain) && domain = Settings.messages_domain
       if user_id
         "#{name} <#{type}-#{id}-#{user_id}-#{digest[0, 6]}@#{domain}>"
       else
         "#{name} <#{type}-#{id}-#{digest[0, 6]}@#{domain}>"
       end
     else
-      EMAIL_FROM
+      Settings.email_from
     end
   end
 end
index 5cdfeb994544444f08edb72cc4f8ba42fead569d..3ca719f6cc663dff860a2157817d34966edb172c 100644 (file)
@@ -196,67 +196,6 @@ class Changeset < ActiveRecord::Base
     end
   end
 
-  def to_xml(include_discussion = false)
-    doc = OSM::API.new.get_xml_doc
-    doc.root << to_xml_node(nil, include_discussion)
-    doc
-  end
-
-  def to_xml_node(user_display_name_cache = nil, include_discussion = false)
-    el1 = XML::Node.new "changeset"
-    el1["id"] = id.to_s
-
-    user_display_name_cache = {} if user_display_name_cache.nil?
-
-    if user_display_name_cache&.key?(user_id)
-      # use the cache if available
-    elsif user.data_public?
-      user_display_name_cache[user_id] = user.display_name
-    else
-      user_display_name_cache[user_id] = nil
-    end
-
-    el1["user"] = user_display_name_cache[user_id] unless user_display_name_cache[user_id].nil?
-    el1["uid"] = user_id.to_s if user.data_public?
-
-    tags.each do |k, v|
-      el2 = XML::Node.new("tag")
-      el2["k"] = k.to_s
-      el2["v"] = v.to_s
-      el1 << el2
-    end
-
-    el1["created_at"] = created_at.xmlschema
-    el1["closed_at"] = closed_at.xmlschema unless is_open?
-    el1["open"] = is_open?.to_s
-
-    bbox.to_unscaled.add_bounds_to(el1, "_") if bbox.complete?
-
-    el1["comments_count"] = comments.length.to_s
-    el1["changes_count"] = num_changes.to_s
-
-    if include_discussion
-      el2 = XML::Node.new("discussion")
-      comments.includes(:author).each do |comment|
-        el3 = XML::Node.new("comment")
-        el3["date"] = comment.created_at.xmlschema
-        el3["uid"] = comment.author.id.to_s if comment.author.data_public?
-        el3["user"] = comment.author.display_name.to_s if comment.author.data_public?
-        el4 = XML::Node.new("text")
-        el4.content = comment.body.to_s
-        el3 << el4
-        el2 << el3
-      end
-      el1 << el2
-    end
-
-    # NOTE: changesets don't include the XML of the changes within them,
-    # they are just structures for tagging. to get the osmChange of a
-    # changeset, see the download method of the controller.
-
-    el1
-  end
-
   ##
   # update this instance from another instance given and the user who is
   # doing the updating. note that this method is not for updating the
index 5dafaaa5c7afefd4097e30f0d3f7283245dacf92..ae95e2908a286793565915fd8f70577387df39c2 100644 (file)
@@ -67,7 +67,7 @@ class ClientApplication < ActiveRecord::Base
   end
 
   def oauth_server
-    @oauth_server ||= OAuth::Server.new("https://" + SERVER_URL)
+    @oauth_server ||= OAuth::Server.new("https://" + Settings.server_url)
   end
 
   def credentials
index ed0cc3ae4c89164f322f32380341f9dbcab0a7c8..f7c9501b56b3c84ce938a98b4966c4c3d8ac11d3 100644 (file)
@@ -77,6 +77,6 @@ class RequestToken < OauthToken
   end
 
   def oauth10?
-    (defined? OAUTH_10_SUPPORT) && OAUTH_10_SUPPORT && callback_url.blank?
+    Settings.key?(:oauth_10_support) && Settings.oauth_10_support && callback_url.blank?
   end
 end
index d2c71524505914e5739fa2b4e52b9176410a2b3f..0e876332874487acbafb3c5b17013e0cbb2b579b 100644 (file)
@@ -110,15 +110,15 @@ class Trace < ActiveRecord::Base
   end
 
   def large_picture_name
-    "#{GPX_IMAGE_DIR}/#{id}.gif"
+    "#{Settings.gpx_image_dir}/#{id}.gif"
   end
 
   def icon_picture_name
-    "#{GPX_IMAGE_DIR}/#{id}_icon.gif"
+    "#{Settings.gpx_image_dir}/#{id}_icon.gif"
   end
 
   def trace_name
-    "#{GPX_TRACE_DIR}/#{id}.gpx"
+    "#{Settings.gpx_trace_dir}/#{id}.gpx"
   end
 
   def mime_type
@@ -289,21 +289,34 @@ class Trace < ActiveRecord::Base
     # If there are any existing points for this trace then delete them
     Tracepoint.where(:gpx_id => id).delete_all
 
-    gpx.points do |point|
-      if first
-        f_lat = point.latitude
-        f_lon = point.longitude
-        first = false
+    gpx.points.each_slice(1_000) do |points|
+      # Gather the trace points together for a bulk import
+      tracepoints = []
+
+      points.each do |point|
+        if first
+          f_lat = point.latitude
+          f_lon = point.longitude
+          first = false
+        end
+
+        tp = Tracepoint.new
+        tp.lat = point.latitude
+        tp.lon = point.longitude
+        tp.altitude = point.altitude
+        tp.timestamp = point.timestamp
+        tp.gpx_id = id
+        tp.trackid = point.segment
+        tracepoints << tp
       end
 
-      tp = Tracepoint.new
-      tp.lat = point.latitude
-      tp.lon = point.longitude
-      tp.altitude = point.altitude
-      tp.timestamp = point.timestamp
-      tp.gpx_id = id
-      tp.trackid = point.segment
-      tp.save!
+      # Run the before_save and before_create callbacks, and then import them in bulk with activerecord-import
+      tracepoints.each do |tp|
+        tp.run_callbacks(:save) { false }
+        tp.run_callbacks(:create) { false }
+      end
+
+      Tracepoint.import!(tracepoints)
     end
 
     if gpx.actual_points.positive?
index fba429338246a1d48a866c2c5d0fa3fe458d7e32..9f13108434793d9f027fe67ac7eab81c19324cd5 100644 (file)
@@ -201,7 +201,7 @@ class User < ActiveRecord::Base
     @preferred_languages = nil
   end
 
-  def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
+  def nearby(radius = Settings.nearby_radius, num = Settings.nearby_users)
     if home_lon && home_lat
       gc = OSM::GreatCircle.new(home_lat, home_lon)
       sql_for_area = QuadTile.sql_for_area(gc.bounds(radius), "home_")
@@ -300,7 +300,7 @@ class User < ActiveRecord::Base
   ##
   # perform a spam check on a user
   def spam_check
-    update(:status => "suspended") if status == "active" && spam_score > SPAM_THRESHOLD
+    update(:status => "suspended") if status == "active" && spam_score > Settings.spam_threshold
   end
 
   ##
index 02af385a7a09389c88aa722ca8766054e3f2f29f..27bc40498b90ba455006ffd054a2eadbb3e7d60f 100644 (file)
@@ -32,7 +32,7 @@ class UserBlock < ActiveRecord::Base
   belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
   belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id
 
-  PERIODS = USER_BLOCK_PERIODS
+  PERIODS = Settings.user_block_periods
 
   ##
   # scope to match active blocks
index c95a1212296acc56746aea30c7959ef0a6678db5..6573b9805ecc449aac0b365e5a9a31798b86f2c2 100644 (file)
@@ -206,7 +206,7 @@ class Way < ActiveRecord::Base
 
   def preconditions_ok?(old_nodes = [])
     return false if nds.empty?
-    raise OSM::APITooManyWayNodesError.new(id, nds.length, MAX_NUMBER_OF_WAY_NODES) if nds.length > MAX_NUMBER_OF_WAY_NODES
+    raise OSM::APITooManyWayNodesError.new(id, nds.length, Settings.max_number_of_way_nodes) if nds.length > Settings.max_number_of_way_nodes
 
     # check only the new nodes, for efficiency - old nodes having been checked last time and can't
     # be deleted when they're in-use.
index 3fa79058b13b759bd9b3c4eb43151fe4659a6d52..682373898be4398a2402a7668b620e12a946aa0a 100644 (file)
@@ -1,20 +1,20 @@
 xml.instruct! :xml, :version => "1.0"
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
   osm.api do |api|
-    api.version(:minimum => API_VERSION.to_s, :maximum => API_VERSION.to_s)
-    api.area(:maximum => MAX_REQUEST_AREA.to_s)
-    api.note_area(:maximum => MAX_NOTE_REQUEST_AREA.to_s)
-    api.tracepoints(:per_page => TRACEPOINTS_PER_PAGE.to_s)
-    api.waynodes(:maximum => MAX_NUMBER_OF_WAY_NODES.to_s)
-    api.changesets(:maximum_elements => Changeset::MAX_ELEMENTS.to_s)
-    api.timeout(:seconds => API_TIMEOUT.to_s)
-    api.status(:database => @database_status.to_s,
-               :api => @api_status.to_s,
-               :gpx => @gpx_status.to_s)
+    api.version(:minimum => Settings.api_version, :maximum => Settings.api_version)
+    api.area(:maximum => Settings.max_request_area)
+    api.note_area(:maximum => Settings.max_note_request_area)
+    api.tracepoints(:per_page => Settings.tracepoints_per_page)
+    api.waynodes(:maximum => Settings.max_number_of_way_nodes)
+    api.changesets(:maximum_elements => Changeset::MAX_ELEMENTS)
+    api.timeout(:seconds => Settings.api_timeout)
+    api.status(:database => @database_status,
+               :api => @api_status,
+               :gpx => @gpx_status)
   end
   osm.policy do |policy|
     policy.imagery do |imagery|
-      IMAGERY_BLACKLIST.each do |url_regex|
+      Settings.imagery_blacklist.each do |url_regex|
         imagery.blacklist(:regex => url_regex.to_s)
       end
     end
diff --git a/app/views/api/changesets/_changeset.builder b/app/views/api/changesets/_changeset.builder
new file mode 100644 (file)
index 0000000..47c494d
--- /dev/null
@@ -0,0 +1,43 @@
+# basic attributes
+
+attrs = {
+  "id" => changeset.id,
+  "created_at" => changeset.created_at.xmlschema,
+  "open" => changeset.is_open?,
+  "comments_count" => changeset.comments.length,
+  "changes_count" => changeset.num_changes
+}
+attrs["closed_at"] = changeset.closed_at unless changeset.is_open?
+changeset.bbox.to_unscaled.add_bounds_to(attrs, "_") if changeset.bbox.complete?
+
+# user attributes
+
+if changeset.user.data_public?
+  attrs["uid"] = changeset.user_id
+  attrs["user"] = changeset.user.display_name
+end
+
+xml.changeset(attrs) do |changeset_xml_node|
+  changeset.tags.each do |k, v|
+    changeset_xml_node.tag(:k => k, :v => v)
+  end
+
+  # include discussion if requested
+
+  if @include_discussion
+    changeset_xml_node.discussion do |discussion_xml_node|
+      changeset.comments.includes(:author).each do |comment|
+        cattrs = {
+          "date" => comment.created_at.xmlschema
+        }
+        if comment.author.data_public?
+          cattrs["uid"] = comment.author.id
+          cattrs["user"] = comment.author.display_name
+        end
+        discussion_xml_node.comment(cattrs) do |comment_xml_node|
+          comment_xml_node.text(comment.body)
+        end
+      end
+    end
+  end
+end
diff --git a/app/views/api/changesets/changeset.builder b/app/views/api/changesets/changeset.builder
new file mode 100644 (file)
index 0000000..e8da400
--- /dev/null
@@ -0,0 +1,7 @@
+xml.instruct! :xml, :version => "1.0"
+
+# basic attributes
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+  osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => @changeset })
+end
diff --git a/app/views/api/changesets/changesets.builder b/app/views/api/changesets/changesets.builder
new file mode 100644 (file)
index 0000000..da434f1
--- /dev/null
@@ -0,0 +1,9 @@
+xml.instruct! :xml, :version => "1.0"
+
+# basic attributes
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+  @changesets.each do |changeset|
+    osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => changeset })
+  end
+end
index 8c6b246d80b145f8fd3cd31102fa3219cc3fb346..86d4665cf0aea7dc3247d7961d30140c46741da4 100644 (file)
@@ -25,8 +25,8 @@
   <%= tag("meta", { :name => "msapplication-TileImage", :content => image_path("mstile-144x144.png") }) %>
   <%= tag("meta", { :name => "theme-color", :content => "#ffffff" }) %>
   <%= canonical_tag %>
-  <% if defined?(PUBLISHER_URL) -%>
-  <%= tag("link", { :rel => "publisher", :href => PUBLISHER_URL }) %>
+  <% if Settings.key?(:publisher_url) -%>
+  <%= tag("link", { :rel => "publisher", :href => Settings.publisher_url }) %>
   <% end -%>
   <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => asset_path("osm.xml") }) %>
   <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %>
index 946f95febf22f23aee9ba1391a70c2ab247be514..a9919f7d2216949b4ea76e691f22f0e4df5c8ea9 100644 (file)
@@ -54,7 +54,7 @@
       <li id="compact-secondary-nav" class="dropdown">
         <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= t 'layouts.more' %> <b class="caret"></b></a>
         <ul class="dropdown-menu">
-          <% if can? :index, Issue %>
+          <% if Settings.status != "database_offline" && can?(:index, Issue) %>
             <li class="<%= current_page_class(issues_path) %>">
               <%= link_to issues_path(:status => 'open') do %>
                 <%= open_issues_count %>
index 5b7c74d7f52dd608bcb41569b6db3c5577d6654b..369c81ae66531d8b70b10d4d4f9089fd1623c580 100644 (file)
@@ -1,6 +1,6 @@
 <p><%= t 'notifier.email_confirm_html.greeting' %></p>
 
-<p><%= t 'notifier.email_confirm_html.hopefully_you', :server_url => SERVER_URL, :new_address => @address %></p>
+<p><%= t 'notifier.email_confirm_html.hopefully_you', :server_url => Settings.server_url, :new_address => @address %></p>
 
 <p><%= t 'notifier.email_confirm_html.click_the_link' %></p>
 
index db9ae0f93f5abb6117880d4b3e771e47094983cc..7c4f0a5abbbe3718e131cb4a4632b4bab688540a 100644 (file)
@@ -1,6 +1,6 @@
 <%= t 'notifier.email_confirm_plain.greeting' %>
 
-<%= word_wrap(t 'notifier.email_confirm_plain.hopefully_you', :server_url => SERVER_URL, :new_address => @address) %>
+<%= word_wrap(t 'notifier.email_confirm_plain.hopefully_you', :server_url => Settings.server_url, :new_address => @address) %>
 
 <%= t 'notifier.email_confirm_plain.click_the_link' %>
 
index a0e0079fc537f92a1fa06c4fdb6ab235379634b5..ea7d101d0e94fbccd2f0511f59d45805be99805e 100644 (file)
@@ -1,6 +1,6 @@
 <p><%= t(".greeting") %></p>
 
-<p><%= t(".created", :site_url => SERVER_URL) %></p>
+<p><%= t(".created", :site_url => Settings.server_url) %></p>
 
 <p><%= t(".confirm") %></p>
 
index e170564687ec0e6f581053fc1033904e44f1de05..774209e5981d99290d0cd4cd60b7dc035c8f0f3d 100644 (file)
@@ -1,6 +1,6 @@
 <%= fp(t(".greeting")) %>
 
-<%= fp(t(".created", :site_url => SERVER_URL)) %>
+<%= fp(t(".created", :site_url => Settings.server_url)) %>
 
 <%= fp(t(".confirm")) %>
 
index 867b148fd4aeba0ea4b1ba5a47945d33a0e6a238..9b44ed4613f38a64345a3e980aa56a0a8dda31c4 100644 (file)
@@ -1,7 +1,7 @@
 <%= javascript_include_tag "edit/id" %>
 
 <div id="map">
-  <% data = { :key => ID_KEY } -%>
+  <% data = { :key => Settings.id_key } -%>
   <% data[:lat] = @lat if @lat -%>
   <% data[:lon] = @lon if @lon -%>
   <% data[:gpx] = trace_data_url(params[:gpx], :format => :xml) if params[:gpx] -%>
index 9e01eef302ab204e49d4d2d5278bd896b6aa7663..eb2a593768330017bf8d4577006a9c438c2feeda 100644 (file)
@@ -6,8 +6,8 @@
   <% data[:lat] = @lat if @lat -%>
   <% data[:lon] = @lon if @lon -%>
   <% data[:zoom] = @zoom if @zoom -%>
-  <% if defined? POTLATCH2_KEY %>
-  <% token = current_user.access_token(POTLATCH2_KEY) %>
+  <% if Settings.key?(:potlatch2_key) %>
+  <% token = current_user.access_token(Settings.potlatch2_key) %>
   <% data[:token] = token.token -%>
   <% data[:token_secret] = token.secret -%>
   <% data[:consumer_key] = token.client_application.key -%>
index ce766fe3426d4c677b3e42f1e51d6e239b1017b6..de4ff3cab1cc6304cf02acca9401ff448adbad5c 100644 (file)
@@ -70,6 +70,7 @@
     <li><%= t ".legal_babble.contributors_nl_html", :locale => @locale %></li>
     <li><%= t ".legal_babble.contributors_nz_html", :locale => @locale %></li>
     <li><%= t ".legal_babble.contributors_si_html", :locale => @locale %></li>
+    <li><%= t ".legal_babble.contributors_es_html", :locale => @locale %></li>
     <li><%= t ".legal_babble.contributors_za_html", :locale => @locale %></li>
     <li><%= t ".legal_babble.contributors_gb_html", :locale => @locale %></li>
   </ul>
index e84adf2d48bae0d20188c14b20c772f0521167ef..d89af0596a5ebc566fa92c81b90520a2f6c64691 100644 (file)
@@ -1,7 +1,7 @@
 <% content_for :content do %>
-  <% if STATUS == :database_offline or STATUS == :api_offline %>
+  <% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
     <p><%= t 'layouts.osm_offline' %></p>
-  <% elsif STATUS == :database_readonly or STATUS == :api_readonly %>
+  <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
     <p><%= t 'layouts.osm_read_only' %></p>
   <% elsif !current_user.data_public? %>
     <p><%= t '.not_public' %></p>
index c115ea59ff47d5c71596f603585535a8c66453bc..f8d0f5858cc7ab0dc3be3e9bade086b4cd32d69b 100644 (file)
@@ -9,8 +9,8 @@
 </head>
 <body>
 <% data = {} -%>
-<% if defined? ID_KEY %>
-<% token = current_user.access_token(ID_KEY) %>
+<% if Settings.key?(:id_key) %>
+<% token = current_user.access_token(Settings.id_key) %>
 <% data[:token] = token.token -%>
 <% data[:token_secret] = token.secret -%>
 <% data[:consumer_key] = token.client_application.key -%>
index 34a2eacc54a0ab4883f4b417ac979f057f0cac0c..d306c2af91fb5d79b3128e6ede3d402e34e83325 100644 (file)
@@ -1,4 +1,4 @@
-<% if STATUS == :database_offline %>
+<% if Settings.status == "database_offline" %>
 <p><%= t 'layouts.osm_offline' %>
 </p>
 <% else %>
index b81e190255a07ef0a0733d43268b40f1bcb16b22..849695e80f86514fb7321b2fc8c129a88edd65d0 100644 (file)
@@ -1,7 +1,7 @@
 <tr>
   <% cl = cycle('table0', 'table1') %>
   <td class="<%= cl %>">
-    <% if STATUS != :gpx_offline %>
+    <% if Settings.status != "gpx_offline" %>
       <% if trace.inserted %>
         <a href="<%= url_for :controller => 'traces', :action => 'show', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'traces', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
       <% else %>
index 178cfbe73235d9e677e8407554b55ab42f254dd7..f8e8510f9de286c3d1b857fb3b6e2f9d0e3386ce 100644 (file)
@@ -2,7 +2,7 @@
   <h2><%= t '.heading', :name => h(@trace.name) %></h2>
 <% end %>
 
-<% if STATUS != :gpx_offline %>
+<% if Settings.status != "gpx_offline" %>
   <% if @trace.inserted %>
     <img src="<%= url_for :controller => 'traces', :action => 'picture', :id => @trace.id, :display_name => @trace.user.display_name %>">
   <% else %>
index 7638b7a770ed9162be1c78b0c4e7cf5f7e30faf2..233f2629fa96f1ca84174e4c873d8b17c36e376f 100644 (file)
@@ -85,7 +85,7 @@
     </div>
     <div class="form-row">
       <label class="standard-label"><%= t '.preferred editor' %></label>
-      <%= f.select :preferred_editor, [[t("editor.default", :name => t("editor.#{DEFAULT_EDITOR}.name")), 'default']] + Editors::ALL_EDITORS.collect { |e| [t("editor.#{e}.description"), e] } %>
+      <%= f.select :preferred_editor, [[t("editor.default", :name => t("editor.#{Settings.default_editor}.name")), 'default']] + Editors::ALL_EDITORS.collect { |e| [t("editor.#{e}.description"), e] } %>
     </div>
   </fieldset>
 
index d5be31ef649f278871bef192164d91f399424848..08ce4cc539454e02f3166332b3da6d02e3521bba 100644 (file)
@@ -6,5 +6,5 @@
 
 <div class="message">
   <h1><%= t 'users.new.no_auto_account_create' %></h1>
-  <h2><%= raw t 'users.new.contact_webmaster', :webmaster => "mailto:#{SUPPORT_EMAIL}" %></h2>
+  <h2><%= raw t 'users.new.contact_webmaster', :webmaster => "mailto:#{Settings.support_email}" %></h2>
 </div>
index 04a04158c93d973569c0392edeafd16fb0b06426..2e27875d2bab5f40d628547b6dd920f53b96a1c7 100644 (file)
 
         <ul class='clearfix' id="login_auth_buttons">
           <li><%= link_to image_tag("openid.png", :alt => t(".auth_providers.openid.title")), "#", :id => "openid_open_url", :title => t(".auth_providers.openid.title") %></li>
-          <% if defined?(GOOGLE_AUTH_ID) -%>
+          <% if Settings.key?(:google_auth_id) -%>
           <li><%= auth_button "google", "google" %></li>
           <% end -%>
-          <% if defined?(FACEBOOK_AUTH_ID) -%>
+          <% if Settings.key?(:facebook_auth_id) -%>
           <li><%= auth_button "facebook", "facebook" %></li>
           <% end -%>
-          <% if defined?(WINDOWSLIVE_AUTH_ID) -%>
+          <% if Settings.key?(:windowslive_auth_id) -%>
           <li><%= auth_button "windowslive", "windowslive" %></li>
           <% end -%>
-          <% if defined?(GITHUB_AUTH_ID) -%>
+          <% if Settings.key?(:github_auth_id) -%>
           <li><%= auth_button "github", "github" %></li>
           <% end -%>
-          <% if defined?(WIKIPEDIA_AUTH_ID) -%>
+          <% if Settings.key?(:wikipedia_auth_id) -%>
           <li><%= auth_button "wikipedia", "wikipedia" %></li>
           <% end -%>
           <li><%= auth_button "yahoo", "openid", :openid_url => "yahoo.com" %></li>
index 20547569d21842898798da6b592e53e2fc526fff..3a2df498ad197d0f8b2734cf716a4bccf7d67efc 100644 (file)
@@ -4,4 +4,4 @@
   <h1><%= t ".heading" %></h1>
 <% end %>
 
-<%= raw t ".body", :webmaster => link_to(t(".webmaster"), "mailto:#{SUPPORT_EMAIL}") %>
+<%= raw t ".body", :webmaster => link_to(t(".webmaster"), "mailto:#{Settings.support_email}") %>
index f8580b4261aeb954e811f0701876c6787b6d1939..b5649dd032e81aa0bf153efcb1d90e9bbfe20df4 100644 (file)
@@ -1,2 +1 @@
-application.yml
 database.yml
index 5139111cc8460dce6bb65d296ff8b84b2c82c37e..3b470bacc5fc2759da6258fc3dd3badaffc26775 100644 (file)
@@ -1,11 +1,13 @@
 require_relative "boot"
 
-require_relative "preinitializer"
-
-if STATUS == :database_offline
+if ENV["OPENSTREETMAP_STATUS"] == "database_offline"
+  require "active_model/railtie"
+  require "active_job/railtie"
+  require "active_storage/engine"
   require "action_controller/railtie"
   require "action_mailer/railtie"
-  require "active_model/railtie"
+  require "action_view/railtie"
+  require "action_cable/engine"
   require "sprockets/railtie"
   require "rails/test_unit/railtie"
 else
@@ -31,24 +33,24 @@ module OpenStreetMap
 
     # This defaults to true from rails 5.0 but our code doesn't comply
     # with it at all so we turn it off
-    config.active_record.belongs_to_required_by_default = false
+    config.active_record.belongs_to_required_by_default = false unless Settings.status == "database_offline"
 
     # Use SQL instead of Active Record's schema dumper when creating the database.
     # This is necessary if your schema can't be completely dumped by the schema dumper,
     # like if you have constraints or database-specific column types
-    config.active_record.schema_format = :sql unless STATUS == :database_offline
+    config.active_record.schema_format = :sql unless Settings.status == "database_offline"
 
     # Don't eager load models when the database is offline
-    config.paths["app/models"].skip_eager_load! if STATUS == :database_offline
+    config.paths["app/models"].skip_eager_load! if Settings.status == "database_offline"
 
     # Use memcached for caching if required
-    config.cache_store = :mem_cache_store, MEMCACHE_SERVERS, { :namespace => "rails:cache" } if defined?(MEMCACHE_SERVERS)
+    config.cache_store = :mem_cache_store, Settings.memcache_servers, { :namespace => "rails:cache" } if Settings.key?(:memcache_servers)
 
     # Use logstash for logging if required
-    if defined?(LOGSTASH_PATH)
+    if Settings.key?(:logstash_path)
       config.logstasher.enabled = true
       config.logstasher.suppress_app_log = false
-      config.logstasher.logger_path = LOGSTASH_PATH
+      config.logstasher.logger_path = Settings.logstash_path
       config.logstasher.log_controller_parameters = true
     end
   end
index bb99b5f0a5233650ea2695338c9d71fe2bc4f0c3..2d3f4dd6305c66a05f9ad7336e29ff7a4d2fc5c0 100644 (file)
@@ -4,3 +4,9 @@ sotm2018:
   link: https://2018.stateofthemap.org/
   img: banners/sotm2018.png
   enddate: 2018-jul-30
+saveyourinternet:
+  id: saveyourinternet
+  alt: "The EU Copyright Directive threatens free content on the Internet and OpenStreetMap. Demonstrations in various European cities on 23 March. https://savetheinternet.info/demos"
+  link: https://savetheinternet.info/demos
+  img: banners/saveyourinternet.png
+  enddate: 2019-mar-26
index b7e60eb4fd9ad352854f96bcee53fa52d3518afc..9a3976f76dd83f20c6754a8f2334b108a008f5da 100644 (file)
@@ -39,10 +39,10 @@ Rails.application.configure do
   config.active_support.deprecation = :log
 
   # Raise an error on page load if there are pending migrations.
-  config.active_record.migration_error = :page_load unless STATUS == :database_offline
+  config.active_record.migration_error = :page_load unless Settings.status == "database_offline"
 
   # Highlight code that triggered database queries in logs.
-  config.active_record.verbose_query_logs = true
+  config.active_record.verbose_query_logs = true unless Settings.status == "database_offline"
 
   # Debug mode disables concatenation and preprocessing of assets.
   # This option may cause significant delays in view rendering with a large
index 9e15487ae4877fb80d9d1e0177958dbaee7efead..97121d5a72825f31009a75edcabcdccfed8676d3 100644 (file)
@@ -57,7 +57,7 @@ Rails.application.configure do
   config.log_tags = [:request_id]
 
   # Use a different log path in production.
-  config.paths["log"] = LOG_PATH if defined?(LOG_PATH)
+  config.paths["log"] = Settings.log_path if Settings.key?(:log_path)
 
   # Use a different cache store in production.
   # config.cache_store = :mem_cache_store
@@ -95,7 +95,7 @@ Rails.application.configure do
   end
 
   # Do not dump schema after migrations.
-  config.active_record.dump_schema_after_migration = false unless STATUS == :database_offline
+  config.active_record.dump_schema_after_migration = false unless Settings.status == "database_offline"
 
   # Enable autoloading of dependencies.
   config.enable_dependency_loading = true
diff --git a/config/example.application.yml b/config/example.application.yml
deleted file mode 100644 (file)
index 8596e10..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-defaults: &defaults
-  # The server protocol and host
-  server_protocol: "http"
-  server_url: "openstreetmap.example.com"
-  # Publisher
-  #publisher_url: ""
-  # The generator
-  generator: "OpenStreetMap server"
-  copyright_owner: "OpenStreetMap and contributors"
-  attribution_url: "http://www.openstreetmap.org/copyright"
-  license_url: "http://opendatacommons.org/licenses/odbl/1-0/"
-  # Support email address
-  support_email: "openstreetmap@example.com"
-  # Sender addresses for emails
-  email_from: "OpenStreetMap <openstreetmap@example.com>"
-  email_return_path: "openstreetmap@example.com"
-  # API version
-  api_version: "0.6"
-  # Application status - possible values are:
-  #   :online - online and operating normally
-  #   :api_readonly - site online but API in read-only mode
-  #   :api_offline - site online but API offline
-  #   :database_readonly - database and site in read-only mode
-  #   :database_offline - database offline with site in emergency mode
-  #   :gpx_offline - gpx storage offline
-  status: :online
-  # The maximum area you're allowed to request, in square degrees
-  max_request_area: 0.25
-  # Number of GPS trace/trackpoints returned per-page
-  tracepoints_per_page: 5000
-  # Maximum number of nodes that will be returned by the api in a map request
-  max_number_of_nodes: 50000
-  # Maximum number of nodes that can be in a way (checked on save)
-  max_number_of_way_nodes: 2000
-  # The maximum area you're allowed to request notes from, in square degrees
-  max_note_request_area: 25
-  # Zoom level to use for postcode results from the geocoder
-  postcode_zoom: 15
-  # Zoom level to use for geonames results from the geocoder
-  geonames_zoom: 12
-  # Timeout for API calls in seconds
-  api_timeout: 300
-  # Timeout for web pages in seconds
-  web_timeout: 30
-  # Periods (in hours) which are allowed for user blocks
-  user_block_periods: [0, 1, 3, 6, 12, 24, 48, 96]
-  # Rate limit for message sending
-  max_messages_per_hour: 60
-  # Domain for handling message replies
-  #messages_domain: "messages.openstreetmap.org"
-  # Geonames authentication details
-  #geonames_username: ""
-  # GeoIP database
-  #geoip_database: ""
-  # Users to show as being nearby
-  nearby_users: 30
-  # Max radius, in km, for nearby users
-  nearby_radius: 50
-  # Spam threshold
-  spam_threshold: 50
-  # Default legale (jurisdiction location) for contributor terms
-  default_legale: GB
-  # Use the built-in jobs queue for importing traces
-  # Leave as false if you are using the external high-speed gpx importer
-  # https://github.com/openstreetmap/gpx-import
-  trace_use_job_queue: false
-  # Location of GPX traces and images
-  gpx_trace_dir: "/home/osm/traces"
-  gpx_image_dir: "/home/osm/images"
-  # Location of data for attachments
-  attachments_dir: ":rails_root/public/attachments"
-  # Log file to use
-  #log_path: ""
-  # Log file to use for logstash
-  #logstash_path: ""
-  # List of memcache servers to use for caching
-  #memcache_servers: []
-  # Enable legacy OAuth 1.0 support
-  oauth_10_support: true
-  # URL of Nominatim instance to use for geocoding
-  nominatim_url: "https://nominatim.openstreetmap.org/"
-  # Default editor
-  default_editor: "id"
-  # OAuth consumer key for Potlatch 2
-  #potlatch2_key: ""
-  # OAuth consumer key for the web site
-  #oauth_key: ""
-  # OAuth consumer key for iD
-  #id_key: ""
-  # Imagery to return in capabilities as blacklisted
-  imagery_blacklist:
-    # Current Google imagery URLs have google or googleapis in the domain
-    # with a vt or kh endpoint, and x, y and z query parameters
-    - ".*\\.google(apis)?\\..*/(vt|kh)[\\?/].*([xyz]=.*){3}.*"
-    # Blacklist VWorld
-    - "http://xdworld\\.vworld\\.kr:8080/.*"
-    # Blacklist here
-    - ".*\\.here\\.com[/:].*"
-  # URL of Overpass instance to use for feature queries
-  overpass_url: "https://overpass-api.de/api/interpreter"
-  # Routing endpoints
-  graphhopper_url: "https://graphhopper.com/api/1/route"
-  fossgis_osrm_url: "https://routing.openstreetmap.de/"
-  # External authentication credentials
-  #google_auth_id: ""
-  #google_auth_secret: ""
-  #google_openid_realm: ""
-  #facebook_auth_id: ""
-  #facebook_auth_secret: ""
-  #windowslive_auth_id: ""
-  #windowslive_auth_secret: ""
-  #github_auth_id: ""
-  #github_auth_secret: ""
-  #wikipedia_auth_id: ""
-  #wikipedia_auth_secret: ""
-  # Thunderforest authentication details
-  #thunderforest_key: ""
-  # Key for generating TOTP tokens
-  #totp_key: ""
-  # Enforce Content-Security-Policy
-  csp_enforce: false
-  # URL for reporting Content-Security-Policy violations
-  #csp_report_url: ""
-
-development:
-  <<: *defaults
-
-production:
-  <<: *defaults
-
-test:
-  <<: *defaults
-  # Geonames credentials for testing
-  geonames_username: "dummy"
-  # External authentication credentials for testing
-  google_auth_id: "dummy"
-  google_auth_secret: "dummy"
-  google_openid_realm: "https://www.openstreetmap.org"
-  facebook_auth_id: "dummy"
-  facebook_auth_secret: "dummy"
-  windowslive_auth_id: "dummy"
-  windowslive_auth_secret: "dummy"
-  github_auth_id: "dummy"
-  github_auth_secret: "dummy"
-  wikipedia_auth_id: "dummy"
-  wikipedia_auth_secret: "dummy"
index 54da2813912d51396cdea479f6d0a219823eab78..32dfa79bbfea05f7de1396385727e8debec7baf8 100644 (file)
@@ -8,6 +8,6 @@ ActionMailer::Base.smtp_settings = {
 
 # Set the host and protocol for all ActionMailer URLs
 ActionMailer::Base.default_url_options = {
-  :host => SERVER_URL,
-  :protocol => SERVER_PROTOCOL
+  :host => Settings.server_url,
+  :protocol => Settings.server_protocol
 }
index 0d1461ed7b153758d893a1216a602a3f9ef792e8..c2c8440476adae5375cdc4713eeb9edd6bb70e89 100644 (file)
@@ -1,12 +1,12 @@
 CanonicalRails.setup do |config|
   # Force the protocol. If you do not specify, the protocol will be based on the incoming request's protocol.
 
-  config.protocol = "#{SERVER_PROTOCOL}://"
+  config.protocol = "#{Settings.server_protocol}://"
 
   # This is the main host, not just the TLD, omit slashes and protocol. If you have more than one, pick the one you want to rank in search results.
 
-  config.host = SERVER_URL
-  config.port = SERVER_PROTOCOL == "https" ? 443 : 80
+  config.host = Settings.server_url
+  config.port = Settings.server_protocol == "https" ? 443 : 80
 
   # http://en.wikipedia.org/wiki/URL_normalization
   # Trailing slash represents semantics of a directory, ie a collection view - implying an :index get route;
diff --git a/config/initializers/config.rb b/config/initializers/config.rb
new file mode 100644 (file)
index 0000000..f7d5d79
--- /dev/null
@@ -0,0 +1,81 @@
+# Guard against deployments with old-style application.yml configurations
+# Otherwise, admins might not be aware that they are now silently ignored
+# and major problems could occur
+# rubocop:disable Rails/Output, Rails/Exit
+if File.exist?(Rails.root.join("config", "application.yml"))
+  puts "The config/application.yml file is no longer supported."
+  puts ""
+  puts "Default settings are now found in config/settings.yml and you"
+  puts "can override these in config/settings.local.yml."
+  puts ""
+  puts "To prevent unexpected behaviour, please copy any custom"
+  puts "settings to config/settings.local.yml and then remove"
+  puts "your config/application.yml file."
+  exit!
+end
+# rubocop:enable Rails/Output, Rails/Exit
+
+# Allowed status values
+ALLOWED_STATUS ||= [
+  "online",            # online and operating normally
+  "api_readonly",      # site online but API in read-only mode
+  "api_offline",       # site online but API offline
+  "database_readonly", # database and site in read-only mode
+  "database_offline",  # database offline with site in emergency mode
+  "gpx_offline"        # gpx storage offline
+].freeze
+
+Config.setup do |config|
+  # Name of the constant exposing loaded settings
+  config.const_name = "Settings"
+
+  # Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
+  #
+  # config.knockout_prefix = nil
+
+  # Overwrite an existing value when merging a `nil` value.
+  # When set to `false`, the existing value is retained after merge.
+  #
+  # config.merge_nil_values = true
+
+  # Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
+  #
+  # config.overwrite_arrays = true
+
+  # Load environment variables from the `ENV` object and override any settings defined in files.
+  #
+  config.use_env = true
+
+  # Define ENV variable prefix deciding which variables to load into config.
+  #
+  config.env_prefix = "OPENSTREETMAP"
+
+  # What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
+  # with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
+  # using dots in variable names might not be allowed (eg. Bash).
+  #
+  config.env_separator = "_"
+
+  # Ability to process variables names:
+  #   * nil  - no change
+  #   * :downcase - convert to lower case
+  #
+  config.env_converter = :downcase
+
+  # Parse numeric values as integers instead of strings.
+  #
+  # config.env_parse_values = true
+
+  # Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
+  #
+  config.schema do
+    required(:api_version).filled(:str?)
+    required(:max_request_area).filled(:number?)
+    required(:max_note_request_area).filled(:number?)
+    required(:tracepoints_per_page).filled(:int?)
+    required(:max_number_of_way_nodes).filled(:int?)
+    required(:api_timeout).filled(:int?)
+    required(:imagery_blacklist).maybe(:array?)
+    required(:status).filled(:str?, :included_in? => ALLOWED_STATUS)
+  end
+end
index 7e499c0e6960cc7aa2545d0ada0eb73bfe9274d7..dc5b28e66f55ef1b58cf3470c61e03e10d041add 100644 (file)
@@ -9,10 +9,10 @@ OpenID::Util.logger = Rails.logger
 OmniAuth.config.logger = Rails.logger
 OmniAuth.config.failure_raise_out_environments = []
 
-if defined?(MEMCACHE_SERVERS)
+if Settings.key?(:memcache_servers)
   require "openid/store/memcache"
 
-  openid_store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
+  openid_store = OpenID::Store::Memcache.new(Dalli::Client.new(Settings.memcache_servers, :namespace => "rails"))
 else
   require "openid/store/filesystem"
 
@@ -26,13 +26,13 @@ windowslive_options = { :name => "windowslive", :scope => "wl.signin,wl.emails"
 github_options = { :name => "github", :scope => "user:email" }
 wikipedia_options = { :name => "wikipedia", :client_options => { :site => "https://meta.wikimedia.org" } }
 
-google_options[:openid_realm] = GOOGLE_OPENID_REALM if defined?(GOOGLE_OPENID_REALM)
+google_options[:openid_realm] = Settings.google_openid_realm if Settings.key?(:google_openid_realm)
 
 Rails.application.config.middleware.use OmniAuth::Builder do
   provider :openid, openid_options
-  provider :google_oauth2, GOOGLE_AUTH_ID, GOOGLE_AUTH_SECRET, google_options if defined?(GOOGLE_AUTH_ID)
-  provider :facebook, FACEBOOK_AUTH_ID, FACEBOOK_AUTH_SECRET, facebook_options if defined?(FACEBOOK_AUTH_ID)
-  provider :windowslive, WINDOWSLIVE_AUTH_ID, WINDOWSLIVE_AUTH_SECRET, windowslive_options if defined?(WINDOWSLIVE_AUTH_ID)
-  provider :github, GITHUB_AUTH_ID, GITHUB_AUTH_SECRET, github_options if defined?(GITHUB_AUTH_ID)
-  provider :mediawiki, WIKIPEDIA_AUTH_ID, WIKIPEDIA_AUTH_SECRET, wikipedia_options if defined?(WIKIPEDIA_AUTH_ID)
+  provider :google_oauth2, Settings.google_auth_id, Settings.google_auth_secret, google_options if Settings.key?(:google_auth_id)
+  provider :facebook, Settings.facebook_auth_id, Settings.facebook_auth_secret, facebook_options if Settings.key?(:facebook_auth_id)
+  provider :windowslive, Settings.windowslive_auth_id, Settings.windowslive_auth_secret, windowslive_options if Settings.key?(:windowslive_auth_id)
+  provider :github, Settings.github_auth_id, Settings.github_auth_secret, github_options if Settings.key?(:github_auth_id)
+  provider :mediawiki, Settings.wikipedia_auth_id, Settings.wikipedia_auth_secret, wikipedia_options if Settings.key?(:wikipedia_auth_id)
 end
index 4db3166ae9a4419003f541bc53772ddc557e9dc6..3aa1d003e354107cc672209daf8477bbe6827569 100644 (file)
@@ -21,5 +21,5 @@ Rails.application.config.after_initialize do |_app|
 end
 
 Paperclip::Attachment.default_options[:url] = "/attachments/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
-Paperclip::Attachment.default_options[:path] = "#{ATTACHMENTS_DIR}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
+Paperclip::Attachment.default_options[:path] = "#{Settings.attachments_dir}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
 Paperclip::Attachment.default_options[:url_generator] = Paperclip::AssetUrlGenerator
index daddd762df65cbdaace333765f6769a425993eb7..54702a39915818ebbd0bace6a7486766c0b445cc 100644 (file)
@@ -21,7 +21,7 @@ csp_policy = {
 csp_policy[:connect_src] << PIWIK["location"] if defined?(PIWIK)
 csp_policy[:img_src] << PIWIK["location"] if defined?(PIWIK)
 csp_policy[:script_src] << PIWIK["location"] if defined?(PIWIK)
-csp_policy[:report_uri] << CSP_REPORT_URL if defined?(CSP_REPORT_URL)
+csp_policy[:report_uri] << Settings.csp_report_url if Settings.key?(:csp_report_url)
 
 cookie_policy = {
   :secure => SecureHeaders::OPT_OUT,
@@ -31,10 +31,10 @@ cookie_policy = {
 SecureHeaders::Configuration.default do |config|
   config.hsts = SecureHeaders::OPT_OUT
 
-  if CSP_ENFORCE
+  if Settings.csp_enforce
     config.csp = csp_policy
     config.csp_report_only = SecureHeaders::OPT_OUT
-  elsif defined?(CSP_REPORT_URL)
+  elsif Settings.key?(:csp_report_url)
     config.csp = SecureHeaders::OPT_OUT
     config.csp_report_only = csp_policy
   else
index a9c735d6255d40e20cdc2e6eaa5fc206850e6fa0..a122848553bf1a9f00fe4d09f2f18ee292617f3b 100644 (file)
@@ -1,7 +1,7 @@
 # Be sure to restart your server when you modify this file.
 
-if defined?(MEMCACHE_SERVERS)
-  Rails.application.config.session_store :mem_cache_store, :memcache_server => MEMCACHE_SERVERS, :namespace => "rails:session", :key => "_osm_session"
+if Settings.key?(:memcache_servers)
+  Rails.application.config.session_store :mem_cache_store, :memcache_server => Settings.memcache_servers, :namespace => "rails:session", :key => "_osm_session"
 else
   Rails.application.config.session_store :cache_store, :key => "_osm_session", :cache => ActiveSupport::Cache::MemoryStore.new
 end
index 7db8e4e99657c169b6630fb7c3d20b630848231b..f811fce4dbce0d3a2746f595d4aa536e31833c71 100644 (file)
@@ -1452,6 +1452,11 @@ ar:
           <a href="http://www.gu.gov.si/en/"> Authority Survey and Mapping Authority </a> and
           <a href="http://www.mkgp.gov.si/en/"> وزارة الزراعة والغابات والأغذية </a>
           (معلومات عامة من سلوفينيا).
+        contributors_es_html: |-
+          <strong>es </strong>: تحتوي على بيانات مصدرها
+          المعهد الجغرافي الوطني الإسباني (<a href="http://www.ign.es/">IGN</a>) و
+          النظام الوطني لرسم الخرائط (<a href="http://www.scne.es/">SCNE</a>)
+          مرخصة لإعادة الاستخدام بموجب <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_za_html: |-
           <strong> جنوب إفريقيا </ strong>: يحتوي على بيانات مصدرها
           <a href="http://www.ngi.gov.za/"> المديرية العامة:
index 366e30f3ad06be13665364d118e4e117fab725a6..fd2698a02708bb017e152f724a7119c99a647c2f 100644 (file)
@@ -527,7 +527,7 @@ arz:
     logo:
       alt_text: شعار خريطه الشارع المفتوحة
     home: روح للصفحه الرئيسيه
-    logout: Ø§Ø®Ø±ج
+    logout: Ø®Ø±Ù\88ج
     log_in: تسجيل الدخول
     log_in_tooltip: سجّل الدخول مع حساب موجود
     sign_up: اعمل حساب
index a633ebba848be79dc888223cef0ba87a2fbc9662..5ceda3ef9855bf31e18d135ab78437ee36de7dfb 100644 (file)
@@ -1454,7 +1454,7 @@ br:
           National Geo-Spatial Information</a>, State copyright reserved.
         contributors_gb_html: |-
           <strong>Rouantelezh-Unanet</strong> : Ennañ roadennoù eus Ordnance
-             Survey data &copy; Crown copyright and database right 2010-12.
+          Survey data &copy; Crown copyright and database right 2010-19.
         contributors_footer_1_html: |-
           ↓Evit muioc'h a vunudoù diwar-benn ar re-se, hag ar mammennoù all a zo bet implijet da sikour da wellaat OpenStreetMap, sellit ouzh ar <a
           href="https://wiki.openstreetmap.org/wiki/Contributors">Bajenn Skoazellerien</a> e Wiki OpenStreetMap.
index 33199c1ab8f8b8f27c129f95fc48a80e49478459..4c890b7668ef9f0ff1678eae94a95f1c3ed24f13 100644 (file)
@@ -1451,11 +1451,16 @@ cs:
         contributors_si_html: '<strong>Slovinsko</strong>: Obsahuje data <a href="http://www.gu.gov.si/">Zeměměřického
           a mapovacího úřadu</a> a <a href="http://www.mkgp.gov.si/">Ministerstva
           zemědělství, lesnictví a potravin</a> (veřejné informace o Slovinsku).'
+        contributors_es_html: '<strong>Španělsko</strong>: Obsahuje data od španělského
+          Národního geografického institutu (<a href="http://www.ign.es/">IGN</a>
+          a Národního kartografického systému (<a href="http://www.scne.es/">SCNE</a>),
+          licencovaná pod <a href="https://creativecommons.org/licenses/by/4.0/deed.cs">CC
+          BY 4.0</a>.'
         contributors_za_html: |-
           <strong>Jihoafrická republika</strong>: Obsahuje data pocházející z <a href="http://www.ngi.gov.za/">Chief Directorate:
           National Geo-Spatial Information</a>, State copyright reserved.
         contributors_gb_html: '<strong>Spojené království</strong>: Obsahuje data
-          Ordnance Survey &copy; Crown copyright a právo k databázi 2010–12.'
+          Ordnance Survey &copy; Crown copyright a právo k databázi 2010–19.'
         contributors_footer_1_html: |-
           Další podrobnosti o těchto a dalších zdrojích, které se používaly pro vylepšení OpenStreetMap, najdete na <a
           href="https://wiki.openstreetmap.org/wiki/Contributors">stránce Contributors</a> na wiki OpenStreetMap.
index 17da3e33a3046974ca301bc85d105c90a721b56d..9be7606515b1fe1207438ab6a2c9a74cefac7e83 100644 (file)
@@ -64,7 +64,8 @@ de:
   activerecord:
     errors:
       messages:
-        invalid_email_address: scheint keine gültige E-Mail-Adresse zu sein
+        invalid_email_address: Die eingegebene E-Mail-Adresse scheint nicht gültig
+          zu sein.
         email_address_not_routable: ist nicht routbar
     models:
       acl: Zugangskontrollliste
@@ -1516,6 +1517,11 @@ de:
           <a href="http://www.gu.gov.si/en/">Vermessungs- und Kartierungsbehörde</a> sowie dem
           <a href="http://www.mkgp.gov.si/en/">Ministerium für Landwirtschaft, Forsten und Ernährung</a>
           (öffentliche Informationen von Slowenien).
+        contributors_es_html: |-
+          <strong>Spanien</strong>: Enthält Daten des
+          spanischen nationalen geografischen Instituts (<a href="http://www.ign.es/">IGN</a>) und
+          nationalen kartografischen Systems (<a href="http://www.scne.es/">SCNE</a>),
+          lizenziert zur Weiterverwendung unter <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_za_html: '<strong>Südafrika</strong>: Enthält Daten von <i><a
           href="http://www.ngi.gov.za/">Chief Directorate: National Geo-Spatial Information</a></i>,
           Staatliches Urheberrecht vorbehalten.'
index 4c0d6e4f4d48e1aee8768083894c1a8986cc1178..cccf242e9a032c4911b91667c5676986f890ab66 100644 (file)
@@ -918,7 +918,7 @@ diq:
       continue: Qeyd be
     terms:
       consider_pd_why: no çıko?
-      agree: Qebul kena
+      agree: Qebul ke
       decline: Red kerê
       legale_names:
         france: Fransa
index 97e5804d967f9f626056f7ada12ce0971135fa85..71c081f4918b1b285f30da04981b9182d5acfaa4 100644 (file)
@@ -1409,6 +1409,11 @@ en:
           <a href="http://www.gu.gov.si/en/">Surveying and Mapping Authority</a> and
           <a href="http://www.mkgp.gov.si/en/">Ministry of Agriculture, Forestry and Food</a>
           (public information of Slovenia).
+        contributors_es_html: |
+          <strong>Spain</strong>: Contains data sourced from the
+          Spanish National Geographic Institute (<a href="http://www.ign.es/">IGN</a>) and
+          National Cartographic System (<a href="http://www.scne.es/">SCNE</a>)
+          licensed for reuse under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_za_html: |
           <strong>South Africa</strong>: Contains data sourced from
           <a href="http://www.ngi.gov.za/">Chief Directorate:
index a903f513f2592594c2eabac00899515563b34825..55cb2557db2361bd1c59365f927c7b2f5ee92aad 100644 (file)
@@ -1429,13 +1429,18 @@ eo:
           <strong>Slovenujo</strong>: enhavas datumojn el <a href="http://www.gu.gov.si/">Ofico de Termezurado kaj Kartografio</a> kaj
           <a href="http://www.mkgp.gov.si/">Ministerio pri Terkulturo, Arbarkulturo kaj Proviantado</a>
           (publikaj informoj de Slovenujo).
+        contributors_es_html: '<strong>Hispanujo</strong>: enhavas datumojn el la
+          Hispana Nacia Geografia Instituto (<a href="http://www.ign.es/">IGN</a>
+          kaj Nacia Kartografia Sistemo (<a href="http://www.scne.es/">SCNE</a>) uzeblaj
+          laŭ la permesilo <a href="https://creativecommons.org/licenses/by/4.0/deed.eo">CC
+          BY 4.0</a>.'
         contributors_za_html: |-
           <strong>Sud-Afriko</strong>: enhavas datumojn ricevitajn el <a href="http://www.ngi.gov.za/">Chief Directorate:
           National Geo-Spatial Information</a>, landaj kopirajtoj rezervitaj.
         contributors_gb_html: |-
           <strong>Unuiĝinta Reĝlando</strong>: enhavas datumojn el 'Ordnance
           Survey' &copy; Crown copyright and database right
-          2010-12.
+          2010 - 2019.
         contributors_footer_1_html: |-
           Por pli da detaloj pri tiuj ĉi kaj aliaj fontoj uzitaj por plibonigi OpenStreetMap, bonvolu viziti la <a
           href="https://wiki.openstreetmap.org/wiki/Contributors">paĝon pri kontribuintoj</a> en la OpenStreetMap-vikio.
index e5e8f823fba089aeb441e7dd9536e0c8dc7cb5b5..fd8d199f33ca80d6017b0399b28709d5ff7ae7c9 100644 (file)
@@ -27,6 +27,7 @@
 # Author: Johnarupire
 # Author: Jynus
 # Author: KATRINE1992
+# Author: Kresp0
 # Author: Ktranz
 # Author: La Mantis
 # Author: Larjona
@@ -1492,13 +1493,18 @@ es:
           <a href="http://www.gu.gov.si/en/">Surveying and Mapping Authority</a> y
           <a href="http://www.mkgp.gov.si/en/">Ministry of Agriculture, Forestry and Food</a>
           (información pública de Eslovenia).
+        contributors_es_html: '<strong>España</strong>: Contiene datos provenientes
+          del Instituto Geográfico Nacional (<a href="http://www.ign.es/">IGN</a>)
+          y del Sistema Cartográfico Nacional (<a href="http://www.scne.es/">SCNE</a>),
+          licenciados para su reutilización bajo la <a href="https://creativecommons.org/licenses/by/4.0/">CC
+          BY 4.0</a>.'
         contributors_za_html: |-
           <strong>Sudáfrica</strong>: Contiene datos extraídos de
           <a href="http://www.ngi.gov.za/">Chief Directorate: Información
           Nacional Geoespacial</a>, State copyright reserved.
         contributors_gb_html: |-
           <strong>Reino Unido</strong>: Contiene datos de Ordnance Survey &copy; Crown copyright and database right
-           2010-12.
+           2010-19.
         contributors_footer_1_html: Para obtener más detalles sobre estas y otras
           fuentes que se han utilizado para ayudar a mejorar OpenStreetMap, véase
           la <a href="https://wiki.openstreetmap.org/wiki/Contributors">página de
index 2f5122864bc3211d85590484b9dab58c85e1d2ac..a13f5a071ef159d332ff694f3cc982b033734461 100644 (file)
@@ -7,6 +7,7 @@
 # Author: Asieriko
 # Author: EukeneFL
 # Author: Gorkaazk
+# Author: Ibai
 # Author: Iñaki LL
 # Author: Maite
 # Author: Mikel Ibaiba
@@ -22,10 +23,14 @@ eu:
     formats:
       friendly: '%e %B %Y %H:%M-ean'
   activerecord:
+    errors:
+      messages:
+        invalid_email_address: badirudi ez dela e-posta helbide egoki bat
+        email_address_not_routable: ezin da biderik kalkulatu
     models:
       acl: Kontrol zerrendara sartu
       changeset: Aldaketak
-      changeset_tag: Etiketa aldaketa
+      changeset_tag: Aldaketa Etiketa
       country: Herrialdea
       diary_comment: Eguneroko iruzkina
       diary_entry: Eguneroko sarrera
@@ -54,7 +59,7 @@ eu:
       user_preference: Erabiltzaile hobespenak
       user_token: Erabiltzaile token-a
       way: Bidea
-      way_node: Nodo bidea
+      way_node: Bidearen nodoa
       way_tag: Bidearen etiketa
     attributes:
       diary_comment:
@@ -76,7 +81,7 @@ eu:
         latitude: Latitude
         longitude: Longitude
         public: Publikoa
-        description: Deskribapen
+        description: Deskribapena
       message:
         sender: Igorlea
         title: Gaia
@@ -86,7 +91,7 @@ eu:
         email: Eposta
         active: Aktibo
         display_name: Erakusteko izena
-        description: Deskribapen
+        description: Deskribapena
         languages: Hizkuntzak
         pass_crypt: Pasahitza
   editor:
@@ -152,20 +157,20 @@ eu:
       title: 'Aldaketa: %{id}'
       belongs_to: Egilea
       node: Nodoak (%{count})
-      node_paginated: (%{count}ren) %{x}-%{y} nodoak
+      node_paginated: Nodoak (%{x}-%{y} %{count}-tik)
       way: Bideak (%{count})
-      way_paginated: Bideak (%{count}ren %{x}-%{y})
+      way_paginated: Bideak (%{x}-%{y} %{count}-tik)
       relation: Erlazioak (%{count})
-      relation_paginated: Erlazioak (%{count}ren %{x}-%{y})
+      relation_paginated: Erlazioak (%{x}-%{y} %{count}-tik)
       comment: Iruzkinak (%{count})
-      hidden_commented_by: '%{user} erabiltzaileak egindako duela <abbr title=''%{exact_time}''>%{when}</abbr>
-        iruzkin ezkutua'
+      hidden_commented_by: '%{user} erabiltzaileak egindako iruzkin ezkutua duela
+        <abbr title=''%{exact_time}''>%{when}</abbr>'
       commented_by: '%{user} erabiltzaileak egindako iruzkina duela <abbr title=''%{exact_time}''>%{when}</abbr>'
-      changesetxml: XML aldaketak
-      osmchangexml: XML osm-aldaketa
+      changesetxml: Aldaketaren XML kodea
+      osmchangexml: osmChange XML kodea
       feed:
         title: '%{id} aldaketak'
-        title_comment: '%{id} - %{comment} aldaketak'
+        title_comment: '%{id} aldaketa - %{comment}'
       join_discussion: Hasi saioa eztabaidan parte hartzeko
       discussion: Eztabaida
       still_open: Aldaketak oraindik zabalik - eztabaida aldaketak itxi ondoren irekiko
@@ -178,8 +183,8 @@ eu:
       history_title: 'Bidearen historia: %{name}'
       nodes: Nodoak
       also_part_of:
-        one: bidearen zatia %{related_ways}
-        other: bideen zatia %{related_ways}
+        one: '%{related_ways} bidearen zatia'
+        other: '%{related_ways} bideen zatia'
     relation:
       title: 'Erlazioa: %{name}'
       history_title: 'Erlazioaren historia: %{name}'
@@ -202,7 +207,7 @@ eu:
         changeset: aldaketak
         note: oharra
     timeout:
-      sorry: Barkatu, %{id} daukan %{type}rako datuak berreskuratzeko denbora asko
+      sorry: Barkatu, %{id} daukan %{type}rako datuak berreskuratzeko denbora gehiegi
         behar izan da.
       type:
         node: nodo
@@ -219,8 +224,8 @@ eu:
         way: bide
         relation: erlazio
     start_rjs:
-      feature_warning: '%{num_features} funtzioak kargatzen, zure arakatzailea motela
-        edo erantzungabekoa izan ez dadin. Ziur datuak bistaratu nahi dituzula?'
+      feature_warning: '%{num_features} ezaugarri kargatzen, zure arakatzailea motela
+        edo erantzungabekoa bihur daiteke. Ziur datuak bistaratu nahi dituzula?'
       load_data: Kargatu datuak
       loading: Kargatzen...
     tag_details:
@@ -242,8 +247,8 @@ eu:
         sortua'
       open_by_anonymous: Erabiltzaile ezezagun batek duela <abbr title='%{exact_time}'>%{when}</abbr>
         sortua
-      commented_by: '%{user} duela <abbr title=''%{exact_time}''>%{when} </abbr> egindako
-        iruzkina'
+      commented_by: '%{user} erabiltzaileak duela <abbr title=''%{exact_time}''>%{when}</abbr>
+        egindako iruzkina'
       commented_by_anonymous: Erabiltzaile ezezagun batek duela <abbr title='%{exact_time}'>%{when}
         </abbr> egindako iruzkina
       closed_by: '%{user} erabiltzaileak duela <abbr title=''%{exact_time}''>%{when}
@@ -262,7 +267,7 @@ eu:
       enclosing: Bildutako ezaugarriak
   changesets:
     changeset_paging_nav:
-      showing_page: '%{page}. orrialdea'
+      showing_page: '%{page} orrialdea'
       next: Hurrengoa »
       previous: « Aurrekoa
     changeset:
@@ -292,11 +297,17 @@ eu:
         behar izan da.
   changeset_comments:
     comment:
-      comment: '%{changeset_id} aldaketan %{author} iruzkin berria egin du'
+      comment: '%{changeset_id} aldaketan %{author} erabiltzaileak iruzkin berria
+        egin du'
       commented_at_by_html: '%{user} erabiltzaileak duela %{when} eguneratua'
+    comments:
+      comment: '%{changeset_id} aldaketan %{author}k iruzkin berria egin du'
     index:
       title_all: OpenStreetMap aldaketen eztabaida
-      title_particular: 'OpenStreetMap #%{changeset_id} eztabaida aldatu egin du.'
+      title_particular: 'OpenStreetMap #%{changeset_id} aldaketen eztabaida.'
+    timeout:
+      sorry: Barkatu, zuk eskatutako aldaketen zerrenda berreskuratzeko denbora gehiegi
+        behar izan da.
   diary_entries:
     new:
       title: Eguneroko Sarrera Berria
@@ -323,7 +334,7 @@ eu:
       longitude: 'Longitudea:'
       use_map_link: erabili mapa
       save_button: Gorde
-      marker_text: Eguneroko sarrera helbidea
+      marker_text: Eguneroko sarrera kokapena
     show:
       title: '%{user}(r)en egunerokoa | %{title}'
       user_title: '%{user}(r)en egunerokoa'
@@ -1105,6 +1116,7 @@ eu:
     intro_text: OpenStreetMap munduko mapa da, zu bezalako jendeak sortutakoa eta
       doako lizentzia irekiarekin erabiltzeko dagoena.
     intro_2_create_account: Erabiltzaile kontua sortu
+    hosting_partners_html: '%{ucl}, %{bytemark} eta beste %{partners}-k babestua.'
     partners_ucl: UCLa
     partners_bytemark: Bytemark Ostatua
     partners_partners: bazkideak
@@ -1439,13 +1451,16 @@ eu:
           <a href="http://www.gu.gov.si/en/"> Burutzea eta Mapping Agintaritzatik </a> eta
           <a href="http://www.mkgp.gov.si/en/"> Nekazaritza, Basogintza eta Elikadura Ministeriotik</a>
           (Esloveniako informazio publikoa).
+        contributors_es_html: |-
+          <strong>Espainia</strong>: Espainiako Institutu Geografiko Nazionaletik (<a href="http://www.ign.es/">IGN</a>) eta
+          Sistema Kartografiko Nazionaletik (<a href="http://www.scne.es/">SCNE</a>) jasotako datuak daude, berrerabiltzeko baimendua <a href="https://creativecommons.org/licenses/by/4.0/deed.eu">CC BY 4.0</a> lizentziapean.
         contributors_za_html: |-
           <strong> Hego Afrika </strong>:
           <a href="http://www.ngi.gov.za/"> Zuzendaritza Nagusia datuen jatorria:
           Geo-Lurralde Informazio Nazionala </a>, Estatuko copyright erreserbatuta.
         contributors_gb_html: |-
           <strong>Erresuma Batua</strong>: Ordnance
-          Inkestaren datuak eta kopiak biltzen ditu; Crown copyright eta datu-basearen eskubidea 2010-12.
+          Inkestaren datuak eta kopiak biltzen ditu; Crown copyright eta datu-basearen eskubidea 2010-19.
         contributors_footer_1_html: |-
           OpenStreetMap hobetzen laguntzeko lagundu dutenen xehetasun gehiago eta erabilitako beste iturri batzuk ezagutzeko, mesedez OpenStreetMap Wikian ikusi <a
           href="http://wiki.openstreetmap.org/wiki/Contributors">Contributors
@@ -1599,6 +1614,11 @@ eu:
         title: switch2osm
         description: Laguntza enpresei eta erakundeei OpenStreetMap-en oinarritutako
           mapetara eta beste zerbitzuetara aldatzeko.
+      welcomemat:
+        url: https://welcome.openstreetmap.org/
+        title: Erakundeentzat
+        description: OpenStreetMap-entzat planak egiten ari den erakunde batekin?
+          Aurkitu jakin beharrekoa Ongietorri Lanpasean.
       wiki:
         url: http://wiki.openstreetmap.org/wiki/Eu:Main_Page
         title: wiki.openstreetmap.org
@@ -1690,7 +1710,7 @@ eu:
       edit: Aldatu
       preview: Aurrikusi
     markdown_help:
-      title_html: Honekin analizatua:<a href="https://daringfireball.net/projects/markdown/">Markdown</a>
+      title_html: Honekin analizatua:<a href="https://kramdown.gettalong.org/quickref.html">kramdown</a>
       headings: Atalburuak
       heading: Goiburua
       subheading: Azpi-goiburua
@@ -1737,7 +1757,7 @@ eu:
         title: Galderarik?
         paragraph_1_html: |-
           OpenStreetMap-ek proiektuari buruz ikasteko baliabideak ditu, galdetuz eta erantzunez, eta mapping gaiak eztabaidatu eta dokumentatuz lankidetzan.
-          <a href='%{help_url}'>Jaso laguntza hemen</a>.
+          <a href='%{help_url}'>Jaso laguntza hemen</a>. OpenStreetMap-entzat planak egiten ari den erakunde batekin? <a href='https://welcome.openstreetmap.org/'>Aurkitu jakin beharrekoa Ongietorri Lanpasean</a>.
       start_mapping: Hasi mapeatzen
       add_a_note:
         title: Editatzeko denborarik ez? Gehitu ohar bat!
@@ -1869,6 +1889,7 @@ eu:
         other: '%{user} %{count} puntuak dituen GPX fitxategia'
       description_without_count: '%{user}ren GPX fitxategia'
   application:
+    permission_denied: Ez duzu baimenik ekintza hori burutzeko
     require_cookies:
       cookies_needed: Cookieak desgaituta dituzu - gaitu cookie-ak zure nabigatzailean
         jarraitu aurretik mesedez.
@@ -2081,6 +2102,7 @@ eu:
       terms accepted: Eskerrik asko laguntzaileen termino berriak onartzeagatik!
       terms declined: Sentitzen dugu Kolaboratzaileen baldintza berriak onartu ez
         dituzula. Informazio gehiagorako, ikus <a href="%{url}"> wiki orri hau </a>.
+      terms declined url: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined
     terms:
       title: Kolaboratzaile terminoak
       heading: Kolaboratzaile terminoak
@@ -2090,10 +2112,12 @@ eu:
       consider_pd: Goiko hitzarmenaz gain, nire ekarpenak Domeinu Publikoan egon behar
         direla uste dut
       consider_pd_why: zer da hau?
+      consider_pd_why_url: https://www.osmfoundation.org/wiki/License/Why_would_I_want_my_contributions_to_be_public_domain
       guidance: 'Termino hauek ulertzeko informazioa: <a href="%{summary}"> giza laburpen
         irakurgarria </a> eta batzuk <a href="%{translations}"> itzulpen informalak
         </a>'
       agree: Ados
+      declined: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined
       decline: Ez onartu
       you need to accept or decline: Irakurri eta gero, onartu edo ezetsi Kolaboratzaileen
         termino berriak jarraitzeko.
@@ -2214,6 +2238,7 @@ eu:
         review link text: Mesedez, jarraitu esteka hau zure Kolaboratzaile Terminoaen
           erosotasuna berrikusteko eta onartzeko.
         agreed_with_pd: Zure aldaketak domeinu publikoan egongo direla adierazi duzu.
+        link: https://www.osmfoundation.org/wiki/License/Contributor_Terms
         link text: zer da hau?
       profile description: 'Profilaren Deskribapena:'
       preferred languages: 'Hobetsitako hizkuntzak:'
@@ -2221,6 +2246,7 @@ eu:
       image: 'Irudia:'
       gravatar:
         gravatar: Gravatar erabili
+        link: https://wiki.openstreetmap.org/wiki/Gravatar
         link text: zer da hau?
         disabled: Gravatar desgaitu egin da.
         enabled: Zure Gravatar bistaratzea gaitu da.
@@ -2546,7 +2572,9 @@ eu:
     directions:
       ascend: Igo
       engines:
+        fossgis_osrm_bike: Bizikleta (OSRM)
         fossgis_osrm_car: Autoz (OSRM)
+        fossgis_osrm_foot: Oinez (OSRM)
         graphhopper_bicycle: Bizikletaz (GraphHopper)
         graphhopper_car: Autoz(GraphHopper)
         graphhopper_foot: Oinez (GraphHopper)
@@ -2678,4 +2706,9 @@ eu:
         aurretik.
       flash: Erredakzioa suntsitu egin da.
       error: Erredakzio hau suntsitzerakoan akats bat egon da.
+  validations:
+    leading_whitespace: zuriunea du hasieran
+    trailing_whitespace: zuriunea du amaieran
+    invalid_characters: karaktere ezegokiak ditu
+    url_characters: URL karaktere bereziak (%{characters}) ditu
 ...
index e23731e526b82f7ca919461b6e0bc35dd5ba8682..6d484034fb8dfd8e525c907e46741e58b0680215 100644 (file)
@@ -888,7 +888,7 @@ fa:
           second_hand: سمساری
           shoes: فروشگاه کفش
           sports: فروشگاه ورزشی
-          stationery: Ù\81رÙ\88شگاÙ\87 Ù\84Ù\88ازÙ\85 Ø§Ù\84تحرÛ\8cر
+          stationery: Ù\81رÙ\88شگاÙ\87 Ù\86Ù\88شتâ\80\8cاÙ\81زار
           supermarket: سوپرمارکت
           tailor: خیاطی
           ticket: فروشگاه بلیط
@@ -1315,7 +1315,7 @@ fa:
     about:
       next: بعدی
       copyright_html: <span>&copy;</span>مشارکت‌کنندگان<br>OpenStreetMap
-      used_by: صدها وبسایت، برنامهٔ موبایل و دستگاه سخت‌افزاری از داده‌های نقشهٔ %{name}
+      used_by: صدها وبسایت، برنامهٔ موبایل و دستگاه سخت‌افزاری از داده‌های %{name}
         نیرو گرفته‌اند.
       lede_text: OpenStreetMap را جامعه‌ای از نقشه‌کشان ساخته‌اند که در ایجاد و نگهداری
         داده‌های مربوط به جاده‌ها، مسیرهای تریل، کافه‌ها، ایستگاه‌های راه‌آهن و بسیاری
@@ -1774,7 +1774,7 @@ fa:
       visibility_help_url: https://wiki.openstreetmap.org/wiki/Fa:Visibility_of_GPS_traces
       upload_button: بارگذاری
       help: کمک
-      help_url: https://wiki.openstreetmap.org/wiki/Upload
+      help_url: https://wiki.openstreetmap.org/wiki/Fa:Upload
     create:
       upload_trace: بارگذاری رد جی‌پی‌اس
       trace_uploaded: فایل GPX شما بارگذاری شده و در انتظار درج در پایگاه‌داده است.
index c0bed024207203bbe93d3e38d4565cec1b27fac0..e6ecb9d12b56640a70ce45488d600a7bbc26c087 100644 (file)
@@ -1509,12 +1509,17 @@ fr:
           l’<a href="http://www.gu.gov.si/en/">Autorité de Planification et de Cartographie</a>
           et du <a href="http://www.mkgp.gov.si/en/">Ministère de l’Agriculture, de
           la Forêt et de l’Alimentation</a> (information publique de la Slovénie).'
+        contributors_es_html: '<strong>Espagne</strong>: contient des données fournies
+          par l''Institut Géographique National Espagnol (<a href="http://www.ign.es/">IGN</a>)
+          et le Système Cartographique National (<a href="http://www.scne.es/">SCNE</a>)
+          sous licence <a href="https://creativecommons.org/licenses/by/4.0/">CC BY
+          4.0</a> pour la réutilisation .'
         contributors_za_html: |-
           <strong>Afrique du Sud</strong> : contient des données issues de la <a href="http://www.ngi.gov.za/">Direction principale des
           Informations Géospatiales Nationales</a>, copyright de l’État réservé.
         contributors_gb_html: '<strong>Royaume-Uni</strong> : contient des données
-          issues de l’<em>Ordnance Survey</em> © 2010-2012 Droits d’auteurs et de
-          la base de données de la Couronne.'
+          issues de l’<em>Ordnance Survey</em> &copy; 2010-2019 Droits d’auteurs et
+          de la base de données de la Couronne.'
         contributors_footer_1_html: Pour plus de détails sur celles-ci et sur les
           autres sources utilisées pour aider à améliorer OpenStreetMap, consultez
           la page des <a href="https://wiki.openstreetmap.org/wiki/Contributors">contributeurs</a>
index d79f8db724303071151ed200cdb710ab1335b368..e7a6fb1c415fd9748ca41899b9d26b1b869b4c52 100644 (file)
@@ -1434,14 +1434,13 @@ gl:
           datos baixo licenzas abertas de axencias nacionais de cartografía
           e outras fontes, entre elas:
         contributors_at_html: |-
-          <strong>Austria:</strong> Contén datos de
-          <a href="https://data.wien.gv.at/">Stadt Wien</a> (baixo a licenza
+          <strong>Austria:</strong> Contén datos de <a href="https://data.wien.gv.at/">Stadt Wien</a> (baixo a licenza
           <a href="https://creativecommons.org/licenses/by/3.0/at/deed.de">CC BY</a>),
           <a href="https://www.vorarlberg.at/vorarlberg/bauen_wohnen/bauen/vermessung_geoinformation/weitereinformationen/services/wmsdienste.htm">Land Vorarlberg</a> e
           Land Tirol (baixo a licenza <a href="https://www.tirol.gv.at/applikationen/e-government/data/nutzungsbedingungen/">CC-BY AT con emendas</a>).
         contributors_au_html: |-
-          <strong>Australia:</strong> Contén datos de barrios baseados
-          nos datos do Australian Bureau of Statistics.
+          <strong>Australia</strong>: Contén datos orixinarios de
+          <a href="https://www.psma.com.au/psma-data-copyright-and-disclaimer">PSMA Australia Limited</a> con licenza polo Commonwealth de Australia baixo <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_ca_html: |-
           <strong>Canadá:</strong> Contén datos de
           GeoBase&reg;, GeoGratis (&copy; Department of Natural
@@ -1460,13 +1459,17 @@ gl:
           <strong>Países Baixos:</strong> Contén datos de &copy; AND, 2007
           (<a href="https://www.and.com">www.and.com</a>)
         contributors_nz_html: |-
-          <strong>Nova Zelandia</strong>: Contén fontes de datos do<a href="https://data.linz.govt.nz/">Servizo de datos LINZ</a> e ten unha licenza para o seu emprego que é a
+          <strong>Nova Zelandia</strong>: Contén fontes de datos do <a href="https://data.linz.govt.nz/">Servizo de datos LINZ</a> e ten unha licenza para o seu emprego que é a
           <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_si_html: |-
           <strong>Eslovenia</strong>: Contén datos da
           <a href="http://www.gu.gov.si/en/">Autoridade de Planificación e de Cartografía</a> e do
           <a href="http://www.mkgp.gov.si/en/">Ministerio de Agricultura, Bosques e Alimentación</a>
           (información pública de Eslovenia).
+        contributors_es_html: |-
+          <strong>España</strong>: Contén datos orixinarios do Instituto Nacional Xeográfico Español (<a href="http://www.ign.es/">IGN</a>) e o
+          Sistema Cartográfico Nacional (<a href="http://www.scne.es/">SCNE</a>)
+          con licenza para a súa reutilización baixo <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_za_html: |-
           <strong>Suráfrica:</strong> Contén datos con orixe no
           <a href="http://www.ngi.gov.za/">Chief Directorate:
@@ -1474,7 +1477,7 @@ gl:
         contributors_gb_html: |-
           <strong>Reino Unido:</strong> Contén datos da Ordnance
           Survey &copy; Dereitos de autor da coroa e dereito da base de datos
-          2010-12.
+          2010-19.
         contributors_footer_1_html: |-
           Para obter máis información sobre estas e outras fontes usadas
           para axudar na mellora do OpenStreetMap, bote unha ollada á <a
index 766eeec95ce708b7fe905e2cdf9ca5f129124ab3..f0f5ee6e733ef3b0aeca0953cf740eaf38c7ca7e 100644 (file)
@@ -1374,8 +1374,8 @@ ja:
           href="http://www.mkgp.gov.si/en/">農林食料省</a>(スロベニアの公開情報)による。'
         contributors_za_html: '<strong>南アフリカ</strong>: <a href="http://www.ngi.gov.za/">Chief
           Directorate: National Geo-Spatial Information</a>,政府によるデータを含み、著作権を保持します。'
-        contributors_gb_html: '<strong>イギリス</strong>: 陸地測量データ &copy;著作権はクラウン・コピーライト及びdatabase
-          right 2010-12 を含みます。'
+        contributors_gb_html: "<strong>イギリス</strong>: 陸地測量\nデータ &copy; クラウン・コピーライト及びデータベース権限
+          database right \n2010-19 を含みます。"
         contributors_footer_1_html: |-
           これらの詳細について、またOpenStreetMapの向上に使用されたその他のソースについては、OpenStreetMap Wikiの<a
           href="https://wiki.openstreetmap.org/wiki/Contributors">協力者ページ</a>をご覧ください。
@@ -1660,8 +1660,7 @@ ja:
       trace_uploaded: GPX ファイルをアップロードしました。データベースへの登録に多少時間がかかります。通常この作業は 30 分以内に完了し、それをお知らせするメールをお送りします。
       upload_failed: 申し訳ありませんが、GPXのアップロードに失敗しました。管理者にエラーが通知されました。もう一度やり直してください
       traces_waiting:
-        one: You は%{count} 件のトレースがアップロード待ちです。これらが完了するまで、アップロードはお控えください。さもなければ他のユーザーのアップロードが制限されてしまいます。
-        other: You have %{count}件のトレースがアップロード待ちです。これらが完了するまでアップロードはお控えください。さもなければ他のユーザーのアップロードが制限されてしまいます。
+        other: あなたの %{count} 件のトレースがアップロード待ち中です。これらのアップロードが完了するまでお待ちください。さもなければ他のユーザーのアップロードが制限されてしまいます。
     edit:
       title: トレース %{name} の編集
       heading: トレース %{name} の編集
index 98689d3654b28106a2253349432fb6f800534c61..b0e0faadcee2d2b33f70a0c4358282c296a2cac7 100644 (file)
@@ -1443,6 +1443,11 @@ mk:
           <a href="http://www.gu.gov.si/en/">Геодетската управа</a> и
           <a href="http://www.mkgp.gov.si/en/">Министерството за земјоделство, шумарство и храна</a>
           (јавни информации од Словенија).
+        contributors_es_html: |-
+          <strong>Шпанија</strong>: Содржи податоци преземени од
+          Националниот географски институт на Шпанија (<a href="http://www.ign.es/">IGN</a>) и
+          Националниот картографски систем (<a href="http://www.scne.es/">SCNE</a>)
+          достапни за употреба под лиценцата <a href="https://creativecommons.org/licenses/by/4.0/deed.mk">CC BY 4.0</a>.
         contributors_za_html: |-
           <strong>ЈАР</strong>: Содржи податоци од
           <a href="http://www.ngi.gov.za/">Главната управа:
@@ -1450,7 +1455,7 @@ mk:
         contributors_gb_html: |-
           <strong>Велика Британија</strong>: Содржи податоци
           од Картографскиот завод на Обединетото Кралство&copy; Крунски авторски права и
-          права на базата 2010-12.
+          права на базата 2010-19 г.
         contributors_footer_1_html: |-
           Повеќе информации за овие и други извори искористени
           за подобрување на OpenStreetMap ќе најдете на страницата <a
index c780093093fd4be913a2bfd532c138c7c06a11c6..0d73f3c6b136fe67e1a4ee11e02bf0f6a252183c 100644 (file)
@@ -2519,7 +2519,7 @@ nb:
       show:
         comment: Kommentar
         subscribe: Abonner
-        unsubscribe: Avbestill
+        unsubscribe: Avslutt abonnement
         hide_comment: skjul
         unhide_comment: vis
     notes:
index 4728dcc6d34b3d427246709398a4191319c6f8fb..5d88661f41e2aa8994e66ea79c80114e05e65cb6 100644 (file)
@@ -1494,13 +1494,17 @@ pt-BR:
           de Levantamento e Mapeamento</a> e do <a href="http://www.mkgp.gov.si/en/">Ministério
           de Agricultura, Silvicultura e Alimentação</a> (informações públicas da
           Eslovênia).'
+        contributors_es_html: |-
+          <strong>Espanha</strong>: Contém dados provenientes do
+          Instituto Geográfico Nacional da Espanha (<a href="http://www.ign.es/">IGN</a>) e
+          Sistema Cartográfico Nacional (<a href="http://www.scne.es/">SCNE</a>)
+          licenciado para reutilização sob <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
         contributors_za_html: |-
           <strong>Africa do Sul</strong>: contém dados originários de
           <a href="http://www.ngi.gov.za/">Chief Directorate:
           National Geo-Spatial Information</a>, com direitos autorais reservados àquele Estado.
-        contributors_gb_html: |-
-          <strong>Reino Unido</strong>: Contém dados da Ordnance
-             Survey &copy; Direitos da base e autorais da Crown 2010.
+        contributors_gb_html: '<strong>Reino Unido</strong>: Contém dados do Ordnance
+          Survey &copy; Crown copyright and database right 2010-2019.'
         contributors_footer_1_html: Para mais informações sobre estas e outras fontes
           utilizadas para melhorar o OpenStreetMap, consulte a <a href="https://wiki.openstreetmap.org/wiki/Contributors">página
           de contribuidores</a> (em inglês) na wiki do OpenStreetMap.
index e6de0d156a1df549f14aaf790434e7a92a0b486d..72b826f42ab232759118e123980cd8777ea5afb6 100644 (file)
@@ -1467,11 +1467,14 @@ pt-PT:
           <a href="http://www.gu.gov.si/en/">Autoridade de Cartografia e Topografia (Geodetska uprava Republike Slovenije)</a> e do
           <a href="http://www.mkgp.gov.si/en/">Ministério da Agricultura, Floresta e Alimentação (Ministrstvo za kmetijstvo, gozdarstvo in prehrano)</a>
           (informação pública da Eslovénia).
+        contributors_es_html: |-
+          <strong>Espanha</strong>: Contém dados provenientes do Instituto Geográfico Nacional (<a href="http://www.ign.es/">IGN</a>) e do Sistema cartográfico Nacional (<a href="http://www.scne.es/">SCNE</a>) de Espanha
+          licenciado para reutilização com a <a href="https://creativecommons.org/licenses/by/4.0/deed.pt">CC BY 4.0</a>.
         contributors_za_html: '<strong>África do Sul</strong>: Contém dados provenientes
           de <a href="http://www.ngi.gov.za/">Chief Directorate: National Geo-Spatial
           Information</a>, State copyright reserved.'
         contributors_gb_html: '<strong>Reino Unido</strong>: Contém dados do Ordnance
-          Survey &copy; Crown copyright and database right 2010-2012.'
+          Survey &copy; Crown copyright and database right 2010-2019.'
         contributors_footer_1_html: Para mais informações sobre estas e outras fontes
           utilizadas para melhorar o OpenStreetMap, consulte a <a href="https://wiki.openstreetmap.org/wiki/Contributors">página
           de contribuidores</a> (em inglês) na wiki do OpenStreetMap.
index 218fb83b8906801e4419f6eefe63195e6d90b6fa..bd7cc8bf87dc9885f41fd88b6a8b02e052c907dc 100644 (file)
@@ -208,7 +208,7 @@ ro:
         note: notă
     timeout:
       sorry: Ne pare rău, dar durata recepționării datelor pentru %{type} cu identificatorul
-        %{id} a fost prea mare.
+        %{id} este prea mare.
       type:
         node: nodul
         way: calea
@@ -226,8 +226,7 @@ ro:
         relation: relații
     start_rjs:
       feature_warning: Se încarcă %{num_features} caracteristici, ceea care ar putea
-        încetini sau bloca navigatorul dumneavoastră. Sigur doriți afișarea acestor
-        date?
+        încetini sau bloca navigatorul dumneavoastră. Doriți afișarea acestor date?
       load_data: Încărcare date
       loading: Se încarcă...
     tag_details:
@@ -1340,8 +1339,7 @@ ro:
         despre drumuri, trasee, cafenele, stații de cale ferată și multe altele din întreaga lume.
       local_knowledge_title: Cunoaștere locală
       local_knowledge_html: |-
-        OpenStreetMap accentuează cunoștințele locale. Colaboratorii folosesc
-        imaginile aeriene, dispozitivele GPS și hărțile câmpurilor de joasă tehnologie pentru a verifica faptul că OSM
+        OpenStreetMap accentuează cunoștințele locale. Colaboratorii folosesc imaginile aeriene, dispozitivele GPS și hărțile câmpurilor de joasă tehnologie pentru a verifica faptul că OSM
         este exactă și actualizată.
       community_driven_title: Condusă de comunitate
       community_driven_html: |-
@@ -1388,13 +1386,11 @@ ro:
           href="https://opendatacommons.org/licenses/odbl/">Open Data
           Commons Open Database License</a> (ODbL) by the  <a
           href="https://osmfoundation.org/">Fundația OpenStreetMap</a> (OSMF).
-        intro_2_html: |-
-          Sunteți liber să copiați, să distribuiți, să transmiteți și să vă adaptați datele,
-          atâta timp cât vă credit OpenStreetMap și ei
-          contribuitori. Dacă modificați sau construiți datele noastre, vă
-          poate distribui rezultatul numai sub aceeași licență.
-          complete <a href="https://opendatacommons.org/licenses/odbl/1.0/">legal
-          code</a> vă explică drepturile și responsabilitățile.
+        intro_2_html: Sunteți liber să copiați, să distribuiți, să transmiteți și
+          să vă adaptați datele, atâta timp cât creditați OpenStreetMap și contribuitorii
+          ei. Dacă modificați sau folosiți datele noastre, puteți distribui rezultatul
+          doar sub aceeași licență. Aici  <a href="https://opendatacommons.org/licenses/odbl/1.0/">codul
+          legal</a> sunt explicate drepturile și responsabilitățile.
         intro_3_html: |-
           Cartografia din hărțile noastre și documentația noastră sunt
           licențiat sub <a href="https://creativecommons.org/licenses/by-sa/2.0/">Creative
@@ -1403,12 +1399,10 @@ ro:
         credit_1_html: Noi cerem să utilizați creditul&copy; contribuitori OpenStreetMap&
           rdquo;.
         credit_2_html: |-
-          De asemenea, trebuie să clarificați faptul că datele sunt disponibile în cadrul opțiunii Deschiderea Licenței bazei de date și, dacă folosim plăcile de pe hartă, că cartografia este licențiat ca CC BY-SA. Puteți face acest lucru prin conectarea la
+          De asemenea, trebuie să clarificați faptul că datele sunt disponibile în cadrul licenței libere a bazei de date și, dacă folosim bucăți de hartă, atunci cartografierea este licențiată de CC BY-SA. Puteți face acest lucru prin conectarea la
           <a href="https://www.openstreetmap.org/copyright"> această pagină de copyright</a>.
-          Alternativ și ca o cerință dacă distribuim OSM într-un
-          formularul de date, puteți numi și să vă conectați direct la licența (licențele). În mass-media
-          unde legăturile nu sunt posibile (de exemplu lucrări tipărite), vă sugerăm
-          direcționați cititorii dvs. la openstreetmap.org (probabil prin extinderea "OpenStreetMap" la această adresă completă), la opendatacommons.org și dacă este cazul, la creativecommons.org.
+          Alternativ, și ca o cerință dacă distribuim OSM într-un
+          formularul de date, puteți numi și să vă conectați direct la licența (licențele). Acolo unde legăturile nu sunt posibile (de exemplu lucrări tipărite), vă sugerăm să direcționați cititorii dvs. la openstreetmap.org (probabil prin extinderea "OpenStreetMap" la această adresă completă), la opendatacommons.org, și dacă este cazul, la creativecommons.org.
         credit_3_html: |-
           Pentru o hartă electronică care poate fi răsfoită, creditul ar trebui să apară în colțul hărții.
           De exemplu:
@@ -1650,7 +1644,7 @@ ro:
       get_directions_title: Găsiți direcții între două puncte
       from: De la
       to: Către
-      where_am_i: Unde este asta?
+      where_am_i: Unde mă aflu?
       where_am_i_title: Descrie locaţia curentă folosind motorul de căutare
       submit_text: Mergi
       reverse_directions_text: Inversează direcția
@@ -2202,8 +2196,8 @@ ro:
       settings_link_text: setări
       my friends: Prietenii mei
       no friends: Nu ați adăugat încă niciun prieten.
-      km away: '%{count}km depărtare'
-      m away: '%{count}m depărtare'
+      km away: '%{count} km depărtare'
+      m away: '%{count} m depărtare'
       nearby users: Alți utilizatori din apropriere
       no nearby users: Nu există alți utilizatori care să admită cartografiere în
         apropiere.
@@ -2613,7 +2607,7 @@ ro:
     edit_help: Deplasați harta și măriți o locație pe care doriți să o editați, apoi
       faceți click aici.
     directions:
-      ascend: Urcă
+      ascend: Urcare
       engines:
         fossgis_osrm_bike: Bicicletă (OSRM)
         fossgis_osrm_car: Mașină (OSRM)
@@ -2621,9 +2615,9 @@ ro:
         graphhopper_bicycle: Bicicletă (GraphHopper)
         graphhopper_car: Mașină (GraphHopper)
         graphhopper_foot: Mers (GraphHopper)
-      descend: Coborî
+      descend: Coborâre
       directions: Direcții
-      distance: Distanţă
+      distance: Distanță
       errors:
         no_route: Nu s-a putut găsi un traseu între cele două locuri.
         no_place: Ne pare rău - nu am găsit locația '%{place}'.
@@ -2654,7 +2648,7 @@ ro:
         turn_right_without_exit: Virează la dreapta pe %{name}
         sharp_right_without_exit: Strângeți dreapta spre %{name}
         uturn_without_exit: Fă o întoarcere în U %{name}
-        sharp_left_without_exit: Strângeți stânga spre %{name}
+        sharp_left_without_exit: Brusc stânga spre %{name}
         turn_left_without_exit: Virează la stânga pe %{name}
         offramp_left: Abordați ieșirea de pe partea stângă
         offramp_left_with_exit: Urmează ieșirea %{exit} prin stânga
@@ -2677,7 +2671,7 @@ ro:
         merge_left_without_exit: Strângeți stânga spre %{name}
         fork_left_without_exit: La intersecția în formă de furculiță (Y) fă stânga
           pe %{name}
-        slight_left_without_exit: Strângeți stânga pe %{name}
+        slight_left_without_exit: Ușor stânga pe %{name}
         via_point_without_exit: (prin via)
         follow_without_exit: Urmarește %{name}
         roundabout_without_exit: La sensul giratoriu, ieșiți pe %{name}
@@ -2704,7 +2698,7 @@ ro:
           eighth: Locul 8
           ninth: Locul 9
           tenth: Locul 10
-      time: Data
+      time: Durată
     query:
       node: Nod
       way: Cale
index cb47952303e7c1184e87e5d1cb887751c4c4e240..1787af1d970dde55a7696e2513aa0fe1e30bf2bd 100644 (file)
@@ -16,6 +16,7 @@
 # Author: Chilin
 # Author: D1g
 # Author: DCamer
+# Author: Diralik
 # Author: Dmitry-s93
 # Author: Dr&mx
 # Author: Edible Melon
@@ -1231,10 +1232,10 @@ ru:
     signup_confirm:
       subject: '[OpenStreetMap] Добро пожаловать в OpenStreetMap'
       greeting: Привет!
-      created: Кто-то (надеемся, что Вы) только что создал учетную запись на %{site_url}.
+      created: Кто-то (надеемся, что Вы) только что создал учётную запись на %{site_url}.
       confirm: 'Прежде, чем мы сможем что-либо сделать, мы должны убедиться, что эта
         просьба исходит от вас, и если это так, то, пожалуйста, нажмите на ссылку
-        ниже для подтверждения вашей учетной записи:'
+        ниже для подтверждения вашей учётной записи:'
       welcome: После подтверждения вашей учётной записи, мы предоставим вам немного
         дополнительной информации для начального ознакомления.
     email_confirm:
@@ -1514,7 +1515,7 @@ ru:
           <a href="http://www.ngi.gov.za/">Главное управление:
           Национальная геоинформационная система</a>, права принадлежат государству.
         contributors_gb_html: <strong>Великобритания.</strong> Данные Ordnance Survey
-          © Crown copyright и права на базы данных 2010-12.
+          © Crown copyright и права на базы данных 2010-19.
         contributors_footer_1_html: Более подробную информацию об этих и других источниках,
           использованных для наполнения OpenStreetMap, смотрите на <a href="https://wiki.openstreetmap.org/wiki/Contributors">странице
           Contributors</a> вики-сервера OpenStreetMap.
@@ -1539,7 +1540,7 @@ ru:
           с <a href="https://wiki.osmfoundation.org/wiki/Trademark_Policy">Политикой
           в области товарных знаков</a>.
     index:
-      js_1: Вы используете браузер, в котором не поддерживается или отключен JavaScript.
+      js_1: Вы используете браузер, в котором не поддерживается или отключён JavaScript.
       js_2: OpenStreetMap использует JavaScript для отображения карт.
       permalink: Постоянная ссылка
       shortlink: Короткая ссылка
index d11f6d4d45e9734b820033aee05cb7f075f54ba8..bbdcff7c14cd2fd9ac22dc2f46e47900015cc4b5 100644 (file)
@@ -15,6 +15,7 @@
 # Author: Sawa
 # Author: Srdjan m
 # Author: Stalker
+# Author: Zoranzoki21
 # Author: Жељко Тодоровић
 # Author: Милан Јелисавчић
 # Author: Обрадовић Горан
@@ -1375,8 +1376,8 @@ sr:
           Национална катастарска служба</a>, државна ауторска права задржана.
         contributors_gb_html: |-
           <strong>Уједињено Краљевство</strong>: Садржи податке
-          Картографског завода Уједињеног Краљевства&copy; Крунска ауторска права и
-          права базе 2010-12.
+          Картографског завода Уједињеног Краљевства&copy; Крунска ауторска права и права базе података
+          2010-19.
         contributors_footer_1_html: |-
           Више информација о овим и другим изворима коришћеним
           за побољшавање Опенстритмапа можете наћи на страници <a
index 488b03744f2a0be92e6def8c6d7ef7aa3554b2d8..a4084f21c80b88f1efa915449fefc879b618680c 100644 (file)
@@ -1490,6 +1490,9 @@ tr:
           <a href="http://www.mkgp.gov.si/en/">Ministry of Agriculture, Forestry and Food</a>
           (Slovenya'nın halka açık bilgileri) sayfalarından
           edinilen verileri içermektedir.
+        contributors_es_html: |-
+          <strong>İspanya</strong>: İspanya Ulusal Coğrafya Enstitüsü (<a href="http://www.ign.es/">IGN</a>) ile
+          Ulusal Kartografik Sistem'den (<a href="http://www.scne.es/">SCNE</a>) elde edilen verileri içerir ve tekrar kullanım amacıyla <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a> ile lisanslanmıştır.
         contributors_za_html: |-
           <strong>Güney Afrika</strong>: <a href="http://www.ngi.gov.za/">Chief Directorate:
           National Geo-Spatial Information</a> kaynaklı verileri içermektedir, Devlet telif hakkı saklıdır.
index 2a2b23f1dc41a973401e2c48643426f6473d3532..b9a0c03db37db0ff7cf526c99b7651766de3043c 100644 (file)
@@ -1385,6 +1385,9 @@ zh-TW:
           <strong>斯洛維尼亞</strong>:包含來自<a href="http://www.gu.gov.si/en/">Surveying and Mapping Authority</a>和
           <a href="http://www.mkgp.gov.si/en/">Ministry of Agriculture, Forestry and Food</a>
           (斯洛維尼亞公開資訊).
+        contributors_es_html: |-
+          <strong>西班牙</strong>:包含來自西班牙國家地理研究所(<a href="http://www.ign.es/">IGN</a>)以及國家製圖系統<a href="http://www.scne.es/">SCNE</a>)的資料來源,並依據
+          <a href="https://creativecommons.org/licenses/by/4.0/deed.zh_TW">姓名標示 4.0 國際</a>條款授權。
         contributors_za_html: |-
           <strong>南非</strong>: 包含來自
           <a href="http://www.ngi.gov.za/">Chief Directorate:
diff --git a/config/preinitializer.rb b/config/preinitializer.rb
deleted file mode 100644 (file)
index 07f1057..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-require "yaml"
-
-env = if defined?(Rake.application) && Rake.application.top_level_tasks.grep(/^(default$|test(:|$))/).any?
-        "test"
-      else
-        ENV["RAILS_ENV"] || "development"
-      end
-
-config = YAML.load_file(File.expand_path(env == "test" ? "../example.application.yml" : "../application.yml", __FILE__))
-
-ENV.each do |key, value|
-  Object.const_set(Regexp.last_match(1).upcase, value) if key =~ /^OSM_(.*)$/
-end
-
-config[env].each do |key, value|
-  Object.const_set(key.upcase, value) unless Object.const_defined?(key.upcase)
-end
diff --git a/config/settings.yml b/config/settings.yml
new file mode 100644 (file)
index 0000000..5af1fb0
--- /dev/null
@@ -0,0 +1,122 @@
+# The server protocol and host
+server_protocol: "http"
+server_url: "openstreetmap.example.com"
+# Publisher
+#publisher_url: ""
+# The generator
+generator: "OpenStreetMap server"
+copyright_owner: "OpenStreetMap and contributors"
+attribution_url: "http://www.openstreetmap.org/copyright"
+license_url: "http://opendatacommons.org/licenses/odbl/1-0/"
+# Support email address
+support_email: "openstreetmap@example.com"
+# Sender addresses for emails
+email_from: "OpenStreetMap <openstreetmap@example.com>"
+email_return_path: "openstreetmap@example.com"
+# API version
+api_version: "0.6"
+# Application status - possible values are:
+#   online - online and operating normally
+#   api_readonly - site online but API in read-only mode
+#   api_offline - site online but API offline
+#   database_readonly - database and site in read-only mode
+#   database_offline - database offline with site in emergency mode
+#   gpx_offline - gpx storage offline
+status: "online"
+# The maximum area you're allowed to request, in square degrees
+max_request_area: 0.25
+# Number of GPS trace/trackpoints returned per-page
+tracepoints_per_page: 5000
+# Maximum number of nodes that will be returned by the api in a map request
+max_number_of_nodes: 50000
+# Maximum number of nodes that can be in a way (checked on save)
+max_number_of_way_nodes: 2000
+# The maximum area you're allowed to request notes from, in square degrees
+max_note_request_area: 25
+# Zoom level to use for postcode results from the geocoder
+postcode_zoom: 15
+# Zoom level to use for geonames results from the geocoder
+geonames_zoom: 12
+# Timeout for API calls in seconds
+api_timeout: 300
+# Timeout for web pages in seconds
+web_timeout: 30
+# Periods (in hours) which are allowed for user blocks
+user_block_periods: [0, 1, 3, 6, 12, 24, 48, 96]
+# Rate limit for message sending
+max_messages_per_hour: 60
+# Domain for handling message replies
+#messages_domain: "messages.openstreetmap.org"
+# Geonames authentication details
+#geonames_username: ""
+# GeoIP database
+#geoip_database: ""
+# Users to show as being nearby
+nearby_users: 30
+# Max radius, in km, for nearby users
+nearby_radius: 50
+# Spam threshold
+spam_threshold: 50
+# Default legale (jurisdiction location) for contributor terms
+default_legale: GB
+# Use the built-in jobs queue for importing traces
+# Leave as false if you are using the external high-speed gpx importer
+# https://github.com/openstreetmap/gpx-import
+trace_use_job_queue: false
+# Location of GPX traces and images
+gpx_trace_dir: "/home/osm/traces"
+gpx_image_dir: "/home/osm/images"
+# Location of data for attachments
+attachments_dir: ":rails_root/public/attachments"
+# Log file to use
+#log_path: ""
+# Log file to use for logstash
+#logstash_path: ""
+# List of memcache servers to use for caching
+#memcache_servers: []
+# Enable legacy OAuth 1.0 support
+oauth_10_support: true
+# URL of Nominatim instance to use for geocoding
+nominatim_url: "https://nominatim.openstreetmap.org/"
+# Default editor
+default_editor: "id"
+# OAuth consumer key for Potlatch 2
+#potlatch2_key: ""
+# OAuth consumer key for the web site
+#oauth_key: ""
+# OAuth consumer key for iD
+#id_key: ""
+# Imagery to return in capabilities as blacklisted
+imagery_blacklist:
+  # Current Google imagery URLs have google or googleapis in the domain
+  # with a vt or kh endpoint, and x, y and z query parameters
+  - ".*\\.google(apis)?\\..*/(vt|kh)[\\?/].*([xyz]=.*){3}.*"
+  # Blacklist VWorld
+  - "http://xdworld\\.vworld\\.kr:8080/.*"
+  # Blacklist here
+  - ".*\\.here\\.com[/:].*"
+# URL of Overpass instance to use for feature queries
+overpass_url: "https://overpass-api.de/api/interpreter"
+# Routing endpoints
+graphhopper_url: "https://graphhopper.com/api/1/route"
+fossgis_osrm_url: "https://routing.openstreetmap.de/"
+# External authentication credentials
+#google_auth_id: ""
+#google_auth_secret: ""
+#google_openid_realm: ""
+#facebook_auth_id: ""
+#facebook_auth_secret: ""
+#windowslive_auth_id: ""
+#windowslive_auth_secret: ""
+#github_auth_id: ""
+#github_auth_secret: ""
+#wikipedia_auth_id: ""
+#wikipedia_auth_secret: ""
+# Thunderforest authentication details
+#thunderforest_key: ""
+# Key for generating TOTP tokens
+#totp_key: ""
+# Enforce Content-Security-Policy
+csp_enforce: false
+# URL for reporting Content-Security-Policy violations
+#csp_report_url: ""
diff --git a/config/settings/development.yml b/config/settings/development.yml
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/config/settings/production.yml b/config/settings/production.yml
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/config/settings/test.yml b/config/settings/test.yml
new file mode 100644 (file)
index 0000000..022c932
--- /dev/null
@@ -0,0 +1,17 @@
+# Trace directories for testing
+gpx_trace_dir: <%= Rails.root.join("test", "gpx", "traces") %>
+gpx_image_dir: <%= Rails.root.join("test", "gpx", "images") %>
+# Geonames credentials for testing
+geonames_username: "dummy"
+# External authentication credentials for testing
+google_auth_id: "dummy"
+google_auth_secret: "dummy"
+google_openid_realm: "https://www.openstreetmap.org"
+facebook_auth_id: "dummy"
+facebook_auth_secret: "dummy"
+windowslive_auth_id: "dummy"
+windowslive_auth_secret: "dummy"
+github_auth_id: "dummy"
+github_auth_secret: "dummy"
+wikipedia_auth_id: "dummy"
+wikipedia_auth_secret: "dummy"
index 434994329d7b62a435335dbbeb6da5c3489ee4b5..6190831f7ada6b8fa18c33a1c05b4036049bb351 100644 (file)
@@ -1,9 +1,9 @@
 module Auth
   PROVIDERS = { "None" => "", "OpenID" => "openid" }.tap do |providers|
-    providers["Google"] = "google" if defined?(GOOGLE_AUTH_ID)
-    providers["Facebook"] = "facebook" if defined?(FACEBOOK_AUTH_ID)
-    providers["Windows Live"] = "windowslive" if defined?(WINDOWSLIVE_AUTH_ID)
-    providers["GitHub"] = "github" if defined?(GITHUB_AUTH_ID)
-    providers["Wikipedia"] = "wikipedia" if defined?(WIKIPEDIA_AUTH_ID)
+    providers["Google"] = "google" if Settings.key?(:google_auth_id)
+    providers["Facebook"] = "facebook" if Settings.key?(:facebook_auth_id)
+    providers["Windows Live"] = "windowslive" if Settings.key?(:windowslive_auth_id)
+    providers["GitHub"] = "github" if Settings.key?(:github_auth_id)
+    providers["Wikipedia"] = "wikipedia" if Settings.key?(:wikipedia_auth_id)
   end.freeze
 end
index 6582a30c0157ed1af60b844853df84743a33e72d..d1c39f1f4dbf73674f6f875d4489c86be17a0c1a 100644 (file)
@@ -69,7 +69,7 @@ class BoundingBox
     self
   end
 
-  def check_size(max_area = MAX_REQUEST_AREA)
+  def check_size(max_area = Settings.max_request_area)
     # check the bbox isn't too large
     if area > max_area
       raise OSM::APIBadBoundingBox, "The maximum bbox size is " + max_area.to_s +
index 5664e0099b131b255ab44455e2c08e308ea10e69..721e5608b5cd9e22d59f2b13ab0a9965b20d51d7 100644 (file)
@@ -13,6 +13,8 @@ module GPX
     end
 
     def points
+      return enum_for(:points) unless block_given?
+
       @possible_points = 0
       @actual_points = 0
       @tracksegs = 0
index 1951e3c31287f82d1bc15929a17573834e3a0c6e..743d1b1c665cbec9d0f2b462714b31c4a0428866 100644 (file)
@@ -502,16 +502,16 @@ module OSM
     end
 
     def xml_root_attributes
-      { "version" => API_VERSION.to_s,
-        "generator" => GENERATOR,
-        "copyright" => COPYRIGHT_OWNER,
-        "attribution" => ATTRIBUTION_URL,
-        "license" => LICENSE_URL }
+      { "version" => Settings.api_version,
+        "generator" => Settings.generator,
+        "copyright" => Settings.copyright_owner,
+        "attribution" => Settings.attribution_url,
+        "license" => Settings.license_url }
     end
   end
 
   def self.ip_to_country(ip_address)
-    ipinfo = geoip_database.country(ip_address) if defined?(GEOIP_DATABASE)
+    ipinfo = geoip_database.country(ip_address) if Settings.key?(:geoip_database)
 
     if ipinfo
       country = ipinfo.country_code2
@@ -566,7 +566,7 @@ module OSM
   # Return the terms and conditions text for a given country
   def self.legal_text_for_country(country_code)
     file_name = Rails.root.join("config", "legales", country_code.to_s + ".yml")
-    file_name = Rails.root.join("config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name
+    file_name = Rails.root.join("config", "legales", Settings.default_legale + ".yml") unless File.exist? file_name
     YAML.load_file(file_name)
   end
 
@@ -577,6 +577,6 @@ module OSM
 
   # Return the GeoIP database handle
   def self.geoip_database
-    @geoip_database ||= GeoIP.new(GEOIP_DATABASE) if defined?(GEOIP_DATABASE)
+    @geoip_database ||= GeoIP.new(Settings.geoip_database) if Settings.key?(:geoip_database)
   end
 end
index 127201f9c2824d3c66607b392ba19cf92a9d323b..03869c638d8145a8d15953799f990d50f74d0a0e 100644 (file)
@@ -18,12 +18,12 @@ module Api
     def test_capabilities
       get :show
       assert_response :success
-      assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+      assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
         assert_select "api", :count => 1 do
-          assert_select "version[minimum='#{API_VERSION}'][maximum='#{API_VERSION}']", :count => 1
-          assert_select "area[maximum='#{MAX_REQUEST_AREA}']", :count => 1
-          assert_select "note_area[maximum='#{MAX_NOTE_REQUEST_AREA}']", :count => 1
-          assert_select "tracepoints[per_page='#{TRACEPOINTS_PER_PAGE}']", :count => 1
+          assert_select "version[minimum='#{Settings.api_version}'][maximum='#{Settings.api_version}']", :count => 1
+          assert_select "area[maximum='#{Settings.max_request_area}']", :count => 1
+          assert_select "note_area[maximum='#{Settings.max_note_request_area}']", :count => 1
+          assert_select "tracepoints[per_page='#{Settings.tracepoints_per_page}']", :count => 1
           assert_select "changesets[maximum_elements='#{Changeset::MAX_ELEMENTS}']", :count => 1
           assert_select "status[database='online']", :count => 1
           assert_select "status[api='online']", :count => 1
index c212ba1d07a66506ced55c3be3a5b2ade3b38864..4b3090443b9a0b8102a1c7870ff46477b9a29a01 100644 (file)
@@ -32,7 +32,7 @@ module Api
         assert_response :success
         now = Time.now.getutc
         hourago = now - 1.hour
-        assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+        assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
           assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do
             assert_select "tile", :count => 0
           end
@@ -47,7 +47,7 @@ module Api
         # changes at the time we have frozen at
         now = Time.now.getutc
         hourago = now - 1.hour
-        assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+        assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
           assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do
             assert_select "tile", :count => 6
           end
@@ -70,7 +70,7 @@ module Api
         assert_response :success
         # NOTE: there was a test here for the timing, but it was too sensitive to be a good test
         # and it was annoying.
-        assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+        assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
           assert_select "changes", :count => 1
         end
       end
index daf062154913559b267465be7beb1718f710ff0c..e9132764c12b3a77ad1b8e96da0e561bf5a5cb7a 100644 (file)
@@ -137,14 +137,14 @@ module Api
       get :show, :params => { :id => changeset_id }
       assert_response :success, "cannot get first changeset"
 
-      assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "osm[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "osm>changeset[id='#{changeset_id}']", 1
       assert_select "osm>changeset>discussion", 0
 
       get :show, :params => { :id => changeset_id, :include_discussion => true }
       assert_response :success, "cannot get first changeset with comments"
 
-      assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "osm[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "osm>changeset[id='#{changeset_id}']", 1
       assert_select "osm>changeset>discussion", 1
       assert_select "osm>changeset>discussion>comment", 0
@@ -155,7 +155,7 @@ module Api
       get :show, :params => { :id => changeset_id, :include_discussion => true }
       assert_response :success, "cannot get closed changeset with comments"
 
-      assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "osm[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "osm>changeset[id='#{changeset_id}']", 1
       assert_select "osm>changeset>discussion", 1
       assert_select "osm>changeset>discussion>comment", 3
@@ -403,7 +403,7 @@ CHANGESET
                       "can't upload a simple valid creation to changeset: #{@response.body}"
 
       # check the returned payload
-      assert_select "diffResult[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "diffResult[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "diffResult>node", 1
       assert_select "diffResult>way", 1
       assert_select "diffResult>relation", 1
@@ -641,7 +641,7 @@ CHANGESET
                       "can't do a conditional delete of in use objects: #{@response.body}"
 
       # check the returned payload
-      assert_select "diffResult[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "diffResult[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "diffResult>node", 1
       assert_select "diffResult>way", 1
       assert_select "diffResult>relation", 1
@@ -736,7 +736,7 @@ CHANGESET
                       "can't upload a complex diff to changeset: #{@response.body}"
 
       # check the returned payload
-      assert_select "diffResult[version='#{API_VERSION}'][generator='#{GENERATOR}']", 1
+      assert_select "diffResult[version='#{Settings.api_version}'][generator='#{Settings.generator}']", 1
       assert_select "diffResult>node", 1
       assert_select "diffResult>way", 1
       assert_select "diffResult>relation", 1
@@ -1228,7 +1228,7 @@ CHANGESET
                       "failed to return error in XML format"
 
       # check the returned payload
-      assert_select "osmError[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "osmError[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
       assert_select "osmError>status", 1
       assert_select "osmError>message", 1
     end
@@ -1422,7 +1422,7 @@ CHANGESET
       assert_template nil
       # print @response.body
       # FIXME: needs more assert_select tests
-      assert_select "osmChange[version='#{API_VERSION}'][generator='#{GENERATOR}']" do
+      assert_select "osmChange[version='#{Settings.api_version}'][generator='#{Settings.generator}']" do
         assert_select "create", :count => 5
         assert_select "create>node[id='#{node.id}'][visible='#{node.visible?}'][version='#{node.version}']" do
           assert_select "tag[k='#{tag.k}'][v='#{tag.v}']"
@@ -1668,7 +1668,7 @@ CHANGESET
       changeset = create(:changeset, :user => user)
 
       ## First try with a non-public user
-      new_changeset = private_changeset.to_xml
+      new_changeset = create_changeset_xml(:user => private_user)
       new_tag = XML::Node.new "tag"
       new_tag["k"] = "tagtesting"
       new_tag["v"] = "valuetesting"
@@ -1689,8 +1689,7 @@ CHANGESET
       assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
 
       ## Now try with the public user
-      create(:changeset_tag, :changeset => changeset)
-      new_changeset = changeset.to_xml
+      new_changeset = create_changeset_xml(:id => 1)
       new_tag = XML::Node.new "tag"
       new_tag["k"] = "tagtesting"
       new_tag["v"] = "valuetesting"
@@ -1712,7 +1711,7 @@ CHANGESET
       assert_response :success
 
       assert_select "osm>changeset[id='#{changeset.id}']", 1
-      assert_select "osm>changeset>tag", 2
+      assert_select "osm>changeset>tag", 1
       assert_select "osm>changeset>tag[k='tagtesting'][v='valuetesting']", 1
     end
 
@@ -1723,7 +1722,7 @@ CHANGESET
       basic_authorization create(:user).email, "test"
 
       changeset = create(:changeset)
-      new_changeset = changeset.to_xml
+      new_changeset = create_changeset_xml(:user => changeset.user, :id => changeset.id)
       new_tag = XML::Node.new "tag"
       new_tag["k"] = "testing"
       new_tag["v"] = "testing"
@@ -1953,5 +1952,20 @@ CHANGESET
       xml.find("//osm/way").first[name] = value.to_s
       xml
     end
+
+    ##
+    # build XML for changesets
+    def create_changeset_xml(user: nil, id: nil)
+      root = XML::Document.new
+      root.root = XML::Node.new "osm"
+      cs = XML::Node.new "changeset"
+      if user
+        cs["user"] = user.display_name
+        cs["uid"] = user.id.to_s
+      end
+      cs["id"] = id.to_s if id
+      root.root << cs
+      root
+    end
   end
 end
index 5ee5a9e6ccaffb63eb65e941f532e79a502c6f9d..db83aaa9f32fe4a29fdf8f0de5dbf13757249923 100644 (file)
@@ -49,7 +49,7 @@ module Api
         print @response.body
       end
       assert_response :success, "Expected scucess with the map call"
-      assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+      assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
         assert_select "bounds[minlon='#{format('%.7f', minlon)}'][minlat='#{format('%.7f', minlat)}'][maxlon='#{format('%.7f', maxlon)}'][maxlat='#{format('%.7f', maxlat)}']", :count => 1
         assert_select "node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
           # This should really be more generic
@@ -75,7 +75,7 @@ module Api
       bbox = "#{node.lon},#{node.lat},#{node.lon},#{node.lat}"
       get :index, :params => { :bbox => bbox }
       assert_response :success, "The map call should have succeeded"
-      assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+      assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
         assert_select "bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']", :count => 1
         assert_select "node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
           # This should really be more generic
@@ -103,7 +103,7 @@ module Api
       bbox = "#{node.lon},#{node.lat},#{node.lon},#{node.lat}"
       get :index, :params => { :bbox => bbox }
       assert_response :success, "The map call should have succeeded"
-      assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+      assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
         assert_select "bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']", :count => 1
         assert_select "node", :count => 3
         assert_select "node[id='#{node.id}']", :count => 1
@@ -120,7 +120,7 @@ module Api
     def test_map_empty
       get :index, :params => { :bbox => "179.998,89.998,179.999.1,89.999" }
       assert_response :success, "The map call should have succeeded"
-      assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
+      assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
         assert_select "bounds[minlon='179.9980000'][minlat='89.9980000'][maxlon='179.9990000'][maxlat='89.9990000']", :count => 1
         assert_select "node", :count => 0
         assert_select "way", :count => 0
@@ -138,7 +138,7 @@ module Api
       @badbigbbox.each do |bbox|
         get :index, :params => { :bbox => bbox }
         assert_response :bad_request, "The bbox:#{bbox} was expected to be too big"
-        assert_equal "The maximum bbox size is #{MAX_REQUEST_AREA}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
+        assert_equal "The maximum bbox size is #{Settings.max_request_area}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
       end
     end
 
index e5390922d64446467e44f9b802c98059fa28b401..4d2969026aa3621dea4936c2abf674425880553d 100644 (file)
@@ -133,7 +133,7 @@ module Api
       assert_response :success
 
       # count one osm element
-      assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
+      assert_select "osm[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
 
       # we should have only the expected number of relations
       assert_select "osm>relation", expected_relations.size
index b9a1c126f350b5bcf06c8ddbc85f386fbd21a8ae..e02dca53307c38d8a6c3ae13f09882cbaca64a81 100644 (file)
@@ -115,7 +115,7 @@ module Api
       @badbigbbox.each do |bbox|
         get :index, :params => { :bbox => bbox }
         assert_response :bad_request, "The bbox:#{bbox} was expected to be too big"
-        assert_equal "The maximum bbox size is #{MAX_REQUEST_AREA}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
+        assert_equal "The maximum bbox size is #{Settings.max_request_area}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
       end
     end
 
index 4f28514775d6cc9284ac95ea0ca47462d55c93da..0466ac9962ff72756daa48ed45b5ea25fc352f12 100644 (file)
@@ -3,23 +3,9 @@ require "minitest/mock"
 
 module Api
   class TracesControllerTest < ActionController::TestCase
-    def setup
-      @gpx_trace_dir = Object.send("remove_const", "GPX_TRACE_DIR")
-      Object.const_set("GPX_TRACE_DIR", Rails.root.join("test", "gpx", "traces"))
-
-      @gpx_image_dir = Object.send("remove_const", "GPX_IMAGE_DIR")
-      Object.const_set("GPX_IMAGE_DIR", Rails.root.join("test", "gpx", "images"))
-    end
-
     def teardown
-      File.unlink(*Dir.glob(File.join(GPX_TRACE_DIR, "*.gpx")))
-      File.unlink(*Dir.glob(File.join(GPX_IMAGE_DIR, "*.gif")))
-
-      Object.send("remove_const", "GPX_TRACE_DIR")
-      Object.const_set("GPX_TRACE_DIR", @gpx_trace_dir)
-
-      Object.send("remove_const", "GPX_IMAGE_DIR")
-      Object.const_set("GPX_IMAGE_DIR", @gpx_image_dir)
+      File.unlink(*Dir.glob(File.join(Settings.gpx_trace_dir, "*.gpx")))
+      File.unlink(*Dir.glob(File.join(Settings.gpx_image_dir, "*.gif")))
     end
 
     ##
index 8e4d5eeb27fd0f4cd062c2dc7627fa5dea2997cd..0348163bab100535279fe5d355f48bb5dd0d7ff9 100644 (file)
@@ -190,7 +190,7 @@ class MessagesControllerTest < ActionController::TestCase
     assert_equal "[OpenStreetMap] Test Message", e.subject
     assert_match(/Test message body/, e.text_part.decoded)
     assert_match(/Test message body/, e.html_part.decoded)
-    assert_match %r{#{SERVER_URL}/messages/[0-9]+}, e.text_part.decoded
+    assert_match %r{#{Settings.server_url}/messages/[0-9]+}, e.text_part.decoded
     ActionMailer::Base.deliveries.clear
     m = Message.last
     assert_equal user.id, m.from_user_id
@@ -483,12 +483,11 @@ class MessagesControllerTest < ActionController::TestCase
   private
 
   def with_message_limit(value)
-    max_messages_per_hour = Object.send("remove_const", "MAX_MESSAGES_PER_HOUR")
-    Object.const_set("MAX_MESSAGES_PER_HOUR", value)
+    max_messages_per_hour = Settings.max_messages_per_hour
+    Settings.max_messages_per_hour = value
 
     yield
 
-    Object.send("remove_const", "MAX_MESSAGES_PER_HOUR")
-    Object.const_set("MAX_MESSAGES_PER_HOUR", max_messages_per_hour)
+    Settings.max_messages_per_hour = max_messages_per_hour
   end
 end
index c4e1a5a66309bfc96ddaec3244c8e649cad60002..a2ea86f6f661c2c469a3c472dab5c197739e4c6b 100644 (file)
@@ -4,8 +4,8 @@ class SiteControllerTest < ActionController::TestCase
   ##
   # setup oauth keys
   def setup
-    Object.const_set("ID_KEY", create(:client_application).key)
-    Object.const_set("POTLATCH2_KEY", create(:client_application).key)
+    Settings.id_key = create(:client_application).key
+    Settings.potlatch2_key = create(:client_application).key
 
     stub_hostip_requests
   end
@@ -13,8 +13,8 @@ class SiteControllerTest < ActionController::TestCase
   ##
   # clear oauth keys
   def teardown
-    Object.send("remove_const", "ID_KEY")
-    Object.send("remove_const", "POTLATCH2_KEY")
+    Settings.id_key = nil
+    Settings.potlatch2_key = nil
   end
 
   ##
@@ -173,7 +173,7 @@ class SiteControllerTest < ActionController::TestCase
     get :edit, :session => { :user => create(:user) }
     assert_response :success
     assert_template "edit"
-    assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
+    assert_template :partial => "_#{Settings.default_editor}", :count => 1
   end
 
   # Test the right editor gets used when the user has set a preference
index 84469437ac8524b7be304df60073430fed9f5642..daa8a678729a31e8a5fc92ddff6ddda955d0ee16 100644 (file)
@@ -2,23 +2,9 @@ require "test_helper"
 require "minitest/mock"
 
 class TracesControllerTest < ActionController::TestCase
-  def setup
-    @gpx_trace_dir = Object.send("remove_const", "GPX_TRACE_DIR")
-    Object.const_set("GPX_TRACE_DIR", Rails.root.join("test", "gpx", "traces"))
-
-    @gpx_image_dir = Object.send("remove_const", "GPX_IMAGE_DIR")
-    Object.const_set("GPX_IMAGE_DIR", Rails.root.join("test", "gpx", "images"))
-  end
-
   def teardown
-    File.unlink(*Dir.glob(File.join(GPX_TRACE_DIR, "*.gpx")))
-    File.unlink(*Dir.glob(File.join(GPX_IMAGE_DIR, "*.gif")))
-
-    Object.send("remove_const", "GPX_TRACE_DIR")
-    Object.const_set("GPX_TRACE_DIR", @gpx_trace_dir)
-
-    Object.send("remove_const", "GPX_IMAGE_DIR")
-    Object.const_set("GPX_IMAGE_DIR", @gpx_image_dir)
+    File.unlink(*Dir.glob(File.join(Settings.gpx_trace_dir, "*.gpx")))
+    File.unlink(*Dir.glob(File.join(Settings.gpx_image_dir, "*.gif")))
   end
 
   ##
index 9381365920a8ab116efbb65ee7cedf2f70bc12ac..3bc6ded98b74b164f9af4ba62cbfc6e8879713cf 100644 (file)
@@ -8,10 +8,10 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
   def test_api_blocked
     blocked_user = create(:user)
 
-    get "/api/#{API_VERSION}/user/details"
+    get "/api/#{Settings.api_version}/user/details"
     assert_response :unauthorized
 
-    get "/api/#{API_VERSION}/user/details", :headers => auth_header(blocked_user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/details", :headers => auth_header(blocked_user.display_name, "test")
     assert_response :success
 
     # now block the user
@@ -21,7 +21,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
       :reason => "testing",
       :ends_at => Time.now.getutc + 5.minutes
     )
-    get "/api/#{API_VERSION}/user/details", :headers => auth_header(blocked_user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/details", :headers => auth_header(blocked_user.display_name, "test")
     assert_response :forbidden
   end
 
@@ -35,7 +35,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
       :reason => "testing",
       :ends_at => Time.now.getutc + 5.minutes
     )
-    get "/api/#{API_VERSION}/user/details", :headers => auth_header(blocked_user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/details", :headers => auth_header(blocked_user.display_name, "test")
     assert_response :forbidden
 
     # revoke the ban
@@ -54,7 +54,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
     reset!
 
     # access the API again. this time it should work
-    get "/api/#{API_VERSION}/user/details", :headers => auth_header(blocked_user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/details", :headers => auth_header(blocked_user.display_name, "test")
     assert_response :success
   end
 end
index 416d226ccd472fde9c735df02990433229475864..32fdba0b2c09516f26209de4400863213ef344b4 100644 (file)
@@ -8,14 +8,14 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest
   def test_api_blocked
     user = create(:user, :terms_seen => false, :terms_agreed => nil)
 
-    get "/api/#{API_VERSION}/user/preferences", :headers => auth_header(user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/preferences", :headers => auth_header(user.display_name, "test")
     assert_response :forbidden
 
     # touch it so that the user has seen the terms
     user.terms_seen = true
     user.save
 
-    get "/api/#{API_VERSION}/user/preferences", :headers => auth_header(user.display_name, "test")
+    get "/api/#{Settings.api_version}/user/preferences", :headers => auth_header(user.display_name, "test")
     assert_response :success
   end
 
index 1497040f04a22ddd946ca101886183054fc2bc04..81120f0e776e0c1103560f153f50912eed50d096 100644 (file)
@@ -2,23 +2,9 @@ require "test_helper"
 require "minitest/mock"
 
 class TraceTest < ActiveSupport::TestCase
-  def setup
-    @gpx_trace_dir = Object.send("remove_const", "GPX_TRACE_DIR")
-    Object.const_set("GPX_TRACE_DIR", Rails.root.join("test", "gpx", "traces"))
-
-    @gpx_image_dir = Object.send("remove_const", "GPX_IMAGE_DIR")
-    Object.const_set("GPX_IMAGE_DIR", Rails.root.join("test", "gpx", "images"))
-  end
-
   def teardown
-    File.unlink(*Dir.glob(File.join(GPX_TRACE_DIR, "*.gpx")))
-    File.unlink(*Dir.glob(File.join(GPX_IMAGE_DIR, "*.gif")))
-
-    Object.send("remove_const", "GPX_TRACE_DIR")
-    Object.const_set("GPX_TRACE_DIR", @gpx_trace_dir)
-
-    Object.send("remove_const", "GPX_IMAGE_DIR")
-    Object.const_set("GPX_IMAGE_DIR", @gpx_image_dir)
+    File.unlink(*Dir.glob(File.join(Settings.gpx_trace_dir, "*.gpx")))
+    File.unlink(*Dir.glob(File.join(Settings.gpx_image_dir, "*.gif")))
   end
 
   def test_visible
@@ -220,6 +206,10 @@ class TraceTest < ActiveSupport::TestCase
 
       trace.reload
       assert_equal 1, Tracepoint.where(:gpx_id => trace.id).count
+
+      # Check that the tile has been set prior to the bulk import
+      # i.e. that the callbacks have been run correctly
+      assert_equal 3221331576, Tracepoint.where(:gpx_id => trace.id).first.tile
     end
   end
 
@@ -227,7 +217,7 @@ class TraceTest < ActiveSupport::TestCase
     FakeFS do
       FakeFS::FileSystem.clone(Rails.root.join("test", "gpx"))
       trace = create(:trace, :fixture => "a")
-      icon_path = File.join(GPX_IMAGE_DIR, "#{trace.id}_icon.gif")
+      icon_path = File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif")
       FileUtils.rm(icon_path)
       assert_equal false, File.exist?(icon_path)
 
@@ -241,7 +231,7 @@ class TraceTest < ActiveSupport::TestCase
     FakeFS do
       FakeFS::FileSystem.clone(Rails.root.join("test", "gpx"))
       trace = create(:trace, :fixture => "a")
-      large_picture_path = File.join(GPX_IMAGE_DIR, "#{trace.id}.gif")
+      large_picture_path = File.join(Settings.gpx_image_dir, "#{trace.id}.gif")
       FileUtils.rm(large_picture_path)
       assert_equal false, File.exist?(large_picture_path)
 
index fb37be1b4fdfb40b31a49957222ae32f9b1dd036..3c44f2f26bd6ddb5975920b2e6948038defb5e4f 100644 (file)
@@ -29,7 +29,7 @@ class WayTest < ActiveSupport::TestCase
     # Take one of the current ways and add nodes to it until we are near the limit
     assert way.valid?
     # it already has 1 node
-    1.upto(MAX_NUMBER_OF_WAY_NODES / 2) do
+    1.upto(Settings.max_number_of_way_nodes / 2) do
       way.add_nd_num(node_a.id)
       way.add_nd_num(node_b.id)
     end