breezy 0.18.1 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5407b99c417dc88944a8c1bf68fe6bda73a072ee43f25c1a45995d9545f97b2
4
- data.tar.gz: 91354f50156543100d7f3add14668b9d1b8d324fa01c4207f6f0c87c863e7dfa
3
+ metadata.gz: fcc4cf35ca92806333f48649d4b91ee05fe5a83a78196495c7be8092082c0b90
4
+ data.tar.gz: 232a74c14a615a93e226b277823d1f53fe4bb68460b21585b6685dd9cf78e998
5
5
  SHA512:
6
- metadata.gz: 449612b076ee7c7226ea368156901725f2736383054c3bef5b8bc103457e6aec4d2921013281d908ea49fa8ffc5d35226789aac47fb9c3e4ac8439ca98791ecb
7
- data.tar.gz: 9d4e775dd2f41a0008bd3a5a8dd0f66032c68f4bc1e3321b3377fe8ae3c7bbcccb3c9a47449b3ec164fc2bab8687a8291a5bf568367847e9325ee3db89329d76
6
+ metadata.gz: edcc8bbd2087fd0e9c9520c3e7fe466786ca8d901b97eacbcc167ae5773bd34067917029c101c0300c6c986c9c0375d30f34725e210d23af4640b6b62809c345
7
+ data.tar.gz: c54a93e9bbe4e0bffa490fa219a0ba2dff705f9424d63b13ff6731b5f0353f011e057b38c53e5061ef8257c5076f2377fb2980223484fe9d2dcb7041325bbc7c
data/lib/breezy.rb CHANGED
@@ -1,21 +1,12 @@
1
- require 'breezy/xhr_headers'
2
- require 'breezy/xhr_url_for'
3
- require 'breezy/x_domain_blocker'
4
1
  require 'breezy/helpers'
5
2
  require 'breezy/redirection'
6
3
  require 'props_template'
7
4
 
8
5
  module Breezy
9
6
  module Controller
10
- include XHRHeaders, XDomainBlocker, Helpers, Redirection
7
+ include Helpers, Redirection
11
8
 
12
9
  def self.included(base)
13
- if base.respond_to?(:before_action)
14
- base.after_action :abort_xdomain_redirect
15
- else
16
- base.after_filter :abort_xdomain_redirect
17
- end
18
-
19
10
  if base.respond_to?(:helper_method)
20
11
  base.helper_method :param_to_search_path
21
12
  base.helper_method :props_from_form_with
@@ -41,19 +32,6 @@ module Breezy
41
32
  if app.config.breezy.auto_include
42
33
  include Controller
43
34
  end
44
-
45
- ActionDispatch::Request.class_eval do
46
- def referer
47
- self.headers['X-XHR-Referer'] || super
48
- end
49
- alias referrer referer
50
- end
51
-
52
- require 'action_dispatch/routing/redirection'
53
-
54
- (ActionView::RoutingUrlFor rescue ActionView::Helpers::UrlHelper).module_eval do
55
- prepend XHRUrlFor
56
- end
57
35
  end
58
36
  end
59
37
  end
@@ -25,7 +25,7 @@ module Rails
25
25
 
26
26
  %w(index show new edit).each do |view|
27
27
  @action_name = view
28
- filename = filename_with_jsx_extensions(view)
28
+ filename = filename_with_js_extensions(view)
29
29
  template 'web/' + filename, File.join('app/views', controller_file_path, filename)
30
30
  end
31
31
 
@@ -68,8 +68,8 @@ module Rails
68
68
  [name, :json, :props] * '.'
69
69
  end
70
70
 
71
- def filename_with_jsx_extensions(name)
72
- [name, :jsx] * '.'
71
+ def filename_with_js_extensions(name)
72
+ [name, :js] * '.'
73
73
  end
74
74
 
75
75
  def filename_with_html_extensions(name)
@@ -4,4 +4,9 @@
4
4
  window.BREEZY_INITIAL_PAGE_STATE=<%%= initial_state.html_safe %>;
5
5
  </script>
6
6
 
7
- <div id="app"></div>
7
+ <div id="app">
8
+ <%%# If you need SSR follow instructions at %>
9
+ <%%# https://github.com/thoughtbot/breezy/blob/main/docs/recipes/server-side-rendering.md %>
10
+ <%%# and uncomment the following line %>
11
+ <%%#= Humid.render(initial_state).html_safe %>
12
+ </div>
@@ -5,7 +5,7 @@
5
5
  // } from './actions'
6
6
  // import produce from "immer"
7
7
  //
8
- // export default function (state = {}, action) {
8
+ // export const applicationPagesReducer = (state = {}, action) => {
9
9
  // switch(action.type) {
10
10
  // case CLEAR_FORM_ERRORS: {
11
11
  // const {pageKey} = action.payload
