catalyst-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/catalyst/helpers.rb +65 -16
- data/lib/catalyst/manifest.rb +15 -2
- data/lib/catalyst/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45f276a4db53b08c80aca358632f1fd2bf9d1fee132fcb9ed2db9a96f8454c7b
|
4
|
+
data.tar.gz: fae2b667b0302d140811d869bef7be5c8f6f9d849ab1b8e7805ebd3003a620dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ca2857dea876499f66d32f119f28d5f666e4deebd79f58082b57ad8e3926f28fab0a70111992209e0254e7d1df5f8e1dde1573be5b373c049e2685ce58417c
|
7
|
+
data.tar.gz: f74c8becccb4d5788be14ba88334087b341ed3954687e182987891c4790fc55a343f6c7651894a81297b300aad2f558a4d1e6fd796ac86d4deee4118165461d5
|
data/lib/catalyst/helpers.rb
CHANGED
@@ -6,36 +6,81 @@ require_relative './manifest'
|
|
6
6
|
module Catalyst
|
7
7
|
module Helpers
|
8
8
|
include ActionView::Helpers::TagHelper
|
9
|
+
include ActionView::Helpers::OutputSafetyHelper
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
11
|
+
def catalyst_javascript_include_tag(path)
|
12
|
+
path = path.to_s.sub(/\.js\z/, '') + '.js'
|
13
|
+
|
14
|
+
if catalyst_referenced_files.include?(path)
|
15
|
+
raise ::Catalyst::Manifest::DuplicateAssetReference,
|
16
|
+
"The asset \"#{path}\" has already been referenced."
|
13
17
|
end
|
18
|
+
|
19
|
+
catalyst_referenced_files << path
|
20
|
+
|
21
|
+
safe_join([
|
22
|
+
catalyst_javascript_vendor_include_tag,
|
23
|
+
catalyst_javascript_common_include_tag,
|
24
|
+
content_tag(
|
25
|
+
:script,
|
26
|
+
nil,
|
27
|
+
type: 'text/javascript',
|
28
|
+
crossorigin: 'anonymous',
|
29
|
+
src: ::Catalyst::Manifest[path]
|
30
|
+
)
|
31
|
+
])
|
14
32
|
end
|
15
33
|
|
16
|
-
def
|
17
|
-
path =
|
34
|
+
def catalyst_javascript_vendor_include_tag
|
35
|
+
path = 'vendor-dll.js'
|
36
|
+
|
37
|
+
return nil unless ::Catalyst.development?
|
38
|
+
return nil if catalyst_referenced_files.include?(path)
|
39
|
+
|
40
|
+
catalyst_javascript_include_tag(path)
|
41
|
+
end
|
18
42
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
43
|
+
def catalyst_javascript_common_include_tag
|
44
|
+
path = 'common.js'
|
45
|
+
|
46
|
+
return nil if catalyst_referenced_files.include?(path)
|
47
|
+
|
48
|
+
if ::Catalyst.development? || ::Catalyst::Manifest.has?(path)
|
49
|
+
catalyst_javascript_include_tag(path)
|
50
|
+
end
|
26
51
|
end
|
27
52
|
|
28
53
|
def catalyst_stylesheet_link_tag(path)
|
29
|
-
|
54
|
+
return nil if ::Catalyst.development?
|
55
|
+
|
56
|
+
path = path.to_s.sub(/\.css\z/, '') + '.css'
|
57
|
+
|
58
|
+
if catalyst_referenced_files.include?(path)
|
59
|
+
raise ::Catalyst::Manifest::DuplicateAssetReference,
|
60
|
+
"The asset \"#{path}\" has already been referenced."
|
61
|
+
end
|
62
|
+
|
63
|
+
catalyst_referenced_files << path
|
30
64
|
|
31
|
-
|
65
|
+
safe_join([
|
66
|
+
catalyst_common_stylesheet_link_tag,
|
32
67
|
content_tag(
|
33
68
|
:link,
|
34
69
|
nil,
|
35
|
-
href: ::Catalyst::Manifest[
|
70
|
+
href: ::Catalyst::Manifest[path],
|
36
71
|
media: 'screen',
|
37
72
|
rel: 'stylesheet'
|
38
73
|
)
|
74
|
+
])
|
75
|
+
end
|
76
|
+
|
77
|
+
def catalyst_common_stylesheet_link_tag
|
78
|
+
path = 'common.css'
|
79
|
+
|
80
|
+
return nil if catalyst_referenced_files.include?(path)
|
81
|
+
|
82
|
+
if ::Catalyst::Manifest.has?(path)
|
83
|
+
catalyst_stylesheet_link_tag(path)
|
39
84
|
end
|
40
85
|
end
|
41
86
|
|
@@ -44,11 +89,15 @@ module Catalyst
|
|
44
89
|
end
|
45
90
|
|
46
91
|
def catalyst_asset_url(path)
|
47
|
-
if Catalyst.development? || Catalyst.config.assets_host.nil?
|
92
|
+
if ::Catalyst.development? || ::Catalyst.config.assets_host.nil?
|
48
93
|
catalyst_asset_path(path)
|
49
94
|
else
|
50
95
|
"#{Catalyst.config.assets_host_protocol}://#{Catalyst.config.assets_host}#{catalyst_asset_path(path)}"
|
51
96
|
end
|
52
97
|
end
|
98
|
+
|
99
|
+
def catalyst_referenced_files
|
100
|
+
@catalyst_referenced_files ||= Set.new
|
101
|
+
end
|
53
102
|
end
|
54
103
|
end
|
data/lib/catalyst/manifest.rb
CHANGED
@@ -3,15 +3,18 @@
|
|
3
3
|
require 'singleton'
|
4
4
|
require 'forwardable'
|
5
5
|
|
6
|
+
require_relative './errors'
|
7
|
+
|
6
8
|
module Catalyst
|
7
9
|
class Manifest
|
8
|
-
AssetMissing = Class.new(
|
10
|
+
AssetMissing = Class.new(::Catalyst::CatalystError)
|
11
|
+
DuplicateAssetReference = Class.new(::Catalyst::CatalystError)
|
9
12
|
|
10
13
|
include Singleton
|
11
14
|
|
12
15
|
class << self
|
13
16
|
extend Forwardable
|
14
|
-
|
17
|
+
def_delegators :instance, :[], :has?
|
15
18
|
end
|
16
19
|
|
17
20
|
def initialize
|
@@ -26,6 +29,16 @@ module Catalyst
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
32
|
+
def has?(path)
|
33
|
+
path = path.to_s.gsub(/\A\/+/, '')
|
34
|
+
|
35
|
+
if Catalyst.development?
|
36
|
+
false
|
37
|
+
else
|
38
|
+
@manifest.key?(path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
29
42
|
def [](path)
|
30
43
|
path = path.to_s.gsub(/\A\/+/, '')
|
31
44
|
|
data/lib/catalyst/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catalyst-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Martens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|