From 159078170aff361c009c87b0f4e7b36d15381468 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Thu, 29 Mar 2018 20:53:22 +0200 Subject: [PATCH 1/2] Update Paperclip library to 5.3 version --- Gemfile | 2 +- Gemfile.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 26c075ad6..e801a19de 100644 --- a/Gemfile +++ b/Gemfile @@ -71,7 +71,7 @@ gem 'jbuilder' # JSON structures via a Builder-style DSL gem 'activerecord-import' gem 'scenic', '~> 1.4' -gem 'paperclip', '~> 5.1' # File attachment, image attachment library +gem 'paperclip', '~> 5.3' # File attachment, image attachment library gem 'aws-sdk', '~> 2' gem 'delayed_job_active_record' diff --git a/Gemfile.lock b/Gemfile.lock index 602a43b82..40f4b1a6f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,8 +148,6 @@ GEM mail climate_control (0.2.0) cliver (0.3.2) - cocaine (0.5.8) - climate_control (>= 0.0.3, < 1.0) coderay (1.1.2) coffee-rails (4.2.2) coffee-script (>= 2.2.0) @@ -227,7 +225,7 @@ GEM activesupport (>= 4.2.0) hammerjs-rails (2.0.8) hashie (3.5.7) - i18n (0.9.3) + i18n (0.9.5) concurrent-ruby (~> 1.0) i18n-js (3.0.3) i18n (~> 0.6, >= 0.6.6) @@ -320,12 +318,12 @@ GEM oauth2 (~> 1.1) omniauth (~> 1.2) orm_adapter (0.5.0) - paperclip (5.2.1) + paperclip (5.3.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) - cocaine (~> 0.5.5) mime-types mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) parallel (1.12.1) parser (2.4.0.2) ast (~> 2.3) @@ -485,6 +483,8 @@ GEM ruby-progressbar (~> 1.9) sourcemap (~> 0.1) stream (0.5) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) thor (0.20.0) thread_safe (0.3.6) tilt (2.0.8) @@ -492,7 +492,7 @@ GEM railties (>= 3.1.1) turbolinks (2.5.4) coffee-rails - tzinfo (1.2.4) + tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.4) execjs (>= 0.3.0, < 3) @@ -575,7 +575,7 @@ DEPENDENCIES nokogiri (~> 1.8.1) omniauth omniauth-linkedin-oauth2 - paperclip (~> 5.1) + paperclip (~> 5.3) pg (~> 0.18) phantomjs poltergeist From 386ede04006eedce2eefad29661443119487c10f Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Thu, 5 Apr 2018 12:54:14 +0200 Subject: [PATCH 2/2] Add special middleware for handling of Rails 5.1 WOPI errors Closes SCI-2266. --- app/middlewares/wopi_method_override.rb | 19 +++++++++++++++++++ config/application.rb | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 app/middlewares/wopi_method_override.rb diff --git a/app/middlewares/wopi_method_override.rb b/app/middlewares/wopi_method_override.rb new file mode 100644 index 000000000..e30a5c75b --- /dev/null +++ b/app/middlewares/wopi_method_override.rb @@ -0,0 +1,19 @@ +# When WOPI performs calls onto sciNote WOPI subdomain REST endpoints +# Rack::MethodOverride MUST be omitted because it crashes the requests +# due to trying to parse body of the requests +class WopiMethodOverride + def initialize(app) + @app = app + end + + def call(env) + app = @app + + unless WopiSubdomain.matches?(ActionDispatch::Request.new(env)) + # Use the wrapped Rack::MethodOverride middleware + app = Rack::MethodOverride.new(@app) + end + + app.call(env) + end +end \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 129ba8e4c..4442591d6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,6 +15,10 @@ module Scinote # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # Swap the Rack::MethodOverride with a wrapped middleware for WOPI handling + require_relative '../app/middlewares/wopi_method_override' + config.middleware.swap Rack::MethodOverride, WopiMethodOverride + # Load all model concerns, including subfolders config.autoload_paths += Dir["#{Rails.root}/app/models/concerns/**/*.rb"]