aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb16
-rw-r--r--vendor/plugins/has_tag_string/lib/has_tag_string.rb18
2 files changed, 31 insertions, 3 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index c63ea5757..047321562 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -682,7 +682,12 @@ module ActsAsXapian
elsif type == :boolean
value ? true : false
else
- value.to_s
+ # Arrays are for terms which require multiple of them, e.g. tags
+ if value.kind_of?(Array)
+ value.map {|v| v.to_s}
+ else
+ value.to_s
+ end
end
end
@@ -707,7 +712,14 @@ module ActsAsXapian
doc.add_term("I" + doc.data)
if self.xapian_options[:terms]
for term in self.xapian_options[:terms]
- doc.add_term(term[1] + xapian_value(term[0]))
+ value = xapian_value(term[0])
+ if value.kind_of?(Array)
+ for v in value
+ doc.add_term(term[1] + v)
+ end
+ else
+ doc.add_term(term[1] + value)
+ end
end
end
if self.xapian_options[:values]
diff --git a/vendor/plugins/has_tag_string/lib/has_tag_string.rb b/vendor/plugins/has_tag_string/lib/has_tag_string.rb
index 5382067fb..49b82ca0d 100644
--- a/vendor/plugins/has_tag_string/lib/has_tag_string.rb
+++ b/vendor/plugins/has_tag_string/lib/has_tag_string.rb
@@ -80,11 +80,27 @@ module HasTagString
return self.tags.map { |t| t.name_and_value }.join(' ')
end
- # Returns the tags the model has, as an array of strings
+ # Returns the tags the model has, as an array of pairs of key/value
+ # (this can't be a dictionary as you can have multiple instances of a
+ # key with different values)
def tag_array
return self.tags.map { |t| [t.name, t.value] }
end
+ # Returns a list of all the strings someone might want to search for.
+ # So that is the key by itself, or the key and value.
+ # e.g. if a request was tagged openlylocal_id:12345, they might
+ # want to search for "openlylocal_id" or for "openlylocal_id:12345" to find it.
+ def tag_array_for_search
+ ret = {}
+ for tag in self.tags
+ ret[tag.name] = 1
+ ret[tag.name_and_value] = 1
+ end
+
+ return ret.keys
+ end
+
# Test to see if class is tagged with the given tag
def has_tag?(tag_as_string)
for tag in self.tags