jets 0.9.2 → 0.10.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: 61d62ec1deed884ea8ccccd1b6f6cafdbccf8f9778b9ddfb9bc80d827c3b8f2d
4
- data.tar.gz: 4edc9600af70c32b175ba077a5d75b55575c030807aa1c1ad26b96914b0c372b
3
+ metadata.gz: e4eba3758c709669dde525de421e7ed5241c0b2e1b4c0488fe928744501f94ca
4
+ data.tar.gz: 37565466a6f5f8382424a110893bf7237012dba8e25eed7cd16ca133fdfd648d
5
5
  SHA512:
6
- metadata.gz: 1ec1dcbb1c0a6a977dcdabbc2138178d43687d1257f40239e2e379400a435f84301f5b5105fb59d36860c9e4a8051c64547770963be63b6ea5a33c0ce4ffc142
7
- data.tar.gz: 1e15d436ecf7fa3dea5852023afb2db0544ca56fc21c76c80d8554b8acffd1d98a20acceb1416038257a233bddeac95a3896ceddd4aceee62c505a55370742de
6
+ metadata.gz: 5cf83a19ca5a635226316bee54bec5c0ab3b74b9dcf25850f0b55ce32798943dc7b280ee25e1b1ef7cf3f9862f1e287b63e38de13f5771378293f2f3be20cea1
7
+ data.tar.gz: aeb7657e68051f368fc97c7aa888e03aae1c001ed17e11b34d9cfa0f18c40a9a3987775d7a5b5eea378ab23af0beb03c55b17c3a8877756876d4864ee8cf1c78
@@ -3,6 +3,11 @@
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/), even before v1.0.
5
5
 
6
+ ## [0.10.0]
7
+ - Merge pull request #45 from tongueroo/remove-internal-welcome
8
+ - Fix routing: Allow multiple paths to point to same controller action
9
+ - Refer to upgrading notes: http://rubyonjets.com/docs/upgrading/
10
+
6
11
  ## [0.9.2]
7
12
  - s3 assets support: Merge pull request #44 from tongueroo/s3-assets
8
13
 
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (0.9.2)
14
+ jets (0.10.0)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -149,6 +149,7 @@ module Jets::Commands
149
149
  # 1. remove app/controllers or app/jobs, etc
150
150
  # 2. remove .rb extension
151
151
  app_file = path.sub(%r{app/\w+/},'').sub(/\.rb$/,'')
152
+
152
153
  # Internal jets controllers like Welcome and Public need a different regexp
153
154
  app_file = app_file.sub(%r{.*lib/jets/internal/},'')
154
155
  app_class = app_file.classify.constantize # IE: PostsController, Jets::PublicController
@@ -163,9 +164,6 @@ module Jets::Commands
163
164
  paths = []
164
165
  controllers = File.expand_path("../../internal/app/controllers/jets", __FILE__)
165
166
 
166
- welcome = Jets::Router.has_controller?("Jets::WelcomeController")
167
- paths << "#{controllers}/welcome_controller.rb" if welcome
168
-
169
167
  public_catchall = Jets::Router.has_controller?("Jets::PublicController")
170
168
  paths << "#{controllers}/public_controller.rb" if public_catchall
171
169
 
@@ -11,7 +11,6 @@
11
11
  | GET | posts/:id/edit | posts#edit |
12
12
  | PUT | posts/:id | posts#update |
13
13
  | DELETE | posts/:id | posts#delete |
14
- | GET | | jets/welcome#index |
15
14
  | ANY | *catchall | jets/public#show |
16
15
  +--------+----------------+--------------------+
17
16
  $
@@ -112,11 +112,11 @@ JS
112
112
 
113
113
  To deploy to AWS Lambda, edit your .env.development.remote and add a DATABASE_URL endpoint.
114
114
  Then run:
115
-
115
+
116
116
  jets deploy
117
117
  EOL
118
118
  end
119
-
119
+
120
120
  puts <<~EOL
121
121
  #{"="*64}
122
122
  Congrats 🎉 You have successfully created a Jets project.
@@ -4,9 +4,17 @@ Jets.application.routes.draw do
4
4
  # More info:
5
5
  # http://rubyonjets.com/docs/routes-workaround/
6
6
  # http://rubyonjets.com/docs/env-extra/
7
- root "jets/welcome#index"
7
+ root "jets/public#show"
8
8
 
9
- # Required for API Gateway to serve static utf8 content out of public folder.
10
- # Replace with your own controller to customize.
9
+ # The jets/public#show controller serves static utf8 content out of the public folder.
10
+ # Replace it with your own controller to customize.
11
+ # Note, binary files do not get served on AWS Lambda unless you specify the Accept header.
12
+ # This is problematic for images requested by the Browser. IE: We don't control
13
+ # that accept header that the browser sends.
14
+ # Caveat, setting the Accept header to '*' for the entire API Gateway settings will force
15
+ # the public controller to serve binary data when requested by the browser, but it
16
+ # also results in form data always being treated as binary data also.
17
+ # Instead, it is recommended to serve binary data using s3.
18
+ # More info here: http://rubyonjets.com/docs/assets-serving/
11
19
  any "*catchall", to: "jets/public#show"
