jets 0.9.2 → 0.10.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/jets/commands/build.rb +1 -3
- data/lib/jets/commands/help/routes.md +0 -1
- data/lib/jets/commands/new.rb +2 -2
- data/lib/jets/commands/templates/skeleton/config/routes.rb +11 -3
- data/lib/jets/internal/app/controllers/jets/public_controller.rb +7 -3
- data/lib/jets/resource/api_gateway/method.rb +14 -1
- data/lib/jets/version.rb +1 -1
- metadata +1 -3
- data/lib/jets/internal/app/controllers/jets/welcome_controller.rb +0 -22
- data/lib/jets/internal/app/controllers/jets/welcome_controller/python/index.py +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4eba3758c709669dde525de421e7ed5241c0b2e1b4c0488fe928744501f94ca
|
4
|
+
data.tar.gz: 37565466a6f5f8382424a110893bf7237012dba8e25eed7cd16ca133fdfd648d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf83a19ca5a635226316bee54bec5c0ab3b74b9dcf25850f0b55ce32798943dc7b280ee25e1b1ef7cf3f9862f1e287b63e38de13f5771378293f2f3be20cea1
|
7
|
+
data.tar.gz: aeb7657e68051f368fc97c7aa888e03aae1c001ed17e11b34d9cfa0f18c40a9a3987775d7a5b5eea378ab23af0beb03c55b17c3a8877756876d4864ee8cf1c78
|
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/Gemfile.lock
CHANGED
data/lib/jets/commands/build.rb
CHANGED
@@ -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
|
|
data/lib/jets/commands/new.rb
CHANGED
@@ -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/
|
7
|
+
root "jets/public#show"
|
8
8
|
|
9
|
-
#
|
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}/#{
|
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
|
-
|
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
|
data/lib/jets/version.rb
CHANGED
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.
|
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({}, {}))
|