mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-04 14:44:26 +08:00
Merge pull request #1078 from Ducz0r/lm-sci-2266-fix
Fix Office Online (WOPI) editing of files [SCI-2266]
This commit is contained in:
commit
3834241cd6
4 changed files with 31 additions and 8 deletions
2
Gemfile
2
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'
|
||||
|
|
14
Gemfile.lock
14
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
|
||||
|
|
19
app/middlewares/wopi_method_override.rb
Normal file
19
app/middlewares/wopi_method_override.rb
Normal file
|
@ -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
|
|
@ -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"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue