scrivito_sdk 0.70.2 → 0.71.0.rc1
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/app/controllers/scrivito/binary_redirect_controller.rb +12 -9
- data/app/controllers/scrivito/blobs_controller.rb +1 -2
- data/app/controllers/scrivito/objs_controller.rb +16 -0
- data/app/helpers/scrivito_helper.rb +6 -2
- data/app/views/cms/index.html.erb +1 -1
- data/app/views/scrivito/blobs/activate_upload.json.jbuilder +1 -0
- data/app/views/scrivito/objs/obj.json.jbuilder +1 -1
- data/app/views/scrivito/objs/transfer_modifications.json.jbuilder +6 -0
- data/config/ca-bundle.crt +128 -81
- data/config/precedence_routes.rb +1 -0
- data/lib/assets/images/scrivito/source_invalid.png +0 -0
- data/lib/assets/images/scrivito/source_too_large.png +0 -0
- data/lib/assets/images/scrivito/source_type_invalid.png +0 -0
- data/lib/assets/javascripts/scrivito_ui.js +1043 -645
- data/lib/assets/stylesheets/scrivito.css +1 -1
- data/lib/assets/stylesheets/scrivito_ui.css +1 -1
- data/lib/generators/scrivito/page/templates/thumbnail.html.erb +1 -1
- data/lib/scrivito/attribute_content.rb +54 -17
- data/lib/scrivito/attribute_deserializer.rb +1 -1
- data/lib/scrivito/attribute_serializer.rb +6 -4
- data/lib/scrivito/backend/obj_query.rb +11 -2
- data/lib/scrivito/base_widget_tag.rb +77 -0
- data/lib/scrivito/basic_obj.rb +67 -67
- data/lib/scrivito/basic_widget.rb +11 -6
- data/lib/scrivito/binary.rb +50 -5
- data/lib/scrivito/binary_param_verifier.rb +4 -5
- data/lib/scrivito/client_attribute_serializer.rb +3 -3
- data/lib/scrivito/cms_backend.rb +12 -0
- data/lib/scrivito/cms_field_tag.rb +8 -6
- data/lib/scrivito/cms_rest_api.rb +28 -8
- data/lib/scrivito/cms_rest_api/rate_limit.rb +1 -0
- data/lib/scrivito/cms_routing.rb +7 -1
- data/lib/scrivito/configuration.rb +1 -1
- data/lib/scrivito/controller_actions.rb +38 -35
- data/lib/scrivito/date_attribute.rb +3 -7
- data/lib/scrivito/editing_context.rb +3 -3
- data/lib/scrivito/editing_context_middleware.rb +3 -3
- data/lib/scrivito/errored_widget_tag.rb +34 -0
- data/lib/scrivito/errors.rb +6 -0
- data/lib/scrivito/future_binary.rb +23 -0
- data/lib/scrivito/link_parser.rb +12 -1
- data/lib/scrivito/membership_collection.rb +8 -8
- data/lib/scrivito/obj_collection.rb +2 -2
- data/lib/scrivito/obj_create_params_parser.rb +2 -2
- data/lib/scrivito/obj_params_parser.rb +5 -1
- data/lib/scrivito/obj_search_builder.rb +2 -12
- data/lib/scrivito/obj_search_enumerator.rb +48 -43
- data/lib/scrivito/page_config.rb +2 -1
- data/lib/scrivito/type_computer.rb +6 -6
- data/lib/scrivito/user.rb +9 -10
- data/lib/scrivito/user_definition.rb +2 -2
- data/lib/scrivito/warning.rb +17 -0
- data/lib/scrivito/widget_garbage_collection.rb +1 -1
- data/lib/scrivito/widget_tag.rb +28 -53
- data/lib/scrivito/workspace.rb +32 -23
- metadata +10 -6
- data/app/views/scrivito/objs/copy_widget.html.erb +0 -1
- data/app/views/scrivito/objs/create_widget.html.erb +0 -1
@@ -2,7 +2,7 @@ module Scrivito
|
|
2
2
|
|
3
3
|
# Adds support for string columns which contain ISO dates
|
4
4
|
module DateAttribute
|
5
|
-
def self.
|
5
|
+
def self.parse(iso_date_time)
|
6
6
|
return nil unless iso_date_time
|
7
7
|
|
8
8
|
if iso_date_time.to_s =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
|
@@ -12,7 +12,7 @@ module Scrivito
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
15
|
+
def self.parse_iso8601(iso8601_date_time)
|
16
16
|
return unless iso8601_date_time
|
17
17
|
|
18
18
|
DateTime.iso8601(iso8601_date_time).in_time_zone
|
@@ -20,17 +20,13 @@ module Scrivito
|
|
20
20
|
raise "The value is not a valid ISO 8601 date time: #{iso8601_date_time.inspect}"
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.
|
23
|
+
def self.serialize(attribute_value)
|
24
24
|
attribute_value = case attribute_value
|
25
25
|
when Date then attribute_value.to_time
|
26
26
|
when Time then attribute_value.to_time.utc
|
27
27
|
end
|
28
28
|
attribute_value.strftime('%Y%m%d%H%M%S') if attribute_value
|
29
29
|
end
|
30
|
-
|
31
|
-
def self.serialize_for_client(attribute_value)
|
32
|
-
attribute_value.utc.iso8601
|
33
|
-
end
|
34
30
|
end
|
35
31
|
|
36
32
|
end
|
@@ -50,13 +50,13 @@ class EditingContext
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# defaults to "published" if no workspace with `selected_workspace_id` can be found.
|
53
|
-
# @return [Workspace]
|
53
|
+
# @return [Scrivito::Workspace]
|
54
54
|
def selected_workspace
|
55
55
|
@selected_workspace ||= find_selected_workspace
|
56
56
|
end
|
57
57
|
|
58
58
|
# when authenticated_editor? return selected_workspace, otherwise published workspace.
|
59
|
-
# @return [Workspace]
|
59
|
+
# @return [Scrivito::Workspace]
|
60
60
|
def visible_workspace
|
61
61
|
@visible_workspace ||= find_visible_workspace
|
62
62
|
end
|
@@ -118,7 +118,7 @@ class EditingContext
|
|
118
118
|
Workspace.published
|
119
119
|
end
|
120
120
|
|
121
|
-
# @return [Revision] or +nil+
|
121
|
+
# @return [Scrivito::Revision] or +nil+
|
122
122
|
def compare_revision
|
123
123
|
case display_mode
|
124
124
|
when 'added'
|
@@ -48,13 +48,13 @@ class EditingContextMiddleware
|
|
48
48
|
if editing_auth_callback = Configuration.editing_auth_callback
|
49
49
|
-> { editing_auth_callback.call(env) }
|
50
50
|
else
|
51
|
-
|
52
|
-
WARNING!
|
51
|
+
Warning.warn <<-EOS
|
53
52
|
|
54
53
|
Application is running in "#{Rails.env}" environment, but authentication is not configured.
|
55
54
|
For security reasons the in-place editing is disabled.
|
56
55
|
Please see https://scrivito.com/permissions for details.
|
57
|
-
|
56
|
+
|
57
|
+
EOS
|
58
58
|
nil
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Scrivito
|
2
|
+
class ErroredWidgetTag < BaseWidgetTag
|
3
|
+
attr_reader :error
|
4
|
+
|
5
|
+
def initialize(view, widget, options)
|
6
|
+
@error = options.fetch(:error)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def content
|
11
|
+
if view.controller.respond_to?(:on_scrivito_widget_error, true)
|
12
|
+
view.controller.__send__(:on_scrivito_widget_error, widget, error)
|
13
|
+
else
|
14
|
+
handle_render_error(widget, error)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def description_for_editor
|
21
|
+
"Error in #{widget.class.description_for_editor}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def handle_render_error(widget, error)
|
25
|
+
message = "Rendering widget with ID #{widget.id} and obj_class #{widget.obj_class} for "\
|
26
|
+
"obj with ID #{widget.obj.id} failed"
|
27
|
+
Warning.error(message, error)
|
28
|
+
|
29
|
+
"We're sorry, but something went wrong. "\
|
30
|
+
"If you are the application owner check the logs for more information."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/scrivito/errors.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Scrivito
|
2
|
+
|
3
|
+
# @api public
|
4
|
+
# The FutureBinary class represents the data to be stored in a binary field.
|
5
|
+
# See {Scrivito::Binary.upload} and {Scrivito::Binary#copy} for details.
|
6
|
+
class FutureBinary
|
7
|
+
attr_reader :filename, :content_type, :id_to_be_copied, :file_to_be_uploaded
|
8
|
+
|
9
|
+
def initialize(filename:, content_type:, id_to_be_copied: nil, file_to_be_uploaded: nil)
|
10
|
+
@filename = filename
|
11
|
+
@content_type = content_type || content_type_of_filename(filename)
|
12
|
+
@id_to_be_copied = id_to_be_copied
|
13
|
+
@file_to_be_uploaded = file_to_be_uploaded
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def content_type_of_filename(filename)
|
19
|
+
MIME::Types.type_for(filename).first.try(:content_type)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/scrivito/link_parser.rb
CHANGED
@@ -40,7 +40,18 @@ module Scrivito
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def application_uri?(uri)
|
43
|
-
uri
|
43
|
+
absolute_uri?(uri) && internal_uri?(uri) || relative_uri?(uri) && uri.path.present?
|
44
|
+
end
|
45
|
+
|
46
|
+
def absolute_uri?(uri)
|
47
|
+
# Ruby's URI parser assumes URLs without a scheme as relativ, while a browser assumes a
|
48
|
+
# schemeless "//scrivito.com" as absolute. Since the URLs are for the browser, we cannot use
|
49
|
+
# Ruby's URI here.
|
50
|
+
uri.to_s =~ /\A([a-z][a-z\d\-+\.]*:|\/\/).*/i
|
51
|
+
end
|
52
|
+
|
53
|
+
def relative_uri?(uri)
|
54
|
+
!absolute_uri?(uri)
|
44
55
|
end
|
45
56
|
|
46
57
|
def internal_uri?(uri)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Scrivito
|
2
2
|
# @api public
|
3
|
-
# The MembershipCollection includes all members of a given {Workspace}.
|
4
|
-
# You can access it using the {Workspace#memberships} method.
|
3
|
+
# The Scrivito::MembershipCollection includes all members of a given {Scrivito::Workspace}.
|
4
|
+
# You can access it using the {Scrivito::Workspace#memberships} method.
|
5
5
|
class MembershipCollection
|
6
6
|
extend Forwardable
|
7
7
|
include Enumerable
|
@@ -10,10 +10,10 @@ module Scrivito
|
|
10
10
|
|
11
11
|
# @api public
|
12
12
|
# @!method each
|
13
|
-
# Iterate over all {Membership Memberships} of a specific {Workspace}.
|
14
|
-
# you to use all the methods defined by Ruby's Enumerable module.
|
13
|
+
# Iterate over all {Scrivito::Membership Memberships} of a specific {Scrivito::Workspace}.
|
14
|
+
# Allows you to use all the methods defined by Ruby's Enumerable module.
|
15
15
|
#
|
16
|
-
# @yield [Membership]
|
16
|
+
# @yield [Scrivito::Membership]
|
17
17
|
#
|
18
18
|
# @return [Enumerator] if no block is given, an Enumerator is returned
|
19
19
|
#
|
@@ -41,7 +41,7 @@ module Scrivito
|
|
41
41
|
|
42
42
|
# @api public
|
43
43
|
# Returns a hash where the keys are +user_id+s and the values are Membership instances.
|
44
|
-
# @return [Hash<String, Membership>]
|
44
|
+
# @return [Hash<String, Scrivito::Membership>]
|
45
45
|
def to_h
|
46
46
|
memberships.inject(HashWithIndifferentAccess.new) do |hash, membership|
|
47
47
|
hash[membership.user_id] = membership
|
@@ -52,8 +52,8 @@ module Scrivito
|
|
52
52
|
# @api public
|
53
53
|
# Returns the membership of a user or nil.
|
54
54
|
#
|
55
|
-
# @param [User, String] id_or_user
|
56
|
-
# @return [Membership, nil]
|
55
|
+
# @param [Scrivito::User, String] id_or_user
|
56
|
+
# @return [Scrivito::Membership, nil]
|
57
57
|
def [](id_or_user)
|
58
58
|
id = if id_or_user.respond_to?(:id)
|
59
59
|
id_or_user.id
|
@@ -32,7 +32,7 @@ module Scrivito
|
|
32
32
|
# Find the {BasicObj Obj} that has the given path.
|
33
33
|
# Returns +nil+ if no matching object exists.
|
34
34
|
# @param [String] path Path of the {BasicObj Obj}.
|
35
|
-
# @return [Obj]
|
35
|
+
# @return [Obj,NilClass]
|
36
36
|
# @api public
|
37
37
|
def find_by_path(path)
|
38
38
|
find_by(:path, [path]).first.first
|
@@ -40,7 +40,7 @@ module Scrivito
|
|
40
40
|
|
41
41
|
# Returns the {BasicObj Obj} that has the given permalink, or +nil+ if no matching object exists.
|
42
42
|
# @param [String] permalink The permalink of the {BasicObj Obj}.
|
43
|
-
# @return [Obj]
|
43
|
+
# @return [Obj,NilClass]
|
44
44
|
# @api public
|
45
45
|
def find_by_permalink(permalink)
|
46
46
|
find_by(:permalink, [permalink]).first.first
|
@@ -3,8 +3,8 @@ module Scrivito
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def convert_params(params)
|
6
|
-
if
|
7
|
-
obj_class = Obj.type_computer.compute_type_without_fallback(
|
6
|
+
if obj_class = params['_obj_class']
|
7
|
+
obj_class = Obj.type_computer.compute_type_without_fallback(obj_class)
|
8
8
|
convert_field_params(params, obj_class.attribute_definitions)
|
9
9
|
else
|
10
10
|
raise ArgumentError, 'Missing "_obj_class" param'
|
@@ -19,7 +19,7 @@ module Scrivito
|
|
19
19
|
when 'link' then ContentConversion.convert_link(value, host, port)
|
20
20
|
when 'linklist' then ContentConversion.convert_linklist_urls(value, host, port)
|
21
21
|
when 'widgetlist' then parse_widgetlist_params(value)
|
22
|
-
when 'date' then
|
22
|
+
when 'date' then parse_date_params(value)
|
23
23
|
else value
|
24
24
|
end
|
25
25
|
end
|
@@ -49,5 +49,9 @@ module Scrivito
|
|
49
49
|
def parse_binary_params(params)
|
50
50
|
UploadedBinary.new(params) if params
|
51
51
|
end
|
52
|
+
|
53
|
+
def parse_date_params(params)
|
54
|
+
DateAttribute.parse_iso8601(params)
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
@@ -26,11 +26,10 @@ class ObjSearchBuilder < Struct.new(:query)
|
|
26
26
|
|
27
27
|
def set_predicates
|
28
28
|
query[:predicates].each do |p|
|
29
|
-
values = deserialize_values(p[:value])
|
30
29
|
if p[:negate]
|
31
|
-
enumerator.and_not(p[:field], p[:operator],
|
30
|
+
enumerator.and_not(p[:field], p[:operator], p[:value])
|
32
31
|
else
|
33
|
-
enumerator.and(p[:field], p[:operator],
|
32
|
+
enumerator.and(p[:field], p[:operator], p[:value], p[:boost])
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -52,15 +51,6 @@ class ObjSearchBuilder < Struct.new(:query)
|
|
52
51
|
enumerator.include_deleted if query[:include_deleted]
|
53
52
|
end
|
54
53
|
|
55
|
-
def deserialize_values(values)
|
56
|
-
values.map do |(type, value)|
|
57
|
-
if type == 'date'
|
58
|
-
DateAttribute.deserialize_from_client(value)
|
59
|
-
else
|
60
|
-
value
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
54
|
end
|
65
55
|
|
66
56
|
end
|
@@ -1,38 +1,40 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Scrivito
|
3
|
-
# Provides an enumerator for iterating over the results of searches for CMS objects to retrieve
|
4
|
-
# This is achieved through the
|
5
|
-
# which provides methods such
|
3
|
+
# Provides an enumerator for iterating over the results of searches for CMS objects to retrieve
|
4
|
+
# instances of these objects. This is achieved through the
|
5
|
+
# {http://ruby-doc.org/core-2.1.3/Enumerable.html +Enumerable+ mixin}, which provides methods such
|
6
|
+
# as +map+, +select+ or +take+.
|
6
7
|
#
|
7
|
-
# This enumerator is lazy. If, for example, you are looking for {BasicObj Obj}s whose
|
8
|
-
# and there are 93 objects in total, then
|
9
|
-
# ignoring the other 83.
|
10
|
-
# This implies that repeatedly iterating over this enumerator causes the search results and the
|
11
|
-
# If you want to get all objects at once, use
|
8
|
+
# This enumerator is lazy. If, for example, you are looking for {Scrivito::BasicObj Obj}s whose
|
9
|
+
# object class is +Publication+, and there are 93 objects in total, then +enum.take(10)+ fetches
|
10
|
+
# the first 10 objects only, ignoring the other 83.
|
11
|
+
# This implies that repeatedly iterating over this enumerator causes the search results and the
|
12
|
+
# objects to be fetched again and again. If you want to get all objects at once, use +enum.to_a+.
|
12
13
|
#
|
13
|
-
# To start searching, use one of the {BasicObj Obj} methods that return an
|
14
|
+
# To start searching, use one of the {Scrivito::BasicObj Obj} methods that return an
|
15
|
+
# {Scrivito::ObjSearchEnumerator}. The preferred way is to start with
|
16
|
+
# {Scrivito::BasicObj.where Obj.where}.
|
14
17
|
#
|
15
18
|
# == Currently available fields and their values
|
16
19
|
#
|
17
20
|
# [+:*+] Searches all fields.
|
18
21
|
# This is only possible with the +contains+ and +starts_with+ operators.
|
19
|
-
# [+:id+] Id of an {BasicObj Obj}. This is a +string+ field.
|
20
|
-
# [+:_path+] Path of an {BasicObj Obj}. This is a +string+ field.
|
21
|
-
# [+:_name+] Name of an {BasicObj Obj}. This is a +string+ field.
|
22
|
-
# [+:title+] Title of an {BasicObj Obj}. This is a +string+ field.
|
23
|
-
# [+:body+] Body of an {BasicObj Obj}. This is an +html+ field. Thus, only the
|
24
|
-
# +contains_prefix+ operators can be applied to this field.
|
25
|
-
# [+:_obj_class+] Object class of an {BasicObj Obj}. This is a +string+ field.
|
26
|
-
# [+:_permalink+] Permalink of an {BasicObj Obj}. This is a +string+ field.
|
27
|
-
# [+:_last_changed+] Date of last change of an {BasicObj Obj}.
|
28
|
-
# [every
|
29
|
-
# depending on the attribute type (e.g. an
|
30
|
-
# +html+ field), some operators cannot be applied.
|
22
|
+
# [+:id+] Id of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
23
|
+
# [+:_path+] Path of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
24
|
+
# [+:_name+] Name of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
25
|
+
# [+:title+] Title of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
26
|
+
# [+:body+] Body of an {Scrivito::BasicObj Obj}. This is an +html+ field. Thus, only the
|
27
|
+
# +contains+ and +contains_prefix+ operators can be applied to this field.
|
28
|
+
# [+:_obj_class+] Object class of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
29
|
+
# [+:_permalink+] Permalink of an {Scrivito::BasicObj Obj}. This is a +string+ field.
|
30
|
+
# [+:_last_changed+] Date of last change of an {Scrivito::BasicObj Obj}.
|
31
|
+
# [every +_:custom_attribute_+] Custom attribute of an {Scrivito::BasicObj Obj}. Note that depending on the attribute type (e.g. an +html+ field), some operators cannot be applied.
|
31
32
|
#
|
32
33
|
# All values are stored as strings.
|
33
34
|
#
|
34
|
-
# Date values are stored in the format YYYYMMDDHHMMSS in UTC. For example, 2000-01-01 00:00:00
|
35
|
-
# This is relevant for string comparisons in which the
|
35
|
+
# Date values are stored in the format +YYYYMMDDHHMMSS+ in UTC. For example, 2000-01-01 00:00:00
|
36
|
+
# UTC is stored as "+20000101000000+". This is relevant for string comparisons in which the
|
37
|
+
# +is_less_than+ and +is_greater_than+ operators are used.
|
36
38
|
#
|
37
39
|
# == Currently available operators
|
38
40
|
#
|
@@ -118,7 +120,7 @@ module Scrivito
|
|
118
120
|
|
119
121
|
# @group Chainable methods
|
120
122
|
|
121
|
-
# Adds the given AND subquery to this {ObjSearchEnumerator}.
|
123
|
+
# Adds the given AND subquery to this {Scrivito::ObjSearchEnumerator}.
|
122
124
|
#
|
123
125
|
# Compares the +field(s)+ with the +value(s)+ using the +operator+ of this subquery.
|
124
126
|
# All CMS objects to which this criterion applies remain in the result set.
|
@@ -126,12 +128,13 @@ module Scrivito
|
|
126
128
|
# @param [Symbol, String, Array<Symbol, String>] field Name(s) of the field(s) to be searched.
|
127
129
|
# For arrays, the subquery matches if one or more of these fields meet this criterion.
|
128
130
|
# @param [Symbol, String] operator See "Currently available operators" above.
|
129
|
-
# @param [String, Array<String>] value The value(s) to compare with the field value(s) using the
|
130
|
-
# For arrays, the subquery matches if the condition is met for
|
131
|
-
#
|
132
|
-
#
|
133
|
-
# Boosting
|
134
|
-
#
|
131
|
+
# @param [String, Array<String>] value The value(s) to compare with the field value(s) using the
|
132
|
+
# +operator+ of this subquery. For arrays, the subquery matches if the condition is met for
|
133
|
+
# one or more of the array elements.
|
134
|
+
# @param [Hash] boost A hash where the keys are field names and their values are boosting
|
135
|
+
# factors. Boosting factors must be in the range from 1 to 10. Boosting can only be applied to
|
136
|
+
# subqueries in which the +contains+ or +contains_prefix+ operator is used.
|
137
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
135
138
|
# @api public
|
136
139
|
def and(field, operator, value, boost = nil)
|
137
140
|
real_operator = operator_mapping(operator)
|
@@ -151,7 +154,7 @@ module Scrivito
|
|
151
154
|
self
|
152
155
|
end
|
153
156
|
|
154
|
-
# Adds the given negated AND subquery to this {ObjSearchEnumerator}.
|
157
|
+
# Adds the given negated AND subquery to this {Scrivito::ObjSearchEnumerator}.
|
155
158
|
#
|
156
159
|
# Compares the +field(s)+ with the +value(s)+ using the negated +operator+ of this subquery.
|
157
160
|
# All CMS objects to which this criterion applies are removed from the result set.
|
@@ -161,9 +164,10 @@ module Scrivito
|
|
161
164
|
# @param [Symbol, String] operator Only applicable to subqueries in which the +equals+,
|
162
165
|
# +starts_with+, +is_greater_than+ or +is_less_than+ operator is used.
|
163
166
|
# (See "Currently available operators" above).
|
164
|
-
# @param [String, Array<String>] value The value(s) to compare with the field value(s) using the
|
165
|
-
# For arrays, the subquery matches if the condition is met for
|
166
|
-
#
|
167
|
+
# @param [String, Array<String>] value The value(s) to compare with the field value(s) using the
|
168
|
+
# +operator+ of this subquery. For arrays, the subquery matches if the condition is met for
|
169
|
+
# one or more of the array elements.
|
170
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
167
171
|
# @api public
|
168
172
|
def and_not(field, operator, value)
|
169
173
|
real_operator = operator_mapping(operator)
|
@@ -180,8 +184,9 @@ module Scrivito
|
|
180
184
|
end
|
181
185
|
|
182
186
|
# Orders the results by +field_name+.
|
183
|
-
# @param [Symbol, String] field_name This parameter specifies the field by which the hits are
|
184
|
-
#
|
187
|
+
# @param [Symbol, String] field_name This parameter specifies the field by which the hits are
|
188
|
+
# sorted (e.g. +:_path+).
|
189
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
185
190
|
# @api public
|
186
191
|
def order(field_name)
|
187
192
|
options[:sort_by] = field_name
|
@@ -190,7 +195,7 @@ module Scrivito
|
|
190
195
|
end
|
191
196
|
|
192
197
|
# Reverses the order of the results. Requires {#order} to be applied before.
|
193
|
-
# @return [ObjSearchEnumerator]
|
198
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
194
199
|
# @api public
|
195
200
|
def reverse_order
|
196
201
|
options[:sort_by].present? or raise "A search order has to be specified"\
|
@@ -203,7 +208,7 @@ module Scrivito
|
|
203
208
|
# Number of search results to be returned by each of the internal search requests.
|
204
209
|
# The default is +10+. The server may reduce large batches to a reasonable size.
|
205
210
|
# @param [Integer] size A value in the range from +1+ to +100+.
|
206
|
-
# @return [ObjSearchEnumerator]
|
211
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
207
212
|
# @api public
|
208
213
|
def batch_size(size)
|
209
214
|
options[:size] = size
|
@@ -212,9 +217,9 @@ module Scrivito
|
|
212
217
|
end
|
213
218
|
|
214
219
|
|
215
|
-
# Omits the first +amount+ of {BasicObj Obj}s from the results. The default is +0+.
|
220
|
+
# Omits the first +amount+ of {Scrivito::BasicObj Obj}s from the results. The default is +0+.
|
216
221
|
# @param [Integer] amount
|
217
|
-
# @return [ObjSearchEnumerator]
|
222
|
+
# @return [Scrivito::ObjSearchEnumerator]
|
218
223
|
# @api public
|
219
224
|
def offset(amount)
|
220
225
|
options[:offset] ||= 0
|
@@ -231,7 +236,7 @@ module Scrivito
|
|
231
236
|
|
232
237
|
# @!endgroup
|
233
238
|
|
234
|
-
# Iterates over the search result, yielding {BasicObj Obj}.
|
239
|
+
# Iterates over the search result, yielding {Scrivito::BasicObj Obj}.
|
235
240
|
# @yield [Obj]
|
236
241
|
# @return [void]
|
237
242
|
# @api public
|
@@ -273,7 +278,7 @@ module Scrivito
|
|
273
278
|
end
|
274
279
|
|
275
280
|
# Loads a single batch of search results from the backend.
|
276
|
-
# @return [Array] of {BasicObj Obj}.
|
281
|
+
# @return [Array] of {Scrivito::BasicObj Obj}.
|
277
282
|
# Usually returns +batch_size+ results if available,
|
278
283
|
# but may occasionally return fewer than +batch_size+ results (due to rate limit, for example).
|
279
284
|
# @api public
|
@@ -303,7 +308,7 @@ module Scrivito
|
|
303
308
|
|
304
309
|
def convert_single_value(value)
|
305
310
|
if value.is_a?(Time) || value.is_a?(Date)
|
306
|
-
DateAttribute.
|
311
|
+
DateAttribute.serialize(value)
|
307
312
|
else
|
308
313
|
value.to_s
|
309
314
|
end
|