jets 3.0.19 → 3.0.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 628d962d35e5e497e1e5362ea11d5844c94e28f9e71877295edd046d291e6b81
4
- data.tar.gz: 0a353487be640729460d85debb14d71064415847311ec952b5612e8a483e6a63
3
+ metadata.gz: 549f5889b18b5a6dc74ec29259f874a80a6064291b1598ef92c4fd0cdcdc499b
4
+ data.tar.gz: 1b6a1b5534296e24729763c26b9c9aeba359412aa13da1fad9912d186c1cbef5
5
5
  SHA512:
6
- metadata.gz: b36f4d843a60052f42935df53e4d801e74dba09237b03b2cee11835894d0a4574493b1b26793f2fdbc8e26b040bd911378752000201b0bcfaeda56727936f04f
7
- data.tar.gz: ce8b72b84930ccd20727504c1955f4d1f4acf9c36e750207eb85ab2ccee6fd8a9d85e5f1ee6e449bf8a7e7925de3e55a08c3c294dd9eb0c8cb84cf98757412b2
6
+ metadata.gz: bc852f9754df45b1b8098a44de6d8b238554ad6ac8baacc005d7b2ce7a6d0a352ae12e19c6f232e8eef1d51fd1fc3fca2326025eeb4b3794d6b5c769b9748fa5
7
+ data.tar.gz: 818e6be78492e348119d083bc50ac91a34cf63f1e4a1785e4e1f96250418ba391388b876055b1f4916ef9a5c53dab59a1d10732b1d27d2f14ea7d64989ba7b96
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [3.0.20] - 2021-10-20
7
+ - [#603](https://github.com/boltops-tools/jets/pull/603) redirect_to: smarter handling of request xhr
8
+ - [#604](https://github.com/boltops-tools/jets/pull/604) fix redirect_to 301 and keep use default
9
+
6
10
  ## [3.0.19] - 2021-10-20
7
11
  - [#602](https://github.com/boltops-tools/jets/pull/602) pin zeitwerk to 2.4.x in gemfile
8
12
 
@@ -10,12 +10,22 @@ class Jets::Controller
10
10
  redirect_url = add_stage(url)
11
11
  redirect_url = ensure_protocol(redirect_url)
12
12
 
13
- aws_proxy = Rendering::RackRenderer.new(self,
14
- status: options[:status] || 302,
13
+ default = {
15
14
  headers: { "Location" => redirect_url },
16
- body: "",
17
15
  isBase64Encoded: false,
18
- )
16
+ }
17
+ if request.xhr?
18
+ options[:content_type] = "application/json"
19
+ options[:status] = 200
20
+ options[:body] = JSON.dump(success: true, location: redirect_url)
21
+ else
22
+ options[:status] = 301
23
+ options[:body] = ""
24
+ end
25
+ Jets.logger.info("redirect_to options #{options}")
26
+ options = default.merge(options)
27
+
28
+ aws_proxy = Rendering::RackRenderer.new(self, options)
19
29
  resp = aws_proxy.render
20
30
  # redirect is a type of rendering
21
31
  @rendered = true
@@ -29,11 +29,7 @@ class <%= controller_class_name %>Controller < ApplicationController
29
29
  @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
30
30
 
31
31
  if @<%= orm_instance.save %>
32
- if request.xhr?
33
- render json: {success: true, location: url_for(@<%= singular_table_name %>)}
34
- else
35
- redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
36
- end
32
+ redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
37
33
  else
38
34
  render :new
39
35
  end
@@ -42,11 +38,7 @@ class <%= controller_class_name %>Controller < ApplicationController
42
38
  # PUT <%= route_url %>/1
43
39
  def update
44
40
  if @<%= orm_instance.update("#{singular_table_name}_params") %>
45
- if request.xhr?
46
- render json: {success: true, location: url_for(@<%= singular_table_name %>)}
47
- else
48
- redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
49
- end
41
+ redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
50
42
  else
51
43
  render :edit
52
44
  end
@@ -55,11 +47,7 @@ class <%= controller_class_name %>Controller < ApplicationController
55
47
  # DELETE <%= route_url %>/1
56
48
  def delete
57
49
  @<%= orm_instance.destroy %>
58
- if request.xhr?
59
- render json: {success: true, location: <%= table_name %>_path}
60
- else
61
- redirect_to <%= table_name %>_path
62
- end
50
+ redirect_to <%= table_name %>_path
63
51
  end
64
52
 
65
53
  private
@@ -13,7 +13,7 @@ module Jets::Middleware
13
13
  middleware.use Shotgun::Static
14
14
  middleware.use Rack::Runtime
15
15
  middleware.use Jets::Controller::Middleware::Cors if cors_enabled?
16
- middleware.use Rack::MethodOverride # must come before Middleware::Local for multipart post forms to work
16
+ middleware.use Rack::MethodOverride unless ENV['JETS_RACK_METHOD_OVERRIDE'] == '0' # must come before Middleware::Local for multipart post forms to work
17
17
  middleware.use Jets::Controller::Middleware::Reloader if Jets.config.hot_reload
18
18
  middleware.use Jets::Controller::Middleware::Local # mimics AWS Lambda for local server only
19
19
  middleware.use session_store, session_options
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "3.0.19"
2
+ VERSION = "3.0.20"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.19
4
+ version: 3.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen