This commit is contained in:
Devin Howard 2017-10-16 18:15:47 -07:00
parent 2dc6a948c6
commit fc701cf485
33 changed files with 82 additions and 29 deletions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative 'boot' require_relative 'boot'
require 'csv' require 'csv'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative 'application'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
@ -24,7 +25,7 @@ Rails.application.configure do
# Print deprecation notices to the Rails logger # Print deprecation notices to the Rails logger
config.active_support.deprecation = :log config.active_support.deprecation = :log
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews" config.action_mailer.preview_path = Rails.root.join('spec', 'mailers', 'previews')
# Expands the lines which load the assets # Expands the lines which load the assets
config.assets.debug = false config.assets.debug = false

View file

@ -1,9 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
config.action_cable.allowed_request_origins = ['https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'] config.action_cable.allowed_request_origins = [
'https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'
]
# log to stdout # log to stdout
logger = Logger.new(STDOUT) logger = Logger.new(STDOUT)

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Metamaps::Application.configure do Metamaps::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
$codes = [] $codes = []
if ActiveRecord::Base.connection.data_source_exists? 'users' if ActiveRecord::Base.connection.data_source_exists? 'users'
$codes = ActiveRecord::Base.connection $codes = ActiveRecord::Base.connection

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
ActiveModelSerializers.config.adapter = :json ActiveModelSerializers.config.adapter = :json

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do # ActiveSupport::Reloader.to_prepare do

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
config.assets.version = '2.0' config.assets.version = '2.0'
@ -9,5 +10,7 @@ Rails.application.configure do
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
config.assets.precompile += %w( application-secret.css application-secret.js webpacked/metamaps.bundle.js ) config.assets.precompile += %w[
application-secret.css application-secret.js webpacked/metamaps.bundle.js
]
end end

View file

@ -1,7 +1,10 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # You can add backtrace silencers for libraries that you're using but don't wish
# to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # You can also remove all the silencers if you're trying to debug a problem that
# might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers! # Rails.backtrace_cleaner.remove_silencers!

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars. # Specify a serializer for the signed and encrypted cookie jars.

View file

@ -1,9 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.config.middleware.insert_before 0, Rack::Cors do Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do allow do
origins '*' origins '*'
resource '/api/*', resource '/api/*',
headers: :any, headers: :any,
methods: [:get, :post, :put, :delete, :options, :head] methods: %i[get post put delete options head]
end end
end end

View file

@ -1,5 +1,8 @@
# frozen_string_literal: true
module ExceptionNotifierInDelayedJob module ExceptionNotifierInDelayedJob
def handle_failed_job(job, error) def handle_failed_job(job, error)
super
ExceptionNotfier.notify_exception(error) ExceptionNotfier.notify_exception(error)
end end
end end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth. # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model. # Many of these configuration options can be set straight in your model.
Devise.setup do |config| Devise.setup do |config|

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Doorkeeper.configure do Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins) # Change the ORM that doorkeeper will use (needs plugins)
orm :active_record orm :active_record

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'exception_notification/rails' require 'exception_notification/rails'
module ExceptionNotifier module ExceptionNotifier
@ -50,11 +51,11 @@ ExceptionNotification.configure do |config|
# Ignore additional exception types. # Ignore additional exception types.
# ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and # ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and
# ActionController::RoutingError are already added. # ActionController::RoutingError are already added.
config.ignored_exceptions += %w( config.ignored_exceptions += %w[
ActionView::TemplateError CustomError UnauthorizedException ActionView::TemplateError CustomError UnauthorizedException
InvalidArgumentException InvalidEntityException InvalidRequestException InvalidArgumentException InvalidEntityException InvalidRequestException
NotFoundException ValidationException NotFoundException ValidationException
) ]
# Adds a condition to decide when an exception must be ignored or not. # Adds a condition to decide when an exception must be ignored or not.
# The ignore_if method can be invoked multiple times to add extra conditions. # The ignore_if method can be invoked multiple times to add extra conditions.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.

View file

