]> git.cworth.org Git - sup/blobdiff - lib/sup/ferret_index.rb
Merge branch 'custom-search-hook'
[sup] / lib / sup / ferret_index.rb
index df1139d97b67d878fa84f9440a173206f11cf26f..d605e8d389f7e61c0cb2eb5a1ba168d077ae6d19 100644 (file)
@@ -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))