turbo_reflex 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/app/controllers/concerns/turbo_reflex/controller.rb +0 -8
- data/lib/turbo_reflex/runner.rb +14 -9
- data/lib/turbo_reflex/state_manager.rb +3 -2
- data/lib/turbo_reflex/version.rb +1 -1
- data/tags +1 -1
- data/turbo_reflex.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 148653f6e602f340ed943feddcc574c059571baae1971c47816df9cd97c672f5
|
4
|
+
data.tar.gz: 32d37a9dc870c39886d7218b2e6d9cdeba1f299cf747d7d165b4e5673f67d4dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f5c538fcb479478fc87789145ccf0aa9908b0bf72b7f3a7f0ba24af5da45951c5b6bf6c776e160adc1d4e07b425f0cdca93d535a7dbf5dba14c8f565a44e8c
|
7
|
+
data.tar.gz: 8a68c4b30fbd18ecc9a213107274c93f2da711c2843fbd8406f2387bec1127967bccfef24f426c0927010add654a08660d203c8e3a9cb5dd18c62617b6a55c85
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
turbo_reflex (0.0.
|
4
|
+
turbo_reflex (0.0.13)
|
5
5
|
rails (>= 6.1)
|
6
6
|
turbo-rails (>= 1.1)
|
7
7
|
turbo_ready (>= 0.1)
|
@@ -156,7 +156,7 @@ GEM
|
|
156
156
|
pry-rails (0.3.9)
|
157
157
|
pry (>= 0.10.4)
|
158
158
|
public_suffix (5.0.0)
|
159
|
-
puma (6.
|
159
|
+
puma (5.6.5)
|
160
160
|
nio4r (~> 2.0)
|
161
161
|
racc (1.6.0)
|
162
162
|
rack (2.2.4)
|
@@ -279,7 +279,7 @@ DEPENDENCIES
|
|
279
279
|
pry-byebug
|
280
280
|
pry-doc
|
281
281
|
pry-rails
|
282
|
-
puma
|
282
|
+
puma (~> 5.6.5)
|
283
283
|
rake
|
284
284
|
rexml
|
285
285
|
rouge
|
@@ -4,14 +4,6 @@ module TurboReflex::Controller
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
module ClassMethods
|
7
|
-
def turbo_reflex_state_cookie_max_bytesize
|
8
|
-
TurboReflex::StateManager.cookie_max_bytesize
|
9
|
-
end
|
10
|
-
|
11
|
-
def turbo_reflex_state_cookie_max_bytesize=(value)
|
12
|
-
TurboReflex::StateManager.cookie_max_bytesize = value
|
13
|
-
end
|
14
|
-
|
15
7
|
def turbo_reflex_state(&block)
|
16
8
|
TurboReflex::StateManager.add_state_override_block name, block
|
17
9
|
end
|
data/lib/turbo_reflex/runner.rb
CHANGED
@@ -154,15 +154,20 @@ class TurboReflex::Runner
|
|
154
154
|
|
155
155
|
def render_response(html: "", status: nil, headers: {TurboReflex: :Append})
|
156
156
|
headers.each { |key, value| response.set_header key.to_s, value.to_s }
|
157
|
-
|
157
|
+
render html: html, layout: false, status: status || response_status
|
158
158
|
end
|
159
159
|
|
160
160
|
def turbo_stream
|
161
|
-
@turbo_stream ||= Turbo::Streams::TagBuilder.new(
|
161
|
+
@turbo_stream ||= Turbo::Streams::TagBuilder.new(view_context)
|
162
162
|
end
|
163
163
|
|
164
164
|
def message_verifier
|
165
|
-
ActiveSupport::MessageVerifier.new
|
165
|
+
ActiveSupport::MessageVerifier.new Rails.application.secret_key_base, digest: "SHA256"
|
166
|
+
end
|
167
|
+
|
168
|
+
# Same implementation as ActionController::Base but with public visibility
|
169
|
+
def cookies
|
170
|
+
request.cookie_jar
|
166
171
|
end
|
167
172
|
|
168
173
|
private
|
@@ -180,7 +185,7 @@ class TurboReflex::Runner
|
|
180
185
|
end
|
181
186
|
|
182
187
|
def server_token
|
183
|
-
|
188
|
+
cookies.encrypted["turbo_reflex.token"]
|
184
189
|
end
|
185
190
|
|
186
191
|
def client_token
|
@@ -195,8 +200,8 @@ class TurboReflex::Runner
|
|
195
200
|
end
|
196
201
|
|
197
202
|
def should_redirect?
|
198
|
-
return false if
|
199
|
-
|
203
|
+
return false if request.method.match?(/GET/i)
|
204
|
+
request.accepts.include? Mime::Type.lookup_by_extension(:turbo_stream)
|
200
205
|
end
|
201
206
|
|
202
207
|
def response_status
|
@@ -205,7 +210,7 @@ class TurboReflex::Runner
|
|
205
210
|
end
|
206
211
|
|
207
212
|
def response_type
|
208
|
-
body =
|
213
|
+
body = response_body.to_s.strip
|
209
214
|
return :body if body.match?(/<\/\s*body.*>/i)
|
210
215
|
return :frame if body.match?(/<\/\s*turbo-frame.*>/i)
|
211
216
|
return :stream if body.match?(/<\/\s*turbo-stream.*>/i)
|
@@ -229,7 +234,7 @@ class TurboReflex::Runner
|
|
229
234
|
end
|
230
235
|
|
231
236
|
def append_meta_tag_to_response_body
|
232
|
-
|
237
|
+
cookies.encrypted["turbo_reflex.token"] = {value: new_token, path: "/"}
|
233
238
|
append_to_response_body turbo_stream.invoke("morph", args: [meta_tag], selector: "#turbo-reflex")
|
234
239
|
end
|
235
240
|
|
@@ -261,7 +266,7 @@ class TurboReflex::Runner
|
|
261
266
|
case response_type
|
262
267
|
when :body then response.body.sub!(/<\/\s*body.*>/i, "#{sanitized_content}</body>")
|
263
268
|
when :frame then response.body.sub!(/<\/\s*turbo-frame.*>/i, "#{sanitized_content}</turbo-frame>")
|
264
|
-
else
|
269
|
+
else response_body << sanitized_content
|
265
270
|
end
|
266
271
|
end
|
267
272
|
end
|
@@ -41,6 +41,7 @@ class TurboReflex::StateManager
|
|
41
41
|
# For ActiveModel::Dirty tracking
|
42
42
|
define_attribute_methods :state
|
43
43
|
|
44
|
+
delegate :cookies, to: :runner
|
44
45
|
delegate :request, :response, to: :"runner.controller"
|
45
46
|
|
46
47
|
def initialize(runner)
|
@@ -77,7 +78,7 @@ class TurboReflex::StateManager
|
|
77
78
|
return unless changed?
|
78
79
|
state.shrink!
|
79
80
|
state.prune! max_bytesize: TurboReflex::StateManager.cookie_max_bytesize
|
80
|
-
|
81
|
+
cookies["turbo_reflex.state"] = {value: state.ordinal_payload, path: "/", expires: 1.day.from_now}
|
81
82
|
changes_applied
|
82
83
|
end
|
83
84
|
|
@@ -97,6 +98,6 @@ class TurboReflex::StateManager
|
|
97
98
|
|
98
99
|
# State that the server last rendered with.
|
99
100
|
def cookie
|
100
|
-
|
101
|
+
cookies["turbo_reflex.state"]
|
101
102
|
end
|
102
103
|
end
|
data/lib/turbo_reflex/version.rb
CHANGED
data/tags
CHANGED
@@ -216621,7 +216621,7 @@ VDash node_modules/parse-srcset/tests/he.js /^ var decodeMap = {'Aacute':'\\xC1'
|
|
216621
216621
|
VDash node_modules/simple-html-tokenizer/dist/es6/index.js /^ Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾̳",/;" p variable:namedCharRefs
|
216622
216622
|
VDash node_modules/simple-html-tokenizer/dist/simple-html-tokenizer.js /^ Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾/;" p variable:anonymousFunction3825d8d70300.namedCharRefs
|
216623
216623
|
VDash node_modules/simple-html-tokenizer/dist/types/generated/html5-named-char-refs.d.ts /^ VDash: string;$/;" C
|
216624
|
-
VERSION lib/turbo_reflex/version.rb /^ VERSION = "0.0.
|
216624
|
+
VERSION lib/turbo_reflex/version.rb /^ VERSION = "0.0.13"$/;" C module:TurboReflex
|
216625
216625
|
VERSION node_modules/@angular/compiler/esm2015/src/output/source_map.js /^const VERSION = 3;$/;" C
|
216626
216626
|
VERSION node_modules/@angular/compiler/esm2015/src/version.js /^export const VERSION = new Version('8.2.14');$/;" C
|
216627
216627
|
VERSION node_modules/@angular/compiler/esm5/src/output/source_map.js /^var VERSION = 3;$/;" v
|
data/turbo_reflex.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_development_dependency "pry-byebug"
|
33
33
|
s.add_development_dependency "pry-doc"
|
34
34
|
s.add_development_dependency "pry-rails"
|
35
|
-
s.add_development_dependency "puma"
|
35
|
+
s.add_development_dependency "puma", "~> 5.6.5" # pin until capybara catches up
|
36
36
|
s.add_development_dependency "rake"
|
37
37
|
s.add_development_dependency "rexml"
|
38
38
|
s.add_development_dependency "rouge"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hopkins (hopsoft)
|
@@ -196,16 +196,16 @@ dependencies:
|
|
196
196
|
name: puma
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- - "
|
199
|
+
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
201
|
+
version: 5.6.5
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- - "
|
206
|
+
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
208
|
+
version: 5.6.5
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: rake
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|