Merge branch 'master' into moderation

This commit is contained in:
Andy Allan 2017-11-29 12:18:39 +00:00
commit effb1b7f41
438 changed files with 83811 additions and 57285 deletions

View file

@ -27,15 +27,34 @@ Rails:
Layout/ExtraSpacing:
AllowForAlignment: true
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
Lint/PercentStringArray:
Exclude:
- 'config/initializers/secure_headers.rb'
- 'app/controllers/site_controller.rb'
Style/FileName:
Naming/FileName:
Exclude:
- 'script/deliver-message'
- 'script/locale/reload-languages'
- 'script/update-spam-blocks'
Rails/ApplicationRecord:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
Rails/HttpPositionalArguments:
Enabled: false
Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/*.rb'
- 'app/controllers/user_controller.rb'
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
Style/FormatStringToken:
EnforcedStyle: template
@ -60,19 +79,3 @@ Style/StringLiterals:
Style/SymbolArray:
EnforcedStyle: brackets
Rails/ApplicationRecord:
Enabled: false
Rails/HttpPositionalArguments:
Enabled: false
Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/*.rb'
- 'app/controllers/user_controller.rb'
Lint/PercentStringArray:
Exclude:
- 'config/initializers/secure_headers.rb'
- 'app/controllers/site_controller.rb'

View file

@ -1,11 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-10-20 21:45:27 +0100 using RuboCop version 0.44.1.
# on 2017-10-05 10:04:24 +0100 using RuboCop version 0.50.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'lib/bounding_box.rb'
# Offense count: 34
Lint/AmbiguousOperator:
Exclude:
@ -14,11 +22,11 @@ Lint/AmbiguousOperator:
- 'test/lib/bounding_box_test.rb'
- 'test/lib/country_test.rb'
# Offense count: 117
# Offense count: 124
Lint/AmbiguousRegexpLiteral:
Enabled: false
# Offense count: 30
# Offense count: 32
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
@ -36,52 +44,62 @@ Lint/AssignmentInCondition:
- 'lib/osm.rb'
- 'script/deliver-message'
# Offense count: 5
# Offense count: 4
Lint/HandleExceptions:
Exclude:
- 'app/controllers/amf_controller.rb'
- 'app/controllers/user_controller.rb'
- 'config/initializers/session.rb'
# Offense count: 3
Lint/InterpolationCheck:
Exclude:
- 'test/controllers/node_controller_test.rb'
# Offense count: 2
Lint/RescueWithoutErrorClass:
Exclude:
- 'app/helpers/browse_helper.rb'
# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'app/views/changeset/list.atom.builder'
# Offense count: 630
# Offense count: 666
Metrics/AbcSize:
Max: 280
# Offense count: 35
# Configuration parameters: CountComments.
# Offense count: 41
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 295
Max: 240
# Offense count: 12
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5
# Offense count: 62
# Offense count: 63
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 1790
Max: 1796
# Offense count: 69
# Offense count: 71
Metrics/CyclomaticComplexity:
Max: 20
# Offense count: 2826
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
# Offense count: 3004
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 1072
Max: 1073
# Offense count: 612
# Offense count: 675
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 179
# Offense count: 1
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 147
@ -95,6 +113,30 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity:
Max: 23
# Offense count: 5
Naming/AccessorMethodName:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/helpers/title_helper.rb'
- 'app/models/old_way.rb'
- 'lib/osm.rb'
- 'lib/potlatch.rb'
# Offense count: 8
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'app/models/changeset.rb'
- 'app/models/old_node.rb'
- 'app/models/old_relation.rb'
- 'app/models/old_way.rb'
- 'app/models/user.rb'
- 'lib/classic_pagination/pagination.rb'
# Offense count: 2
# Configuration parameters: Include.
# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb
@ -122,7 +164,7 @@ Rails/NotNullColumn:
- 'db/migrate/025_add_end_time_to_changesets.rb'
- 'db/migrate/20120404205604_add_user_and_description_to_redaction.rb'
# Offense count: 17
# Offense count: 20
Rails/OutputSafety:
Exclude:
- 'app/controllers/user_controller.rb'
@ -136,27 +178,18 @@ Rails/OutputSafety:
- 'lib/rich_text.rb'
- 'test/helpers/application_helper_test.rb'
# Offense count: 74
# Offense count: 86
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Enabled: false
# Offense count: 5
Style/AccessorMethodName:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/helpers/title_helper.rb'
- 'app/models/old_way.rb'
- 'lib/osm.rb'
- 'lib/potlatch.rb'
# Offense count: 1
Style/AsciiComments:
Exclude:
- 'test/models/message_test.rb'
# Offense count: 220
# Offense count: 219
Style/Documentation:
Enabled: false
@ -182,35 +215,15 @@ Style/LineEndConcatenation:
- 'test/controllers/relation_controller_test.rb'
- 'test/controllers/way_controller_test.rb'
# Offense count: 71
# Offense count: 75
# Cop supports --auto-correct.
# Configuration parameters: Strict.
Style/NumericLiterals:
MinDigits: 11
# Offense count: 8
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Exclude:
- 'spec/**/*'
- 'app/models/changeset.rb'
- 'app/models/old_node.rb'
- 'app/models/old_relation.rb'
- 'app/models/old_way.rb'
- 'app/models/user.rb'
- 'lib/classic_pagination/pagination.rb'
# Offense count: 97
# Offense count: 95
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'app/helpers/browse_helper.rb'

View file

@ -4,10 +4,10 @@ rvm:
- 2.3.1
cache: bundler
addons:
postgresql: 9.1
postgresql: 9.5
apt:
packages:
- postgresql-server-dev-9.1
- postgresql-server-dev-9.5
services:
- memcached
env:
@ -18,9 +18,10 @@ before_script:
- psql -U postgres -c "CREATE DATABASE openstreetmap"
- psql -U postgres -c "CREATE EXTENSION btree_gist" openstreetmap
- make -C db/functions libpgosm.so
- psql -U postgres -c "CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '${PWD}/db/functions/libpgosm', 'maptile_for_point' LANGUAGE C STRICT" openstreetmap
- psql -U postgres -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '${PWD}/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT" openstreetmap
- psql -U postgres -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '${PWD}/db/functions/libpgosm', 'xid_to_int4' LANGUAGE C STRICT" openstreetmap
- ln db/functions/libpgosm.so /tmp
- psql -U postgres -c "CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '/tmp/libpgosm', 'maptile_for_point' LANGUAGE C STRICT" openstreetmap
- 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
- bundle exec rake db:migrate
script:

View file

