mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-05 16:00:00 +01:00
Migrate from Travis to GitHub Actions for CI (#1534)
* Try migrating from Travis to GitHub Actions for CI * Update actions.yml and tests.yml * Add ruby version * Update config/database.yml.example * Try rubocop and docker jobs * Fix indentation * Update tests.yml * Update tests.yml * Update gemfile * Update rubocop job and Gemfile * Update .rubocop_shopify_styleguide.yml * Update gemfile * Update .rubocop_todo.yml * Update rubocop configuration and styleguides * Fix rubocop offenses * Update .rubocop.yml * Update .rubocop.yml * Udate .codeclimate.yml * Update .codeclimate.yml * Update .codeclimate.yml * Update .codeclimate.yml * Setup unit tests * Update find_verified_user method in connection.rb * Add yarn cache and install to setup * install exporter dependencies; gdal/imagemagick * Introduce Gitpod to migration work (#1538) * Add CORS headers (#1536) * Create .gitpod.dockerfile * Create .gitpod.yml * Create database.yml.gitpod * Update .gitpod.yml * ruby 2.4.6 in gitpod.dockerfile * Update .gitpod.yml * Update database.yml.gitpod Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> * Install gdal and use egordm for yarn cache * Delete unnecessary query and fix layout * Run script with verbose output * Try installing package in action.yml * Setup controllers job * Fix indentation * Setup system tests job * Setup docker development build job * Fix identifiers * Fix path to action.yml * Update development dockerfile * Setup docker production build job * Update tests.yml * Setup assets precompilation job * Setup production environment * Update tests.yml * Update action.yml for production * Try with test setup * Remove action.yml for production * Change names of jobs for friendliness and clarity * Update .github/workflows/tests.yml Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> * Move dockerfiles to directory and change docker job names for clarity * Update docker job names Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
version: 2
|
||||
plugins:
|
||||
rubocop:
|
||||
enabled: true
|
||||
channel: rubocop-0-70
|
||||
brakeman:
|
||||
enabled: true
|
||||
bundler-audit:
|
||||
|
||||
31
.github/actions/setup-test-environment/action.yml
vendored
Normal file
31
.github/actions/setup-test-environment/action.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: 'Set up test environment'
|
||||
description: 'Set up test environment for mapknitter'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
ports:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Setup database
|
||||
shell: bash
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
DB_USER: root
|
||||
DB_PASS: root
|
||||
# tell Rails to use proper port for MySQL
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DISABLE_BOOTSNAP: true
|
||||
run: |
|
||||
cp config/database.yml.example config/database.yml
|
||||
cp db/schema.rb.example db/schema.rb
|
||||
cp config/config.yml.example config/config.yml
|
||||
sudo systemctl start mysql
|
||||
mysql -uroot -proot -e "CREATE DATABASE mapknitter_test;"
|
||||
bundle exec rake db:schema:load db:migrate --trace
|
||||
sudo apt-get install -y gdal-bin
|
||||
166
.github/workflows/tests.yml
vendored
Normal file
166
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
name: CI/CD workflow
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
rubocop:
|
||||
name: Code style suggestions
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Prepare Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- name: Rubocop report
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
run: bundle exec rubocop --color --fail-fast
|
||||
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- uses: egordm/gha-yarn-node-cache@v1
|
||||
- name: Install packages
|
||||
run: yarn install
|
||||
- name: 'Model Tests'
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
DB_PASSWORD: root
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DISABLE_BOOTSNAP: true
|
||||
run: |
|
||||
bundle exec rails test test:models
|
||||
|
||||
integration-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- uses: egordm/gha-yarn-node-cache@v1
|
||||
- name: Install JavaScript dependencies with Yarn
|
||||
run: yarn check || yarn install;
|
||||
- name: 'Integration Tests'
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
DB_PASSWORD: root
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DISABLE_BOOTSNAP: true
|
||||
run: bundle exec rails test test:integration
|
||||
|
||||
controller-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- uses: egordm/gha-yarn-node-cache@v1
|
||||
- name: Install JavaScript dependencies with Yarn
|
||||
run: yarn check || yarn install;
|
||||
- name: 'Controller Tests'
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
DB_PASSWORD: root
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DISABLE_BOOTSNAP: true
|
||||
run: bundle exec rails test test:controllers
|
||||
|
||||
system-tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
# Set health checks to wait until redis has started
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
# Maps port 6379 on service container to the host
|
||||
- 6379:6379
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: nanasess/setup-chromedriver@v1.0.1
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- uses: egordm/gha-yarn-node-cache@v1
|
||||
- name: Install JavaScript dependencies with Yarn
|
||||
run: yarn check || yarn install;
|
||||
- name: 'System Tests'
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
DB_PASSWORD: root
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
REDIS_HOST: localhost
|
||||
REDIS_PORT: 6379
|
||||
run: |
|
||||
export DISPLAY=:99
|
||||
chromedriver --url-base=/wd/hub &
|
||||
bundle exec rails test test:system
|
||||
- name: Archive system test screenshots
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: system-test-screenshots
|
||||
path: tmp/screenshots/*
|
||||
|
||||
docker-build-check-development:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- name: 'Development Docker Build'
|
||||
run: docker build -t mapknitter -f dockerfiles/development .
|
||||
|
||||
docker-build-check-production:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- name: 'Development Docker Build'
|
||||
run: docker build -t mapknitter -f dockerfiles/production .
|
||||
|
||||
assets-precompilation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.4.6
|
||||
bundler-cache: true
|
||||
- uses: ./.github/actions/setup-test-environment
|
||||
- uses: egordm/gha-yarn-node-cache@v1
|
||||
- name: Install JavaScript dependencies with Yarn
|
||||
run: yarn check || yarn install;
|
||||
- name: 'Asset Precompilation'
|
||||
env:
|
||||
RAILS_ENV: production
|
||||
DB_PASSWORD: root
|
||||
DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
DISABLE_BOOTSNAP: true
|
||||
run: bundle exec rails assets:precompile
|
||||
@@ -1,10 +1,13 @@
|
||||
require: rubocop-rails
|
||||
require: rubocop-performance
|
||||
|
||||
# Start with Spotifys style guide as a base then customize from there
|
||||
inherit_from:
|
||||
- .rubocop_shopify_styleguide.yml
|
||||
- .rubocop_todo.yml
|
||||
|
||||
inherit_gem:
|
||||
rubocop-shopify: rubocop.yml
|
||||
|
||||
# Apply rule to all cops
|
||||
AllCops:
|
||||
Include:
|
||||
@@ -12,7 +15,7 @@ AllCops:
|
||||
- '/Rakefile'
|
||||
- '/config.ru'
|
||||
Exclude:
|
||||
- 'vendor/*'
|
||||
- 'vendor/**/*'
|
||||
- 'node_modules/**/*'
|
||||
- 'spec/**/*'
|
||||
- 'bin/*'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,142 +1,7 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2019-03-02 16:51:15 +0100 using RuboCop version 0.65.0.
|
||||
# on 2021-08-31 01:32:53 UTC using RuboCop version 1.12.1.
|
||||
# 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: 180
|
||||
Metrics/AbcSize:
|
||||
Max: 178
|
||||
|
||||
# Offense count: 13
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
# ExcludedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
Max: 257
|
||||
|
||||
# Offense count: 24
|
||||
# Configuration parameters: CountBlocks.
|
||||
Metrics/BlockNesting:
|
||||
Max: 6
|
||||
|
||||
# Offense count: 50
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 28
|
||||
|
||||
# Offense count: 171
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
Metrics/MethodLength:
|
||||
Max: 86
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ModuleLength:
|
||||
Max: 347
|
||||
|
||||
# Offense count: 60
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 33
|
||||
|
||||
# Offense count: 7
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/MethodName:
|
||||
Exclude:
|
||||
- 'app/controllers/tag_controller.rb'
|
||||
- 'app/models/doc_list.rb'
|
||||
- 'app/models/search_request.rb'
|
||||
- 'app/services/search_service.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
||||
# NamePrefix: is_, has_, have_
|
||||
# NamePrefixBlacklist: is_, has_, have_
|
||||
# NameWhitelist: is_a?
|
||||
# MethodDefinitionMacros: define_method, define_singleton_method
|
||||
Naming/PredicateName:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'app/controllers/openid_controller.rb'
|
||||
- 'app/models/drupal_file.rb'
|
||||
- 'app/models/image.rb'
|
||||
- 'app/models/node.rb'
|
||||
- 'app/models/revision.rb'
|
||||
- 'app/models/tag.rb'
|
||||
- 'app/models/user.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Exclude:
|
||||
- 'app/models/doc_list.rb'
|
||||
|
||||
|
||||
# Offense count: 9
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/VariableName:
|
||||
Exclude:
|
||||
- 'app/models/concerns/node_shared.rb'
|
||||
- 'app/models/doc_list.rb'
|
||||
- 'app/models/revision.rb'
|
||||
- 'app/models/search_request.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Security/Open:
|
||||
Exclude:
|
||||
- 'app/models/image.rb'
|
||||
- 'app/models/node.rb'
|
||||
|
||||
|
||||
# Offense count: 26
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Exclude:
|
||||
- 'app/controllers/admin_controller.rb'
|
||||
- 'app/controllers/application_controller.rb'
|
||||
- 'app/controllers/features_controller.rb'
|
||||
- 'app/controllers/notes_controller.rb'
|
||||
- 'app/controllers/openid_controller.rb'
|
||||
- 'app/controllers/users_controller.rb'
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/comment_helper.rb'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/node.rb'
|
||||
- 'app/models/spamaway.rb'
|
||||
- 'app/models/user.rb'
|
||||
- 'app/models/user_tag.rb'
|
||||
- 'app/services/search_criteria.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/IdenticalConditionalBranches:
|
||||
Exclude:
|
||||
# - 'app/controllers/answers_controller.rb'
|
||||
|
||||
# Offense count: 45
|
||||
# Cop supports --auto-correct.
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: false
|
||||
|
||||
|
||||
# Offense count: 1
|
||||
Style/MixinUsage:
|
||||
Exclude:
|
||||
- 'app/controllers/application_controller.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
||||
# SupportedStyles: predicate, comparison
|
||||
Style/NumericPredicate:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'app/controllers/application_controller.rb'
|
||||
- 'app/controllers/users_controller.rb'
|
||||
- 'app/controllers/wiki_controller.rb'
|
||||
- 'app/jobs/digest_mail_job.rb'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/concerns/statistics.rb'
|
||||
- 'app/models/user.rb'
|
||||
|
||||
8
Gemfile
8
Gemfile
@@ -52,8 +52,6 @@ group :dependencies do
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'rubocop', '~> 0.70.0'
|
||||
gem 'rubocop-performance'
|
||||
gem 'ruby-prof'
|
||||
gem 'rails-perftest'
|
||||
gem 'rails-controller-testing'
|
||||
@@ -74,15 +72,19 @@ group :development, :test do
|
||||
gem 'faker', '~> 2.12.0'
|
||||
gem 'pry-rails', '~> 0.3.9'
|
||||
gem 'action-cable-testing'
|
||||
gem 'rubocop', require: false
|
||||
gem 'rubocop-performance'
|
||||
gem 'rubocop-rails', require: false
|
||||
gem 'rubocop-shopify', require: false
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'jshintrb', '~> 0.3.0'
|
||||
gem 'mini_racer', platforms: :ruby
|
||||
gem 'listen', '~> 3.2.1'
|
||||
gem 'web-console', '~> 3.3'
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
gem 'web-console', '~> 3.3'
|
||||
end
|
||||
|
||||
group :sqlite do
|
||||
|
||||
258
Gemfile.lock
258
Gemfile.lock
@@ -6,72 +6,72 @@ GEM
|
||||
ZenTest (4.12.0)
|
||||
action-cable-testing (0.6.1)
|
||||
actioncable (>= 5.0)
|
||||
actioncable (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actioncable (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
actionmailer (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activejob (= 5.2.6)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
actionpack (5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
actionview (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
activejob (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
activerecord (5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
activemodel (5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
activerecord (5.2.6)
|
||||
activemodel (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.3)
|
||||
activestorage (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
activerecord (= 5.2.6)
|
||||
marcel (~> 1.0.0)
|
||||
activesupport (5.2.6)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.7.0)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
ansi (1.5.0)
|
||||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
autoprefixer-rails (10.0.0.2)
|
||||
ast (2.4.2)
|
||||
autoprefixer-rails (10.0.3.0)
|
||||
execjs
|
||||
aws-eventstream (1.1.0)
|
||||
aws-partitions (1.383.0)
|
||||
aws-sdk-core (3.109.1)
|
||||
aws-eventstream (1.1.1)
|
||||
aws-partitions (1.492.0)
|
||||
aws-sdk-core (3.119.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.239.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.39.0)
|
||||
aws-sdk-core (~> 3, >= 3.109.0)
|
||||
aws-sdk-kms (1.47.0)
|
||||
aws-sdk-core (~> 3, >= 3.119.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.83.1)
|
||||
aws-sdk-core (~> 3, >= 3.109.0)
|
||||
aws-sdk-s3 (1.100.0)
|
||||
aws-sdk-core (~> 3, >= 3.119.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sigv4 (1.2.2)
|
||||
aws-sigv4 (1.2.4)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.4.8)
|
||||
bootsnap (1.4.9)
|
||||
msgpack (~> 1.0)
|
||||
bootstrap-sass (3.4.1)
|
||||
autoprefixer-rails (>= 5.2.1)
|
||||
@@ -88,21 +88,37 @@ GEM
|
||||
xpath (~> 3.2)
|
||||
childprocess (3.0.0)
|
||||
climate_control (0.2.0)
|
||||
codecov (0.2.11)
|
||||
json
|
||||
simplecov
|
||||
coderay (1.1.2)
|
||||
concurrent-ruby (1.1.7)
|
||||
codecov (0.6.0)
|
||||
simplecov (>= 0.15, < 0.22)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.1.9)
|
||||
crass (1.0.6)
|
||||
docile (1.3.2)
|
||||
erubi (1.9.0)
|
||||
execjs (2.7.0)
|
||||
docile (1.3.5)
|
||||
erubi (1.10.0)
|
||||
execjs (2.8.1)
|
||||
faker (2.12.0)
|
||||
i18n (>= 1.6, < 2)
|
||||
faraday (1.0.1)
|
||||
faraday (1.7.1)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.12.2)
|
||||
friendly_id (5.3.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
ffi (1.15.3)
|
||||
friendly_id (5.4.2)
|
||||
activerecord (>= 4.0.0)
|
||||
geokit (1.13.1)
|
||||
geokit-rails (1.1.4)
|
||||
@@ -112,11 +128,10 @@ GEM
|
||||
httparty (0.18.1)
|
||||
mime-types (~> 3.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.8.5)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
image_science (1.3.1)
|
||||
RubyInline (~> 3.9)
|
||||
jaro_winkler (1.5.4)
|
||||
jmespath (1.4.0)
|
||||
jquery-rails (4.4.0)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
@@ -126,41 +141,43 @@ GEM
|
||||
execjs
|
||||
multi_json (>= 1.3)
|
||||
rake
|
||||
json (2.3.1)
|
||||
libv8 (7.3.492.27.1)
|
||||
json (2.5.1)
|
||||
libv8-node (15.14.0.1)
|
||||
libxml-ruby (3.1.0)
|
||||
listen (3.2.1)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loofah (2.6.0)
|
||||
loofah (2.12.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
marcel (1.0.1)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2020.0512)
|
||||
mini_magick (4.10.1)
|
||||
mini_mime (1.0.2)
|
||||
mime-types-data (3.2021.0704)
|
||||
mimemagic (0.3.10)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
mini_magick (4.11.0)
|
||||
mini_mime (1.1.1)
|
||||
mini_portile2 (2.4.0)
|
||||
mini_racer (0.2.15)
|
||||
libv8 (> 7.3)
|
||||
minitest (5.14.2)
|
||||
minitest-reporters (1.4.2)
|
||||
mini_racer (0.4.0)
|
||||
libv8-node (~> 15.14.0.0)
|
||||
minitest (5.14.4)
|
||||
minitest-reporters (1.4.3)
|
||||
ansi
|
||||
builder
|
||||
minitest (>= 5.0)
|
||||
ruby-progressbar
|
||||
msgpack (1.3.3)
|
||||
multi_json (1.14.1)
|
||||
msgpack (1.4.2)
|
||||
multi_json (1.15.0)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
mysql2 (0.5.3)
|
||||
net-http-persistent (2.9.4)
|
||||
nio4r (2.5.2)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oa-core (0.3.2)
|
||||
@@ -170,7 +187,7 @@ GEM
|
||||
ruby-openid-apps-discovery (~> 1.2.0)
|
||||
open_id_authentication (1.3.0)
|
||||
rack-openid (~> 1.3)
|
||||
paper_trail (11.0.0)
|
||||
paper_trail (11.1.0)
|
||||
activerecord (>= 5.2)
|
||||
request_store (~> 1.1)
|
||||
paperclip (6.1.0)
|
||||
@@ -179,20 +196,20 @@ GEM
|
||||
mime-types
|
||||
mimemagic (~> 0.3.0)
|
||||
terrapin (~> 0.6.0)
|
||||
parallel (1.19.1)
|
||||
parser (2.7.1.1)
|
||||
ast (~> 2.4.0)
|
||||
passenger (6.0.6)
|
||||
parallel (1.20.1)
|
||||
parser (3.0.2.0)
|
||||
ast (~> 2.4.1)
|
||||
passenger (6.0.10)
|
||||
rack
|
||||
rake (>= 0.8.1)
|
||||
popper_js (1.16.0)
|
||||
pry (0.13.1)
|
||||
pry (0.14.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
pry-rails (0.3.9)
|
||||
pry (>= 0.10.4)
|
||||
public_suffix (4.0.5)
|
||||
puma (4.3.6)
|
||||
public_suffix (4.0.6)
|
||||
puma (4.3.8)
|
||||
nio4r (~> 2.0)
|
||||
rack (2.2.3)
|
||||
rack-openid (1.3.1)
|
||||
@@ -203,18 +220,18 @@ GEM
|
||||
rack_session_access (0.2.0)
|
||||
builder (>= 2.0.0)
|
||||
rack (>= 1.0.0)
|
||||
rails (5.2.4.3)
|
||||
actioncable (= 5.2.4.3)
|
||||
actionmailer (= 5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
activestorage (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
rails (5.2.6)
|
||||
actioncable (= 5.2.6)
|
||||
actionmailer (= 5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
actionview (= 5.2.6)
|
||||
activejob (= 5.2.6)
|
||||
activemodel (= 5.2.6)
|
||||
activerecord (= 5.2.6)
|
||||
activestorage (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.3)
|
||||
railties (= 5.2.6)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.5)
|
||||
actionpack (>= 5.0.1.rc1)
|
||||
@@ -223,27 +240,28 @@ GEM
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
rails-html-sanitizer (1.4.2)
|
||||
loofah (~> 2.3)
|
||||
rails-perftest (0.0.7)
|
||||
railties (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
railties (5.2.6)
|
||||
actionpack (= 5.2.6)
|
||||
activesupport (= 5.2.6)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.1)
|
||||
rb-fsevent (0.10.3)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.0)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rdiscount (2.2.0.2)
|
||||
recaptcha (5.5.0)
|
||||
json
|
||||
redcarpet (3.5.0)
|
||||
regexp_parser (1.7.1)
|
||||
redcarpet (3.5.1)
|
||||
regexp_parser (1.8.2)
|
||||
request_store (1.5.0)
|
||||
rack (>= 1.4)
|
||||
rexml (3.2.5)
|
||||
right_aws_api (0.3.5)
|
||||
right_cloud_api_base (>= 0.2.6)
|
||||
right_cloud_api_base (0.2.6)
|
||||
@@ -252,28 +270,40 @@ GEM
|
||||
net-http-persistent (~> 2.9)
|
||||
redcarpet (>= 3.0.0)
|
||||
ruby-hmac (>= 0.4.0)
|
||||
rubocop (0.70.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
rubocop (1.12.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.6)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.2.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 1.7)
|
||||
rubocop-performance (1.3.0)
|
||||
rubocop (>= 0.68.0)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.4.1)
|
||||
parser (>= 2.7.1.5)
|
||||
rubocop-performance (1.10.2)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.9.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-shopify (2.0.1)
|
||||
rubocop (~> 1.11)
|
||||
ruby-hmac (0.4.0)
|
||||
ruby-openid (2.9.2)
|
||||
ruby-openid-apps-discovery (1.2.0)
|
||||
ruby-openid (>= 2.1.7)
|
||||
ruby-prof (1.3.2)
|
||||
ruby-progressbar (1.10.1)
|
||||
rubyzip (2.3.0)
|
||||
ruby-prof (1.4.2)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.3.2)
|
||||
sass (3.7.4)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sassc (2.3.0)
|
||||
sassc (2.4.0)
|
||||
ffi (~> 1.9)
|
||||
sassc-rails (2.1.2)
|
||||
railties (>= 4.0.0)
|
||||
@@ -284,15 +314,15 @@ GEM
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
sentry-raven (3.0.4)
|
||||
sentry-raven (3.1.2)
|
||||
faraday (>= 1.0)
|
||||
simplecov (0.18.5)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
simplecov-html (0.12.2)
|
||||
skylight (4.3.1)
|
||||
skylight-core (= 4.3.1)
|
||||
skylight-core (4.3.1)
|
||||
simplecov-html (0.12.3)
|
||||
skylight (4.3.2)
|
||||
skylight-core (= 4.3.2)
|
||||
skylight-core (4.3.2)
|
||||
activesupport (>= 4.2.0)
|
||||
spring (2.1.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
@@ -301,32 +331,32 @@ GEM
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
sprockets-rails (3.2.2)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.2)
|
||||
terrapin (0.6.0)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
thor (1.0.1)
|
||||
thor (1.1.0)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.10)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (1.2.7)
|
||||
tzinfo (1.2.9)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo-data (1.2020.1)
|
||||
tzinfo-data (1.2021.1)
|
||||
tzinfo (>= 1.0.0)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.6.1)
|
||||
unicode-display_width (2.0.0)
|
||||
web-console (3.7.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.7.2)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
will_paginate (3.3.0)
|
||||
@@ -377,8 +407,10 @@ DEPENDENCIES
|
||||
rdiscount (= 2.2.0.2)
|
||||
recaptcha (~> 5.5.0)
|
||||
right_aws_api (~> 0.3.5)
|
||||
rubocop (~> 0.70.0)
|
||||
rubocop
|
||||
rubocop-performance
|
||||
rubocop-rails
|
||||
rubocop-shopify
|
||||
ruby-openid (~> 2.9)
|
||||
ruby-prof
|
||||
sass
|
||||
@@ -403,4 +435,4 @@ RUBY VERSION
|
||||
ruby 2.4.6p354
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
2.2.26
|
||||
|
||||
@@ -9,7 +9,8 @@ module ApplicationCable
|
||||
private
|
||||
|
||||
def find_verified_user
|
||||
User.find(cookies.signed["user_id"])
|
||||
reject_unauthorized_connection if cookies.signed["user_id"].nil?
|
||||
User.find(cookies.signed["user_id"].id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
reject_unauthorized_connection
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class ConcurrentEditingChannel < ApplicationCable::Channel
|
||||
|
||||
def subscribed
|
||||
# Called first to connect user to the channel.
|
||||
stream_from "concurrent_editing_channel:#{params[:mapSlug]}"
|
||||
stream_from("concurrent_editing_channel:#{params[:mapSlug]}")
|
||||
end
|
||||
|
||||
def unsubscribed
|
||||
@@ -12,6 +12,6 @@ class ConcurrentEditingChannel < ApplicationCable::Channel
|
||||
|
||||
def sync(changes)
|
||||
# Responsible for broadcasting the updated warpables or simply images to the user's connected on this channel.
|
||||
ActionCable.server.broadcast "concurrent_editing_channel:#{changes['map_slug']}", changes
|
||||
ActionCable.server.broadcast("concurrent_editing_channel:#{changes["map_slug"]}", changes)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class AnnotationsController < ApplicationController
|
||||
before_action :find_map
|
||||
|
||||
def index
|
||||
render file: 'annotations/index.json.erb', content_type: 'application/json'
|
||||
render(file: 'annotations/index.json.erb', content_type: 'application/json')
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -20,38 +20,38 @@ class AnnotationsController < ApplicationController
|
||||
style: geojson[:properties][:style]
|
||||
)
|
||||
@annotation.user_id = current_user.id if logged_in?
|
||||
redirect_to map_annotation_url(@map, @annotation) if @annotation.save
|
||||
redirect_to(map_annotation_url(@map, @annotation)) if @annotation.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@annotation = Annotation.find params[:id]
|
||||
render file: 'annotations/show.json.erb', content_type: 'application/json'
|
||||
@annotation = Annotation.find(params[:id])
|
||||
render(file: 'annotations/show.json.erb', content_type: 'application/json')
|
||||
end
|
||||
|
||||
def update
|
||||
@annotation = Annotation.find params[:id]
|
||||
@annotation = Annotation.find(params[:id])
|
||||
geojson = params[:annotation]
|
||||
return if @annotation.user_id.nil? || current_user.can_edit?(@annotation)
|
||||
|
||||
Annotation.update(@annotation.id,
|
||||
coordinates: geojson[:geometry][:coordinates],
|
||||
text: geojson[:properties][:textContent],
|
||||
style: geojson[:properties][:style])
|
||||
render file: 'annotations/update.json.erb',
|
||||
content_type: 'application/json'
|
||||
coordinates: geojson[:geometry][:coordinates],
|
||||
text: geojson[:properties][:textContent],
|
||||
style: geojson[:properties][:style])
|
||||
render(file: 'annotations/update.json.erb',
|
||||
content_type: 'application/json')
|
||||
end
|
||||
|
||||
def destroy
|
||||
@annotation = Annotation.find params[:id]
|
||||
@annotation = Annotation.find(params[:id])
|
||||
# if current_user.can_delete?(@annotation)
|
||||
@annotation.delete
|
||||
head :ok
|
||||
head(:ok)
|
||||
# end
|
||||
end
|
||||
|
||||
def find_map
|
||||
@map = Map.find params[:map_id]
|
||||
@map = Map.find(params[:map_id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
|
||||
unless logged_in?
|
||||
path_info = request.env['PATH_INFO']
|
||||
flash[:warning] = 'You must be logged in to access this section'
|
||||
redirect_to '/login?back_to=' + path_info.to_param # halts request cycle
|
||||
redirect_to('/login?back_to=' + path_info.to_param) # halts request cycle
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base
|
||||
begin
|
||||
user_id && User.find(user_id) ? true : false
|
||||
rescue StandardError
|
||||
return false
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,24 +14,24 @@ class CommentsController < ApplicationController
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render partial: 'comments/comment', locals: { comment: @comment } }
|
||||
format.json { render json: @comment, status: :created }
|
||||
format.html { render(partial: 'comments/comment', locals: { comment: @comment }) }
|
||||
format.json { render(json: @comment, status: :created) }
|
||||
end
|
||||
|
||||
else
|
||||
# we intercept this message in /app/assets/javascripts/maps.js
|
||||
render plain: 'Login required.'
|
||||
render(plain: 'Login required.')
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@comment = Comment.find params[:id]
|
||||
@comment = Comment.find(params[:id])
|
||||
if logged_in? && current_user.can_edit?(@comment)
|
||||
@comment.update_attributes(comment_params)
|
||||
redirect_to @comment.map
|
||||
redirect_to(@comment.map)
|
||||
else
|
||||
flash[:error] = 'You do not have permissions to update that comment.'
|
||||
redirect_to '/login'
|
||||
redirect_to('/login')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ class CommentsController < ApplicationController
|
||||
else
|
||||
flash[:error] = 'You do not have permission to delete that comment.'
|
||||
end
|
||||
redirect_to @comment.map
|
||||
redirect_to(@comment.map)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -23,12 +23,12 @@ class ExportController < ApplicationController
|
||||
|
||||
# https://mapknitter.org/warps/yale-farm/yale-farm.jpg
|
||||
def jpg
|
||||
send_file 'public/warps/' + params[:id] + '/' + params[:id] + '.jpg'
|
||||
send_file('public/warps/' + params[:id] + '/' + params[:id] + '.jpg')
|
||||
end
|
||||
|
||||
# https://mapknitter.org/warps/yale-farm/yale-farm-geo.tif
|
||||
def geotiff
|
||||
send_file 'public/warps/' + params[:id] + '/' + params[:id] + '-geo.tif'
|
||||
send_file('public/warps/' + params[:id] + '/' + params[:id] + '-geo.tif')
|
||||
end
|
||||
|
||||
def cancel
|
||||
@@ -39,12 +39,12 @@ class ExportController < ApplicationController
|
||||
export.save
|
||||
if params[:exports]
|
||||
flash[:notice] = 'Export cancelled.'
|
||||
redirect_to '/exports'
|
||||
redirect_to('/exports')
|
||||
else
|
||||
render plain: 'cancelled'
|
||||
render(plain: 'cancelled')
|
||||
end
|
||||
else
|
||||
render plain: 'You must be logged in to export, unless the map is anonymous.'
|
||||
render(plain: 'You must be logged in to export, unless the map is anonymous.')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,19 +52,19 @@ class ExportController < ApplicationController
|
||||
map = Map.find_by(id: params[:id])
|
||||
export = map.export
|
||||
output = if export.present?
|
||||
if export.status == 'complete'
|
||||
'complete'
|
||||
elsif export.status == 'none'
|
||||
'export not running'
|
||||
elsif export.status == 'failed'
|
||||
'export failed'
|
||||
else
|
||||
export.status
|
||||
end
|
||||
else
|
||||
'export has not been run'
|
||||
if export.status == 'complete'
|
||||
'complete'
|
||||
elsif export.status == 'none'
|
||||
'export not running'
|
||||
elsif export.status == 'failed'
|
||||
'export failed'
|
||||
else
|
||||
export.status
|
||||
end
|
||||
else
|
||||
'export has not been run'
|
||||
end
|
||||
render plain: output, layout: false
|
||||
render(plain: output, layout: false)
|
||||
end
|
||||
|
||||
def status
|
||||
@@ -72,12 +72,12 @@ class ExportController < ApplicationController
|
||||
if export = map.export
|
||||
if export.export_url.present?
|
||||
status_response = ExporterClient.new(export.export_url).status
|
||||
render json: status_response
|
||||
render(json: status_response)
|
||||
else
|
||||
render json: export.to_json
|
||||
render(json: export.to_json)
|
||||
end
|
||||
else
|
||||
render json: { status: 'export has not been run' }
|
||||
render(json: { status: 'export has not been run' })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -93,12 +93,12 @@ class ExportController < ApplicationController
|
||||
map_id: params[:map_id],
|
||||
bands_string: 'default bands_string'
|
||||
)
|
||||
render json: export.to_json
|
||||
render(json: export.to_json)
|
||||
end
|
||||
|
||||
# for demoing remote url functionality during testing
|
||||
def external_url_test
|
||||
render json: Export.last.to_json
|
||||
render(json: Export.last.to_json)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,18 +8,18 @@ class FeedsController < ApplicationController
|
||||
.group('maps.id')
|
||||
.order('id DESC')
|
||||
.limit(20)
|
||||
render layout: false, template: 'feeds/all'
|
||||
render(layout: false, template: 'feeds/all')
|
||||
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
|
||||
end
|
||||
|
||||
def clean
|
||||
render layout: false, template: 'feeds/clean'
|
||||
render(layout: false, template: 'feeds/clean')
|
||||
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
|
||||
end
|
||||
|
||||
def license
|
||||
@maps = @maps.where(license: params[:id])
|
||||
render layout: false, template: 'feeds/license'
|
||||
render(layout: false, template: 'feeds/license')
|
||||
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
|
||||
end
|
||||
|
||||
@@ -33,17 +33,17 @@ class FeedsController < ApplicationController
|
||||
images += map.warpables
|
||||
end
|
||||
@feed = (@maps + images).sort_by(&:created_at)
|
||||
render layout: false, template: 'feeds/author'
|
||||
render(layout: false, template: 'feeds/author')
|
||||
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
|
||||
end
|
||||
|
||||
def tag
|
||||
@tag = Tag.find_by_name params[:id]
|
||||
@tag = Tag.find_by_name(params[:id])
|
||||
@maps = @tag.maps.paginate(page: params[:page], per_page: 24)
|
||||
render layout: false, template: 'feeds/tag'
|
||||
render(layout: false, template: 'feeds/tag')
|
||||
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
|
||||
rescue NoMethodError
|
||||
render plain: "No maps with tag #{params[:id]}"
|
||||
render(plain: "No maps with tag #{params[:id]}")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -10,9 +10,9 @@ class FrontUiController < ApplicationController
|
||||
# TODO: these could use optimization but are better than prev:
|
||||
tag = Tag.where(name: 'featured').first
|
||||
@mappers = if tag
|
||||
User.where(login: tag.maps.collect(&:author))
|
||||
else
|
||||
[]
|
||||
User.where(login: tag.maps.collect(&:author))
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class FrontUiController < ApplicationController
|
||||
|
||||
session[:lat] = lat
|
||||
session[:lon] = lon
|
||||
head 200, content_type: "text/html"
|
||||
head(200, content_type: "text/html")
|
||||
end
|
||||
|
||||
def about
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'open-uri'
|
||||
class ImagesController < ApplicationController
|
||||
rescue_from Errno::ENOENT, Errno::ETIMEDOUT,
|
||||
OpenURI::HTTPError, Timeout::Error,
|
||||
with: :url_upload_not_found
|
||||
OpenURI::HTTPError, Timeout::Error,
|
||||
with: :url_upload_not_found
|
||||
protect_from_forgery except: %i(update delete)
|
||||
# Convert model to json without including root name. Eg. 'warpable'
|
||||
ActiveRecord::Base.include_root_in_json = false
|
||||
@@ -14,10 +14,10 @@ class ImagesController < ApplicationController
|
||||
if params[:url][0..42] == 'https://s3.amazonaws.com/grassrootsmapping/'
|
||||
url = URI.parse(params[:url])
|
||||
result = Net::HTTP.get_response(url)
|
||||
send_data result.body, type: result.content_type, disposition: 'inline'
|
||||
send_data(result.body, type: result.content_type, disposition: 'inline')
|
||||
end
|
||||
else
|
||||
redirect_to params[:url]
|
||||
redirect_to(params[:url])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,46 +32,46 @@ class ImagesController < ApplicationController
|
||||
map.save
|
||||
respond_to do |format|
|
||||
if @warpable.save
|
||||
format.html { render json: [@warpable.fup_json].to_json, content_type: 'text/html' }
|
||||
format.json { render json: { files: [@warpable.fup_json] }, status: :created, location: @warpable.image.url }
|
||||
format.html { render(json: [@warpable.fup_json].to_json, content_type: 'text/html') }
|
||||
format.json { render(json: { files: [@warpable.fup_json] }, status: :created, location: @warpable.image.url) }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: { files: [@warpable.fup_error_json] }, layout: false }
|
||||
format.html { render(action: 'new') }
|
||||
format.json { render(json: { files: [@warpable.fup_error_json] }, layout: false) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# mapknitter.org/import/<map-name>/?url=http://myurl.com/image.jpg
|
||||
def import
|
||||
map = Map.find_by_name params[:name]
|
||||
map = Map.find_by_name(params[:name])
|
||||
@warpable = Warpable.new
|
||||
@warpable.map_id = map.id
|
||||
@warpable.url = params[:url]
|
||||
map.updated_at = Time.now
|
||||
map.save
|
||||
if @warpable.save
|
||||
redirect_to '/maps/' + params[:name]
|
||||
redirect_to('/maps/' + params[:name])
|
||||
else
|
||||
flash[:notice] = 'Sorry, the image failed to import.'
|
||||
redirect_to '/map/edit/' + params[:name]
|
||||
redirect_to('/map/edit/' + params[:name])
|
||||
end
|
||||
end
|
||||
|
||||
def url_upload_not_found
|
||||
flash[:notice] = 'Sorry, the URL you provided was not valid.'
|
||||
redirect_to '/map/edit/' + params[:id]
|
||||
redirect_to('/map/edit/' + params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@image = Warpable.find params[:id]
|
||||
@image = Warpable.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @image.map(&:fup_json) }
|
||||
format.json { render(json: @image.map(&:fup_json)) }
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@warpable = Warpable.find params[:warpable_id]
|
||||
@warpable = Warpable.find(params[:warpable_id])
|
||||
|
||||
if Map.find(@warpable.map_id).anonymous? || logged_in?
|
||||
nodes = []
|
||||
@@ -94,11 +94,11 @@ class ImagesController < ApplicationController
|
||||
@warpable.save
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render html: 'success' }
|
||||
format.json { render json: @warpable.map.fetch_map_data }
|
||||
format.html { render(html: 'success') }
|
||||
format.json { render(json: @warpable.map.fetch_map_data) }
|
||||
end
|
||||
else
|
||||
render plain: 'You must be logged in to update the image, unless the map is anonymous.'
|
||||
render(plain: 'You must be logged in to update the image, unless the map is anonymous.')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -106,7 +106,7 @@ class ImagesController < ApplicationController
|
||||
@warpable = Warpable.find(params[:id])
|
||||
version = @warpable.versions.find(params[:version])
|
||||
version.reify&.save
|
||||
redirect_to @warpable.map
|
||||
redirect_to(@warpable.map)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -114,15 +114,15 @@ class ImagesController < ApplicationController
|
||||
if (logged_in? && current_user.can_edit?(@warpable.map)) || @warpable.map.anonymous?
|
||||
@warpable.destroy
|
||||
respond_to do |format|
|
||||
format.html { render html: { notice: 'Image was successfully destroyed.' } }
|
||||
format.json { render json: @warpable }
|
||||
format.html { render(html: { notice: 'Image was successfully destroyed.' }) }
|
||||
format.json { render(json: @warpable) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
msg = "You do not have privileges to delete this image"
|
||||
flash[:notice] = msg
|
||||
format.html { redirect_to @warpable.map }
|
||||
format.json { render json: msg, status: 401 }
|
||||
format.html { redirect_to(@warpable.map) }
|
||||
format.json { render(json: msg, status: 401) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class MapsController < ApplicationController
|
||||
|
||||
def index
|
||||
# show only maps with at least 1 image to reduce spammer interest
|
||||
redirect_to '/gallery'
|
||||
redirect_to('/gallery')
|
||||
# @maps = Map.page(params[:page])
|
||||
# .per_page(20)
|
||||
# .where(archived: false, password: '')
|
||||
@@ -26,7 +26,7 @@ class MapsController < ApplicationController
|
||||
|
||||
def map
|
||||
@maps = Map.map
|
||||
render layout: false
|
||||
render(layout: false)
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -46,10 +46,10 @@ class MapsController < ApplicationController
|
||||
end
|
||||
|
||||
if @map.save
|
||||
redirect_to "/maps/#{@map.slug}/edit"
|
||||
redirect_to("/maps/#{@map.slug}/edit")
|
||||
else
|
||||
flash.now[:errors] = @map.errors.full_messages
|
||||
render 'new'
|
||||
render('new')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ class MapsController < ApplicationController
|
||||
.sample(4)
|
||||
@unpaginated = true
|
||||
@users = @map.authors
|
||||
render layout: 'application'
|
||||
render(layout: 'application')
|
||||
end
|
||||
|
||||
def archive
|
||||
@@ -80,8 +80,8 @@ class MapsController < ApplicationController
|
||||
def embed
|
||||
@map.zoom ||= 12
|
||||
@embed = true
|
||||
response.headers.except! 'X-Frame-Options' # allow use of embed in iframes
|
||||
render template: 'maps/edit'
|
||||
response.headers.except!('X-Frame-Options') # allow use of embed in iframes
|
||||
render(template: 'maps/edit')
|
||||
end
|
||||
|
||||
def annotate
|
||||
@@ -102,7 +102,7 @@ class MapsController < ApplicationController
|
||||
|
||||
save_tags(@map)
|
||||
@map.save
|
||||
redirect_to action: 'show'
|
||||
redirect_to(action: 'show')
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -112,29 +112,29 @@ class MapsController < ApplicationController
|
||||
redirect_back(fallback_location: "/")
|
||||
else
|
||||
flash[:error] = 'Only admins or map owners may delete maps.'
|
||||
redirect_to @map
|
||||
redirect_to(@map)
|
||||
end
|
||||
end
|
||||
|
||||
# used by leaflet to fetch corner coords of each warpable
|
||||
def images
|
||||
render json: @map.warpables
|
||||
render(json: @map.warpables)
|
||||
end
|
||||
|
||||
# run the export
|
||||
def export
|
||||
@map = Map.find_by(id: params[:id])
|
||||
if logged_in? || Rails.env.development? || verify_recaptcha(model: @map, message: "ReCAPTCHA thinks you're not a human!")
|
||||
render plain: @map.run_export(current_user, params[:resolution].to_f)
|
||||
render(plain: @map.run_export(current_user, params[:resolution].to_f))
|
||||
else
|
||||
render plain: 'You must be logged in to export, unless the map is anonymous.'
|
||||
render(plain: 'You must be logged in to export, unless the map is anonymous.')
|
||||
end
|
||||
end
|
||||
|
||||
# render list of exports
|
||||
def exports
|
||||
@map = Map.find_by(id: params[:id])
|
||||
render partial: 'maps/exports', layout: false
|
||||
render(partial: 'maps/exports', layout: false)
|
||||
end
|
||||
|
||||
# list by region
|
||||
@@ -155,8 +155,8 @@ class MapsController < ApplicationController
|
||||
map.image_urls = map.warpables.map { |warpable| warpable.image.url }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { render 'maps/index', layout: 'application' }
|
||||
format.json { render json: @maps.to_json(methods: :image_urls) }
|
||||
format.html { render('maps/index', layout: 'application') }
|
||||
format.json { render(json: @maps.to_json(methods: :image_urls)) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -166,13 +166,13 @@ class MapsController < ApplicationController
|
||||
@maps = Map.where(password: '', license: params[:id])
|
||||
.order('updated_at DESC')
|
||||
.paginate(page: params[:page], per_page: 24)
|
||||
render 'maps/index', layout: 'application'
|
||||
render('maps/index', layout: 'application')
|
||||
end
|
||||
|
||||
def featured
|
||||
@title = 'Featured maps'
|
||||
@maps = Map.featured.paginate(page: params[:page], per_page: 24)
|
||||
render 'maps/index', layout: 'application'
|
||||
render('maps/index', layout: 'application')
|
||||
end
|
||||
|
||||
def search
|
||||
@@ -188,12 +188,12 @@ class MapsController < ApplicationController
|
||||
.except(:styles, :email)
|
||||
@authors = User.where(login: Map.featured.collect(&:author))
|
||||
.paginate(page: params[:mappers], per_page: 20)
|
||||
format.html { render 'front_ui/gallery', layout: 'application' }
|
||||
format.html { render('front_ui/gallery', layout: 'application') }
|
||||
else
|
||||
@title = "Search results for '#{data}'"
|
||||
@maps = Map.search(data).paginate(page: params[:page], per_page: 24)
|
||||
format.html { render 'front_ui/gallery', layout: 'application' }
|
||||
format.json { render json: @maps }
|
||||
format.html { render('front_ui/gallery', layout: 'application') }
|
||||
format.json { render(json: @maps) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class SessionsController < ApplicationController
|
||||
|
||||
def new
|
||||
if logged_in?
|
||||
redirect_to "/"
|
||||
redirect_to("/")
|
||||
else
|
||||
@referer = params[:back_to]
|
||||
end
|
||||
@@ -21,25 +21,25 @@ class SessionsController < ApplicationController
|
||||
openid_url = CGI.unescape(open_id)
|
||||
# here it is localhost:3000/people/admin/identity for admin
|
||||
# possibly user is providing the whole URL
|
||||
if openid_url.include? "publiclab"
|
||||
if openid_url.include? "http"
|
||||
if openid_url.include?("publiclab")
|
||||
if openid_url.include?("http")
|
||||
# params[:subaction] contains the value of the provider
|
||||
# provider implies ['github', 'google_oauth2', 'twitter', 'facebook']
|
||||
url = if params[:subaction]
|
||||
# provider based authentication
|
||||
openid_url + "/" + params[:subaction]
|
||||
else
|
||||
# form based authentication
|
||||
openid_url
|
||||
# provider based authentication
|
||||
openid_url + "/" + params[:subaction]
|
||||
else
|
||||
# form based authentication
|
||||
openid_url
|
||||
end
|
||||
end
|
||||
else
|
||||
url = if params[:subaction]
|
||||
# provider based authentication
|
||||
@openid_url_base + openid_url + @openid_url_suffix + "/" + params[:subaction]
|
||||
else
|
||||
# form based authentication
|
||||
@openid_url_base + openid_url + @openid_url_suffix
|
||||
# provider based authentication
|
||||
@openid_url_base + openid_url + @openid_url_suffix + "/" + params[:subaction]
|
||||
else
|
||||
# form based authentication
|
||||
@openid_url_base + openid_url + @openid_url_suffix
|
||||
end
|
||||
end
|
||||
openid_authentication(url, back_to)
|
||||
@@ -52,14 +52,14 @@ class SessionsController < ApplicationController
|
||||
successful_login('', nil)
|
||||
else
|
||||
flash[:error] = "Forbidden"
|
||||
redirect_to "/"
|
||||
redirect_to("/")
|
||||
end
|
||||
end
|
||||
|
||||
def logout
|
||||
session[:user_id] = nil
|
||||
flash[:success] = "You have successfully logged out."
|
||||
redirect_to '/' + '?_=' + Time.now.to_i.to_s
|
||||
redirect_to('/' + '?_=' + Time.now.to_i.to_s)
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -88,13 +88,13 @@ class SessionsController < ApplicationController
|
||||
@user.save!
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
puts e
|
||||
failed_login "User can not be associated to local account. Probably the account already exists with different capitalization!"
|
||||
failed_login("User can not be associated to local account. Probably the account already exists with different capitalization!")
|
||||
return
|
||||
end
|
||||
end
|
||||
nonce = params[:n]
|
||||
if nonce
|
||||
tmp = Sitetmp.find_by nonce: nonce
|
||||
tmp = Sitetmp.find_by(nonce: nonce)
|
||||
if tmp
|
||||
data = tmp.attributes
|
||||
data.delete("nonce")
|
||||
@@ -105,12 +105,12 @@ class SessionsController < ApplicationController
|
||||
end
|
||||
@current_user = @user
|
||||
if site
|
||||
successful_login back_to, site.id
|
||||
successful_login(back_to, site.id)
|
||||
else
|
||||
successful_login back_to, nil
|
||||
successful_login(back_to, nil)
|
||||
end
|
||||
else
|
||||
failed_login result.message
|
||||
failed_login(result.message)
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -120,19 +120,19 @@ class SessionsController < ApplicationController
|
||||
|
||||
def failed_login(message = "Authentication failed.")
|
||||
flash[:danger] = message
|
||||
redirect_to '/'
|
||||
redirect_to('/')
|
||||
end
|
||||
|
||||
def successful_login(back_to, id)
|
||||
session[:user_id] = @current_user.id
|
||||
flash[:success] = "You have successfully logged in."
|
||||
if id
|
||||
redirect_to '/sites/' + id.to_s + '/upload'
|
||||
redirect_to('/sites/' + id.to_s + '/upload')
|
||||
else
|
||||
if back_to
|
||||
redirect_to back_to
|
||||
redirect_to(back_to)
|
||||
else
|
||||
redirect_to '/sites'
|
||||
redirect_to('/sites')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,22 +5,22 @@ class TagsController < ApplicationController
|
||||
@map = Map.find_by(slug: params[:map_id])
|
||||
if logged_in?
|
||||
save_tags(@map)
|
||||
redirect_to @map
|
||||
redirect_to(@map)
|
||||
else
|
||||
flash[:error] = 'You must be logged in to add tags'
|
||||
redirect_to "/login?back_to=/maps/#{@map.slug}"
|
||||
redirect_to("/login?back_to=/maps/#{@map.slug}")
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@tag = Tag.find_by_name params[:id]
|
||||
@tag = Tag.find_by_name(params[:id])
|
||||
@maps = @tag.maps.paginate(page: params[:page], per_page: 24)
|
||||
@title = "Maps tagged with ' #{@tag.name} '"
|
||||
tag = Tag.where(name: 'featured').first # note that this is not a join table but the .maps method still works
|
||||
@unpaginated = true
|
||||
@authors = User.where(login: tag.maps.collect(&:author)) if tag
|
||||
@authors ||= []
|
||||
render template: 'tags/index'
|
||||
render(template: 'tags/index')
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -29,10 +29,10 @@ class TagsController < ApplicationController
|
||||
if logged_in? && current_user.can_delete?(@tag)
|
||||
@tag.delete
|
||||
flash[:notice] = "Tag #{@tag.name} deleted."
|
||||
redirect_to @tag.map
|
||||
redirect_to(@tag.map)
|
||||
else
|
||||
flash[:error] = 'You must be logged in to delete tags.'
|
||||
redirect_to '/login'
|
||||
redirect_to('/login')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class UsersController < ApplicationController
|
||||
.group('maps.user_id')
|
||||
.order(sort_column + ' ' + sort_direction)
|
||||
.paginate(page: params[:page], per_page: 24)
|
||||
render 'users/index'
|
||||
render('users/index')
|
||||
end
|
||||
|
||||
private
|
||||
@@ -30,6 +30,6 @@ class UsersController < ApplicationController
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:login, :email, :name,
|
||||
:password, :password_confirmation)
|
||||
:password, :password_confirmation)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,6 @@ class UtilityController < ApplicationController
|
||||
# /z/x/y.png
|
||||
# /z/x/(2*z-y-1).png
|
||||
y = 2**params[:z].to_i - params[:y].to_i - 1
|
||||
redirect_to "/tms/#{params[:id]}/#{params[:z]}/#{params[:x]}/#{y}.png"
|
||||
redirect_to("/tms/#{params[:id]}/#{params[:z]}/#{params[:x]}/#{y}.png")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,13 +19,13 @@ module ApplicationHelper
|
||||
unless object.nil? || object.errors.blank?
|
||||
html << "<div class='alert alert-error #{object.class.name.humanize.downcase}Errors'>\n"
|
||||
html << if message.blank?
|
||||
if object.new_record?
|
||||
"\t\t<h5>There was a problem creating the #{object.class.name.humanize.downcase}</h5>\n"
|
||||
else
|
||||
"\t\t<h5>There was a problem updating the #{object.class.name.humanize.downcase}</h5>\n"
|
||||
end
|
||||
else
|
||||
"<h5>#{message}</h5>"
|
||||
if object.new_record?
|
||||
"\t\t<h5>There was a problem creating the #{object.class.name.humanize.downcase}</h5>\n"
|
||||
else
|
||||
"\t\t<h5>There was a problem updating the #{object.class.name.humanize.downcase}</h5>\n"
|
||||
end
|
||||
else
|
||||
"<h5>#{message}</h5>"
|
||||
end
|
||||
html << "\t\t<ul>\n"
|
||||
object.errors.full_messages.each do |error|
|
||||
@@ -50,6 +50,6 @@ module ApplicationHelper
|
||||
def sortable(column, title = nil)
|
||||
title ||= column.titleize
|
||||
direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
|
||||
link_to title, sort: column, direction: direction
|
||||
link_to(title, sort: column, direction: direction)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,11 +43,11 @@ module UsersHelper
|
||||
def link_to_user(user, options = {})
|
||||
raise "Invalid user" unless user
|
||||
|
||||
options.reverse_merge! content_method: :login, title_method: :login, class: :nickname
|
||||
options.reverse_merge!(content_method: :login, title_method: :login, class: :nickname)
|
||||
content_text = options.delete(:content_text)
|
||||
content_text ||= user.send(options.delete(:content_method))
|
||||
options[:title] ||= user.send(options.delete(:title_method))
|
||||
link_to h(content_text), user_path(user), options
|
||||
link_to(h(content_text), user_path(user), options)
|
||||
end
|
||||
|
||||
#
|
||||
@@ -65,11 +65,11 @@ module UsersHelper
|
||||
def link_to_login_with_IP(content_text = nil, options = {}) # rubocop:disable Naming/MethodName
|
||||
ip_addr = request.remote_ip
|
||||
content_text ||= ip_addr
|
||||
options.reverse_merge! title: ip_addr
|
||||
options.reverse_merge!(title: ip_addr)
|
||||
if tag = options.delete(:tag)
|
||||
content_tag tag, h(content_text), options
|
||||
content_tag(tag, h(content_text), options)
|
||||
else
|
||||
link_to h(content_text), login_path, options
|
||||
link_to(h(content_text), login_path, options)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,12 +79,12 @@ module UsersHelper
|
||||
#
|
||||
def link_to_current_user(options = {})
|
||||
if current_user
|
||||
link_to_user current_user, options
|
||||
link_to_user(current_user, options)
|
||||
else
|
||||
content_text = options.delete(:content_text) || 'not signed in'
|
||||
# kill ignored options from link_to_user
|
||||
%i(content_method title_method).each { |opt| options.delete(opt) }
|
||||
link_to_login_with_IP content_text, options
|
||||
link_to_login_with_IP(content_text, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Export < ApplicationRecord
|
||||
|
||||
# currently exporting?
|
||||
def running?
|
||||
!(%w(complete none failed).include? status)
|
||||
!%w(complete none failed).include?(status)
|
||||
end
|
||||
|
||||
def self.average_cm_per_pixel
|
||||
@@ -52,12 +52,12 @@ class Export < ApplicationRecord
|
||||
|
||||
def self.export_count
|
||||
Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?',
|
||||
(DateTime.now - 24.hours).to_s(:db)).count
|
||||
(DateTime.now - 24.hours).to_s(:db)).count
|
||||
end
|
||||
|
||||
# all exports currently running
|
||||
def self.exporting
|
||||
Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?',
|
||||
(DateTime.now - 24.hours).to_s(:db))
|
||||
(DateTime.now - 24.hours).to_s(:db))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -150,7 +150,7 @@ class Map < ApplicationRecord
|
||||
return [] if lat.to_f == 0.0 || lon.to_f == 0.0
|
||||
|
||||
Map.where('id != ? AND lat > ? AND lat < ? AND lon > ? AND lon < ?',
|
||||
id, lat - dist, lat + dist, lon - dist, lon + dist)
|
||||
id, lat - dist, lat + dist, lon - dist, lon + dist)
|
||||
.limit(10)
|
||||
end
|
||||
|
||||
@@ -240,14 +240,14 @@ class Map < ApplicationRecord
|
||||
new_export = Export.new(map_id: id) unless export
|
||||
|
||||
Exporter.run_export(user,
|
||||
resolution,
|
||||
export || new_export,
|
||||
id,
|
||||
slug,
|
||||
Rails.root.to_s,
|
||||
average_scale,
|
||||
placed_warpables,
|
||||
key)
|
||||
resolution,
|
||||
export || new_export,
|
||||
id,
|
||||
slug,
|
||||
Rails.root.to_s,
|
||||
average_scale,
|
||||
placed_warpables,
|
||||
key)
|
||||
end
|
||||
|
||||
def after_create
|
||||
|
||||
@@ -27,11 +27,11 @@ class User < ApplicationRecord
|
||||
#
|
||||
|
||||
def login=(value)
|
||||
write_attribute :login, (value ? value.downcase : nil)
|
||||
write_attribute(:login, (value ? value.downcase : nil))
|
||||
end
|
||||
|
||||
def email=(value)
|
||||
write_attribute :email, (value ? value.downcase : nil)
|
||||
write_attribute(:email, (value ? value.downcase : nil))
|
||||
end
|
||||
|
||||
def last_action
|
||||
|
||||
@@ -7,12 +7,12 @@ class Warpable < ApplicationRecord
|
||||
# Paperclip; config and production/development specific configs
|
||||
# in /config/initializers/paperclip.rb
|
||||
has_attached_file :image,
|
||||
s3_protocol: 'https',
|
||||
styles: {
|
||||
medium: "500x375",
|
||||
small: "240x180",
|
||||
thumb: "100x100>"
|
||||
}
|
||||
s3_protocol: 'https',
|
||||
styles: {
|
||||
medium: "500x375",
|
||||
small: "240x180",
|
||||
thumb: "100x100>",
|
||||
}
|
||||
|
||||
validates_attachment_content_type :image, content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
|
||||
|
||||
@@ -23,7 +23,7 @@ class Warpable < ApplicationRecord
|
||||
|
||||
# overriding JSON formatting for Leaflet.DistortableImage
|
||||
def as_json(options = {})
|
||||
json = super options
|
||||
json = super(options)
|
||||
json[:src] = image.url
|
||||
json[:srcmedium] = image.url(:medium)
|
||||
json[:nodes] = nodes_array
|
||||
@@ -70,14 +70,14 @@ class Warpable < ApplicationRecord
|
||||
nodes = nodes_array
|
||||
nodes.each_with_index do |node, index|
|
||||
nextnode = if index < nodes.length - 1
|
||||
nodes[index + 1]
|
||||
else
|
||||
nodes[0]
|
||||
nodes[index + 1]
|
||||
else
|
||||
nodes[0]
|
||||
end
|
||||
last = if index.positive?
|
||||
nodes[index - 1]
|
||||
else
|
||||
nodes[nodes.length - 1]
|
||||
nodes[index - 1]
|
||||
else
|
||||
nodes[nodes.length - 1]
|
||||
end
|
||||
scale = 20_037_508.34
|
||||
# inefficient but workable, we don't use this that often:
|
||||
@@ -128,7 +128,7 @@ class Warpable < ApplicationRecord
|
||||
end
|
||||
|
||||
def nodes_array
|
||||
Node.find nodes.split(',')
|
||||
Node.find(nodes.split(','))
|
||||
end
|
||||
|
||||
# allow uploads via URL
|
||||
@@ -155,12 +155,12 @@ class Warpable < ApplicationRecord
|
||||
end
|
||||
|
||||
def user_id
|
||||
Map.find map_id
|
||||
Map.find(map_id)
|
||||
map.user_id
|
||||
end
|
||||
|
||||
# adjust filename behavior of Paperclip after migrating from attachment_fu
|
||||
Paperclip.interpolates :custom_filename do |attachment, style|
|
||||
Paperclip.interpolates(:custom_filename) do |attachment, style|
|
||||
if style == :original
|
||||
basename(attachment, style) # generate hash path here
|
||||
else
|
||||
|
||||
@@ -23,6 +23,6 @@ production:
|
||||
|
||||
test:
|
||||
<<: *default
|
||||
username:
|
||||
password:
|
||||
username: <%= ENV['DB_USER'] || 'root' %>
|
||||
password: <%= ENV['DB_PASS'] || 'root' %>
|
||||
database: mapknitter_test
|
||||
|
||||
@@ -8,11 +8,11 @@ FROM ruby:2.4.6-stretch
|
||||
ENV HOME /root
|
||||
|
||||
# Backported GDAL
|
||||
RUN echo "deb http://packages.laboratoriopublico.org/publiclab/ stretch main" > /etc/apt/sources.list.d/publiclab.list
|
||||
RUN echo "deb [trusted=yes] http://packages.laboratoriopublico.org/publiclab/ stretch main" > /etc/apt/sources.list.d/publiclab.list
|
||||
|
||||
# We bring our own key to verify our packages
|
||||
COPY sysadmin.publiclab.key /app/sysadmin.publiclab.key
|
||||
RUN apt-key add /app/sysadmin.publiclab.key
|
||||
RUN apt-key add /app/sysadmin.publiclab.key > /dev/null 2>&1
|
||||
|
||||
# Install dependencies for Mapknitter
|
||||
RUN apt-get update -qq && apt-get install -y \
|
||||
@@ -51,6 +51,7 @@ RUN git config --global url."https://".insteadOf git://
|
||||
COPY . /app/
|
||||
WORKDIR /app
|
||||
|
||||
RUN gem install bundler
|
||||
RUN bundle install
|
||||
|
||||
CMD [ "sh", "/app/start.sh" ]
|
||||
@@ -8,11 +8,11 @@ FROM ruby:2.4.6-stretch
|
||||
ENV HOME /root
|
||||
|
||||
# Backported GDAL
|
||||
RUN echo "deb http://packages.laboratoriopublico.org/publiclab/ stretch main" > /etc/apt/sources.list.d/publiclab.list
|
||||
RUN echo "deb [trusted=yes] http://packages.laboratoriopublico.org/publiclab/ stretch main" > /etc/apt/sources.list.d/publiclab.list
|
||||
|
||||
# We bring our own key to verify our packages
|
||||
COPY sysadmin.publiclab.key /app/sysadmin.publiclab.key
|
||||
RUN apt-key add /app/sysadmin.publiclab.key
|
||||
RUN apt-key add /app/sysadmin.publiclab.key > /dev/null 2>&1
|
||||
|
||||
# Install dependencies for Mapknitter
|
||||
RUN apt-get update -qq && apt-get install --allow-unauthenticated -y --no-install-recommends \
|
||||
@@ -41,6 +41,6 @@ WORKDIR /app
|
||||
RUN apt-get clean && \
|
||||
apt-get autoremove -y
|
||||
|
||||
RUN bundle install
|
||||
RUN gem install bundler && bundle install
|
||||
|
||||
CMD [ "sh", "/app/start.sh" ]
|
||||
Reference in New Issue
Block a user