spark_engine 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spark_engine/helpers/layout_helpers.rb +4 -2
- data/lib/spark_engine/middleware.rb +17 -49
- data/lib/spark_engine/plugin/assets/stylesheets.rb +7 -3
- data/lib/spark_engine/plugin.rb +1 -1
- data/lib/spark_engine/scaffold/gem/app/views/layouts/namespace/default.html.erb +12 -7
- data/lib/spark_engine/version.rb +1 -1
- data/lib/spark_engine.rb +0 -4
- data/spark_engine.gemspec +1 -2
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c58ea63e7821a0a536de0aaa29bf71c6cfbd6b3de7fb14199f7caa7d161d4708
|
4
|
+
data.tar.gz: b415c04a849dd42c435d94f840a50e5df1c017f8145a4a53d93dde9b69751086
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2659a3d59b3e9e857ca1619165d2282c205fbbfe9a0495c4b04967befdc9d6ff816ed13200b1c0cd6a2b02777e86a4258e016a169a4eb43a5676fe8d53818fa9
|
7
|
+
data.tar.gz: ccbe2ddb02852e853a2867fc1a65ecc53f9d8c2081a9eb34c709e4b4ba05884c9fde84eba0554873394ab7d4f52f18b025c54678f849a0931133c80542707d34
|
@@ -3,8 +3,10 @@ module SparkEngine
|
|
3
3
|
module LayoutHelper
|
4
4
|
def render_layout(*args, &block)
|
5
5
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
6
|
-
|
7
|
-
options[:
|
6
|
+
options[:template] = "layouts/#{args.first}"
|
7
|
+
options[:locals] ||= {}
|
8
|
+
options[:locals][:classes] = [options.delete(:classes)].flatten
|
9
|
+
|
8
10
|
yield if block_given?
|
9
11
|
render options
|
10
12
|
end
|
@@ -9,64 +9,32 @@ module SparkEngine
|
|
9
9
|
|
10
10
|
class StaticAssets
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@engine_name = engine_name
|
18
|
-
@file_handler = ActionDispatch::FileHandler.new(path, index: index, headers: headers)
|
19
|
-
end
|
12
|
+
def initialize(app, path, index: 'index', headers: {}, engine_name: nil)
|
13
|
+
@app = app
|
14
|
+
@engine_name = engine_name
|
15
|
+
@file_handler = ActionDispatch::FileHandler.new(path, index: index, headers: headers)
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
def call(env)
|
19
|
+
req = Rack::Request.new env
|
20
|
+
prefix = File.join Application.config.assets.prefix, @engine_name
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
if req.get? || req.head?
|
23
|
+
path = req.path_info.chomp('/'.freeze)
|
27
24
|
|
28
|
-
|
29
|
-
|
25
|
+
if path.start_with? prefix
|
26
|
+
path = path.remove /\A#{prefix}\//
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
28
|
+
if match = @file_handler.match?(path)
|
29
|
+
req.path_info = match
|
30
|
+
return @file_handler.serve(req)
|
35
31
|
end
|
36
32
|
end
|
37
|
-
|
38
|
-
@app.call(req.env)
|
39
33
|
end
|
40
34
|
|
41
|
-
|
42
|
-
else
|
43
|
-
|
44
|
-
def initialize(app, path, cache_control=nil, engine_name: nil)
|
45
|
-
@app = app
|
46
|
-
@engine_name = engine_name
|
47
|
-
@file_handler = ::ActionDispatch::FileHandler.new(path, cache_control)
|
48
|
-
end
|
49
|
-
|
50
|
-
def call(env)
|
51
|
-
prefix = File.join Application.config.assets.prefix, @engine_name
|
52
|
-
|
53
|
-
case env['REQUEST_METHOD']
|
54
|
-
when 'GET', 'HEAD'
|
55
|
-
path = env['PATH_INFO'].chomp('/')
|
56
|
-
|
57
|
-
if path.start_with? prefix
|
58
|
-
path = path.remove /\A#{prefix}\//
|
59
|
-
|
60
|
-
if match = @file_handler.match?(path)
|
61
|
-
env["PATH_INFO"] = match
|
62
|
-
return @file_handler.call(env)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
@app.call(env)
|
68
|
-
end
|
35
|
+
@app.call(req.env)
|
69
36
|
end
|
37
|
+
|
70
38
|
end
|
71
39
|
|
72
40
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'sass'
|
2
|
-
|
2
|
+
begin
|
3
|
+
require "autoprefixer-rails"
|
4
|
+
rescue
|
5
|
+
end
|
3
6
|
|
4
7
|
module SparkEngine
|
5
8
|
module Assets
|
@@ -41,7 +44,8 @@ module SparkEngine
|
|
41
44
|
end
|
42
45
|
|
43
46
|
def build_css(file)
|
44
|
-
css =
|
47
|
+
css = File.read(file)
|
48
|
+
css = AutoprefixerRails.process().css if defined? AutoprefixerRails
|
45
49
|
File.open(destination(file), 'w') { |io| io.write(css) }
|
46
50
|
|
47
51
|
compress(destination(file))
|
@@ -54,7 +58,7 @@ module SparkEngine
|
|
54
58
|
Sass.logger.log_level = :error if SparkEngine.production?
|
55
59
|
|
56
60
|
css = Sass.compile_file(file, style: style)
|
57
|
-
css = AutoprefixerRails.process(css).css
|
61
|
+
css = AutoprefixerRails.process(css).css if defined? AutoprefixerRails
|
58
62
|
|
59
63
|
File.open(dest, 'w') { |io| io.write(css) }
|
60
64
|
|
data/lib/spark_engine/plugin.rb
CHANGED
@@ -37,7 +37,7 @@ module SparkEngine
|
|
37
37
|
require 'spark_engine/middleware'
|
38
38
|
|
39
39
|
initializer "#{name}.static_assets" do |app|
|
40
|
-
if
|
40
|
+
if app.config.public_file_server.enabled
|
41
41
|
app.middleware.insert_after ::ActionDispatch::Static, SparkEngine::StaticAssets, "#{root}/public", engine_name: SparkEngine.plugin.name
|
42
42
|
app.middleware.insert_before ::ActionDispatch::Static, Rack::Deflater
|
43
43
|
end
|
@@ -2,17 +2,22 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title><%= @plugin_module %></title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
7
|
+
<meta name="HandheldFriendly" content="True">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
9
|
<%%= csrf_meta_tags %>
|
6
|
-
<%%=
|
10
|
+
<%%= stylesheet_tag "<%= @engine %>" %>
|
7
11
|
<%%= yield :stylesheets %>
|
8
12
|
<%%= yield :head %>
|
13
|
+
<script>console.log("<%= @plugin_module %>: <%%= <%= @gem_module %>::VERSION %>")</script>
|
9
14
|
</head>
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
<%% body_classes ||= [] %>
|
17
|
+
<body class="<%%= body_classes.join(' ') %>">
|
18
|
+
<%%= yield %>
|
19
|
+
|
20
|
+
<%%= javascript_tag "<%= @engine %>" %>
|
21
|
+
<%%= yield :javascripts %>
|
15
22
|
</body>
|
16
|
-
<%%= javascript_tag "<%= @engine %>" %>
|
17
|
-
<%%= yield :javascripts %>
|
18
23
|
</html>
|
data/lib/spark_engine/version.rb
CHANGED
data/lib/spark_engine.rb
CHANGED
data/spark_engine.gemspec
CHANGED
@@ -23,8 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'block_helpers', '~> 0.3'
|
24
24
|
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
25
25
|
spec.add_runtime_dependency 'bundler', '~> 1.10'
|
26
|
-
spec.add_runtime_dependency '
|
27
|
-
spec.add_runtime_dependency 'rails', '>= 4.2', '< 6'
|
26
|
+
spec.add_runtime_dependency 'rails', '>= 5.0', '< 6'
|
28
27
|
|
29
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
29
|
spec.add_development_dependency 'pry-byebug'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spark_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -94,27 +94,13 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.10'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: autoprefixer-rails
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '9.0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '9.0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rails
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '5.0'
|
118
104
|
- - "<"
|
119
105
|
- !ruby/object:Gem::Version
|
120
106
|
version: '6'
|
@@ -124,7 +110,7 @@ dependencies:
|
|
124
110
|
requirements:
|
125
111
|
- - ">="
|
126
112
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
113
|
+
version: '5.0'
|
128
114
|
- - "<"
|
129
115
|
- !ruby/object:Gem::Version
|
130
116
|
version: '6'
|