commit 8903cdedc810b5570b5d2cfb35d60683782aa84a
parent c8562c943ee4d956df93dea76a71e7ff2160fb4b
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Tue, 8 Sep 2009 15:58:28 -0400
Merge branch 'custom-search-hook'
Conflicts:
lib/sup/hook.rb
lib/sup/index.rb
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/lib/sup/ferret_index.rb b/lib/sup/ferret_index.rb
@@ -4,6 +4,13 @@ module Redwood
class FerretIndex < BaseIndex
+ HookManager.register "custom-search", <<EOS
+Executes before a string search is applied to the index,
+returning a new search string.
+Variables:
+ subs: The string being searched.
+EOS
+
def initialize dir=BASE_DIR
super
@@ -332,6 +339,7 @@ class FerretIndex < BaseIndex
def parse_query s
query = {}
+ subs = HookManager.run("custom-search", :subs => s) || s
subs = s.gsub(/\b(to|from):(\S+)\b/) do
field, name = $1, $2
if(p = ContactManager.contact_for(name))
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
@@ -16,6 +16,13 @@ class XapianIndex < BaseIndex
MIN_DATE = Time.at 0
MAX_DATE = Time.at(2**31-1)
+ HookManager.register "custom-search", <<EOS
+Executes before a string search is applied to the index,
+returning a new search string.
+Variables:
+ subs: The string being searched.
+EOS
+
def initialize dir=BASE_DIR
super
@@ -185,6 +192,7 @@ class XapianIndex < BaseIndex
def parse_query s
query = {}
+ subs = HookManager.run("custom-search", :subs => s) || s
subs = s.gsub(/\b(to|from):(\S+)\b/) do
field, name = $1, $2
if(p = ContactManager.contact_for(name))