data/lib/install/web.rb CHANGED
@@ -56,10 +56,8 @@ say "Adding required member methods to ApplicationRecord"
56
56
  add_member_methods
57
57
 
58
58
  say "Installing React, Redux, and Breezy"
59
- run "yarn add babel-plugin-module-resolver history@\"^4\" html-react-parser@\"^0.13\" react-redux redux-thunk redux redux-persist reduce-reducers immer @jho406/breezy --save"
59
+ run "yarn add babel-plugin-module-resolver history@\"^4\" html-react-parser react-redux redux-thunk redux redux-persist reduce-reducers immer @jho406/breezy --save"
60
60
 
61
- say "Updating webpack config to include .jsx file extension and resolved_paths"
62
- insert_into_file Webpacker.config.config_path, " - .jsx\n", after: /\bextensions:\n/
63
61
  # For newer webpacker
64
62
  insert_into_file Webpacker.config.config_path, "'app/views', 'app/components'", after: /additional_paths: \[/
65
63
  # For older webpacker
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breezy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-11 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -159,9 +159,6 @@ files:
159
159
  - lib/breezy.rb
160
160
  - lib/breezy/helpers.rb
161
161
  - lib/breezy/redirection.rb
162
- - lib/breezy/x_domain_blocker.rb
163
- - lib/breezy/xhr_headers.rb
164
- - lib/breezy/xhr_url_for.rb
165
162
  - lib/generators/rails/breezy_generator.rb
166
163
  - lib/generators/rails/scaffold_controller_generator.rb
167
164
  - lib/generators/rails/templates/_form.json.props
@@ -171,13 +168,13 @@ files:
171
168
  - lib/generators/rails/templates/new.json.props
172
169
  - lib/generators/rails/templates/show.json.props
173
170
  - lib/generators/rails/templates/web/edit.html.erb
174
- - lib/generators/rails/templates/web/edit.jsx
171
+ - lib/generators/rails/templates/web/edit.js
175
172
  - lib/generators/rails/templates/web/index.html.erb
176
- - lib/generators/rails/templates/web/index.jsx
173
+ - lib/generators/rails/templates/web/index.js
177
174
  - lib/generators/rails/templates/web/new.html.erb
178
- - lib/generators/rails/templates/web/new.jsx
175
+ - lib/generators/rails/templates/web/new.js
179
176
  - lib/generators/rails/templates/web/show.html.erb
180
- - lib/generators/rails/templates/web/show.jsx
177
+ - lib/generators/rails/templates/web/show.js
181
178
  - lib/install/templates/web/action_creators.js
182
179
  - lib/install/templates/web/actions.js
183
180
  - lib/install/templates/web/application.js
@@ -210,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
207
  - !ruby/object:Gem::Version
211
208
  version: '0'
212
209
  requirements: []
213
- rubygems_version: 3.1.2
210
+ rubygems_version: 3.0.3
214
211
  signing_key:
215
212
  specification_version: 4
216
213
  summary: Rails integration for BreezyJS
@@ -1,22 +0,0 @@
1
- module Breezy
2
- # Changes the response status to 403 Forbidden if all of these conditions are true:
3
- # - The current request originated from Breezy
4
- # - The request is being redirected to a different domain
5
- module XDomainBlocker
6
- private
7
- def same_origin?(a, b)
8
- a = URI.parse URI.escape(a)
9
- b = URI.parse URI.escape(b)
10
- [a.scheme, a.host, a.port] == [b.scheme, b.host, b.port]
11
- end
12
-
13
- def abort_xdomain_redirect
14
- to_uri = response.headers['Location']
15
- current = request.headers['X-XHR-Referer']
16
- unless to_uri.blank? || current.blank? || same_origin?(current, to_uri)
17
- self.status = 403
18
- end
19
- rescue URI::InvalidURIError
20
- end
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- module Breezy
2
- module XHRHeaders
3
- def redirect_back(fallback_location:, **args)
4
- if referer = request.headers["X-XHR-Referer"]
5
- redirect_to referer, **args
6
- else
7
- super
8
- end
9
- end
10
-
11
- def _compute_redirect_to_location(request, options)
12
- url = begin
13
- if options == :back && request.headers["X-XHR-Referer"]
14
- super(request, request.headers["X-XHR-Referer"])
15
- else
16
- super
17
- end
18
- end
19
-
20
- url
21
- end
22
- end
23
- end
@@ -1,11 +0,0 @@
1
- module Breezy
2
- # Corrects the behavior of url_for (and link_to, which uses url_for) with the :back
3
- # option by using the X-XHR-Referer request header instead of the standard Referer
4
- # request header.
5
- module XHRUrlFor
6
- def url_for(options = {})
7
- options = (controller.request.headers["X-XHR-Referer"] || options) if options == :back
8
- super
9
- end
10
- end
11
- end