Xapian search hook implementation for a quick jump to a document
This commit is contained in:
parent
3d0ca5838c
commit
598d861262
@ -51,6 +51,7 @@ require 'redmine_dmsf/errors/dmsf_zip_max_file_error.rb'
|
||||
# Hooks
|
||||
require 'redmine_dmsf/hooks/view_projects_form_hook'
|
||||
require 'redmine_dmsf/hooks/base_view_hooks'
|
||||
require 'redmine_dmsf/hooks/search_controller_hooks'
|
||||
|
||||
# Macros
|
||||
require 'redmine_dmsf/macros'
|
||||
|
||||
41
lib/redmine_dmsf/hooks/search_controller_hooks.rb
Normal file
41
lib/redmine_dmsf/hooks/search_controller_hooks.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-16 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.
|
||||
|
||||
module RedmineDmsf
|
||||
module Hooks
|
||||
include Redmine::Hook
|
||||
|
||||
class ControllerSearchHook < RedmineDmsf::Hooks::Listener
|
||||
|
||||
def controller_search_quick_jump(context={})
|
||||
if context.is_a?(Hash)
|
||||
question = context[:question]
|
||||
if question.present?
|
||||
if question.match(/^D(\d+)$/) && DmsfFile.visible.find_by_id($1.to_i)
|
||||
return { :controller => 'dmsf_files', :action => 'show', :id => $1.to_i }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user