Merge branch 'master' into setup/pagination

This commit is contained in:
2020-04-28 09:41:20 +02:00
committed by GitHub
80 changed files with 564 additions and 236 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'boot'
require 'rails/all'
@@ -29,7 +31,7 @@ module Tinyform
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '/s/*', headers: :any, methods: [:post, :put, :options]
resource '/s/*', headers: :any, methods: %i[post put options]
end
end
end

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -14,7 +16,7 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -51,7 +53,7 @@ Rails.application.configure do
config.log_level = :info
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
@@ -80,7 +82,7 @@ Rails.application.configure do
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Rails.configuration.to_prepare do
ActiveStorage::Attachment.send(:has_secure_token)
end

View File

@@ -1,3 +1,4 @@
# frozen_string_literal: true
# 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.

View File

@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
GOOGLE_DEMO_FORM = Form.find_by(id: ENV['GOOGLE_DEMO_FORM_ID'])
AIRTABLE_DEMO_FORM = Form.find_by(id: ENV['AIRTABLE_DEMO_FORM_ID'])
AIRTABLE_DEMO_EMBED_URL = ENV['AIRTABLE_DEMO_EMBED_URL']

View File

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

View File

@@ -1,13 +1,15 @@
# frozen_string_literal: true
require 'google/api_client/client_secrets'
require 'google/apis'
secrets_options = {
"client_id" => ENV['GOOGLE_CLIENT_ID'],
"project_id" => ENV['GOOGLE_PROJECT_ID'],
"client_secret" => ENV['GOOGLE_CLIENT_SECRET'],
"auth_uri" => "https://accounts.google.com/o/oauth2/auth",
"token_uri" => "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url" => "https://www.googleapis.com/oauth2/v1/certs"
'client_id' => ENV['GOOGLE_CLIENT_ID'],
'project_id' => ENV['GOOGLE_PROJECT_ID'],
'client_secret' => ENV['GOOGLE_CLIENT_SECRET'],
'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
'token_uri' => 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs'
}
CLIENT_SECRETS = Google::APIClient::ClientSecrets.new("web" => secrets_options)
CLIENT_SECRETS = Google::APIClient::ClientSecrets.new('web' => secrets_options)
Google::Apis.logger = ::Rails.logger

View File

@@ -1 +1,3 @@
# frozen_string_literal: true
DEFAULT_HOST = ENV['DEFAULT_HOST'] || 'localhost:3000'

View File

@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections

View File

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

View File

@@ -1,10 +1,12 @@
# frozen_string_literal: true
# The first thing you need to configure is which modules you need in your app.
# The default is nothing which will include only core features (password encryption, login/logout).
#
# Available submodules are: :user_activation, :http_basic_auth, :remember_me,
# :reset_password, :session_timeout, :brute_force_protection, :activity_logging,
# :magic_login, :external
Rails.application.config.sorcery.submodules = [:reset_password, :external, :magic_login]
Rails.application.config.sorcery.submodules = %i[reset_password external magic_login]
# Here you can configure each submodule's features.
Rails.application.config.sorcery.configure do |config|
@@ -152,9 +154,9 @@ Rails.application.config.sorcery.configure do |config|
#
config.google.key = ENV['GOOGLE_CLIENT_ID']
config.google.secret = ENV['GOOGLE_CLIENT_SECRET']
config.google.callback_url = (ENV['GOOGLE_AUTH_CALLBACK_URL'] || "http://localhost:3000/oauth/callback?provider=google")
config.google.user_info_mapping = {:email => "email", :name => "name", :google_id => "id"}
config.google.scope = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/spreadsheets"
config.google.callback_url = (ENV['GOOGLE_AUTH_CALLBACK_URL'] || 'http://localhost:3000/oauth/callback?provider=google')
config.google.user_info_mapping = { email: 'email', name: 'name', google_id: 'id' }
config.google.scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/spreadsheets'
config.google.auth_url = '/o/oauth2/auth?access_type=offline&include_granted_scopes=true'
#
# For Microsoft Graph, the key will be your App ID, and the secret will be your app password/public key.
@@ -407,7 +409,7 @@ Rails.application.config.sorcery.configure do |config|
#
# user.magic_login_token_expires_at_attribute_name =
# When was magic login email sent — used for hammering protection.
# When was magic login email sent - for hammering protection.
# Default: `:magic_login_email_sent_at`
#
# user.magic_login_email_sent_at_attribute_name =
@@ -528,5 +530,5 @@ Rails.application.config.sorcery.configure do |config|
# This line must come after the 'user config' block.
# Define which model authenticates with sorcery.
config.user_class = "User"
config.user_class = 'User'
end

View File

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

View File

@@ -1,23 +1,25 @@
# frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# 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
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
# 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.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
@@ -11,25 +13,25 @@ Rails.application.routes.draw do
# short link for submission file uploads
# we add the filename as part of the URL which allows e.g. Airtable to identify and name the file properly
# the constraint makes sure that a . (dot) can be in the filename. e.g. cat.jpg
get '/s/:form_id/:submission_id/:id(/:filename)' => 'file_uploads#show', as: :file_upload, constraints: { filename: /[^\/]+/ }
get '/s/:form_id/:submission_id/:id(/:filename)' => 'file_uploads#show', :as => :file_upload, :constraints => { filename: %r{[^/]+} }
# form post url to save new submissions
post '/s/:form_id' => 'submissions#create', as: :submission
post '/s/:form_id' => 'submissions#create', :as => :submission
# short URL for form page
get '/s/:id/form' => 'forms#form', as: :form_submitter
get '/s/:id/form' => 'forms#form', :as => :form_submitter
get 'oauth/callback', to: 'oauths#callback'
get 'oauth/:provider', to: 'oauths#oauth', as: :auth_at_provider
get '/signup' => 'sessions#new', as: :signup # TODO: add proper signup page
get '/login' => 'sessions#new', as: :login
get '/logout' => 'sessions#destroy', as: :logout
get '/auth' => 'sessions#auth', as: :auth
get '/signup' => 'sessions#new', :as => :signup # TODO: add proper signup page
get '/login' => 'sessions#new', :as => :login
get '/logout' => 'sessions#destroy', :as => :logout
get '/auth' => 'sessions#auth', :as => :auth
get '/demo(/:backend)' => 'home#demo', as: :demo
get '/contact' => 'home#contact', as: :contact
get '/demo(/:backend)' => 'home#demo', :as => :demo
get '/contact' => 'home#contact', :as => :contact
get '/help', to: redirect('https://www.notion.so/Tinyforms-Help-Center-04f13b5908bc46cfb4283079a3cb1149')
get '/form-building-service', to: redirect('https://www.notion.so/Tinyforms-Help-Center-04f13b5908bc46cfb4283079a3cb1149')
root 'home#index'
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
Spring.watch(
".ruby-version",
".rbenv-vars",
"tmp/restart.txt",
"tmp/caching-dev.txt"
'.ruby-version',
'.rbenv-vars',
'tmp/restart.txt',
'tmp/caching-dev.txt'
)