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 +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +8 -0
- data/lib/frails/monkey/action_view/abstract_renderer.rb +2 -0
- data/lib/frails/monkey/action_view/partial_renderer.rb +2 -2
- data/lib/frails/railtie.rb +10 -2
- data/lib/frails/side_load_assets.rb +15 -0
- data/lib/frails/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322669f68bd84081e8486c39f5fb28a531603a3a059044556c6d4ede45c13893
|
4
|
+
data.tar.gz: 334028b2e58f8ecb973623f8a13cfe9cd1ec92a5d4eb8ff374570f279f01996c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f98d83b83354a19a6d6469cc16704fcf1053623e0ff2862515c313795a65d9318eafe8d804aaf2852ff54c7a462f68eb6d1093292fe244c59e77eab74d50b06
|
7
|
+
data.tar.gz: 6818327395fb917c763dc9d93179f95b39cf846b3c215583195885639d031e617a3bc3993450fb2ad780ac43efff7f519a856a469cba338088094103b56c3c27
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
frails (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.
|
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.
|
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 (
|
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
|
-
|
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)
|
data/lib/frails/railtie.rb
CHANGED
@@ -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
|
12
|
+
initializer 'frails.rendering' do
|
13
13
|
ActiveSupport.on_load :action_controller do
|
14
|
-
|
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
|
data/lib/frails/version.rb
CHANGED
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.
|
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
|