infopark_fiona7 1.5.4.3.0 → 1.5.5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fiona7/naive_search_engine.rb +98 -23
- data/lib/fiona7/scrivito_patches/binary.rb +33 -9
- data/lib/fiona7/verity_search_engine.rb +7 -1
- data/lib/fiona7/version.rb +1 -1
- 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: f0590fa89cace0547e0dbf261e5acf5946c37cc8
|
4
|
+
data.tar.gz: f88431937133bfb08439d6d2ee1f9bc3441e9524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9883ff71077c343ba7f33c4f6bae47e2c19ef83a2489ec1d8cf28848be9b9a66a409adea54ed110161ba1be73e655db3cdfc7bba9ee5e41b4cb325727284440f
|
7
|
+
data.tar.gz: 07179e47fe6f27c1cc31bc279f4121e6e0e79cfd4413ee7697b69bc51432315fc87dfda28835344f861adb78d41d622cb6cd9f61a38268aa0752eee6a34e7eb2
|
@@ -25,11 +25,19 @@ module Fiona7
|
|
25
25
|
obj_class_filter = @query.find {|q| (q[:field] == :_obj_class || q[:field] == "_obj_class") && q[:operator] == :equal }
|
26
26
|
id_filter = @query.find {|q| (q[:field] == :id || q[:field] == "id") && q[:operator] == :equal }
|
27
27
|
if obj_class_filter
|
28
|
-
|
28
|
+
if obj_class_filter[:negate]
|
29
|
+
@all = @klass.where.not(obj_class: obj_class_filter[:value])
|
30
|
+
else
|
31
|
+
@all = @klass.where(obj_class: obj_class_filter[:value])
|
32
|
+
end
|
29
33
|
@query.delete(obj_class_filter)
|
30
34
|
elsif id_filter
|
35
|
+
if id_filter[:negate]
|
36
|
+
@all = @klass.where.not(obj_id: id_filter[:value])
|
37
|
+
else
|
38
|
+
@all = @klass.where(obj_id: id_filter[:value])
|
39
|
+
end
|
31
40
|
@query.delete(id_filter)
|
32
|
-
@all = @klass.where(obj_id: id_filter[:value])
|
33
41
|
else
|
34
42
|
# FIXME: this is deprecated
|
35
43
|
@all = @klass.all
|
@@ -68,7 +76,6 @@ module Fiona7
|
|
68
76
|
|
69
77
|
sort_field = @sort
|
70
78
|
@all = @all.to_a
|
71
|
-
#@all.sort_by! {|o| o.send(:[], resolve_field_name(o,sort_field)) }
|
72
79
|
@all.sort! do |a,b|
|
73
80
|
a_value = a.send(:[], resolve_field_name(a,sort_field))
|
74
81
|
b_value = b.send(:[], resolve_field_name(b,sort_field))
|
@@ -105,38 +112,79 @@ module Fiona7
|
|
105
112
|
if value != ["new", "edited", "deleted"]
|
106
113
|
raise "Unsupported modification values: #{value.inspect}. Only #{["new", "edited", "deleted"].inspect} are supported"
|
107
114
|
else
|
108
|
-
|
109
|
-
|
115
|
+
if (@all.is_a?(Array))
|
116
|
+
if filter[:negate]
|
117
|
+
@all = @all.to_a.select {|o| !o.edited? }
|
118
|
+
else
|
119
|
+
@all = @all.to_a.select {|o| o.edited? }
|
120
|
+
end
|
121
|
+
else
|
122
|
+
if filter[:negate]
|
123
|
+
@all = @all.where.not(is_edited: '1')
|
124
|
+
else
|
125
|
+
@all = @all.where(is_edited: '1')
|
126
|
+
end
|
127
|
+
end
|
110
128
|
end
|
111
129
|
elsif field == :_path
|
112
130
|
value = [value] unless value.is_a?(Array)
|
113
131
|
value.map{|v| v.gsub!('.', '_') }
|
114
132
|
if (@all.is_a?(Array))
|
115
|
-
|
116
|
-
|
133
|
+
if filter[:negate]
|
134
|
+
@all = @all.select do |o|
|
135
|
+
!value.include?(o.path)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
@all = @all.select do |o|
|
139
|
+
value.include?(o.path)
|
140
|
+
end
|
117
141
|
end
|
118
142
|
else
|
119
|
-
|
143
|
+
if filter[:negate]
|
144
|
+
@all = @all.where.not(:path => value)
|
145
|
+
else
|
146
|
+
@all = @all.where(:path => value)
|
147
|
+
end
|
120
148
|
end
|
121
149
|
elsif field == :_permalink
|
122
150
|
value = [value] unless value.is_a?(Array)
|
123
151
|
if (@all.is_a?(Array))
|
124
|
-
|
125
|
-
|
152
|
+
if filter[:negate]
|
153
|
+
@all = @all.select do |o|
|
154
|
+
!value.include?(o.permalink)
|
155
|
+
end
|
156
|
+
else
|
157
|
+
@all = @all.select do |o|
|
158
|
+
value.include?(o.permalink)
|
159
|
+
end
|
126
160
|
end
|
127
161
|
else
|
128
|
-
|
162
|
+
if filter[:negate]
|
163
|
+
@all = @all.where.not(:permalink => value)
|
164
|
+
else
|
165
|
+
@all = @all.where(:permalink => value)
|
166
|
+
end
|
129
167
|
end
|
130
168
|
elsif field == :_parent_path
|
131
169
|
parent_obj = @klass.where(path: value).first
|
132
170
|
if parent_obj
|
133
171
|
parent_obj_id = parent_obj.id
|
134
172
|
if (@all.is_a?(Array))
|
135
|
-
|
136
|
-
|
173
|
+
if filter[:negate]
|
174
|
+
@all = @all.select do |o|
|
175
|
+
o.parent_obj_id != parent_obj_id
|
176
|
+
end
|
177
|
+
else
|
178
|
+
@all = @all.select do |o|
|
179
|
+
o.parent_obj_id == parent_obj_id
|
180
|
+
end
|
137
181
|
end
|
138
182
|
else
|
139
|
-
|
183
|
+
if filter[:negate]
|
184
|
+
@all = @all.where.not(:parent_obj_id => parent_obj_id)
|
185
|
+
else
|
186
|
+
@all = @all.where(:parent_obj_id => parent_obj_id)
|
187
|
+
end
|
140
188
|
end
|
141
189
|
else
|
142
190
|
@all = []
|
@@ -149,11 +197,18 @@ module Fiona7
|
|
149
197
|
if resolved_field == :obj_id
|
150
198
|
field_value = field_value.to_s
|
151
199
|
end
|
152
|
-
|
153
|
-
|
154
|
-
|
200
|
+
if filter[:negate]
|
201
|
+
if field_value.is_a?(Array)
|
202
|
+
(value & field_value).empty?
|
203
|
+
else
|
204
|
+
!value.include?(field_value)
|
205
|
+
end
|
155
206
|
else
|
156
|
-
|
207
|
+
if field_value.is_a?(Array)
|
208
|
+
!(value & field_value).empty?
|
209
|
+
else
|
210
|
+
value.include?(field_value)
|
211
|
+
end
|
157
212
|
end
|
158
213
|
end
|
159
214
|
else
|
@@ -163,7 +218,11 @@ module Fiona7
|
|
163
218
|
if resolved_field == :obj_id
|
164
219
|
field_value = field_value.to_s
|
165
220
|
end
|
166
|
-
|
221
|
+
if filter[:negate]
|
222
|
+
field_value != value
|
223
|
+
else
|
224
|
+
field_value == value
|
225
|
+
end
|
167
226
|
end
|
168
227
|
end
|
169
228
|
end
|
@@ -171,14 +230,30 @@ module Fiona7
|
|
171
230
|
if !@all.is_a?(Array) && field.to_sym == :_path
|
172
231
|
# TODO: handle this properly
|
173
232
|
value = value.first if value.kind_of?(Array)
|
174
|
-
|
233
|
+
if filter[:negate]
|
234
|
+
@all = @all.where.not("path LIKE ?", "#{value}%")
|
235
|
+
else
|
236
|
+
@all = @all.where("path LIKE ?", "#{value}%")
|
237
|
+
end
|
175
238
|
else
|
176
|
-
|
239
|
+
if filter[:negate]
|
240
|
+
@all = @all.to_a.select {|o| !o.send(:[], resolve_field_name(o,field)).to_s.start_with?(value) }
|
241
|
+
else
|
242
|
+
@all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s.start_with?(value) }
|
243
|
+
end
|
177
244
|
end
|
178
245
|
when :greater_than
|
179
|
-
|
246
|
+
if filter[:negate]
|
247
|
+
@all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s <= (value) }
|
248
|
+
else
|
249
|
+
@all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s > (value) }
|
250
|
+
end
|
180
251
|
when :less_than
|
181
|
-
|
252
|
+
if filter[:negate]
|
253
|
+
@all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s >= (value) }
|
254
|
+
else
|
255
|
+
@all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s < (value) }
|
256
|
+
end
|
182
257
|
else
|
183
258
|
raise "Operator: #{filter[:operator]} not supported"
|
184
259
|
end
|
@@ -146,13 +146,14 @@ module Fiona7
|
|
146
146
|
def valid_transformation?
|
147
147
|
true &&
|
148
148
|
(self.mime_type =~ /image\//) &&
|
149
|
-
(self.width.present? || self.height.present?) &&
|
150
149
|
(!self.width.present? || (1..4096).include?(self.width.to_i)) &&
|
151
150
|
(!self.height.present? || (1..4096).include?(self.height.to_i)) &&
|
152
|
-
((
|
153
|
-
(self.fit
|
154
|
-
|
155
|
-
|
151
|
+
((0..100).include?(self.quality.to_i)) &&
|
152
|
+
(!self.fit.present? || (
|
153
|
+
(self.fit == 'clip' || self.fit == 'crop') &&
|
154
|
+
(self.width.to_i + self.height.to_i < 4096) &&
|
155
|
+
(self.fit == 'clip' || (self.width.present? && self.height.present?))
|
156
|
+
))
|
156
157
|
end
|
157
158
|
|
158
159
|
def transformed_filepath
|
@@ -170,15 +171,21 @@ module Fiona7
|
|
170
171
|
|
171
172
|
image = MiniMagick::Image.open(original_filepath)
|
172
173
|
|
173
|
-
if self.fit
|
174
|
+
if self.fit.blank?
|
175
|
+
image.combine_options do |b|
|
176
|
+
b.quality self.quality.to_i
|
177
|
+
end
|
178
|
+
elsif self.fit == 'clip'
|
174
179
|
image.combine_options do |b|
|
175
180
|
b.resize "#{self.width}x#{self.height}>"
|
181
|
+
b.quality self.quality.to_i
|
176
182
|
end
|
177
183
|
elsif self.fit == 'crop'
|
178
184
|
image.combine_options do |b|
|
179
185
|
b.resize "#{self.width}x#{self.height}^"
|
180
|
-
b.gravity
|
186
|
+
b.gravity self.gravity
|
181
187
|
b.extent "#{self.width}x#{self.height}>"
|
188
|
+
b.quality self.quality.to_i
|
182
189
|
end
|
183
190
|
else
|
184
191
|
raise 'invalid fit'
|
@@ -190,13 +197,30 @@ module Fiona7
|
|
190
197
|
|
191
198
|
def transformed_filename
|
192
199
|
ext = ::File.extname(self.original_filepath)
|
193
|
-
"#{self.fit}_#{self.width}_#{self.height}_#{self.quality}#{ext}"
|
200
|
+
"#{self.fit}_#{self.crop}_#{self.width}_#{self.height}_#{self.quality}#{ext}"
|
194
201
|
end
|
195
202
|
|
196
203
|
def transformation_with_fallback
|
197
204
|
@transformation_with_fallback ||= (self.transformation || {}).with_indifferent_access
|
198
205
|
end
|
199
206
|
|
207
|
+
CROP_TO_GRAVITY = {
|
208
|
+
'center' => 'Center',
|
209
|
+
'top' => 'North',
|
210
|
+
'left' => 'West',
|
211
|
+
'right' => 'East',
|
212
|
+
'bottom' => 'South',
|
213
|
+
}.freeze
|
214
|
+
|
215
|
+
|
216
|
+
def crop
|
217
|
+
self.transformation_with_fallback[:crop].presence || 'center'
|
218
|
+
end
|
219
|
+
|
220
|
+
def gravity
|
221
|
+
CROP_TO_GRAVITY[self.crop] || 'Center'
|
222
|
+
end
|
223
|
+
|
200
224
|
def width
|
201
225
|
self.transformation_with_fallback[:width].to_s
|
202
226
|
end
|
@@ -210,7 +234,7 @@ module Fiona7
|
|
210
234
|
end
|
211
235
|
|
212
236
|
def fit
|
213
|
-
self.transformation_with_fallback[:fit]
|
237
|
+
self.transformation_with_fallback[:fit]
|
214
238
|
end
|
215
239
|
end
|
216
240
|
|
@@ -89,7 +89,7 @@ module Fiona7
|
|
89
89
|
# paths are sadly not in the search index by default.
|
90
90
|
next if field == :visiblePath
|
91
91
|
|
92
|
-
case q[:operator]
|
92
|
+
condition = case q[:operator]
|
93
93
|
when :equal
|
94
94
|
if field == :__dummy__
|
95
95
|
'("edited" <#IN> state)'
|
@@ -125,6 +125,12 @@ module Fiona7
|
|
125
125
|
else
|
126
126
|
raise "Operator: #{q[:operator]} not supported"
|
127
127
|
end
|
128
|
+
|
129
|
+
if q[:negate] && condition.present?
|
130
|
+
condition = %|<#NOT> (#{condition})|
|
131
|
+
end
|
132
|
+
|
133
|
+
condition
|
128
134
|
end.compact
|
129
135
|
|
130
136
|
if conditions.empty?
|
data/lib/fiona7/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_fiona7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Przedmojski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|