@ -1,3 +1,12 @@
# frozen_string_literal: true
TESTER_EMAILS = %w[
connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com
ishanshapiro@gmail.com
].freeze
# rubocop:disable Style/PredicateName
def is_tester(user) def is_tester(user)
user && %w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email) user && TESTER_EMAILS.include?(user.email)
end end
# rubocop:enable Style/PredicateName

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Kaminari.configure do |config| Kaminari.configure do |config|
# config.default_per_page = 25 # config.default_per_page = 25
# config.max_per_page = nil # config.max_per_page = nil

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 5.0 upgrade. # This file contains migration options to ease your Rails 5.0 upgrade.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 5.1 upgrade. # This file contains migration options to ease your Rails 5.1 upgrade.

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Paperclip::Attachment.default_options[:url] = ':s3_domain_url' Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module Rack module Rack
class Attack class Attack
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies. # Your secret key for verifying the integrity of signed cookies.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_Metamaps_session' Rails.application.config.session_store :cookie_store, key: '_Metamaps_session'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
METAMAPS_VERSION = '3.5' METAMAPS_VERSION = '3.5'
METAMAPS_BUILD = `git log -1 --pretty=%H`.chomp[0..11].freeze METAMAPS_BUILD = `git log -1 --pretty=%H`.chomp[0..11].freeze
METAMAPS_LAST_UPDATED = `git log -1 --pretty='%ad'`.split(' ').values_at(1, 2, 4).join(' ').freeze METAMAPS_LAST_UPDATED = `git log -1 --pretty='%ad'`.split(' ').values_at(1, 2, 4).join(' ').freeze

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Warden::Manager.after_set_user do |user, auth, opts| Warden::Manager.after_set_user do |user, auth, opts|
scope = opts[:scope] scope = opts[:scope]
auth.cookies.signed["#{scope}.id"] = user.id auth.cookies.signed["#{scope}.id"] = user.id

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains settings for ActionController::ParamsWrapper which # This file contains settings for ActionController::ParamsWrapper which

View file

@ -1,19 +1,21 @@
# frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum. # The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record. # and maximum; this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
threads threads_count, threads_count threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# #
port ENV.fetch("PORT") { 3000 } port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in. # Specifies the `environment` that Puma will run in.
# #
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode. # Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together # Workers are forked webserver processes. If using threads and workers together

View file

@ -1,4 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
Metamaps::Application.routes.draw do Metamaps::Application.routes.draw do
use_doorkeeper use_doorkeeper
mount ActionCable.server => '/cable' mount ActionCable.server => '/cable'
@ -16,7 +18,7 @@ Metamaps::Application.routes.draw do
end end
get :explore, to: redirect('/') get :explore, to: redirect('/')
resources :maps, except: [:index, :edit] do resources :maps, except: %i[index edit] do
member do member do
get :conversation get :conversation
get :export get :export
@ -54,10 +56,10 @@ Metamaps::Application.routes.draw do
end end
end end
resources :mappings, except: [:index, :new, :edit] resources :mappings, except: %i[index new edit]
resources :messages, only: [:show, :create, :update, :destroy] resources :messages, only: %i[show create update destroy]
resources :notifications, only: [:index, :show] do resources :notifications, only: %i[index show] do
collection do collection do
get :unsubscribe get :unsubscribe
end end
@ -79,9 +81,9 @@ Metamaps::Application.routes.draw do
get :synapses get :synapses
end end
resources :synapses, except: [:index, :new, :edit] resources :synapses, except: %i[index new edit]
resources :topics, except: [:index, :new, :edit] do resources :topics, except: %i[index new edit] do
member do member do
get :network get :network
get :relative_numbers get :relative_numbers
@ -110,7 +112,7 @@ Metamaps::Application.routes.draw do
get 'join' => 'users/registrations#new', :as => :sign_up get 'join' => 'users/registrations#new', :as => :sign_up
end end
resources :users, except: [:index, :destroy] do resources :users, except: %i[index destroy] do
member do member do
get :details get :details
end end
@ -120,16 +122,16 @@ Metamaps::Application.routes.draw do
namespace :api, path: '/api', default: { format: :json } do namespace :api, path: '/api', default: { format: :json } do
namespace :v2, path: '/v2' do namespace :v2, path: '/v2' do
resources :metacodes, only: [:index, :show] resources :metacodes, only: %i[index show]
resources :mappings, only: [:index, :create, :show, :update, :destroy] resources :mappings, only: %i[index create show update destroy]
resources :maps, only: [:index, :create, :show, :update, :destroy] do resources :maps, only: %i[index create show update destroy] do
post :stars, to: 'stars#create', on: :member post :stars, to: 'stars#create', on: :member
delete :stars, to: 'stars#destroy', on: :member delete :stars, to: 'stars#destroy', on: :member
end end
resources :synapses, only: [:index, :create, :show, :update, :destroy] resources :synapses, only: %i[index create show update destroy]
resources :tokens, only: [:index, :create, :destroy] resources :tokens, only: %i[index create destroy]
resources :topics, only: [:index, :create, :show, :update, :destroy] resources :topics, only: %i[index create show update destroy]
resources :users, only: [:index, :show] do resources :users, only: %i[index show] do
get :current, on: :collection get :current, on: :collection
end end
match '*path', to: 'restful#catch_404', via: :all match '*path', to: 'restful#catch_404', via: :all
@ -145,4 +147,4 @@ Metamaps::Application.routes.draw do
get 'load_url_title' get 'load_url_title'
end end
end end
# rubocop:enable Rubocop/Metrics/BlockLength # rubocop:enable Metrics/BlockLength

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
%w(
%w[
.ruby-version .ruby-version
.ruby-gemset .ruby-gemset
.rbenv-vars .rbenv-vars
tmp/restart.txt tmp/restart.txt
tmp/caching-dev.txt tmp/caching-dev.txt
).each { |path| Spring.watch(path) } ].each { |path| Spring.watch(path) }