effective_datatables 4.4.1 → 4.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/datatable.rb +1 -0
- data/app/models/effective/effective_datatable/attributes.rb +1 -6
- data/app/models/effective/effective_datatable/cookie.rb +14 -2
- data/app/models/effective/effective_datatable/params.rb +1 -2
- data/config/effective_datatables.rb +4 -2
- data/lib/effective_datatables.rb +7 -1
- data/lib/effective_datatables/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: d2e589bf3b121ec3ec0286dc8c1e94169a26edd9
|
4
|
+
data.tar.gz: f35b96216db08d011c858c3876b4e94cefbafada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4181de92a46520e05f875cd0b2d650a7f9cd304f44605e72d858fecf1688578a85f53d93f9a5597a99dd2b950c482201cfa848ff248ad4e32a1d65c7755dce83
|
7
|
+
data.tar.gz: 142a507377e8340ae1a9f1bee1881c351295f4f05e53748750a8ab216cda05682c5bf6bbc9b13482a9ee0961e367afd48f202c08ff9141a908352271fd1631b8
|
@@ -11,13 +11,8 @@ module Effective
|
|
11
11
|
|
12
12
|
def load_attributes!
|
13
13
|
if datatables_ajax_request? || datatables_inline_request?
|
14
|
-
raise 'expected cookie to be present' unless cookie
|
15
|
-
raise 'expected attributes cookie to be present' unless cookie[:attributes]
|
16
|
-
|
17
14
|
@attributes = cookie.delete(:attributes)
|
18
|
-
|
19
|
-
|
20
|
-
unless datatables_ajax_request? || datatables_inline_request?
|
15
|
+
else
|
21
16
|
@attributes[:_n] ||= view.controller_path.split('/')[0...-1].join('/').presence
|
22
17
|
end
|
23
18
|
end
|
@@ -48,15 +48,27 @@ module Effective
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def assert_cookie!
|
52
|
+
if datatables_ajax_request? || datatables_inline_request?
|
53
|
+
raise 'expected cookie to be present' unless cookie
|
54
|
+
raise 'expected attributes cookie to be present' unless cookie[:attributes]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
def save_cookie!
|
52
59
|
@dt_cookie ||= []
|
53
60
|
@dt_cookie << [cookie_key, cookie_payload]
|
54
61
|
|
55
|
-
while @dt_cookie.to_s.size > EffectiveDatatables.
|
62
|
+
while @dt_cookie.to_s.size > EffectiveDatatables.cookie_max_size.to_i
|
56
63
|
@dt_cookie.shift((@dt_cookie.length / 3) + 1)
|
57
64
|
end
|
58
65
|
|
59
|
-
|
66
|
+
# Generate cookie
|
67
|
+
domain = EffectiveDatatables.cookie_domain || :all
|
68
|
+
tld_length = EffectiveDatatables.cookie_tld_length
|
69
|
+
tld_length ||= (view.request.host == 'localhost' ? nil : view.request.host.to_s.split('.').count)
|
70
|
+
|
71
|
+
view.cookies.signed['_effective_dt'] = { value: Base64.encode64(Marshal.dump(@dt_cookie)), domain: domain, tld_length: tld_length }.compact
|
60
72
|
end
|
61
73
|
|
62
74
|
def cookie_payload
|
@@ -7,8 +7,7 @@ module Effective
|
|
7
7
|
def datatables_ajax_request?
|
8
8
|
return @_datatables_ajax_request unless @_datatables_ajax_request.nil?
|
9
9
|
|
10
|
-
@_datatables_ajax_request =
|
11
|
-
(view && view.params[:draw] && view.params[:columns] && cookie_keys.include?(view.params[:cookie])) == true
|
10
|
+
@_datatables_ajax_request = (view.present? && view.params.key?(:draw) && view.params.key?(:columns) && view.params.key?(:cookie))
|
12
11
|
end
|
13
12
|
|
14
13
|
def datatables_inline_request?
|
@@ -35,7 +35,9 @@ EffectiveDatatables.setup do |config|
|
|
35
35
|
# Irregardless of this setting, effective_datatables still uses a cookie to function
|
36
36
|
config.save_state = true
|
37
37
|
|
38
|
-
#
|
39
|
-
config.
|
38
|
+
# Configure the _effective_dt cookie.
|
39
|
+
config.cookie_max_size = 2000 # String size. Final byte size is about 1.5 times bigger, after rails signs it
|
40
|
+
config.cookie_domain = :all # Should usually be :all
|
41
|
+
config.cookie_tld_length = nil # Leave nil to autodetect, or set to probably 2
|
40
42
|
|
41
43
|
end
|
data/lib/effective_datatables.rb
CHANGED
@@ -9,10 +9,16 @@ module EffectiveDatatables
|
|
9
9
|
mattr_accessor :default_length
|
10
10
|
mattr_accessor :html_class
|
11
11
|
mattr_accessor :save_state
|
12
|
-
|
12
|
+
|
13
|
+
mattr_accessor :cookie_max_size
|
14
|
+
mattr_accessor :cookie_domain
|
15
|
+
mattr_accessor :cookie_tld_length
|
13
16
|
|
14
17
|
mattr_accessor :debug
|
15
18
|
|
19
|
+
alias_method :max_cookie_size, :cookie_max_size
|
20
|
+
alias_method :max_cookie_size=, :cookie_max_size=
|
21
|
+
|
16
22
|
def self.setup
|
17
23
|
yield self
|
18
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|