Module: Conjoin::Assets
Defined Under Namespace
Modules: ClassMethods
Classes: App, Helpers, Routes
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
add_asset, all_assets, assets_settings
Class Attribute Details
.app ⇒ Object
Returns the value of attribute app.
15
16
17
|
# File 'lib/conjoin/assets.rb', line 15
def app
@app
end
|
Class Method Details
.setup(app) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/conjoin/assets.rb', line 18
def self.setup app
self.app = app
Slim::Engine.set_default_options \
disable_escape: true,
use_html_safe: true,
disable_capture: false,
pretty: (Conjoin.env.production? or Conjoin.env.staging?) ? false : true
app.settings[:assets] ||= OpenStruct.new({
settings: {},
stylesheet: [],
images: [],
javascript_head: [],
javascript: []
})
end
|
Instance Method Details
#accepted_assets ⇒ Object
76
77
78
|
# File 'lib/conjoin/assets.rb', line 76
def accepted_assets
"(.*)\.(js|css|eot|svg|ttf|woff|png|gif|jpg|jpeg)$"
end
|
#asset_path(file) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/conjoin/assets.rb', line 46
def asset_path file
if Conjoin.env.production? or Conjoin.env.staging?
path = "#{plugin.settings[:path] || '/'}public/assets/#{file}"
else
case file[/(\.[^.]+)$/]
when '.css', '.js'
path = "#{plugin.settings[:path] || '/'}#{cache_string}assets/#{file}"
else
path = "#{plugin.settings[:path] || '/'}#{cache_string}assets/images/#{file}"
end
end
"http#{(Conjoin.env.production? or Conjoin.env.staging?)? 's' : ''}://#{req.env['HTTP_HOST']}#{path}"
end
|
#fa_icon(icon, options = {}) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/conjoin/assets.rb', line 67
def fa_icon icon, options = {}
options[:class] ||= ''
options[:class] += " fa fa-#{icon}"
mab do
i options
end
end
|
#image_tag(file, options = {}) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/conjoin/assets.rb', line 60
def image_tag file, options = {}
options[:src] = asset_path(file)
mab do
img options
end
end
|