@ -42,7 +42,8 @@ sudo gem install rcov
rcov -x gems test/*/*.rb
```
The tests are automatically run on commit with the results shown at [http://cruise.openstreetmap.org/](http://cruise.openstreetmap.org/)
The tests are automatically run on Pull Requests and other commits with the
results shown on [Travis CI](https://travis-ci.org/openstreetmap/openstreetmap-website).
## Comments
@ -96,4 +97,3 @@ Otherwise you should either push your changes to a publicly visible git reposito
and send the details to the [rails-dev](http://lists.openstreetmap.org/listinfo/rails-dev)
list or generate patches with `git format-patch` and send them to the
[rails-dev](http://lists.openstreetmap.org/listinfo/rails-dev) list.

30
FAQ.md Normal file
View file

@ -0,0 +1,30 @@
## How do I create a banner to promote my OpenStreetMap event?
We occasionally display banner images on the main page of [openstreetmap.org](https://www.openstreetmap.org/) to
promote a large OpenStreetMap focused conference or host a worldwide donation
drive. This is a great way to reach a lot of people!
1. Please review [openstreetmap/operations#150](https://github.com/openstreetmap/operations/issues/150) to
know whether your event qualifies for a front-page banner.
2. Create the banner image. Some guidelines:
* Image should be 350px wide (exactly) x 350px tall (or shorter).
* Use a standard web image format (.gif, .jpg, .png)
* Note that a close 'X' button will be drawn over the top right 60x60px
corner of the banner, so please do not put anything important in that space.
3. Prepare a pull request which includes the following:
* The banner should be saved under the
[`app/assets/images/banners/`](https://github.com/openstreetmap/openstreetmap-website/tree/master/app/assets/images/banners) folder, and should have a name that makes it clear what it is for (e.g. `donate-2017.jpg`)
* Edit [`config/banners.yml`](https://github.com/openstreetmap/openstreetmap-website/blob/master/config/banners.yml)
to contain an entry for the event banner. It should contain the following:
* `id` - a unique identifier (e.g. `donate2017`)
* `alt` - alt name for the image (e.g. `OpenStreetMap Funding Drive 2017`)
* `link` - URL for your event page (e.g. `https://donate.openstreetmap.org/`)
* `img` - the filename for the banner image (e.g. `banners/donate-2017.jpg`)
* `enddate` - the final date that the banner will be shown (e.g. `2017-oct-31`)
* (optional) Feel free to cleanup the old images from the `app/assets/images/banners/`
folder and old entries in the `config/banners.yml` file.
See [PR #1296](https://github.com/openstreetmap/openstreetmap-website/pull/1296)
as an example.

14
Gemfile
View file

@ -1,7 +1,7 @@
source "https://rubygems.org"
# Require rails
gem "rails", "5.0.5"
gem "rails", "5.1.4"
# Require things which have moved to gems in ruby 1.9
gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19
@ -32,7 +32,7 @@ gem "jquery-rails"
gem "jsonify-rails"
# Use R2 for RTL conversion
gem "r2"
gem "r2", "~> 0.2.7"
# Use autoprefixer to generate CSS prefixes
gem "autoprefixer-rails"
@ -42,12 +42,12 @@ gem "image_optim_rails"
# Load rails plugins
gem "actionpack-page_caching"
gem "composite_primary_keys", "~> 9.0.7"
gem "deadlock_retry", ">= 1.2.0"
gem "composite_primary_keys", "~> 10.0.0"
gem "dynamic_form"
gem "http_accept_language", "~> 2.0.0"
gem "i18n-js", ">= 3.0.0"
gem "oauth-plugin", ">= 0.5.1"
gem "openstreetmap-deadlock_retry", ">= 1.3.0", :require => "deadlock_retry"
gem "paperclip", "~> 4.0"
gem "rack-cors"
gem "rails-i18n", "~> 4.0.0"
@ -107,6 +107,7 @@ gem "logstasher"
# Gems useful for development
group :development do
gem "annotate"
gem "listen"
gem "vendorer"
end
@ -122,9 +123,10 @@ end
# Needed in development as well so rake can see konacha tasks
group :development, :test do
gem "capybara", "~> 2.13"
gem "coveralls", :require => false
gem "factory_girl_rails"
gem "factory_bot_rails"
gem "jshint"
# gem "konacha"
gem "poltergeist"
gem "puma", "~> 3.7"
end

View file

@ -3,58 +3,61 @@ GEM
specs:
SystemTimer (1.2.3)
aasm (4.1.0)
actioncable (5.0.5)
actionpack (= 5.0.5)
nio4r (>= 1.2, < 3.0)
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.5)
actionpack (= 5.0.5)
actionview (= 5.0.5)
activejob (= 5.0.5)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.5)
actionview (= 5.0.5)
activesupport (= 5.0.5)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (~> 0.6.3)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-page_caching (1.1.0)
actionpack (>= 4.0.0, < 6)
actionview (5.0.5)
activesupport (= 5.0.5)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.5)
activesupport (= 5.0.5)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.0.5)
activesupport (= 5.0.5)
activerecord (5.0.5)
activemodel (= 5.0.5)
activesupport (= 5.0.5)
arel (~> 7.0)
activesupport (5.0.5)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
arel (~> 8.0)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
annotate (2.7.2)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
arel (8.0.0)
ast (2.3.0)
autoprefixer-rails (7.1.2.3)
autoprefixer-rails (7.1.6)
execjs
bigdecimal (1.1.0)
builder (3.2.3)
canonical-rails (0.2.1)
rails (>= 4.1, < 5.2)
capybara (2.14.4)
capybara (2.15.4)
addressable
mime-types (>= 1.16)
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
@ -70,8 +73,8 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
composite_primary_keys (9.0.7)
activerecord (~> 5.0.0)
composite_primary_keys (10.0.1)
activerecord (~> 5.1.0)
concurrent-ruby (1.0.5)
coveralls (0.8.21)
json (>= 1.8, < 3)
@ -83,30 +86,30 @@ GEM
safe_yaml (~> 1.0.0)
crass (1.0.2)
dalli (2.7.6)
deadlock_retry (1.2.0)
docile (1.1.5)
dynamic_form (1.1.4)
erubis (2.7.0)
erubi (1.7.0)
execjs (2.7.0)
exifr (1.3.1)
factory_girl (4.8.0)
exifr (1.3.2)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
fspath (3.1.0)
geoip (1.6.3)
globalid (0.4.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashdiff (0.3.4)
hashdiff (0.3.7)
hashie (3.5.6)
htmlentities (4.3.4)
http_accept_language (2.0.5)
i18n (0.8.6)
i18n-js (3.0.0)
i18n (0.9.0)
concurrent-ruby (~> 1.0)
i18n-js (3.0.2)
i18n (~> 0.6, >= 0.6.6)
image_optim (0.25.0)
exifr (~> 1.2, >= 1.2.2)
@ -143,20 +146,22 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
logstash-event (1.2.02)
logstasher (1.2.1)
logstasher (1.2.2)
activesupport (>= 4.0)
logstash-event (~> 1.2.0)
request_store
loofah (2.0.3)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.0)
mini_portile2 (2.2.0)
mini_mime (0.1.4)
mini_portile2 (2.3.0)
minitest (5.10.3)
minitest-capybara (0.8.2)
capybara (~> 2.2)
@ -172,12 +177,12 @@ GEM
minitest-capybara (~> 0.8)
minitest-metadata (~> 0.6)
minitest-rails (~> 3.0)
multi_json (1.12.1)
multi_json (1.12.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
nokogumbo (1.4.13)
nokogiri
oauth (0.4.7)
@ -192,7 +197,7 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
omniauth (1.7.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
@ -220,6 +225,7 @@ GEM
omniauth-windowslive (0.0.12)
multi_json (~> 1.12)
omniauth-oauth2 (~> 1.4)
openstreetmap-deadlock_retry (1.3.0)
paperclip (4.3.7)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
@ -230,34 +236,35 @@ GEM
parser (2.4.0.0)
ast (~> 2.2)
pg (0.21.0)
poltergeist (1.15.0)
poltergeist (1.16.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
powerpack (0.1.1)
progress (3.3.1)
progress (3.4.0)
psych (2.2.4)
public_suffix (2.0.5)
public_suffix (3.0.0)
puma (3.10.0)
r2 (0.2.7)
rack (2.0.3)
rack-cors (1.0.1)
rack-cors (1.0.2)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rack-test (0.7.0)
rack (>= 1.0, < 3)
rack-uri_sanitizer (0.0.2)
rails (5.0.5)
actioncable (= 5.0.5)
actionmailer (= 5.0.5)
actionpack (= 5.0.5)
actionview (= 5.0.5)
activejob (= 5.0.5)
activemodel (= 5.0.5)
activerecord (= 5.0.5)
activesupport (= 5.0.5)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
bundler (>= 1.3.0)
railties (= 5.0.5)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
@ -271,15 +278,15 @@ GEM
rails-i18n (4.0.2)
i18n (~> 0.6)
rails (>= 4.0)
railties (5.0.5)
actionpack (= 5.0.5)
activesupport (= 5.0.5)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (12.0.0)
rake (12.2.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
@ -288,24 +295,24 @@ GEM
redcarpet (3.4.0)
ref (2.0.0)
request_store (1.3.2)
rinku (2.0.2)
rinku (2.0.3)
rotp (3.3.0)
rubocop (0.49.1)
rubocop (0.51.0)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
rainbow (>= 2.2.2, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-openid (2.7.0)
ruby-progressbar (1.8.1)
ruby-progressbar (1.9.0)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
sanitize (4.5.0)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4.1)
sass (3.5.1)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
@ -316,17 +323,17 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
secure_headers (3.6.7)
useragent
secure_headers (5.0.1)
useragent (>= 0.15.0)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.1)
simplecov-html (0.10.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
@ -339,7 +346,7 @@ GEM
thread_safe (0.3.6)
tilt (2.0.8)
tins (1.15.0)
tzinfo (1.2.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
@ -348,7 +355,7 @@ GEM
validates_email_format_of (1.6.3)
i18n
vendorer (0.1.16)
webmock (3.0.1)
webmock (3.1.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
@ -365,16 +372,17 @@ DEPENDENCIES
SystemTimer (>= 1.1.3)
aasm
actionpack-page_caching
annotate
autoprefixer-rails
bigdecimal (~> 1.1.0)
canonical-rails
capybara (~> 2.13)
coffee-rails (~> 4.2)
composite_primary_keys (~> 9.0.7)
composite_primary_keys (~> 10.0.0)
coveralls
dalli
deadlock_retry (>= 1.2.0)
dynamic_form
factory_girl_rails
factory_bot_rails
faraday
geoip
htmlentities
@ -399,14 +407,16 @@ DEPENDENCIES
omniauth-mediawiki (>= 0.0.3)
omniauth-openid
omniauth-windowslive
openstreetmap-deadlock_retry (>= 1.3.0)
paperclip (~> 4.0)
pg
poltergeist
psych
r2
puma (~> 3.7)
r2 (~> 0.2.7)
rack-cors
rack-uri_sanitizer
rails (= 5.0.5)
rails (= 5.1.4)
rails-controller-testing
rails-i18n (~> 4.0.0)
record_tag_helper
@ -423,4 +433,4 @@ DEPENDENCIES
webmock
BUNDLED WITH
1.13.7
1.15.4

View file

@ -40,3 +40,8 @@ We're always keen to have more developers! Pull requests are very welcome.
* IRC - there is the #osm-dev channel on irc.oftc.net.
More details on contributing to the code are in the [CONTRIBUTING.md](CONTRIBUTING.md) file.
# Maintainers
* Tom Hughes [@tomhughes](https://github.com/tomhughes/)
* Andy Allan [@gravitystorm](https://github.com/gravitystorm/)

View file

@ -11,13 +11,13 @@ folder 'vendor/assets' do
end
folder 'leaflet' do
file 'leaflet.js', 'https://unpkg.com/leaflet@1.1.0/dist/leaflet-src.js'
file 'leaflet.css', 'https://unpkg.com/leaflet@1.1.0/dist/leaflet.css'
file 'leaflet.js', 'https://unpkg.com/leaflet@1.2.0/dist/leaflet-src.js'
file 'leaflet.css', 'https://unpkg.com/leaflet@1.2.0/dist/leaflet.css'
[ 'layers.png', 'layers-2x.png',
'marker-icon.png', 'marker-icon-2x.png',
'marker-shadow.png' ].each do |image|
file "images/#{image}", "https://unpkg.com/leaflet@1.1.0/dist/images/#{image}"
file "images/#{image}", "https://unpkg.com/leaflet@1.2.0/dist/images/#{image}"
end
from 'git://github.com/aratcliffe/Leaflet.contextmenu.git', :tag => 'v1.2.1' do

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -1,4 +1,4 @@
//= require jquery
//= require jquery3
//= require jquery_ujs
//= require jquery.timers
//= require jquery.cookie
@ -79,18 +79,6 @@ $(document).ready(function () {
var headerWidth = 0,
compactWidth = 0;
$("header").children(":visible").each(function (i,e) {
headerWidth = headerWidth + $(e).outerWidth();
});
$("body").addClass("compact");
$("header").children(":visible").each(function (i,e) {
compactWidth = compactWidth + $(e).outerWidth();
});
$("body").removeClass("compact");
function updateHeader() {
var windowWidth = $(window).width();
@ -103,9 +91,29 @@ $(document).ready(function () {
}
}
updateHeader();
/*
* Chrome 60 and later seem to fire the "ready" callback
* before the DOM is fully ready causing us to measure the
* wrong sizes for the header elements - use a 0ms timeout
* to defer the measurement slightly as a workaround.
*/
setTimeout(function () {
$("header").children(":visible").each(function (i,e) {
headerWidth = headerWidth + $(e).outerWidth();
});
$(window).resize(updateHeader);
$("body").addClass("compact");
$("header").children(":visible").each(function (i,e) {
compactWidth = compactWidth + $(e).outerWidth();
});
$("body").removeClass("compact");
updateHeader();
$(window).resize(updateHeader);
}, 0);
$("#menu-icon").on("click", function(e) {
e.preventDefault();

View file

@ -20,6 +20,8 @@ $(document).ready(function () {
if (hashParams.background) params.background = hashParams.background;
if (hashParams.comment) params.comment = hashParams.comment;
if (hashParams.disable_features) params.disable_features = hashParams.disable_features;
if (hashParams.hashtags) params.hashtags = hashParams.hashtags;
if (hashParams.offset) params.offset = hashParams.offset;
if (hashParams.walkthrough) params.walkthrough = hashParams.walkthrough;

View file

@ -114,6 +114,7 @@ $(document).ready(function () {
.removeClass('leaflet-control-locate leaflet-bar')
.addClass('control-locate')
.children("a")
.attr('href', '#')
.removeClass('leaflet-bar-part leaflet-bar-part-single')
.addClass('control-button');

View file

@ -8,7 +8,8 @@ OSM.initializeContextMenu = function (map) {
lng = latlng.lng.toFixed(precision);
OSM.router.route("/directions?" + querystring.stringify({
route: lat + "," + lng + ";" + $("#route_to").val()
from: lat + "," + lng,
to: $("#route_to").val()
}));
}
});
@ -22,7 +23,8 @@ OSM.initializeContextMenu = function (map) {
lng = latlng.lng.toFixed(precision);
OSM.router.route("/directions?" + querystring.stringify({
route: $("#route_from").val() + ";" + lat + "," + lng
from: $("#route_from").val(),
to: lat + "," + lng
}));
}
});

View file

@ -146,7 +146,7 @@ OSM.Query = function(map) {
if (feature.type === "node" && feature.lat && feature.lon) {
geometry = L.circleMarker([feature.lat, feature.lon], featureStyle);
} else if (feature.type === "way" && feature.geometry) {
} else if (feature.type === "way" && feature.geometry && feature.geometry.length > 0) {
geometry = L.polyline(feature.geometry.filter(function (point) {
return point !== null;
}).map(function (point) {

View file

@ -49,7 +49,7 @@ L.OSM.layers = function(options) {
.appendTo(item);
map.whenReady(function() {
var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false})
var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false, keyboard: false})
.addLayer(new layer.constructor({ apikey: layer.options.apikey }));
miniMap.dragging.disable();

View file

@ -28,6 +28,7 @@ $(document).ready(function () {
.removeClass('leaflet-control-locate leaflet-bar')
.addClass('control-locate')
.children("a")
.attr('href', '#')
.removeClass('leaflet-bar-part leaflet-bar-part-single')
.addClass('control-button');
@ -84,6 +85,10 @@ $(document).ready(function () {
$("select#user_auth_provider").on("change", updateAuthUID);
$("input#user_image").on("change", function () {
$("#image_action_new").prop("checked", true);
});
function enableAuth() {
$("#auth_prompt").hide();
$("#auth_field").show();

View file

@ -1664,6 +1664,10 @@ tr.turn:hover {
display: inline;
}
.pagination {
padding-top: $lineheight;
}
/* Rules for the diary entry page */
.diary_entry {
@ -2776,12 +2780,30 @@ input.richtext_title[type="text"] {
vertical-align: middle;
background: 40px 40px image-url('about/sprite.png') no-repeat;
&.local { background-position: 0px 0px; }
&.community { background-position: 0px -40px; }
&.open { background-position: 0px -80px; }
&.partners { background-position: 0px -120px; }
&.infringement { background-position: 0px -160px; }
&.legal { background-position: -45px -160px; }
&.local {
/* no-r2 */
background-position: 0px 0px;
}
&.community {
/* no-r2 */
background-position: 0px -40px;
}
&.open {
/* no-r2 */
background-position: 0px -80px;
}
&.partners {
/* no-r2 */
background-position: 0px -120px;
}
&.infringement {
/* no-r2 */
background-position: 0px -160px;
}
&.legal {
/* no-r2 */
background-position: -45px -160px;
}
}
}

View file

@ -151,7 +151,7 @@ class AmfController < ApplicationController
cs = Changeset.find(closeid.to_i)
cs.set_closed_time_now
if cs.user_id != user.id
raise OSM::APIUserChangesetMismatchError.new
raise OSM::APIUserChangesetMismatchError
elsif closecomment.empty?
cs.save!
else
@ -186,7 +186,7 @@ class AmfController < ApplicationController
# Return presets (default tags, localisation etc.):
# uses POTLATCH_PRESETS global, set up in OSM::Potlatch.
def getpresets(usertoken, lang) #:doc:
def getpresets(usertoken, _lang)
user = getuser(usertoken)
langs = if user && !user.languages.empty?
@ -229,7 +229,7 @@ class AmfController < ApplicationController
begin
other = YAML.safe_load(File.open(Rails.root.join("config", "potlatch", "locales", "#{lang}.yml")))[lang]
loaded_lang = lang
rescue
rescue StandardError
other = en
end
@ -253,7 +253,7 @@ class AmfController < ApplicationController
# nodes in the bbox, nodes are any visible nodes in the bbox but not
# used in any way, rel is any relation which refers to either a way
# or node that we're returning.
def whichways(xmin, ymin, xmax, ymax) #:doc:
def whichways(xmin, ymin, xmax, ymax)
amf_handle_error_with_timeout("'whichways'", nil, nil) do
enlarge = [(xmax - xmin) / 8, 0.01].min
xmin -= enlarge
@ -297,7 +297,7 @@ class AmfController < ApplicationController
# Find deleted ways in current bounding box (similar to whichways, but ways
# with a deleted node only - not POIs or relations).
def whichways_deleted(xmin, ymin, xmax, ymax) #:doc:
def whichways_deleted(xmin, ymin, xmax, ymax)
amf_handle_error_with_timeout("'whichways_deleted'", nil, nil) do
enlarge = [(xmax - xmin) / 8, 0.01].min
xmin -= enlarge
@ -321,7 +321,7 @@ class AmfController < ApplicationController
# Get a way including nodes and tags.
# Returns the way id, a Potlatch-style array of points, a hash of tags, the version number, and the user ID.
def getway(wayid) #:doc:
def getway(wayid)
amf_handle_error_with_timeout("'getway' #{wayid}", "way", wayid) do
if POTLATCH_USE_SQL
points = sql_get_nodes_in_way(wayid)
@ -366,7 +366,7 @@ class AmfController < ApplicationController
# 4. version,
# 5. is this the current, visible version? (boolean)
def getway_old(id, timestamp) #:doc:
def getway_old(id, timestamp)
amf_handle_error_with_timeout("'getway_old' #{id}, #{timestamp}", "way", id) do
if timestamp == ""
# undelete
@ -375,7 +375,7 @@ class AmfController < ApplicationController
else
begin
# revert
timestamp = DateTime.strptime(timestamp.to_s, "%d %b %Y, %H:%M:%S")
timestamp = Time.strptime(timestamp.to_s, "%d %b %Y, %H:%M:%S")
old_way = OldWay.where("way_id = ? AND timestamp <= ?", id, timestamp).unredacted.order("timestamp DESC").first
unless old_way.nil?
if old_way.visible
@ -411,7 +411,7 @@ class AmfController < ApplicationController
# sort and collapse list (to within 2 seconds); trim all dates before the
# start date of the way.
def getway_history(wayid) #:doc:
def getway_history(wayid)
revdates = []
revusers = {}
Way.find(wayid).old_ways.unredacted.collect do |a|
@ -444,7 +444,7 @@ class AmfController < ApplicationController
# Find history of a node. Returns 'node', id, and an array of previous versions as above.
def getnode_history(nodeid) #:doc:
def getnode_history(nodeid)
history = Node.find(nodeid).old_nodes.unredacted.reverse.collect do |old_node|
[(old_node.timestamp + 1).strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
end
@ -492,7 +492,7 @@ class AmfController < ApplicationController
# 4. list of members,
# 5. version.
def getrelation(relid) #:doc:
def getrelation(relid)
amf_handle_error("'getrelation' #{relid}", "relation", relid) do
rel = Relation.where(:id => relid).first
@ -528,7 +528,7 @@ class AmfController < ApplicationController
# 2. new relation id,
# 3. version.
def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible) #:doc:
def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible)
amf_handle_error("'putrelation' #{relid}", "relation", relid) do
user = getuser(usertoken)
@ -582,7 +582,7 @@ class AmfController < ApplicationController
new_relation.id = relid
relation.delete_with_history!(new_relation, user)
end
end # transaction
end
if relid <= 0
return [0, "", relid, new_relation.id, new_relation.version]
@ -616,7 +616,7 @@ class AmfController < ApplicationController
# 6. hash of changed node versions (node=>version)
# 7. hash of deleted node versions (node=>version)
def putway(renumberednodes, usertoken, changeset_id, wayversion, originalway, pointlist, attributes, nodes, deletednodes) #:doc:
def putway(renumberednodes, usertoken, changeset_id, wayversion, originalway, pointlist, attributes, nodes, deletednodes)
amf_handle_error("'putway' #{originalway}", "way", originalway) do
# -- Initialise
@ -679,7 +679,7 @@ class AmfController < ApplicationController
pointlist.collect! do |a|
renumberednodes[a] ? renumberednodes[a] : a
end # renumber nodes
end
new_way = Way.new
new_way.tags = attributes
new_way.nds = pointlist
@ -711,7 +711,7 @@ class AmfController < ApplicationController
# and we don't want to delete it
end
end
end # transaction
end
[0, "", originalway, way.id, renumberednodes, way.version, nodeversions, deletednodes]
end
@ -726,7 +726,7 @@ class AmfController < ApplicationController
# 3. new node id,
# 4. version.
def putpoi(usertoken, changeset_id, version, id, lon, lat, tags, visible) #:doc:
def putpoi(usertoken, changeset_id, version, id, lon, lat, tags, visible)
amf_handle_error("'putpoi' #{id}", "node", id) do
user = getuser(usertoken)
return -1, "You are not logged in, so the point could not be saved." unless user
@ -772,7 +772,7 @@ class AmfController < ApplicationController
new_node.id = id
node.delete_with_history!(new_node, user)
end
end # transaction
end
if id <= 0
return [0, "", id, new_node.id, new_node.version]
@ -787,7 +787,7 @@ class AmfController < ApplicationController
#
# Returns array of id, long, lat, hash of tags, (current) version.
def getpoi(id, timestamp) #:doc:
def getpoi(id, timestamp)
amf_handle_error("'getpoi' #{id}", "node", id) do
id = id.to_i
n = Node.where(:id => id).first
@ -816,7 +816,7 @@ class AmfController < ApplicationController
# of the nodes have been changed by someone else then, there is a problem!
# Returns 0 (success), unchanged way id, new way version, new node versions.
def deleteway(usertoken, changeset_id, way_id, way_version, deletednodes) #:doc:
def deleteway(usertoken, changeset_id, way_id, way_version, deletednodes)
amf_handle_error("'deleteway' #{way_id}", "way", way_id) do
user = getuser(usertoken)
return -1, "You are not logged in, so the way could not be deleted." unless user
@ -853,7 +853,7 @@ class AmfController < ApplicationController
# elsewhere and we don't want to delete it
end
end
end # transaction
end
[0, "", way_id, old_way.version, nodeversions]
end
end
@ -866,7 +866,7 @@ class AmfController < ApplicationController
# When we are writing to the api, we need the actual user model,
# not just the id, hence this abstraction
def getuser(token) #:doc:
def getuser(token)
if token =~ /^(.+)\:(.+)$/
User.authenticate(:username => Regexp.last_match(1), :password => Regexp.last_match(2))
else
@ -907,7 +907,7 @@ class AmfController < ApplicationController
# Alternative SQL queries for getway/whichways
def sql_find_ways_in_area(bbox)
sql = <<-EOF
sql = <<-SQL
SELECT DISTINCT current_ways.id AS wayid,current_ways.version AS version
FROM current_way_nodes
INNER JOIN current_nodes ON current_nodes.id=current_way_nodes.node_id
@ -915,20 +915,20 @@ class AmfController < ApplicationController
WHERE current_nodes.visible=TRUE
AND current_ways.visible=TRUE
AND #{OSM.sql_for_area(bbox, 'current_nodes.')}
EOF
SQL
ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["wayid"].to_i, a["version"].to_i] }
end
def sql_find_pois_in_area(bbox)
pois = []
sql = <<-EOF
sql = <<-SQL
SELECT current_nodes.id,current_nodes.latitude*0.0000001 AS lat,current_nodes.longitude*0.0000001 AS lon,current_nodes.version
FROM current_nodes
LEFT OUTER JOIN current_way_nodes cwn ON cwn.node_id=current_nodes.id
WHERE current_nodes.visible=TRUE
AND cwn.id IS NULL
AND #{OSM.sql_for_area(bbox, 'current_nodes.')}
EOF
SQL
ActiveRecord::Base.connection.select_all(sql).each do |row|
poitags = {}
ActiveRecord::Base.connection.select_all("SELECT k,v FROM current_node_tags WHERE id=#{row['id']}").each do |n|
@ -942,36 +942,36 @@ class AmfController < ApplicationController
def sql_find_relations_in_area_and_ways(bbox, way_ids)
# ** It would be more Potlatchy to get relations for nodes within ways
# during 'getway', not here
sql = <<-EOF
sql = <<-SQL
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
INNER JOIN current_nodes cn ON crm.member_id=cn.id AND crm.member_type='Node'
WHERE #{OSM.sql_for_area(bbox, 'cn.')}
EOF
SQL
unless way_ids.empty?
sql += <<-EOF
sql += <<-SQL
UNION
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
WHERE crm.member_type='Way'
AND crm.member_id IN (#{way_ids.join(',')})
EOF
SQL
end
ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] }
end
def sql_get_nodes_in_way(wayid)
points = []
sql = <<-EOF
sql = <<-SQL
SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,current_nodes.id,current_nodes.version
FROM current_way_nodes,current_nodes
WHERE current_way_nodes.id=#{wayid.to_i}
AND current_way_nodes.node_id=current_nodes.id
AND current_nodes.visible=TRUE
ORDER BY sequence_id
EOF
SQL
ActiveRecord::Base.connection.select_all(sql).each do |row|
nodetags = {}
ActiveRecord::Base.connection.select_all("SELECT k,v FROM current_node_tags WHERE id=#{row['id']}").each do |n|

View file

@ -193,7 +193,7 @@ class ApiController < ApplicationController
# this "uniq" may be slightly inefficient; it may be better to first collect and output
# all node-related relations, then find the *not yet covered* way-related ones etc.
relations.uniq.each do |relation|
doc.root << relation.to_xml_node(nil, changeset_cache, user_display_name_cache)
doc.root << relation.to_xml_node(changeset_cache, user_display_name_cache)
end
response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""

View file

@ -346,7 +346,7 @@ class ApplicationController < ActionController::Base
# or raises a suitable error. +method+ should be a symbol, e.g: :put or :get.
def assert_method(method)
ok = request.send((method.to_s.downcase + "?").to_sym)
raise OSM::APIBadMethodError.new(method) unless ok
raise OSM::APIBadMethodError, method unless ok
end
##
@ -366,7 +366,7 @@ class ApplicationController < ActionController::Base
yield
end
rescue ActionView::Template::Error => ex
ex = ex.original_exception
ex = ex.cause
if ex.is_a?(Timeout::Error) ||
(ex.is_a?(ActiveRecord::StatementInvalid) && ex.message =~ /execution expired/)
@ -413,7 +413,9 @@ class ApplicationController < ActionController::Base
def map_layout
append_content_security_policy_directives(
:child_src => %w[127.0.0.1:8111 127.0.0.1:8112],
:connect_src => %w[nominatim.openstreetmap.org overpass-api.de router.project-osrm.org valhalla.mapzen.com],
:form_action => %w[render.openstreetmap.org],
:script_src => %w[graphhopper.com open.mapquestapi.com],
:img_src => %w[developer.mapquest.com]
)
@ -427,6 +429,10 @@ class ApplicationController < ActionController::Base
request.xhr? ? "xhr" : "map"
end
def allow_thirdparty_images
append_content_security_policy_directives(:img_src => %w[*])
end
def preferred_editor
editor = if params[:editor]
params[:editor]

View file

@ -28,7 +28,7 @@ class ChangesetController < ApplicationController
cs = Changeset.from_xml(request.raw_post, true)
# Assume that Changeset.from_xml has thrown an exception if there is an error parsing the xml
cs.user_id = current_user.id
cs.user = current_user
cs.save_with_tags!
# Subscribe user to changeset comments
@ -310,8 +310,8 @@ class ChangesetController < ApplicationController
# Add a comment to a changeset
def comment
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
id = params[:id].to_i
@ -319,7 +319,7 @@ class ChangesetController < ApplicationController
# Find the changeset and check it is valid
changeset = Changeset.find(id)
raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
# Add a comment to the changeset
comment = changeset.comments.create(:changeset => changeset,
@ -344,15 +344,15 @@ class ChangesetController < ApplicationController
# Adds a subscriber to the changeset
def subscribe
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Find the changeset and check it is valid
changeset = Changeset.find(id)
raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
raise OSM::APIChangesetAlreadySubscribedError.new(changeset) if changeset.subscribers.exists?(current_user.id)
raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
raise OSM::APIChangesetAlreadySubscribedError, changeset if changeset.subscribers.exists?(current_user.id)
# Add the subscriber
changeset.subscribers << current_user
@ -365,15 +365,15 @@ class ChangesetController < ApplicationController
# Removes a subscriber from the changeset
def unsubscribe
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Find the changeset and check it is valid
changeset = Changeset.find(id)
raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
raise OSM::APIChangesetNotSubscribedError.new(changeset) unless changeset.subscribers.exists?(current_user.id)
raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
raise OSM::APIChangesetNotSubscribedError, changeset unless changeset.subscribers.exists?(current_user.id)
# Remove the subscriber
changeset.subscribers.delete(current_user)
@ -386,7 +386,7 @@ class ChangesetController < ApplicationController
# Sets visible flag on comment to false
def hide_comment
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@ -405,7 +405,7 @@ class ChangesetController < ApplicationController
# Sets visible flag on comment to true
def unhide_comment
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@ -434,7 +434,7 @@ class ChangesetController < ApplicationController
@comments = changeset.comments.includes(:author, :changeset).limit(comments_limit)
else
# Return comments
@comments = ChangesetComment.includes(:author, :changeset).where(:visible => :true).order("created_at DESC").limit(comments_limit).preload(:changeset)
@comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC").limit(comments_limit).preload(:changeset)
end
# Render the result
@ -475,19 +475,19 @@ class ChangesetController < ApplicationController
changesets
else
# shouldn't provide both name and UID
raise OSM::APIBadUserInput.new("provide either the user ID or display name, but not both") if user && name
raise OSM::APIBadUserInput, "provide either the user ID or display name, but not both" if user && name
# use either the name or the UID to find the user which we're selecting on.
u = if name.nil?
# user input checking, we don't have any UIDs < 1
raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
raise OSM::APIBadUserInput, "invalid user ID" if user.to_i < 1
u = User.find(user.to_i)
else
u = User.find_by(:display_name => name)
end
# make sure we found a user
raise OSM::APINotFoundError.new if u.nil?
raise OSM::APINotFoundError if u.nil?
# should be able to get changesets of public users only, or
# our own changesets regardless of public-ness.
@ -496,7 +496,7 @@ class ChangesetController < ApplicationController
# changesets if they're non-public
setup_user_auth
raise OSM::APINotFoundError if current_user.nil? || current_user.id != u.id
raise OSM::APINotFoundError if current_user.nil? || current_user != u
end
changesets.where(:user_id => u.id)
@ -514,20 +514,20 @@ class ChangesetController < ApplicationController
# check that we actually have 2 elements in the array
times = time.split(/,/)
raise OSM::APIBadUserInput.new("bad time range") if times.size != 2
raise OSM::APIBadUserInput, "bad time range" if times.size != 2
from, to = times.collect { |t| DateTime.parse(t) }
from, to = times.collect { |t| Time.parse(t) }
return changesets.where("closed_at >= ? and created_at <= ?", from, to)
else
# if there is no comma, assume its a lower limit on time
return changesets.where("closed_at >= ?", DateTime.parse(time))
return changesets.where("closed_at >= ?", Time.parse(time))
end
# stupid DateTime seems to throw both of these for bad parsing, so
# stupid Time seems to throw both of these for bad parsing, so
# we have to catch both and ensure the correct code path is taken.
rescue ArgumentError => ex
raise OSM::APIBadUserInput.new(ex.message.to_s)
raise OSM::APIBadUserInput, ex.message.to_s
rescue RuntimeError => ex
raise OSM::APIBadUserInput.new(ex.message.to_s)
raise OSM::APIBadUserInput, ex.message.to_s
end
##
@ -563,7 +563,7 @@ class ChangesetController < ApplicationController
if ids.nil?
changesets
elsif ids.empty?
raise OSM::APIBadUserInput.new("No changesets were given to search for")
raise OSM::APIBadUserInput, "No changesets were given to search for"
else
ids = ids.split(",").collect(&:to_i)
changesets.where(:id => ids)
@ -584,7 +584,7 @@ class ChangesetController < ApplicationController
if params[:limit].to_i > 0 && params[:limit].to_i <= 10000
params[:limit].to_i
else
raise OSM::APIBadUserInput.new("Comments limit must be between 1 and 10000")
raise OSM::APIBadUserInput, "Comments limit must be between 1 and 10000"
end
else
100

View file

@ -8,6 +8,7 @@ class DiaryEntryController < ApplicationController
before_action :check_database_readable
before_action :check_database_writable, :only => [:new, :edit, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
before_action :require_administrator, :only => [:hide, :hidecomment]
before_action :allow_thirdparty_images, :only => [:new, :edit, :list, :view, :comments]
def new
@title = t "diary_entry.new.title"

View file

@ -1,5 +1,3 @@
# coding: utf-8
class GeocoderController < ApplicationController
require "cgi"
require "uri"
@ -19,7 +17,6 @@ class GeocoderController < ApplicationController
@sources.push "geonames_reverse" if defined?(GEONAMES_USERNAME)
elsif @params[:query]
if @params[:query] =~ /^\d{5}(-\d{4})?$/
@sources.push "us_postcode"
@sources.push "osm_nominatim"
elsif @params[:query] =~ /^(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])\s*[0-9][ABD-HJLNP-UW-Z]{2})$/i
@sources.push "uk_postcode"
@ -58,31 +55,6 @@ class GeocoderController < ApplicationController
end
end
def search_us_postcode
# get query parameters
query = params[:query]
# create result array
@results = []
# ask geocoder.us (they have a non-commercial use api)
response = fetch_text("http://rpc.geocoder.us/service/csv?zip=#{escape_query(query)}")
# parse the response
unless response =~ /couldn't find this zip/
data = response.split(/\s*,\s+/) # lat,long,town,state,zip
@results.push(:lat => data[0], :lon => data[1],
:zoom => POSTCODE_ZOOM,
:prefix => "#{data[2]}, #{data[3]},",
:name => data[4])
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting rpc.geocoder.us: #{ex}"
render :action => "error"
end
def search_uk_postcode
# get query parameters
query = params[:query]
@ -313,7 +285,7 @@ class GeocoderController < ApplicationController
end
def escape_query(query)
URI.escape(query, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]", false, "N"))
CGI.escape(query)
end
def normalize_params
@ -348,7 +320,7 @@ class GeocoderController < ApplicationController
Float(captures[0])
lat = !captures[2].casecmp("s").zero? ? captures[0].to_f : -captures[0].to_f
lon = !captures[5].casecmp("w").zero? ? captures[3].to_f : -captures[3].to_f
rescue
rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f : -captures[1].to_f
lon = !captures[3].casecmp("w").zero? ? captures[4].to_f : -captures[4].to_f
end
@ -360,7 +332,7 @@ class GeocoderController < ApplicationController
Float(captures[0])
lat = !captures[3].casecmp("s").zero? ? captures[0].to_f + captures[1].to_f / 60 : -(captures[0].to_f + captures[1].to_f / 60)
lon = !captures[7].casecmp("w").zero? ? captures[4].to_f + captures[5].to_f / 60 : -(captures[4].to_f + captures[5].to_f / 60)
rescue
rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f + captures[2].to_f / 60 : -(captures[1].to_f + captures[2].to_f / 60)
lon = !captures[4].casecmp("w").zero? ? captures[5].to_f + captures[6].to_f / 60 : -(captures[5].to_f + captures[6].to_f / 60)
end
@ -372,7 +344,7 @@ class GeocoderController < ApplicationController
Float(captures[0])
lat = !captures[4].casecmp("s").zero? ? captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60 : -(captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60)
lon = !captures[9].casecmp("w").zero? ? captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60 : -(captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60)
rescue
rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60 : -(captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60)
lon = !captures[5].casecmp("w").zero? ? captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60 : -(captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60)
end

View file

@ -7,6 +7,7 @@ class MessageController < ApplicationController
before_action :lookup_this_user, :only => [:new]
before_action :check_database_readable
before_action :check_database_writable, :only => [:new, :reply, :mark]
before_action :allow_thirdparty_images, :only => [:new, :read]
# Allow the user to write a new message to another user. This action also
# deals with the sending of that message to the other user when the user
@ -18,8 +19,8 @@ class MessageController < ApplicationController
flash[:error] = t "message.new.limit_exceeded"
else
@message = Message.new(message_params)
@message.to_user_id = @this_user.id
@message.from_user_id = current_user.id
@message.recipient = @this_user
@message.sender = current_user
@message.sent_on = Time.now.getutc
if @message.save
@ -38,7 +39,7 @@ class MessageController < ApplicationController
def reply
message = Message.find(params[:message_id])
if message.to_user_id == current_user.id
if message.recipient == current_user
message.update(:message_read => true)
@message = Message.new(
@ -64,8 +65,8 @@ class MessageController < ApplicationController
@title = t "message.read.title"
@message = Message.find(params[:message_id])
if @message.to_user_id == current_user.id || @message.from_user_id == current_user.id
@message.message_read = true if @message.to_user_id == current_user.id
if @message.recipient == current_user || @message.sender == current_user
@message.message_read = true if @message.recipient == current_user
@message.save
else
flash[:notice] = t "message.read.wrong_user", :user => current_user.display_name

View file

@ -41,7 +41,7 @@ class NodeController < ApplicationController
new_node = Node.from_xml(request.raw_post)
unless new_node && new_node.id == node.id
raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})"
end
node.update_from(new_node, current_user)
@ -56,7 +56,7 @@ class NodeController < ApplicationController
new_node = Node.from_xml(request.raw_post)
unless new_node && new_node.id == node.id
raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})"
end
node.delete_with_history!(new_node, current_user)
render :plain => node.version.to_s
@ -65,13 +65,13 @@ class NodeController < ApplicationController
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
def nodes
unless params["nodes"]
raise OSM::APIBadUserInput.new("The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]")
raise OSM::APIBadUserInput, "The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]"
end
ids = params["nodes"].split(",").collect(&:to_i)
if ids.empty?
raise OSM::APIBadUserInput.new("No nodes were given to search for")
raise OSM::APIBadUserInput, "No nodes were given to search for"
end
doc = OSM::API.new.get_xml_doc

View file

@ -20,10 +20,10 @@ class NotesController < ApplicationController
if params[:bbox]
bbox = BoundingBox.from_bbox_params(params)
else
raise OSM::APIBadUserInput.new("No l was given") unless params[:l]
raise OSM::APIBadUserInput.new("No r was given") unless params[:r]
raise OSM::APIBadUserInput.new("No b was given") unless params[:b]
raise OSM::APIBadUserInput.new("No t was given") unless params[:t]
raise OSM::APIBadUserInput, "No l was given" unless params[:l]
raise OSM::APIBadUserInput, "No r was given" unless params[:r]
raise OSM::APIBadUserInput, "No b was given" unless params[:b]
raise OSM::APIBadUserInput, "No t was given" unless params[:t]
bbox = BoundingBox.from_lrbt_params(params)
end
@ -56,9 +56,9 @@ class NotesController < ApplicationController
raise OSM::APIAccessDenied if Acl.no_note_comment(request.remote_ip)
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No lat was given") unless params[:lat]
raise OSM::APIBadUserInput.new("No lon was given") unless params[:lon]
raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
raise OSM::APIBadUserInput, "No lat was given" unless params[:lat]
raise OSM::APIBadUserInput, "No lon was given" unless params[:lon]
raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
lon = OSM.parse_float(params[:lon], OSM::APIBadUserInput, "lon was not a number")
@ -69,7 +69,7 @@ class NotesController < ApplicationController
Note.transaction do
# Create the note
@note = Note.create(:lat => lat, :lon => lon)
raise OSM::APIBadUserInput.new("The note is outside this world") unless @note.in_world?
raise OSM::APIBadUserInput, "The note is outside this world" unless @note.in_world?
# Save the note
@note.save!
@ -92,8 +92,8 @@ class NotesController < ApplicationController
raise OSM::APIAccessDenied if Acl.no_note_comment(request.remote_ip)
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
id = params[:id].to_i
@ -103,7 +103,7 @@ class NotesController < ApplicationController
@note = Note.find(id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
raise OSM::APINoteAlreadyClosedError, @note if @note.closed?
# Add a comment to the note
Note.transaction do
@ -121,7 +121,7 @@ class NotesController < ApplicationController
# Close a note
def close
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@ -131,7 +131,7 @@ class NotesController < ApplicationController
@note = Note.find_by(:id => id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
raise OSM::APINoteAlreadyClosedError, @note if @note.closed?
# Close the note and add a comment
Note.transaction do
@ -151,7 +151,7 @@ class NotesController < ApplicationController
# Reopen a note
def reopen
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@ -161,7 +161,7 @@ class NotesController < ApplicationController
@note = Note.find_by(:id => id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || current_user.moderator?
raise OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed? || !@note.visible?
raise OSM::APINoteAlreadyOpenError, @note unless @note.closed? || !@note.visible?
# Reopen the note and add a comment
Note.transaction do
@ -206,7 +206,7 @@ class NotesController < ApplicationController
# Read a note
def show
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Find the note and check it is valid
@note = Note.find(params[:id])
@ -226,7 +226,7 @@ class NotesController < ApplicationController
# Delete (hide) a note
def destroy
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@ -256,7 +256,7 @@ class NotesController < ApplicationController
# Return a list of notes matching a given string
def search
# Check the arguments are sane
raise OSM::APIBadUserInput.new("No query string was given") unless params[:q]
raise OSM::APIBadUserInput, "No query string was given" unless params[:q]
# Get any conditions that need to be applied
@notes = closed_condition(Note.all)
@ -310,7 +310,7 @@ class NotesController < ApplicationController
if params[:limit].to_i > 0 && params[:limit].to_i <= 10000
params[:limit].to_i
else
raise OSM::APIBadUserInput.new("Note limit must be between 1 and 10000")
raise OSM::APIBadUserInput, "Note limit must be between 1 and 10000"
end
else
100

View file

@ -38,6 +38,8 @@ class OauthController < ApplicationController
protected
def oauth1_authorize
append_content_security_policy_directives(:form_action => %w[*])
if @token.invalidated?
@message = t "oauth.oauthorize_failure.invalid"
render :action => "authorize_failure"

View file

@ -19,7 +19,7 @@ class OldController < ApplicationController
# the .where() method used in the lookup_old_element_versions
# call won't throw an error if no records are found, so we have
# to do that ourselves.
raise OSM::APINotFoundError.new if @elements.empty?
raise OSM::APINotFoundError if @elements.empty?
doc = OSM::API.new.get_xml_doc

View file

@ -36,7 +36,7 @@ class RelationController < ApplicationController
new_relation = Relation.from_xml(request.raw_post)
unless new_relation && new_relation.id == relation.id
raise OSM::APIBadUserInput.new("The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})")
raise OSM::APIBadUserInput, "The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})"
end
relation.update_from new_relation, current_user
@ -91,7 +91,6 @@ class RelationController < ApplicationController
# create XML.
doc = OSM::API.new.get_xml_doc
visible_nodes = {}
visible_members = { "Node" => {}, "Way" => {}, "Relation" => {} }
changeset_cache = {}
user_display_name_cache = {}
@ -100,25 +99,22 @@ class RelationController < ApplicationController
doc.root << node.to_xml_node(changeset_cache, user_display_name_cache)
visible_nodes[node.id] = node
visible_members["Node"][node.id] = true
end
ways.each do |way|
next unless way.visible? # should be unnecessary if data is consistent.
doc.root << way.to_xml_node(visible_nodes, changeset_cache, user_display_name_cache)
visible_members["Way"][way.id] = true
end
relations.each do |rel|
next unless rel.visible? # should be unnecessary if data is consistent.
doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
visible_members["Relation"][rel.id] = true
doc.root << rel.to_xml_node(changeset_cache, user_display_name_cache)
end
# finally add self and output
doc.root << relation.to_xml_node(visible_members, changeset_cache, user_display_name_cache)
doc.root << relation.to_xml_node(changeset_cache, user_display_name_cache)
render :xml => doc.to_s
else
@ -128,13 +124,13 @@ class RelationController < ApplicationController
def relations
unless params["relations"]
raise OSM::APIBadUserInput.new("The parameter relations is required, and must be of the form relations=id[,id[,id...]]")
raise OSM::APIBadUserInput, "The parameter relations is required, and must be of the form relations=id[,id[,id...]]"
end
ids = params["relations"].split(",").collect(&:to_i)
if ids.empty?
raise OSM::APIBadUserInput.new("No relations were given to search for")
raise OSM::APIBadUserInput, "No relations were given to search for"
end
doc = OSM::API.new.get_xml_doc

View file

@ -91,7 +91,7 @@ class SearchController < ApplicationController
end
relations.each do |rel|
doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
doc.root << rel.to_xml_node(changeset_cache, user_display_name_cache)
end
render :xml => doc.to_s

View file

@ -120,9 +120,9 @@ class SiteController < ApplicationController
def id
append_content_security_policy_directives(
:connect_src => %w[taginfo.openstreetmap.org *.mapillary.com],
:img_src => %w[*],
:script_src => %w[dev.virtualearth.net]
:connect_src => %w[*],
:img_src => %w[* blob:],
:script_src => %w[dev.virtualearth.net 'unsafe-eval']
)
render "id", :layout => false

View file

@ -112,7 +112,7 @@ class TraceController < ApplicationController
begin
do_create(params[:trace][:gpx_file], params[:trace][:tagstring],
params[:trace][:description], params[:trace][:visibility])
rescue => ex
rescue StandardError => ex
logger.debug ex
end
@ -149,9 +149,9 @@ class TraceController < ApplicationController
if Acl.no_trace_download(request.remote_ip)
head :forbidden
elsif request.format == Mime[:xml]
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
send_data(trace.xml_file.read, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
elsif request.format == Mime[:gpx]
send_file(trace.xml_file, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
send_data(trace.xml_file.read, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
else
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
end
@ -263,15 +263,7 @@ class TraceController < ApplicationController
trace = Trace.visible.find(params[:id])
if trace.user == current_user
new_trace = Trace.from_xml(request.raw_post)
unless new_trace && new_trace.id == trace.id
raise OSM::APIBadUserInput.new("The id in the url (#{trace.id}) is not the same as provided in the xml (#{new_trace.id})")
end
trace.description = new_trace.description
trace.tags = new_trace.tags
trace.visibility = new_trace.visibility
trace.update_from_xml(request.raw_post)
trace.save!
head :ok
@ -298,9 +290,9 @@ class TraceController < ApplicationController
if trace.public? || trace.user == current_user
if request.format == Mime[:xml]
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
send_data(trace.xml_file.read, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
elsif request.format == Mime[:gpx]
send_file(trace.xml_file, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
send_data(trace.xml_file.read, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
else
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
end

View file

@ -20,7 +20,7 @@ class UserBlocksController < ApplicationController
end
def show
if current_user && current_user.id == @user_block.user_id
if current_user && current_user == @user_block.user
@user_block.needs_view = false
@user_block.save!
end
@ -37,8 +37,8 @@ class UserBlocksController < ApplicationController
def create
if @valid_params
@user_block = UserBlock.new(
:user_id => @this_user.id,
:creator_id => current_user.id,
:user => @this_user,
:creator => current_user,
:reason => params[:user_block][:reason],
:ends_at => Time.now.getutc + @block_period.hours,
:needs_view => params[:user_block][:needs_view]
@ -57,7 +57,7 @@ class UserBlocksController < ApplicationController
def update
if @valid_params
if @user_block.creator_id != current_user.id
if @user_block.creator != current_user
flash[:error] = t("user_block.update.only_creator_can_edit")
redirect_to :action => "edit"
elsif @user_block.update_attributes(

View file

@ -18,6 +18,7 @@ class UserController < ApplicationController
around_action :api_call_handle_error, :only => [:api_read, :api_details, :api_gpx_files]
before_action :lookup_user_by_id, :only => [:api_read]
before_action :lookup_user_by_name, :only => [:set_status, :delete]
before_action :allow_thirdparty_images, :only => [:view, :account]
def terms
@legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || DEFAULT_LEGALE
@ -99,7 +100,7 @@ class UserController < ApplicationController
"lat" => m[2],
"lon" => m[3] }.merge(editor))
end
rescue
rescue StandardError
# Use default
end
@ -202,6 +203,10 @@ class UserController < ApplicationController
@title = t "user.new.title"
@referer = params[:referer] || session[:referer]
append_content_security_policy_directives(
:form_action => %w[accounts.google.com *.facebook.com login.live.com github.com meta.wikimedia.org]
)
if current_user
# The user is logged in already, so don't show them the signup
# page, instead send them to the home page
@ -411,8 +416,8 @@ class UserController < ApplicationController
if @new_friend
if request.post?
friend = Friend.new
friend.user_id = current_user.id
friend.friend_user_id = @new_friend.id
friend.befriender = current_user
friend.befriendee = @new_friend
if current_user.is_friends_with?(@new_friend)
flash[:warning] = t "user.make_friend.already_a_friend", :name => @new_friend.display_name
elsif friend.save
@ -723,7 +728,7 @@ class UserController < ApplicationController
begin
Notifier.email_confirm(user, user.tokens.create).deliver_now
rescue
rescue StandardError
# Ignore errors sending email
end
else

View file

@ -45,7 +45,7 @@ class UserPreferenceController < ApplicationController
if preference = old_preferences.delete(pt["k"])
preference.v = pt["v"]
elsif new_preferences.include?(pt["k"])
raise OSM::APIDuplicatePreferenceError.new(pt["k"])
raise OSM::APIDuplicatePreferenceError, pt["k"]
else
preference = current_user.preferences.build(:k => pt["k"], :v => pt["v"])
end

View file

@ -10,7 +10,7 @@ class UserRolesController < ApplicationController
before_action :in_role, :only => [:revoke]
def grant
@this_user.roles.create(:role => @role, :granter_id => current_user.id)
@this_user.roles.create(:role => @role, :granter => current_user)
redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name
end

View file

@ -36,7 +36,7 @@ class WayController < ApplicationController
new_way = Way.from_xml(request.raw_post)
unless new_way && new_way.id == way.id
raise OSM::APIBadUserInput.new("The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})")
raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})"
end
way.update_from(new_way, current_user)
@ -81,14 +81,12 @@ class WayController < ApplicationController
def ways
unless params["ways"]
raise OSM::APIBadUserInput.new("The parameter ways is required, and must be of the form ways=id[,id[,id...]]")
raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]"
end
ids = params["ways"].split(",").collect(&:to_i)
if ids.empty?
raise OSM::APIBadUserInput.new("No ways were given to search for")
end
raise OSM::APIBadUserInput, "No ways were given to search for" if ids.empty?
doc = OSM::API.new.get_xml_doc

View file

@ -3,9 +3,9 @@ module ApplicationHelper
def linkify(text)
if text.html_safe?
Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow")).html_safe
Rinku.auto_link(text, :urls, tag_builder.tag_options(:rel => "nofollow")).html_safe
else
Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow"))
Rinku.auto_link(text, :urls, tag_builder.tag_options(:rel => "nofollow"))
end
end

View file

@ -4,7 +4,7 @@ module BannerHelper
enddate = v[:enddate]
begin
parsed = enddate && Date.parse(enddate)
rescue
rescue StandardError
parsed = nil
end
!parsed.is_a?(Date) || (parsed.is_a?(Date) && parsed.past?)

View file

@ -1,4 +1,4 @@
require "uri"
require "cgi"
module BrowseHelper
def printable_name(object, version = false)
@ -114,9 +114,9 @@ module BrowseHelper
# the correct page.
lookup_us = lookup.tr(" ", "_")
if page = WIKI_PAGES[locale][type][lookup_us] rescue nil
if page = WIKI_PAGES.dig(locale, type, lookup_us)
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil
elsif page = WIKI_PAGES.dig("en", type, lookup_us)
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
end
@ -151,7 +151,7 @@ module BrowseHelper
# Must break it up to correctly build the url
value = Regexp.last_match(1)
section = "#" + Regexp.last_match(2)
encoded_section = "#" + URI.encode(Regexp.last_match(2).gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).tr("%", ".")
encoded_section = "#" + CGI.escape(Regexp.last_match(2).gsub(/ +/, "_")).tr("%", ".")
else
section = ""
encoded_section = ""

View file

@ -10,7 +10,7 @@ module ChangesetHelper
end
def changeset_details(changeset)
if changeset.closed_at > DateTime.now
if changeset.closed_at > Time.now
action = :created
time = distance_of_time_in_words_to_now(changeset.created_at)
title = l(changeset.created_at)

View file

@ -2,7 +2,7 @@ module OpenGraphHelper
def opengraph_tags(title = nil)
tags = {
"og:site_name" => t("layouts.project_name.title"),
"og:title" => [t("layouts.project_name.title"), title].compact.join(" | "),
"og:title" => [title, t("layouts.project_name.title")].compact.join(" | "),
"og:type" => "website",
"og:image" => image_url("osm_logo_256.png", :protocol => "http"),
"og:image:secure_url" => image_url("osm_logo_256.png", :protocol => "https"),

View file

@ -8,10 +8,10 @@ module TitleHelper
def set_title(title = nil)
if title
@title = TitleHelper.coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title)
response.headers["X-Page-Title"] = ERB::Util.u(@title + " | " + t("layouts.project_name.title"))
else
@title = title
response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title"))
response.headers["X-Page-Title"] = ERB::Util.u(t("layouts.project_name.title"))
end
end
end

View file

@ -1,3 +1,40 @@
# == Schema Information
#
# Table name: oauth_tokens
#
# id :integer not null, primary key
# user_id :integer
# type :string(20)
# client_application_id :integer
# token :string(50)
# secret :string(50)
# authorized_at :datetime
# invalidated_at :datetime
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# callback_url :string
# verifier :string(20)
# scope :string
# valid_to :datetime
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_oauth_tokens_on_token (token) UNIQUE
# index_oauth_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# oauth_tokens_client_application_id_fkey (client_application_id => client_applications.id)
# oauth_tokens_user_id_fkey (user_id => users.id)
#
class AccessToken < OauthToken
belongs_to :user
belongs_to :client_application

View file

@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: acls
#
# id :integer not null, primary key
# address :inet
# k :string not null
# v :string
# domain :string
#
# Indexes
#
# acls_k_idx (k)
#
class Acl < ActiveRecord::Base
validates :k, :presence => true

View file

@ -1,3 +1,30 @@
# == Schema Information
#
# Table name: changesets
#
# id :integer not null, primary key
# user_id :integer not null
# created_at :datetime not null
# min_lat :integer
# max_lat :integer
# min_lon :integer
# max_lon :integer
# closed_at :datetime not null
# num_changes :integer default(0), not null
#
# Indexes
#
# changesets_bbox_idx (min_lat,max_lat,min_lon,max_lon)
# changesets_closed_at_idx (closed_at)
# changesets_created_at_idx (created_at)
# changesets_user_id_created_at_idx (user_id,created_at)
# changesets_user_id_id_idx (user_id,id)
#
# Foreign Keys
#
# changesets_user_id_fkey (user_id => users.id)
#
class Changeset < ActiveRecord::Base
require "xml/libxml"
@ -133,7 +160,7 @@ class Changeset < ActiveRecord::Base
attr_writer :tags
def add_tag_keyval(k, v)
@tags = {} unless @tags
@tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
@ -241,10 +268,10 @@ class Changeset < ActiveRecord::Base
# bounding box, only the tags of the changeset.
def update_from(other, user)
# ensure that only the user who opened the changeset may modify it.
raise OSM::APIUserChangesetMismatchError.new unless user.id == user_id
raise OSM::APIUserChangesetMismatchError unless user.id == user_id
# can't change a closed changeset
raise OSM::APIChangesetAlreadyClosedError.new(self) unless is_open?
raise OSM::APIChangesetAlreadyClosedError, self unless is_open?
# copy the other's tags
self.tags = other.tags

View file

@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: changeset_comments
#
# id :integer not null, primary key
# changeset_id :integer not null
# author_id :integer not null
# body :text not null
# created_at :datetime not null
# visible :boolean not null
#
# Indexes
#
# index_changeset_comments_on_created_at (created_at)
#
# Foreign Keys
#
# changeset_comments_author_id_fkey (author_id => users.id)
# changeset_comments_changeset_id_fkey (changeset_id => changesets.id)
#
class ChangesetComment < ActiveRecord::Base
belongs_to :changeset
belongs_to :author, :class_name => "User"

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: changeset_tags
#
# changeset_id :integer not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
#
# Indexes
#
# changeset_tags_id_idx (changeset_id)
#
# Foreign Keys
#
# changeset_tags_id_fkey (changeset_id => changesets.id)
#
class ChangesetTag < ActiveRecord::Base
self.primary_keys = "changeset_id", "k"

View file

@ -1,3 +1,35 @@
# == Schema Information
#
# Table name: client_applications
#
# id :integer not null, primary key
# name :string
# url :string
# support_url :string
# callback_url :string
# key :string(50)
# secret :string(50)
# user_id :integer
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_client_applications_on_key (key) UNIQUE
# index_client_applications_on_user_id (user_id)
#
# Foreign Keys
#
# client_applications_user_id_fkey (user_id => users.id)
#
require "oauth"
class ClientApplication < ActiveRecord::Base
@ -43,7 +75,7 @@ class ClientApplication < ActiveRecord::Base
@oauth_client ||= OAuth::Consumer.new(key, secret)
end
def create_request_token(params = {})
def create_request_token(_params = {})
params = { :client_application => self, :callback_url => token_callback_url }
permissions.each do |p|
params[p] = true

View file

@ -1,3 +1,27 @@
# == Schema Information
#
# Table name: diary_comments
#
# id :integer not null, primary key
# diary_entry_id :integer not null
# user_id :integer not null
# body :text not null
# created_at :datetime not null
# updated_at :datetime not null
# visible :boolean default(TRUE), not null
# body_format :enum default("markdown"), not null
#
# Indexes
#
# diary_comment_user_id_created_at_index (user_id,created_at)
# diary_comments_entry_id_idx (diary_entry_id,id) UNIQUE
#
# Foreign Keys
#
# diary_comments_diary_entry_id_fkey (diary_entry_id => diary_entries.id)
# diary_comments_user_id_fkey (user_id => users.id)
#
class DiaryComment < ActiveRecord::Base
belongs_to :user
belongs_to :diary_entry

View file

@ -1,3 +1,31 @@
# == Schema Information
#
# Table name: diary_entries
#
# id :integer not null, primary key
# user_id :integer not null
# title :string not null
# body :text not null
# created_at :datetime not null
# updated_at :datetime not null
# latitude :float
# longitude :float
# language_code :string default("en"), not null
# visible :boolean default(TRUE), not null
# body_format :enum default("markdown"), not null
#
# Indexes
#
# diary_entry_created_at_index (created_at)
# diary_entry_language_code_created_at_index (language_code,created_at)
# diary_entry_user_id_created_at_index (user_id,created_at)
#
# Foreign Keys
#
# diary_entries_language_code_fkey (language_code => languages.code)
# diary_entries_user_id_fkey (user_id => users.id)
#
class DiaryEntry < ActiveRecord::Base
belongs_to :user, :counter_cache => true
belongs_to :language, :foreign_key => "language_code"

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: diary_entry_subscriptions
#
# user_id :integer not null, primary key
# diary_entry_id :integer not null, primary key
#
# Indexes
#
# index_diary_entry_subscriptions_on_diary_entry_id (diary_entry_id)
#
# Foreign Keys
#
# diary_entry_subscriptions_diary_entry_id_fkey (diary_entry_id => diary_entries.id)
# diary_entry_subscriptions_user_id_fkey (user_id => users.id)
#
class DiaryEntrySubscription < ActiveRecord::Base
self.primary_keys = "user_id", "diary_entry_id"

View file

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: friends
#
# id :integer not null, primary key
# user_id :integer not null
# friend_user_id :integer not null
#
# Indexes
#
# friends_user_id_idx (user_id)
# user_id_idx (friend_user_id)
#
# Foreign Keys
#
# friends_friend_user_id_fkey (friend_user_id => users.id)
# friends_user_id_fkey (user_id => users.id)
#
class Friend < ActiveRecord::Base
belongs_to :befriender, :class_name => "User", :foreign_key => :user_id
belongs_to :befriendee, :class_name => "User", :foreign_key => :friend_user_id

View file

@ -1,3 +1,12 @@
# == Schema Information
#
# Table name: languages
#
# code :string not null, primary key
# english_name :string not null
# native_name :string
#
class Language < ActiveRecord::Base
self.primary_key = "code"

View file

@ -1,3 +1,29 @@
# == Schema Information
#
# Table name: messages
#
# id :integer not null, primary key
# from_user_id :integer not null
# title :string not null
# body :text not null
# sent_on :datetime not null
# message_read :boolean default(FALSE), not null
# to_user_id :integer not null
# to_user_visible :boolean default(TRUE), not null
# from_user_visible :boolean default(TRUE), not null
# body_format :enum default("markdown"), not null
#
# Indexes
#
# messages_from_user_id_idx (from_user_id)
# messages_to_user_id_idx (to_user_id)
#
# Foreign Keys
#
# messages_from_user_id_fkey (from_user_id => users.id)
# messages_to_user_id_fkey (to_user_id => users.id)
#
require "validators"
class Message < ActiveRecord::Base

View file

@ -1,3 +1,26 @@
# == Schema Information
#
# Table name: current_nodes
#
# id :integer not null, primary key
# latitude :integer not null
# longitude :integer not null
# changeset_id :integer not null
# visible :boolean not null
# timestamp :datetime not null
# tile :integer not null
# version :integer not null
#
# Indexes
#
# current_nodes_tile_idx (tile)
# current_nodes_timestamp_idx (timestamp)
#
# Foreign Keys
#
# current_nodes_changeset_id_fkey (changeset_id => changesets.id)
#
class Node < ActiveRecord::Base
require "xml/libxml"
@ -70,7 +93,7 @@ class Node < ActiveRecord::Base
raise OSM::APIBadXMLError.new("node", pt, "Changeset id is missing") if pt["changeset"].nil?
node.changeset_id = pt["changeset"].to_i
raise OSM::APIBadUserInput.new("The node is outside this world") unless node.in_world?
raise OSM::APIBadUserInput, "The node is outside this world" unless node.in_world?
# version must be present unless creating
raise OSM::APIBadXMLError.new("node", pt, "Version is required when updating") unless create || !pt["version"].nil?
@ -81,7 +104,7 @@ class Node < ActiveRecord::Base
node.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of node cannot be zero when updating.") if node.id.zero?
raise OSM::APIBadUserInput, "ID of node cannot be zero when updating." if node.id.zero?
end
# We don't care about the time, as it is explicitly set on create/update/delete
@ -120,10 +143,10 @@ class Node < ActiveRecord::Base
lock!
check_consistency(self, new_node, user)
ways = Way.joins(:way_nodes).where(:visible => true, :current_way_nodes => { :node_id => id }).order(:id)
raise OSM::APIPreconditionFailedError.new("Node #{id} is still used by ways #{ways.collect(&:id).join(',')}.") unless ways.empty?
raise OSM::APIPreconditionFailedError, "Node #{id} is still used by ways #{ways.collect(&:id).join(',')}." unless ways.empty?
rels = Relation.joins(:relation_members).where(:visible => true, :current_relation_members => { :member_type => "Node", :member_id => id }).order(:id)
raise OSM::APIPreconditionFailedError.new("Node #{id} is still used by relations #{rels.collect(&:id).join(',')}.") unless rels.empty?
raise OSM::APIPreconditionFailedError, "Node #{id} is still used by relations #{rels.collect(&:id).join(',')}." unless rels.empty?
self.changeset_id = new_node.changeset_id
self.tags = {}
@ -205,7 +228,7 @@ class Node < ActiveRecord::Base
attr_writer :tags
def add_tag_key_val(k, v)
@tags = {} unless @tags
@tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: current_node_tags
#
# node_id :integer not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
#
# Foreign Keys
#
# current_node_tags_id_fkey (node_id => current_nodes.id)
#
class NodeTag < ActiveRecord::Base
self.table_name = "current_node_tags"
self.primary_keys = "node_id", "k"

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: notes
#
# id :integer not null, primary key
# latitude :integer not null
# longitude :integer not null
# tile :integer not null
# updated_at :datetime not null
# created_at :datetime not null
# status :enum not null
# closed_at :datetime
#
# Indexes
#
# notes_created_at_idx (created_at)
# notes_tile_status_idx (tile,status)
# notes_updated_at_idx (updated_at)
#
class Note < ActiveRecord::Base
include GeoRecord

View file

@ -1,3 +1,28 @@
# == Schema Information
#
# Table name: note_comments
#
# id :integer not null, primary key
# note_id :integer not null
# visible :boolean not null
# created_at :datetime not null
# author_ip :inet
# author_id :integer
# body :text
# event :enum
#
# Indexes
#
# index_note_comments_on_body (to_tsvector('english'::regconfig, body))
# index_note_comments_on_created_at (created_at)
# note_comments_note_id_idx (note_id)
#
# Foreign Keys
#
# note_comments_author_id_fkey (author_id => users.id)
# note_comments_note_id_fkey (note_id => notes.id)
#
class NoteComment < ActiveRecord::Base
belongs_to :note, :foreign_key => :note_id, :touch => true
belongs_to :author, :class_name => "User", :foreign_key => :author_id

View file

@ -1,3 +1,40 @@
# == Schema Information
#
# Table name: oauth_tokens
#
# id :integer not null, primary key
# user_id :integer
# type :string(20)
# client_application_id :integer
# token :string(50)
# secret :string(50)
# authorized_at :datetime
# invalidated_at :datetime
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# callback_url :string
# verifier :string(20)
# scope :string
# valid_to :datetime
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_oauth_tokens_on_token (token) UNIQUE
# index_oauth_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# oauth_tokens_client_application_id_fkey (client_application_id => client_applications.id)
# oauth_tokens_user_id_fkey (user_id => users.id)
#
class Oauth2Token < AccessToken
attr_accessor :state
@ -9,9 +46,9 @@ class Oauth2Token < AccessToken
def to_query
q = "access_token=#{token}&token_type=bearer"
q << "&state=#{URI.escape(state)}" if @state
q << "&state=#{CGI.escape(state)}" if @state
q << "&expires_in=#{expires_in}" if expires_at
q << "&scope=#{URI.escape(scope)}" if scope
q << "&scope=#{CGI.escape(scope)}" if scope
q
end

View file

@ -1,3 +1,40 @@
# == Schema Information
#
# Table name: oauth_tokens
#
# id :integer not null, primary key
# user_id :integer
# type :string(20)
# client_application_id :integer
# token :string(50)
# secret :string(50)
# authorized_at :datetime
# invalidated_at :datetime
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# callback_url :string
# verifier :string(20)
# scope :string
# valid_to :datetime
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_oauth_tokens_on_token (token) UNIQUE
# index_oauth_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# oauth_tokens_client_application_id_fkey (client_application_id => client_applications.id)
# oauth_tokens_user_id_fkey (user_id => users.id)
#
class Oauth2Verifier < OauthToken
validates :user, :presence => true, :associated => true
@ -21,7 +58,7 @@ class Oauth2Verifier < OauthToken
def to_query
q = "code=#{token}"
q << "&state=#{URI.escape(state)}" if @state
q << "&state=#{CGI.escape(state)}" if @state
q
end

View file

@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: oauth_nonces
#
# id :integer not null, primary key
# nonce :string
# timestamp :integer
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_oauth_nonces_on_nonce_and_timestamp (nonce,timestamp) UNIQUE
#
# Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
# Thus you can use the same nonce with a different timestamp and viceversa.
class OauthNonce < ActiveRecord::Base

View file

@ -1,3 +1,40 @@
# == Schema Information
#
# Table name: oauth_tokens
#
# id :integer not null, primary key
# user_id :integer
# type :string(20)
# client_application_id :integer
# token :string(50)
# secret :string(50)
# authorized_at :datetime
# invalidated_at :datetime
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# callback_url :string
# verifier :string(20)
# scope :string
# valid_to :datetime
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_oauth_tokens_on_token (token) UNIQUE
# index_oauth_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# oauth_tokens_client_application_id_fkey (client_application_id => client_applications.id)
# oauth_tokens_user_id_fkey (user_id => users.id)
#
class OauthToken < ActiveRecord::Base
belongs_to :client_application
belongs_to :user

View file

@ -1,3 +1,29 @@
# == Schema Information
#
# Table name: nodes
#
# node_id :integer not null, primary key
# latitude :integer not null
# longitude :integer not null
# changeset_id :integer not null
# visible :boolean not null
# timestamp :datetime not null
# tile :integer not null
# version :integer not null, primary key
# redaction_id :integer
#
# Indexes
#
# nodes_changeset_id_idx (changeset_id)
# nodes_tile_idx (tile)
# nodes_timestamp_idx (timestamp)
#
# Foreign Keys
#
# nodes_changeset_id_fkey (changeset_id => changesets.id)
# nodes_redaction_id_fkey (redaction_id => redactions.id)
#
class OldNode < ActiveRecord::Base
include GeoRecord
include ConsistencyValidations

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: node_tags
#
# node_id :integer not null, primary key
# version :integer not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
#
# Foreign Keys
#
# node_tags_id_fkey (node_id => nodes.node_id)
#
class OldNodeTag < ActiveRecord::Base
self.table_name = "node_tags"
self.primary_keys = "node_id", "version", "k"

View file

@ -1,3 +1,25 @@
# == Schema Information
#
# Table name: relations
#
# relation_id :integer default(0), not null, primary key
# changeset_id :integer not null
# timestamp :datetime not null
# version :integer not null, primary key
# visible :boolean default(TRUE), not null
# redaction_id :integer
#
# Indexes
#
# relations_changeset_id_idx (changeset_id)
# relations_timestamp_idx (timestamp)
#
# Foreign Keys
#
# relations_changeset_id_fkey (changeset_id => changesets.id)
# relations_redaction_id_fkey (redaction_id => redactions.id)
#
class OldRelation < ActiveRecord::Base
include ConsistencyValidations
include ObjectMetadata

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: relation_members
#
# relation_id :integer default(0), not null, primary key
# member_type :enum not null
# member_id :integer not null
# member_role :string not null
# version :integer default(0), not null, primary key
# sequence_id :integer default(0), not null, primary key
#
# Indexes
#
# relation_members_member_idx (member_type,member_id)
#
# Foreign Keys
#
# relation_members_id_fkey (relation_id => relations.relation_id)
#
class OldRelationMember < ActiveRecord::Base
self.table_name = "relation_members"
self.primary_keys = "relation_id", "version", "sequence_id"

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: relation_tags
#
# relation_id :integer default(0), not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
# version :integer not null, primary key
#
# Foreign Keys
#
# relation_tags_id_fkey (relation_id => relations.relation_id)
#
class OldRelationTag < ActiveRecord::Base
self.table_name = "relation_tags"
self.primary_keys = "relation_id", "version", "k"

View file

@ -1,3 +1,25 @@
# == Schema Information
#
# Table name: ways
#
# way_id :integer default(0), not null, primary key
# changeset_id :integer not null
# timestamp :datetime not null
# version :integer not null, primary key
# visible :boolean default(TRUE), not null
# redaction_id :integer
#
# Indexes
#
# ways_changeset_id_idx (changeset_id)
# ways_timestamp_idx (timestamp)
#
# Foreign Keys
#
# ways_changeset_id_fkey (changeset_id => changesets.id)
# ways_redaction_id_fkey (redaction_id => redactions.id)
#
class OldWay < ActiveRecord::Base
include ConsistencyValidations
include ObjectMetadata

View file

@ -1,3 +1,21 @@
# == Schema Information
#
# Table name: way_nodes
#
# way_id :integer not null, primary key
# node_id :integer not null
# version :integer not null, primary key
# sequence_id :integer not null, primary key
#
# Indexes
#
# way_nodes_node_idx (node_id)
#
# Foreign Keys
#
# way_nodes_id_fkey (way_id => ways.way_id)
#
class OldWayNode < ActiveRecord::Base
self.table_name = "way_nodes"
self.primary_keys = "way_id", "version", "sequence_id"

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: way_tags
#
# way_id :integer default(0), not null, primary key
# k :string not null, primary key
# v :string not null
# version :integer not null, primary key
#
# Foreign Keys
#
# way_tags_id_fkey (way_id => ways.way_id)
#
class OldWayTag < ActiveRecord::Base
self.table_name = "way_tags"
self.primary_keys = "way_id", "version", "k"

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: redactions
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime
# updated_at :datetime
# user_id :integer not null
# description_format :enum default("markdown"), not null
#
# Foreign Keys
#
# redactions_user_id_fkey (user_id => users.id)
#
##
# Redaction represents a record associated with a particular
# action on the database to hide revisions from the history

View file

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: current_relations
#
# id :integer not null, primary key
# changeset_id :integer not null
# timestamp :datetime not null
# visible :boolean not null
# version :integer not null
#
# Indexes
#
# current_relations_timestamp_idx (timestamp)
#
# Foreign Keys
#
# current_relations_changeset_id_fkey (changeset_id => changesets.id)
#
class Relation < ActiveRecord::Base
require "xml/libxml"
@ -60,7 +79,7 @@ class Relation < ActiveRecord::Base
relation.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of relation cannot be zero when updating.") if relation.id.zero?
raise OSM::APIBadUserInput, "ID of relation cannot be zero when updating." if relation.id.zero?
end
# We don't care about the timestamp nor the visibility as these are either
@ -92,7 +111,7 @@ class Relation < ActiveRecord::Base
member["role"] ||= "" # Allow the upload to not include this, in which case we default to an empty string.
relation.add_member(member["type"].classify, member["ref"], member["role"])
end
raise OSM::APIBadUserInput.new("Some bad xml in relation") if relation.nil?
raise OSM::APIBadUserInput, "Some bad xml in relation" if relation.nil?
relation
end
@ -103,25 +122,13 @@ class Relation < ActiveRecord::Base
doc
end
def to_xml_node(visible_members = nil, changeset_cache = {}, user_display_name_cache = {})
def to_xml_node(changeset_cache = {}, user_display_name_cache = {})
el = XML::Node.new "relation"
el["id"] = id.to_s
add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache)
relation_members.each do |member|
p = 0
if visible_members
# if there is a list of visible members then use that to weed out deleted segments
p = 1 if visible_members[member.member_type][member.member_id]
else
# otherwise, manually go to the db to check things
p = 1 if member.member.visible?
end
next unless p
member_el = XML::Node.new "member"
member_el["type"] = member.member_type.downcase
member_el["ref"] = member.member_id.to_s
@ -155,7 +162,7 @@ class Relation < ActiveRecord::Base
end
def add_tag_keyval(k, v)
@tags = {} unless @tags
@tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
@ -187,7 +194,7 @@ class Relation < ActiveRecord::Base
check_consistency(self, new_relation, user)
# This will check to see if this relation is used by another relation
rel = RelationMember.joins(:relation).find_by("visible = ? AND member_type = 'Relation' and member_id = ? ", true, id)
raise OSM::APIPreconditionFailedError.new("The relation #{new_relation.id} is used in relation #{rel.relation.id}.") unless rel.nil?
raise OSM::APIPreconditionFailedError, "The relation #{new_relation.id} is used in relation #{rel.relation.id}." unless rel.nil?
self.changeset_id = new_relation.changeset_id
self.tags = {}
@ -202,7 +209,7 @@ class Relation < ActiveRecord::Base
lock!
check_consistency(self, new_relation, user)
unless new_relation.preconditions_ok?(members)
raise OSM::APIPreconditionFailedError.new("Cannot update relation #{id}: data or member data is invalid.")
raise OSM::APIPreconditionFailedError, "Cannot update relation #{id}: data or member data is invalid."
end
self.changeset_id = new_relation.changeset_id
self.changeset = new_relation.changeset
@ -216,7 +223,7 @@ class Relation < ActiveRecord::Base
def create_with_history(user)
check_create_consistency(self, user)
unless preconditions_ok?
raise OSM::APIPreconditionFailedError.new("Cannot create relation: data or member data is invalid.")
raise OSM::APIPreconditionFailedError, "Cannot create relation: data or member data is invalid."
end
self.version = 0
self.visible = true
@ -253,7 +260,7 @@ class Relation < ActiveRecord::Base
# and check that it is OK to use.
unless element && element.visible? && element.preconditions_ok?
raise OSM::APIPreconditionFailedError.new("Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}")
raise OSM::APIPreconditionFailedError, "Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}"
end
hash[m[1]] = true
end
@ -270,7 +277,7 @@ class Relation < ActiveRecord::Base
old_id = id.to_i
if old_id < 0
new_id = id_map[type.downcase.to_sym][old_id]
raise OSM::APIBadUserInput.new("Placeholder #{type} not found for reference #{old_id} in relation #{self.id.nil? ? placeholder_id : self.id}.") if new_id.nil?
raise OSM::APIBadUserInput, "Placeholder #{type} not found for reference #{old_id} in relation #{self.id.nil? ? placeholder_id : self.id}." if new_id.nil?
[type, new_id, role]
else
[type, id, role]

View file

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: current_relation_members
#
# relation_id :integer not null, primary key
# member_type :enum not null
# member_id :integer not null
# member_role :string not null
# sequence_id :integer default(0), not null, primary key
#
# Indexes
#
# current_relation_members_member_idx (member_type,member_id)
#
# Foreign Keys
#
# current_relation_members_id_fkey (relation_id => current_relations.id)
#
class RelationMember < ActiveRecord::Base
self.table_name = "current_relation_members"
self.primary_keys = "relation_id", "sequence_id"

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: current_relation_tags
#
# relation_id :integer not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
#
# Foreign Keys
#
# current_relation_tags_id_fkey (relation_id => current_relations.id)
#
class RelationTag < ActiveRecord::Base
self.table_name = "current_relation_tags"
self.primary_keys = "relation_id", "k"

View file

@ -1,3 +1,40 @@
# == Schema Information
#
# Table name: oauth_tokens
#
# id :integer not null, primary key
# user_id :integer
# type :string(20)
# client_application_id :integer
# token :string(50)
# secret :string(50)
# authorized_at :datetime
# invalidated_at :datetime
# created_at :datetime
# updated_at :datetime
# allow_read_prefs :boolean default(FALSE), not null
# allow_write_prefs :boolean default(FALSE), not null
# allow_write_diary :boolean default(FALSE), not null
# allow_write_api :boolean default(FALSE), not null
# allow_read_gpx :boolean default(FALSE), not null
# allow_write_gpx :boolean default(FALSE), not null
# callback_url :string
# verifier :string(20)
# scope :string
# valid_to :datetime
# allow_write_notes :boolean default(FALSE), not null
#
# Indexes
#
# index_oauth_tokens_on_token (token) UNIQUE
# index_oauth_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# oauth_tokens_client_application_id_fkey (client_application_id => client_applications.id)
# oauth_tokens_user_id_fkey (user_id => users.id)
#
class RequestToken < OauthToken
attr_accessor :provided_oauth_verifier

View file

@ -1,3 +1,30 @@
# == Schema Information
#
# Table name: gpx_files
#
# id :integer not null, primary key
# user_id :integer not null
# visible :boolean default(TRUE), not null
# name :string default(""), not null
# size :integer
# latitude :float
# longitude :float
# timestamp :datetime not null
# description :string default(""), not null
# inserted :boolean not null
# visibility :enum default("public"), not null
#
# Indexes
#
# gpx_files_timestamp_idx (timestamp)
# gpx_files_user_id_idx (user_id)
# gpx_files_visible_visibility_idx (visible,visibility)
#
# Foreign Keys
#
# gpx_files_user_id_fkey (user_id => users.id)
#
class Trace < ActiveRecord::Base
self.table_name = "gpx_files"
@ -172,13 +199,12 @@ class Trace < ActiveRecord::Base
el1
end
# Read in xml as text and return it's Node object representation
def self.from_xml(xml, create = false)
def update_from_xml(xml, create = false)
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/gpx_file").each do |pt|
return Trace.from_xml_node(pt, create)
return update_from_xml_node(pt, create)
end
raise OSM::APIBadXMLError.new("trace", xml, "XML doesn't contain an osm/gpx_file element.")
@ -186,34 +212,31 @@ class Trace < ActiveRecord::Base
raise OSM::APIBadXMLError.new("trace", xml, ex.message)
end
def self.from_xml_node(pt, create = false)
trace = Trace.new
def update_from_xml_node(pt, create = false)
raise OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt["visibility"].nil?
trace.visibility = pt["visibility"]
self.visibility = pt["visibility"]
unless create
raise OSM::APIBadXMLError.new("trace", pt, "ID is required when updating.") if pt["id"].nil?
trace.id = pt["id"].to_i
id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of trace cannot be zero when updating.") if trace.id.zero?
raise OSM::APIBadUserInput, "ID of trace cannot be zero when updating." if id.zero?
raise OSM::APIBadUserInput, "The id in the url (#{self.id}) is not the same as provided in the xml (#{id})" unless self.id == id
end
# We don't care about the time, as it is explicitly set on create/update/delete
# We don't care about the visibility as it is implicit based on the action
# and set manually before the actual delete
trace.visible = true
self.visible = true
description = pt.find("description").first
raise OSM::APIBadXMLError.new("trace", pt, "description missing") if description.nil?
trace.description = description.content
self.description = description.content
pt.find("tag").each do |tag|
trace.tags.build(:tag => tag.content)
self.tags = pt.find("tag").collect do |tag|
Tracetag.new(:tag => tag.content)
end
trace
end
def xml_file

View file

@ -1,3 +1,25 @@
# == Schema Information
#
# Table name: gps_points
#
# altitude :float
# trackid :integer not null
# latitude :integer not null
# longitude :integer not null
# gpx_id :integer not null
# timestamp :datetime
# tile :integer
#
# Indexes
#
# points_gpxid_idx (gpx_id)
# points_tile_idx (tile)
#
# Foreign Keys
#
# gps_points_gpx_id_fkey (gpx_id => gpx_files.id)
#
class Tracepoint < ActiveRecord::Base
include GeoRecord

View file

@ -1,3 +1,21 @@
# == Schema Information
#
# Table name: gpx_file_tags
#
# gpx_id :integer default(0), not null
# tag :string not null
# id :integer not null, primary key
#
# Indexes
#
# gpx_file_tags_gpxid_idx (gpx_id)
# gpx_file_tags_tag_idx (tag)
#
# Foreign Keys
#
# gpx_file_tags_gpx_id_fkey (gpx_id => gpx_files.id)
#
class Tracetag < ActiveRecord::Base
self.table_name = "gpx_file_tags"

View file

@ -1,3 +1,48 @@
# == Schema Information
#
# Table name: users
#
# email :string not null
# id :integer not null, primary key
# pass_crypt :string not null
# creation_time :datetime not null
# display_name :string default(""), not null
# data_public :boolean default(FALSE), not null
# description :text default(""), not null
# home_lat :float
# home_lon :float
# home_zoom :integer default(3)
# nearby :integer default(50)
# pass_salt :string
# image_file_name :text
# email_valid :boolean default(FALSE), not null
# new_email :string
# creation_ip :string
# languages :string
# status :enum default("pending"), not null
# terms_agreed :datetime
# consider_pd :boolean default(FALSE), not null
# auth_uid :string
# preferred_editor :string
# terms_seen :boolean default(FALSE), not null
# description_format :enum default("markdown"), not null
# image_fingerprint :string
# changesets_count :integer default(0), not null
# traces_count :integer default(0), not null
# diary_entries_count :integer default(0), not null
# image_use_gravatar :boolean default(FALSE), not null
# image_content_type :string
# auth_provider :string
#
# Indexes
#
# users_auth_idx (auth_provider,auth_uid) UNIQUE
# users_display_name_idx (display_name) UNIQUE
# users_display_name_lower_idx (lower((display_name)::text))
# users_email_idx (email) UNIQUE
# users_email_lower_idx (lower((email)::text))
#
class User < ActiveRecord::Base
require "xml/libxml"

View file

@ -1,3 +1,29 @@
# == Schema Information
#
# Table name: user_blocks
#
# id :integer not null, primary key
# user_id :integer not null
# creator_id :integer not null
# reason :text not null
# ends_at :datetime not null
# needs_view :boolean default(FALSE), not null
# revoker_id :integer
# created_at :datetime
# updated_at :datetime
# reason_format :enum default("markdown"), not null
#
# Indexes
#
# index_user_blocks_on_user_id (user_id)
#
# Foreign Keys
#
# user_blocks_moderator_id_fkey (creator_id => users.id)
# user_blocks_revoker_id_fkey (revoker_id => users.id)
# user_blocks_user_id_fkey (user_id => users.id)
#
class UserBlock < ActiveRecord::Base
validate :moderator_permissions

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: user_preferences
#
# user_id :integer not null, primary key
# k :string not null, primary key
# v :string not null
#
# Foreign Keys
#
# user_preferences_user_id_fkey (user_id => users.id)
#
class UserPreference < ActiveRecord::Base
self.primary_keys = "user_id", "k"

View file

@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: user_roles
#
# id :integer not null, primary key
# user_id :integer not null
# role :enum not null
# created_at :datetime
# updated_at :datetime
# granter_id :integer not null
#
# Indexes
#
# user_roles_id_role_unique (user_id,role) UNIQUE
#
# Foreign Keys
#
# user_roles_granter_id_fkey (granter_id => users.id)
# user_roles_user_id_fkey (user_id => users.id)
#
class UserRole < ActiveRecord::Base
belongs_to :user
belongs_to :granter, :class_name => "User"

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: user_tokens
#
# id :integer not null, primary key
# user_id :integer not null
# token :string not null
# expiry :datetime not null
# referer :text
#
# Indexes
#
# user_tokens_token_idx (token) UNIQUE
# user_tokens_user_id_idx (user_id)
#
# Foreign Keys
#
# user_tokens_user_id_fkey (user_id => users.id)
#
class UserToken < ActiveRecord::Base
belongs_to :user

View file

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: current_ways
#
# id :integer not null, primary key
# changeset_id :integer not null
# timestamp :datetime not null
# visible :boolean not null
# version :integer not null
#
# Indexes
#
# current_ways_timestamp_idx (timestamp)
#
# Foreign Keys
#
# current_ways_changeset_id_fkey (changeset_id => changesets.id)
#
class Way < ActiveRecord::Base
require "xml/libxml"
@ -58,7 +77,7 @@ class Way < ActiveRecord::Base
way.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id.zero?
raise OSM::APIBadUserInput, "ID of way cannot be zero when updating." if way.id.zero?
end
# We don't care about the timestamp nor the visibility as these are either
@ -138,12 +157,12 @@ class Way < ActiveRecord::Base
attr_writer :tags
def add_nd_num(n)
@nds = [] unless @nds
@nds ||= []
@nds << n.to_i
end
def add_tag_keyval(k, v)
@tags = {} unless @tags
@tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
@ -166,7 +185,7 @@ class Way < ActiveRecord::Base
lock!
check_consistency(self, new_way, user)
unless new_way.preconditions_ok?(nds)
raise OSM::APIPreconditionFailedError.new("Cannot update way #{id}: data is invalid.")
raise OSM::APIPreconditionFailedError, "Cannot update way #{id}: data is invalid."
end
self.changeset_id = new_way.changeset_id
@ -181,7 +200,7 @@ class Way < ActiveRecord::Base
def create_with_history(user)
check_create_consistency(self, user)
unless preconditions_ok?
raise OSM::APIPreconditionFailedError.new("Cannot create way: data is invalid.")
raise OSM::APIPreconditionFailedError, "Cannot create way: data is invalid."
end
self.version = 0
self.visible = true
@ -205,7 +224,7 @@ class Way < ActiveRecord::Base
if db_nds.length < new_nds.length
missing = new_nds - db_nds.collect(&:id)
raise OSM::APIPreconditionFailedError.new("Way #{id} requires the nodes with id in (#{missing.join(',')}), which either do not exist, or are not visible.")
raise OSM::APIPreconditionFailedError, "Way #{id} requires the nodes with id in (#{missing.join(',')}), which either do not exist, or are not visible."
end
end
@ -222,7 +241,7 @@ class Way < ActiveRecord::Base
lock!
check_consistency(self, new_way, user)
rels = Relation.joins(:relation_members).where(:visible => true, :current_relation_members => { :member_type => "Way", :member_id => id }).order(:id)
raise OSM::APIPreconditionFailedError.new("Way #{id} is still used by relations #{rels.collect(&:id).join(',')}.") unless rels.empty?
raise OSM::APIPreconditionFailedError, "Way #{id} is still used by relations #{rels.collect(&:id).join(',')}." unless rels.empty?
self.changeset_id = new_way.changeset_id
self.changeset = new_way.changeset
@ -242,7 +261,7 @@ class Way < ActiveRecord::Base
nds.map! do |node_id|
if node_id < 0
new_id = id_map[:node][node_id]
raise OSM::APIBadUserInput.new("Placeholder node not found for reference #{node_id} in way #{id.nil? ? placeholder_id : id}") if new_id.nil?
raise OSM::APIBadUserInput, "Placeholder node not found for reference #{node_id} in way #{id.nil? ? placeholder_id : id}" if new_id.nil?
new_id
else
node_id

View file

@ -1,3 +1,21 @@
# == Schema Information
#
# Table name: current_way_nodes
#
# way_id :integer not null, primary key
# node_id :integer not null
# sequence_id :integer not null, primary key
#
# Indexes
#
# current_way_nodes_node_idx (node_id)
#
# Foreign Keys
#
# current_way_nodes_id_fkey (way_id => current_ways.id)
# current_way_nodes_node_id_fkey (node_id => current_nodes.id)
#
class WayNode < ActiveRecord::Base
self.table_name = "current_way_nodes"
self.primary_keys = "way_id", "sequence_id"

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: current_way_tags
#
# way_id :integer not null, primary key
# k :string default(""), not null, primary key
# v :string default(""), not null
#
# Foreign Keys
#
# current_way_tags_id_fkey (way_id => current_ways.id)
#
class WayTag < ActiveRecord::Base
self.table_name = "current_way_tags"
self.primary_keys = "way_id", "k"

View file

@ -62,7 +62,7 @@ atom_feed(:language => I18n.locale, :schema_date => 2009,
td.table :cellpadding => "0" do |table|
changeset.tags.sort.each do |tag|
table.tr do |tr|
tr.td << "#{h(tag[0])} = #{auto_link(h(tag[1]))}"
tr.td << "#{h(tag[0])} = #{linkify(h(tag[1]))}"
end
end
end

View file

@ -34,19 +34,21 @@
<%= render :partial => 'diary_list_entry', :collection => @entries %>
<% end %>
<% if @entries.size < @page_size -%>
<%= t('diary_entry.list.older_entries') %>
<% else -%>
<%= link_to t('diary_entry.list.older_entries'), @params.merge(:page => @page + 1 ) %>
<% end -%>
<div class="pagination">
<% if @entries.size < @page_size -%>
<%= t('diary_entry.list.older_entries') %>
<% else -%>
<%= link_to t('diary_entry.list.older_entries'), @params.merge(:page => @page + 1 ) %>
<% end -%>
|
|
<% if @page > 1 -%>
<%= link_to t('diary_entry.list.newer_entries'), @params.merge(:page => @page - 1) %>
<% else -%>
<%= t('diary_entry.list.newer_entries') %>
<% end -%>
<% if @page > 1 -%>
<%= link_to t('diary_entry.list.newer_entries'), @params.merge(:page => @page - 1) %>
<% else -%>
<%= t('diary_entry.list.newer_entries') %>
<% end -%>
</div>
<% end %>
<% unless params[:friends] or params[:nearby] -%>

View file

@ -7,7 +7,6 @@
<%= stylesheet_link_tag "print-#{dir}", :media => "print" %>
<%= stylesheet_link_tag "leaflet-all", :media => "screen, print" %>
<!--[if IE]>
<%= stylesheet_link_tag "large-#{dir}", :media => "screen" %>
<%= favicon_link_tag "favicon.ico" %>
<![endif]-->
<% [57, 60, 72, 76, 114, 120, 144, 152, 180].each do |size| -%>
@ -18,7 +17,7 @@
<%= favicon_link_tag "favicon-96x96.png", :rel => "icon", :sizes => "96x96", :type => "image/png" %>
<%= favicon_link_tag "android-chrome-192x192.png", :rel => "icon", :sizes => "192x192", :type => "image/png" %>
<%= favicon_link_tag "favicon-16x16.png", :rel => "icon", :sizes => "16x16", :type => "image/png" %>
<%= tag("link", { :rel => "mask-icon", :href => asset_path("tag-icon.svg"), :color => "#7ebc6f" }) %>
<%= tag("link", { :rel => "mask-icon", :href => asset_path("tab-icon.svg"), :color => "#7ebc6f" }) %>
<%= tag("link", { :rel => "manifest", :href => asset_path("manifest.json") }) %>
<%= tag("meta", { :name => "msapplication-config", :content => asset_path("browserconfig.xml") }) %>
<%= tag("meta", { :name => "msapplication-TileColor", :content => "#00a300" }) %>
@ -33,10 +32,10 @@
<%= opengraph_tags(@title) %>
<% if flash[:piwik_goal] -%>
<%= tag("meta", :name => "piwik-goal", :content => flash[:piwik_goal]) %>
<% end -%>
<% end -%>
<%= style_rules %>
<%= yield :head %>
<%= yield :auto_discovery_link_tag %>
<%= csrf_meta_tag %>
<title><%= t 'layouts.project_name.title' %><%= ' | ' + @title if @title %></title>
<title><%= @title + ' | ' if @title %><%= t 'layouts.project_name.title' %></title>
<% end %>

View file

@ -11,7 +11,7 @@
<% end %>
<%= error_messages_for current_user %>
<%= form_for current_user, :url => { :action => :account }, :html => { :multipart => true, :id => 'accountForm', :class => 'standard-form', :autocomplete => :off } do |f| %>
<%= form_for current_user, :url => { :action => :account }, :method => :post, :html => { :multipart => true, :id => 'accountForm', :class => 'standard-form', :autocomplete => :off } do |f| %>
<fieldset>
<div class="form-row">
<label class="standard-label"><%= t 'user.new.display name' %></label>
@ -123,7 +123,7 @@
<%= t 'user.account.replace image' %>
<span class="form-help deemphasize"><%= t 'user.account.image size hint' %></span>
</label>
<%= f.file_field :image, :onchange => "$('#image_action_new').prop('checked', true)" %>
<%= f.file_field :image %>
</li>
<% else %>
<li>
@ -132,7 +132,7 @@
<%= t 'user.account.new image' %>
<span class="form-help deemphasize"><%= t 'user.account.image size hint' %></span>
</label>
<%= f.file_field :image, :onchange => "$('#image_action_new').prop('checked', true)" %>
<%= f.file_field :image %>
</li>
<% end %>
<li>

View file

@ -2,7 +2,7 @@
<h1><%= t 'user.reset_password.heading', :user => current_user.display_name %></h1>
<% end %>
<%= error_messages_for :user %>
<%= error_messages_for current_user %>
<%= form_tag do %>
<%= hidden_field_tag(:token, params[:token]) %>

View file

@ -1 +0,0 @@
<%= current_user.email %>

View file

@ -1,6 +1,18 @@
sotm2017:
id: sotm2017
alt: State of the Map 2017
link: http://2017.stateofthemap.org/
img: banners/banner-sotm-2017.png
enddate: 2017-aug-27
sotmasia2017:
id: sotmasia2017
alt: State of the Map Asia 2017
link: http://stateofthemap.asia/
img: banners/sotmasia-2017-banner.png
enddate: 2017-sep-25
sotmus2017:
id: sotmus2017
alt: State of the Map US 2017
link: https://2017.stateofthemap.us/
img: banners/banner-sotmus2017.png
enddate: 2017-oct-20
osmfmembership2017:
id: osmfmembership2017
alt: Join the OpenStreetMap Foundation
link: https://blog.openstreetmap.org/2017/09/25/join-the-openstreetmap-foundation-now-and-help-shape-the-future-of-the-project/
img: banners/osmf-membership-drive-2017.png
enddate: 2017-nov-11

View file

@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path("../application", __FILE__)
require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!

View file

@ -12,6 +12,20 @@ Rails.application.configure do
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

Some files were not shown because too many files have changed in this diff Show more