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