From 52a777cc3b7b9553cd8fb95efd2eec13072f8394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 14 Jul 2023 09:21:32 +0200 Subject: [PATCH] Xapian Easy search --- .../patches/application_helper_patch.rb | 2 +- .../xapian_easy_search_helper_patch.rb | 4 ++- lib/xapian_easy_search/base_mapper.rb | 32 +++++++++++++++++++ lib/xapian_easy_search/dmsf_file_mapper.rb | 2 +- lib/xapian_easy_search/dmsf_folder_mapper.rb | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 lib/xapian_easy_search/base_mapper.rb diff --git a/lib/redmine_dmsf/patches/application_helper_patch.rb b/lib/redmine_dmsf/patches/application_helper_patch.rb index 90d1a6ef..28471e2b 100644 --- a/lib/redmine_dmsf/patches/application_helper_patch.rb +++ b/lib/redmine_dmsf/patches/application_helper_patch.rb @@ -40,4 +40,4 @@ module RedmineDmsf end # Apply the patch -ApplicationHelper.prepend RedmineDmsf::Patches::ApplicationHelperPatch +ApplicationHelper.prepend RedmineDmsf::Patches::ApplicationHelperPatch if Redmine::Plugin.installed?('easy_extensions') diff --git a/lib/redmine_dmsf/patches/xapian_easy_search_helper_patch.rb b/lib/redmine_dmsf/patches/xapian_easy_search_helper_patch.rb index 94a1700e..46c052c2 100644 --- a/lib/redmine_dmsf/patches/xapian_easy_search_helper_patch.rb +++ b/lib/redmine_dmsf/patches/xapian_easy_search_helper_patch.rb @@ -37,4 +37,6 @@ module RedmineDmsf end # Apply the patch -XapianEasySearchHelper.prepend RedmineDmsf::Patches::XapianEasySearchHelperPatch +if Redmine::Plugin.installed?('easy_extensions') + XapianEasySearchHelper.prepend RedmineDmsf::Patches::XapianEasySearchHelperPatch +end diff --git a/lib/xapian_easy_search/base_mapper.rb b/lib/xapian_easy_search/base_mapper.rb new file mode 100644 index 00000000..3beda5d8 --- /dev/null +++ b/lib/xapian_easy_search/base_mapper.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011 Vít Jonáš +# Copyright © 2012 Daniel Munn +# Copyright © 2011-23 Karel Pičman +# +# 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. + +if defined?(EasyExtensions) + require 'xapian_easy_search/base_mapper' +else + module XapianEasySearch + # Foo class + class BaseMapper + def foo; end + end + end +end diff --git a/lib/xapian_easy_search/dmsf_file_mapper.rb b/lib/xapian_easy_search/dmsf_file_mapper.rb index 3ad5c148..8dfdca0e 100644 --- a/lib/xapian_easy_search/dmsf_file_mapper.rb +++ b/lib/xapian_easy_search/dmsf_file_mapper.rb @@ -20,7 +20,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'xapian_easy_search/base_mapper' +require('xapian_easy_search/base_mapper') if defined?(EasyExtensions) module XapianEasySearch # DmsfFile mapper diff --git a/lib/xapian_easy_search/dmsf_folder_mapper.rb b/lib/xapian_easy_search/dmsf_folder_mapper.rb index eafe339c..a8d982f7 100644 --- a/lib/xapian_easy_search/dmsf_folder_mapper.rb +++ b/lib/xapian_easy_search/dmsf_folder_mapper.rb @@ -20,7 +20,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'xapian_easy_search/base_mapper' +require('xapian_easy_search/base_mapper') if defined?(EasyExtensions) module XapianEasySearch # DmsfFolder mapper