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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e14e3ea9f6106b145bd3c3a68525a2bf4bc20682aecf4c23844ecf6b2d2db7a1
4
- data.tar.gz: c10f52044b61ee93dafb647fdd80ed18291fbe3d7f5d5110b662fde42d7bab52
3
+ metadata.gz: c58ea63e7821a0a536de0aaa29bf71c6cfbd6b3de7fb14199f7caa7d161d4708
4
+ data.tar.gz: b415c04a849dd42c435d94f840a50e5df1c017f8145a4a53d93dde9b69751086
5
5
  SHA512:
6
- metadata.gz: 4d35cd50784a6fca125005939335ee5359f3adb6929db9cb63cb61248fb90be2d526b9b4334348aef63086627cd1ec931d35fbafef0ee4e955313e048c85e323
7
- data.tar.gz: 2821d2dc7ce2d36d9f354768243e195e62b9f1f7e55dc26806dd3e472a604d67bdeef2d1631163cb61dc4c8522efe3c1fb32f3fb14689aa14ff95c61f4b2f79e
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
- layout = args.first || 'default'
7
- options[:template] = "layouts/#{layout}"
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
- # Rails 5 middleware patch
13
- if SparkEngine.rails5?
14
-
15
- def initialize(app, path, index: 'index', headers: {}, engine_name: nil)
16
- @app = app
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
- def call(env)
22
- req = Rack::Request.new env
23
- prefix = File.join Application.config.assets.prefix, @engine_name
18
+ def call(env)
19
+ req = Rack::Request.new env
20
+ prefix = File.join Application.config.assets.prefix, @engine_name
24
21
 
25
- if req.get? || req.head?
26
- path = req.path_info.chomp('/'.freeze)
22
+ if req.get? || req.head?
23
+ path = req.path_info.chomp('/'.freeze)
27
24
 
28
- if path.start_with? prefix
29
- path = path.remove /\A#{prefix}\//
25
+ if path.start_with? prefix
26
+ path = path.remove /\A#{prefix}\//
30
27
 
31
- if match = @file_handler.match?(path)
32
- req.path_info = match
33
- return @file_handler.serve(req)
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
- # Rails 4 middleware patch
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
- require "autoprefixer-rails"
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 = AutoprefixerRails.process(File.read(file)).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
 
@@ -37,7 +37,7 @@ module SparkEngine
37
37
  require 'spark_engine/middleware'
38
38
 
39
39
  initializer "#{name}.static_assets" do |app|
40
- if !SparkEngine.rails5? || app.config.public_file_server.enabled
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
- <%%= asset_tags %>
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
- <body>
12
- <div class='site'>
13
- <div class='page'><%%= yield %></div>
14
- </div>
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>
@@ -1,3 +1,3 @@
1
1
  module SparkEngine
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/spark_engine.rb CHANGED
@@ -18,10 +18,6 @@ module SparkEngine
18
18
  ENV['CI'] || ENV['RAILS_ENV'] == 'production' || ( defined?(Command) && Command.production? )
19
19
  end
20
20
 
21
- def rails5?
22
- Gem::Version.new(Rails.version) >= Gem::Version.new('5')
23
- end
24
-
25
21
  def plugin
26
22
  @plugin
27
23
  end
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 'autoprefixer-rails', '~> 9.0'
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.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-12 00:00:00.000000000 Z
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: '4.2'
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: '4.2'
113
+ version: '5.0'
128
114
  - - "<"
129
115
  - !ruby/object:Gem::Version
130
116
  version: '6'