#1589 Puma compatibility
This commit is contained in:
parent
879f30b34a
commit
ecf5ba498e
@ -362,7 +362,7 @@ class DmsfFile < ApplicationRecord
|
|||||||
results = scope.where(find_options).uniq.to_a
|
results = scope.where(find_options).uniq.to_a
|
||||||
results.delete_if { |x| !DmsfFolder.permissions?(x.dmsf_folder) }
|
results.delete_if { |x| !DmsfFolder.permissions?(x.dmsf_folder) }
|
||||||
|
|
||||||
if !options[:titles_only] && RedmineDmsf::Plugin.xapian_available?
|
if !options[:titles_only] && RedmineDmsf::Plugin.lib_available?('xapian')
|
||||||
database = nil
|
database = nil
|
||||||
begin
|
begin
|
||||||
lang = RedmineDmsf.dmsf_stemming_lang
|
lang = RedmineDmsf.dmsf_stemming_lang
|
||||||
|
|||||||
@ -355,15 +355,7 @@
|
|||||||
</em>
|
</em>
|
||||||
</p>
|
</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% begin %>
|
<% if RedmineDmsf::Plugin.lib_available?('xapian') %>
|
||||||
<% require 'xapian' %>
|
|
||||||
<% xapian_disabled = false %>
|
|
||||||
<% rescue LoadError => e %>
|
|
||||||
<p class="warning"><%= l(:warning_xapian_not_available) %></p>
|
|
||||||
<% Rails.logger.warn e.message %>
|
|
||||||
<% xapian_disabled = true %>
|
|
||||||
<% end %>
|
|
||||||
<% if RedmineDmsf::Plugin.xapian_available? %>
|
|
||||||
<p>
|
<p>
|
||||||
<%= content_tag :label, l(:label_index_database) %>
|
<%= content_tag :label, l(:label_index_database) %>
|
||||||
<%= text_field_tag 'settings[dmsf_index_database]', RedmineDmsf.dmsf_index_database, size: 50 %>
|
<%= text_field_tag 'settings[dmsf_index_database]', RedmineDmsf.dmsf_index_database, size: 50 %>
|
||||||
|
|||||||
@ -253,6 +253,7 @@ unless defined?(EasyPatchManager)
|
|||||||
require "#{File.dirname(__FILE__)}/../patches/access_control_patch"
|
require "#{File.dirname(__FILE__)}/../patches/access_control_patch"
|
||||||
require "#{File.dirname(__FILE__)}/../patches/search_patch"
|
require "#{File.dirname(__FILE__)}/../patches/search_patch"
|
||||||
require "#{File.dirname(__FILE__)}/../patches/custom_field_patch"
|
require "#{File.dirname(__FILE__)}/../patches/custom_field_patch"
|
||||||
|
require "#{File.dirname(__FILE__)}/../patches/puma_patch"
|
||||||
# A workaround for obsolete 'alias_method' usage in RedmineUp's plugins
|
# A workaround for obsolete 'alias_method' usage in RedmineUp's plugins
|
||||||
if RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
if RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
||||||
require "#{File.dirname(__FILE__)}/../patches/notifiable_ru_patch"
|
require "#{File.dirname(__FILE__)}/../patches/notifiable_ru_patch"
|
||||||
|
|||||||
@ -39,12 +39,12 @@ module RedmineDmsf
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return true if Xapian binding is installed (gem ruby_xapian)
|
# Return true if the given gem is installed
|
||||||
def self.xapian_available?
|
def self.lib_available?(path)
|
||||||
require 'xapian'
|
require path
|
||||||
true
|
true
|
||||||
rescue LoadError => e
|
rescue LoadError => e
|
||||||
Rails.logger.warn e.message
|
Rails.logger.info e.message
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
45
patches/puma_patch.rb
Normal file
45
patches/puma_patch.rb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# Redmine's PDF export patch to view DMS images
|
||||||
|
|
||||||
|
module RedmineDmsf
|
||||||
|
module Patches
|
||||||
|
# Puma
|
||||||
|
module PumaPatch
|
||||||
|
##################################################################################################################
|
||||||
|
# Overridden methods
|
||||||
|
def self.included(base)
|
||||||
|
base.class_eval do
|
||||||
|
# WebDAV methods
|
||||||
|
methods = Puma::Const::SUPPORTED_HTTP_METHODS |
|
||||||
|
%w[OPTIONS HEAD GET PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK]
|
||||||
|
remove_const :SUPPORTED_HTTP_METHODS
|
||||||
|
const_set :SUPPORTED_HTTP_METHODS, methods.freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Apply the patch
|
||||||
|
if !defined?(EasyPatchManager) && RedmineDmsf::Plugin.lib_available?('puma/const')
|
||||||
|
Puma::Const.include RedmineDmsf::Patches::PumaPatch
|
||||||
|
end
|
||||||
@ -42,4 +42,9 @@ class DmsfPluginTest < RedmineDmsf::Test::HelperTest
|
|||||||
assert RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
assert RedmineDmsf::Plugin.an_obsolete_plugin_present?
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_lib_available?
|
||||||
|
assert RedmineDmsf::Plugin.lib_available?('zip')
|
||||||
|
assert_not RedmineDmsf::Plugin.lib_available?('not_existing_gem')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user