frails 0.3.0 → 0.4.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: 6b49013f43563b5bf245a5e4190e36326ed5c92086e8b189918504fa9fd31904
4
- data.tar.gz: 1cc03eb7682559dd5563d4b7152266fbe7f4ab3f0b2a7b0d6393a90833bb547f
3
+ metadata.gz: 322669f68bd84081e8486c39f5fb28a531603a3a059044556c6d4ede45c13893
4
+ data.tar.gz: 334028b2e58f8ecb973623f8a13cfe9cd1ec92a5d4eb8ff374570f279f01996c
5
5
  SHA512:
6
- metadata.gz: 63a219ca5f4ebf78c7cfbf53b1d38c7ee8b7e7ddfec0d9578046962cace8e1eb7e3bf18bbdb323610e4b61144f76c1def6c679e08238a7c220afb7d717c7d02a
7
- data.tar.gz: 78e7991fa8ee31e6c911cf651dd232ee7a56b23e2b081457d8152e834d55da8afbd82185a6252db69d008245098be6d4338ba4aa8241451d6cab414acee87d6b
6
+ metadata.gz: 4f98d83b83354a19a6d6469cc16704fcf1053623e0ff2862515c313795a65d9318eafe8d804aaf2852ff54c7a462f68eb6d1093292fe244c59e77eab74d50b06
7
+ data.tar.gz: 6818327395fb917c763dc9d93179f95b39cf846b3c215583195885639d031e617a3bc3993450fb2ad780ac43efff7f519a856a469cba338088094103b56c3c27
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frails (0.3.0)
4
+ frails (0.4.0)
5
5
  nokogiri (>= 1.10.4)
6
6
  rack-proxy (>= 0.6.5)
7
7
  rails (>= 6.0)
@@ -74,7 +74,7 @@ GEM
74
74
  i18n (1.6.0)
75
75
  concurrent-ruby (~> 1.0)
76
76
  jaro_winkler (1.5.3)
77
- loofah (2.2.3)
77
+ loofah (2.3.0)
78
78
  crass (~> 1.0.2)
79
79
  nokogiri (>= 1.5.9)
80
80
  mail (2.7.1)
@@ -85,7 +85,7 @@ GEM
85
85
  mimemagic (0.3.3)
86
86
  mini_mime (1.0.2)
87
87
  mini_portile2 (2.4.0)
88
- minitest (5.12.0)
88
+ minitest (5.12.2)
89
89
  nio4r (2.5.2)
90
90
  nokogiri (1.10.4)
91
91
  mini_portile2 (~> 2.4.0)
@@ -124,7 +124,7 @@ GEM
124
124
  rake (>= 0.8.7)
125
125
  thor (>= 0.20.3, < 2.0)
126
126
  rainbow (3.0.0)
127
- rake (12.3.3)
127
+ rake (13.0.0)
128
128
  rubocop (0.74.0)
129
129
  jaro_winkler (~> 1.5.1)
130
130
  parallel (~> 1.10)
data/README.md CHANGED
@@ -100,6 +100,14 @@ image_pack_tag 'logo.png'
100
100
  Frails has the ability to automatically include your Javascript and CSS based on the current layout
101
101
  and/or view. It even supports side loading partials.
102
102
 
103
+ Just add the following tio your `ApplicationController`:
104
+
105
+ ```ruby
106
+ class ApplicationController < ActionController::Base
107
+ side_load_assets
108
+ end
109
+ ```
110
+
103
111
  As an example, given a view at `/app/views/pages/home.html.erb`, we can create
104
112
  `/app/views/pages/home.css` and/or `/app/views/pages/home.js`. These side-loaded assets will then be
105
113
  included automatically in the page.
@@ -5,6 +5,8 @@ module Frails
5
5
  module ActionView
6
6
  module AbstractRenderer
7
7
  def side_load_assets(view, tpl)
8
+ return unless view.controller._side_load_assets?
9
+
8
10
  path = tpl.short_identifier.delete_prefix('app/').delete_suffix('.html.erb')
9
11
 
10
12
  instrument :side_loaded_assets, identifier: tpl.identifier, asset_types: [] do |payload|
@@ -12,8 +12,8 @@ module Frails
12
12
  end
13
13
 
14
14
  def build_rendered_template(content, template, layout = nil)
15
- content = transform_css_modules(content).html_safe
16
- ::ActionView::AbstractRenderer::RenderedTemplate.new content, layout, template
15
+ content = transform_css_modules(content).html_safe if @asset_path
16
+ super
17
17
  end
18
18
 
19
19
  def transform_css_modules(content)
@@ -9,9 +9,17 @@ class Frails::Engine < ::Rails::Engine
9
9
  app.middleware.insert_before 0, Frails::DevServerProxy, ssl_verify_none: true
10
10
  end
11
11
 
12
- initializer 'frails.rendering' do |_conf|
12
+ initializer 'frails.rendering' do
13
13
  ActiveSupport.on_load :action_controller do
14
- ActionController::Base.prepend_view_path Rails.root.join('app', 'components')
14
+ require 'frails/side_load_assets'
15
+
16
+ include Frails::SideLoadAssets
17
+ end
18
+
19
+ ActiveSupport.on_load :action_mailer do
20
+ require 'frails/side_load_assets'
21
+
22
+ include Frails::SideLoadAssets
15
23
  end
16
24
 
17
25
  ActiveSupport.on_load :action_view do
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frails::SideLoadAssets
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ class_attribute :_side_load_assets, default: false
8
+ end
9
+
10
+ class_methods do
11
+ def side_load_assets
12
+ self._side_load_assets = true
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Frails
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
@@ -92,6 +92,7 @@ files:
92
92
  - lib/frails/monkey/action_view/renderer.rb
93
93
  - lib/frails/monkey/action_view/template_renderer.rb
94
94
  - lib/frails/railtie.rb
95
+ - lib/frails/side_load_assets.rb
95
96
  - lib/frails/version.rb
96
97
  - lib/install/template.rb
97
98
  - lib/tasks/frails.rake