railz_lite 0.2.1 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/railz_lite/cli.rb +0 -1
- data/lib/railz_lite/controllers/controller_base.rb +22 -4
- data/lib/railz_lite/controllers/static.rb +6 -4
- data/lib/railz_lite/generators/project.rb +6 -1
- data/lib/railz_lite/generators/templates/application.html.erb +10 -0
- data/lib/railz_lite/generators/templates/welcome_view.index.html.erb +1 -1
- data/lib/railz_lite/models/db_connection.rb +1 -1
- data/lib/railz_lite/version.rb +1 -1
- data/railz_lite.gemspec +6 -5
- metadata +37 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f212021508124c75b30ec2d598c39939597f7263f8a08d8909efedc5d13220e7
|
4
|
+
data.tar.gz: 2b45fc4a2b46f7aa168a48d1fc0c222cbeca5007c1c1df7400bbd591363388a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a20d00eeab48b8738ee9f136468f97081a2b14c1819c9473277374a169cc8dbe85a45ee4ed48bfcc4df24856791019cf994df791d062c4a339d5d0ea83bc03
|
7
|
+
data.tar.gz: 0646d6b6f01ac5c7998e9bf3c0431a34777cf22f7ac46e34756b2fc197832c9794949d2de2398c2ccbdaa5f2c8d59497a3dacaca62d9c2e5ace82fa1eae261bf
|
data/.gitignore
CHANGED
data/lib/railz_lite/cli.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'active_support/core_ext'
|
3
3
|
require 'erb'
|
4
|
+
require 'loofah'
|
4
5
|
require_relative './session'
|
5
6
|
require_relative './flash'
|
6
7
|
|
7
8
|
module RailzLite
|
9
|
+
class LayoutRenderer # dummy class used to pass yield blocks into ERB method results https://hostiledeveloper.com/2015/05/28/working-with-templates-in-ruby-erb.html
|
10
|
+
end
|
11
|
+
|
8
12
|
class ControllerBase
|
9
13
|
attr_reader :req, :res, :params
|
10
14
|
|
@@ -46,10 +50,24 @@ module RailzLite
|
|
46
50
|
# pass the rendered html to render_content
|
47
51
|
def render(template_name)
|
48
52
|
dir_path = Dir.pwd
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
|
54
|
+
layout_path = File.join(dir_path, 'views', 'application', 'application.html.erb')
|
55
|
+
inner_file_path = File.join(dir_path, 'views', "#{self.class.name.underscore.split('_controller').first}", "#{template_name.to_s}.html.erb")
|
56
|
+
|
57
|
+
layout_template = File.read(layout_path)
|
58
|
+
inner_template = File.read(inner_file_path)
|
59
|
+
|
60
|
+
layout = ERB.new(layout_template)
|
61
|
+
inner = ERB.new(inner_template)
|
62
|
+
|
63
|
+
layout.def_method(LayoutRenderer, 'render') # dummy method used so that blocks can be passed to ERB result
|
64
|
+
|
65
|
+
result = LayoutRenderer.new.render do
|
66
|
+
inner_html = inner.result(binding)
|
67
|
+
Loofah.fragment(inner_html).scrub!(:prune).to_s # prevent non-safe html from being executed
|
68
|
+
end
|
69
|
+
|
70
|
+
render_content(result, 'text/html')
|
53
71
|
end
|
54
72
|
|
55
73
|
# method exposing a `Session` object
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'rack'
|
2
2
|
|
3
3
|
class Static
|
4
|
-
attr_reader :app, :file_server, :
|
4
|
+
attr_reader :app, :file_server, :root_paths
|
5
5
|
|
6
6
|
def initialize(app)
|
7
7
|
@app = app
|
8
|
-
@
|
8
|
+
@root_paths = ['public', 'assets']
|
9
9
|
@file_server = FileServer.new
|
10
10
|
end
|
11
11
|
|
@@ -23,7 +23,7 @@ class Static
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def can_match?(path)
|
26
|
-
path.index("/#{root}")
|
26
|
+
root_paths.any? { |root| path.index("/#{root}") }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -32,7 +32,9 @@ class FileServer
|
|
32
32
|
MIME_TYPES = {
|
33
33
|
'.txt' => 'text/plain',
|
34
34
|
'.jpg' => 'image/jpeg',
|
35
|
-
'.zip' => 'application/zip'
|
35
|
+
'.zip' => 'application/zip',
|
36
|
+
'.css' => 'text/css',
|
37
|
+
'.js' => 'text/javascript'
|
36
38
|
}
|
37
39
|
|
38
40
|
def call(env)
|
@@ -26,8 +26,13 @@ module RailzLite
|
|
26
26
|
template('server.rb', "#{project_name}/config/server.rb")
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def setup_views
|
30
30
|
template('welcome_view.index.html.erb', "#{project_name}/views/welcome/index.html.erb")
|
31
|
+
template('application.html.erb', "#{project_name}/views/application/application.html.erb")
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_assets
|
35
|
+
create_file("#{project_name}/assets/application.css")
|
31
36
|
end
|
32
37
|
|
33
38
|
def add_public
|
@@ -6,7 +6,7 @@
|
|
6
6
|
">
|
7
7
|
<h1>Welcome To Railz Lite!</h1>
|
8
8
|
|
9
|
-
<img src="
|
9
|
+
<img src="public/winter_fox_large.jpg" />
|
10
10
|
|
11
11
|
<h3>For guidelines on how to build an app with this framework see <a href="https://github.com/bryanqb07/railz_lite">here</a>.</h3>
|
12
12
|
</div>
|
data/lib/railz_lite/version.rb
CHANGED
data/railz_lite.gemspec
CHANGED
@@ -29,11 +29,12 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
32
|
-
spec.add_dependency "rack"
|
33
|
-
spec.add_dependency "activesupport"
|
34
|
-
spec.add_dependency "puma"
|
35
|
-
spec.add_dependency "sqlite3"
|
36
|
-
spec.add_dependency "thor"
|
32
|
+
spec.add_dependency "rack", '~> 2.2.3'
|
33
|
+
spec.add_dependency "activesupport", '~> 6.1.4'
|
34
|
+
spec.add_dependency "puma", '~> 5.3.2'
|
35
|
+
spec.add_dependency "sqlite3", '~> 1.4.2'
|
36
|
+
spec.add_dependency "thor", '~> 1.1.0'
|
37
|
+
spec.add_dependency "loofah", '~> 2.10.0'
|
37
38
|
|
38
39
|
|
39
40
|
spec.add_development_dependency "byebug"
|
metadata
CHANGED
@@ -1,85 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railz_lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bryan lynch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.1.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: puma
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.3.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 5.3.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.4.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.4.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.1.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: loofah
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.10.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.10.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: byebug
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,6 +180,7 @@ files:
|
|
166
180
|
- lib/railz_lite/controllers/templates/rescue.html.erb
|
167
181
|
- lib/railz_lite/generators/project.rb
|
168
182
|
- lib/railz_lite/generators/project.rb~
|
183
|
+
- lib/railz_lite/generators/templates/application.html.erb
|
169
184
|
- lib/railz_lite/generators/templates/application_controller.rb~
|
170
185
|
- lib/railz_lite/generators/templates/server.rb
|
171
186
|
- lib/railz_lite/generators/templates/welcome_view.index.html.erb
|