12
20
  end
@@ -10,14 +10,18 @@ class Jets::PublicController < Jets::Controller::Base
10
10
  python :show
11
11
  else
12
12
  def show
13
+ catchall = params[:catchall].blank? ? 'index.html' : params[:catchall]
13
14
  public_path = Jets.root + "public"
14
- catchall_path = "#{public_path}/#{params[:catchall]}"
15
+ catchall_path = "#{public_path}/#{catchall}"
16
+
15
17
  if File.exist?(catchall_path)
16
18
  content_type = Rack::Mime.mime_type(File.extname(catchall_path))
17
19
  binary = !MimeMagic.by_path(catchall_path).text?
18
- puts "content_type #{content_type.inspect}"
19
- puts "binary #{binary}"
20
20
 
21
+ # TODO: binary support doesn't quite work yet.
22
+ # We have to add '*/*' as a binary media type to the API Gateway RestApi
23
+ # to enable binary support without having to send a Accept header.
24
+ # But doing so breaks regular form submission. Figure out how to workaround this.
21
25
  if binary
22
26
  encoded_content = Base64.encode64(IO.read(catchall_path))
23
27
  render plain: encoded_content, content_type: content_type, base64: true
@@ -34,7 +34,20 @@ module Jets::Resource::ApiGateway
34
34
  end
35
35
 
36
36
  def method_logical_id
37
- "{namespace}_api_method"
37
+ # https://stackoverflow.com/questions/6104240/how-do-i-strip-non-alphanumeric-characters-from-a-string-and-keep-spaces
38
+ # Add path to the logical id to allow 2 different paths to be connected to the same controller action.
39
+ # Example:
40
+ #
41
+ # root "jets/public#show"
42
+ # any "*catchall", to: "jets/public#show"
43
+ #
44
+ # Without the path in the logical id, the logical id would be ShowApiMethod for both routes and only the
45
+ # last one would be created in the CloudFormation template.
46
+ path = @route.path.gsub('*','')
47
+ .gsub(/[^0-9a-z]/i, ' ')
48
+ .gsub(/\s+/, '_')
49
+ path = nil if path == ''
50
+ [path, "{namespace}_api_method"].compact.join('_')
38
51
  end
39
52
 
40
53
  def replacements
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
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: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -588,8 +588,6 @@ files:
588
588
  - lib/jets/internal/app/controllers/jets/public_controller.rb
589
589
  - lib/jets/internal/app/controllers/jets/public_controller/python/show.py
590
590
  - lib/jets/internal/app/controllers/jets/public_controller/python/show.pyc
591
- - lib/jets/internal/app/controllers/jets/welcome_controller.rb
592
- - lib/jets/internal/app/controllers/jets/welcome_controller/python/index.py
593
591
  - lib/jets/internal/app/jobs/jets/preheat_job.rb
594
592
  - lib/jets/io.rb
595
593
  - lib/jets/job.rb
@@ -1,22 +0,0 @@
1
- class Jets::WelcomeController < Jets::Controller::Base
2
- layout false
3
- internal true
4
-
5
- # # Use python until ruby support is added.
6
- # python :index
7
-
8
- if Jets::Commands::Build.poly_only?
9
- # Use python if poly only so we don't have to upload rubuy
10
- python :index
11
- else
12
- # TODO: When ruby support is relesed, switch to it only.
13
- def index
14
- homepage = "#{Jets.root}public/index.html"
15
- if File.exist?(homepage)
16
- render file: homepage
17
- else
18
- render plain: "The public/index.html file does not exist but the root route in config/routes.rb routes to this file. You probably want to update the root route."
19
- end
20
- end
21
- end
22
- end
@@ -1,24 +0,0 @@
1
- from pprint import pprint
2
- import json
3
- import os.path
4
-
5
- def lambda_handler(event, context):
6
- homepage = "public/index.html"
7
- html = None
8
- if os.path.exists(homepage):
9
- with open(homepage,'r') as f:
10
- html = f.read()
11
- return response(html, 200)
12
-
13
- def response(body, status_code):
14
- return {
15
- 'statusCode': str(status_code),
16
- 'body': body,
17
- 'headers': {
18
- 'Content-Type': 'text/html',
19
- 'Access-Control-Allow-Origin': '*'
20
- },
21
- }
22
-
23
- if __name__ == '__main__':
24
- print(lambda_handler({}, {}))