algoliasearch-rails 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README.md +15 -0
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +2 -2
- data/lib/algoliasearch-rails.rb +31 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7268843b4187ac3dcf7935b7cc6210ae2537bc
|
4
|
+
data.tar.gz: b2c861d79e0098fc865887ca837df5f95629e9ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a07ec13513cbd052d1c44739ccb74d0c8270ad938cf232c960e8b7530dc5b4010baeb0c3b927eb913f52a3c75fa9e6df5b5025bb41d0c80859936c42da21927
|
7
|
+
data.tar.gz: 0e553e1bcdfd3aff649438957e72705cdb0da1da64a8f29b854a7524b537e363c7956d74a0f4b3058d5a6a8bccbfb71b1c884c02d535f0e676a0bb8a792b5508
|
data/ChangeLog
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2014-08-25 1.11.1
|
4
|
+
|
5
|
+
* While using a temporary index to reindex, do not set the "slaves" index setting (will be set at move-time)
|
6
|
+
* Ability to strip HTML tags from attributes
|
7
|
+
|
3
8
|
2014-08-20 1.11.0
|
4
9
|
|
5
10
|
* Do not rely of _changed? method to detect reindexing needs, if those methods are missing we probably need to reindex
|
data/README.md
CHANGED
@@ -274,6 +274,21 @@ or
|
|
274
274
|
MyModel.index_objects MyModel.limit(5)
|
275
275
|
```
|
276
276
|
|
277
|
+
#### Sanitizer
|
278
|
+
|
279
|
+
You can sanitize all your attributes using the ```sanitize``` option. It will strip all HTML tags from your attributes.
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
class User < ActiveRecord::Base
|
283
|
+
include AlgoliaSearch
|
284
|
+
|
285
|
+
algoliasearch per_environment: true, sanitize: true do
|
286
|
+
attributes :name, :email, :company
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
```
|
291
|
+
|
277
292
|
|
278
293
|
Configuration example
|
279
294
|
---------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.11.
|
1
|
+
1.11.1
|
data/algoliasearch-rails.gemspec
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "algoliasearch-rails"
|
9
|
-
s.version = "1.11.
|
9
|
+
s.version = "1.11.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Algolia"]
|
13
|
-
s.date = "2014-08-
|
13
|
+
s.date = "2014-08-25"
|
14
14
|
s.description = "AlgoliaSearch integration to your favorite ORM"
|
15
15
|
s.email = "contact@algolia.com"
|
16
16
|
s.extra_rdoc_files = [
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -87,7 +87,7 @@ module AlgoliaSearch
|
|
87
87
|
|
88
88
|
def get_attributes(object)
|
89
89
|
clazz = object.class
|
90
|
-
if defined?(::Mongoid::Document) && clazz.include?(::Mongoid::Document)
|
90
|
+
attributes = if defined?(::Mongoid::Document) && clazz.include?(::Mongoid::Document)
|
91
91
|
# work-around mongoid 2.4's unscoped method, not accepting a block
|
92
92
|
res = @attributes.nil? || @attributes.length == 0 ? object.attributes :
|
93
93
|
Hash[@attributes.map { |name, value| [name.to_s, value.call(object) ] }]
|
@@ -101,6 +101,26 @@ module AlgoliaSearch
|
|
101
101
|
res
|
102
102
|
end
|
103
103
|
end
|
104
|
+
|
105
|
+
if @options[:sanitize]
|
106
|
+
sanitizer = HTML::FullSanitizer.new
|
107
|
+
attributes = sanitize_attributes(attributes, sanitizer)
|
108
|
+
end
|
109
|
+
|
110
|
+
attributes
|
111
|
+
end
|
112
|
+
|
113
|
+
def sanitize_attributes(v, sanitizer)
|
114
|
+
case v
|
115
|
+
when String
|
116
|
+
sanitizer.sanitize(v)
|
117
|
+
when Hash
|
118
|
+
v.each { |key, value| v[key] = sanitize_attributes(value, sanitizer) }
|
119
|
+
when Array
|
120
|
+
v.map { |x| sanitize_attributes(x, sanitizer) }
|
121
|
+
else
|
122
|
+
v
|
123
|
+
end
|
104
124
|
end
|
105
125
|
|
106
126
|
def geoloc(lat_attr, lng_attr)
|
@@ -241,7 +261,7 @@ module AlgoliaSearch
|
|
241
261
|
|
242
262
|
tmp_options = options.merge({ :index_name => "#{index_name}.tmp" })
|
243
263
|
tmp_settings = settings.dup
|
244
|
-
tmp_index = algolia_ensure_init(tmp_options, tmp_settings)
|
264
|
+
tmp_index = algolia_ensure_init(tmp_options, tmp_settings, true)
|
245
265
|
|
246
266
|
algolia_find_in_batches(batch_size) do |group|
|
247
267
|
if algolia_conditional_index?(tmp_options)
|
@@ -418,14 +438,21 @@ module AlgoliaSearch
|
|
418
438
|
|
419
439
|
protected
|
420
440
|
|
421
|
-
def algolia_ensure_init(options = nil, settings = nil)
|
441
|
+
def algolia_ensure_init(options = nil, settings = nil, remove_slaves = false)
|
422
442
|
@algolia_indexes ||= {}
|
423
443
|
options ||= algoliasearch_options
|
424
444
|
settings ||= algoliasearch_settings
|
425
445
|
return @algolia_indexes[settings] if @algolia_indexes[settings]
|
426
446
|
@algolia_indexes[settings] = Algolia::Index.new(algolia_index_name(options))
|
427
447
|
current_settings = @algolia_indexes[settings].get_settings rescue nil # if the index doesn't exist
|
428
|
-
|
448
|
+
if !algolia_indexing_disabled?(options) && algoliasearch_settings_changed?(current_settings, settings.to_settings)
|
449
|
+
index_settings = settings.to_settings
|
450
|
+
if remove_slaves
|
451
|
+
index_settings.delete :slaves
|
452
|
+
index_settings.delete 'slaves'
|
453
|
+
end
|
454
|
+
@algolia_indexes[settings].set_settings(index_settings)
|
455
|
+
end
|
429
456
|
@algolia_indexes[settings]
|
430
457
|
end
|
431
458
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|