Module: Conjoin::Assets
- Defined in:
- lib/conjoin/assets.rb
Defined Under Namespace
Modules: ClassMethods
Classes: App, Helpers, Routes
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.app ⇒ Object
Returns the value of attribute app.
4
5
6
|
# File 'lib/conjoin/assets.rb', line 4
def app
@app
end
|
Class Method Details
.setup(app) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/conjoin/assets.rb', line 7
def self.setup app
self.app = app
require 'mimemagic'
require 'base64'
require 'slim'
require 'sass'
require 'ostruct'
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
67
68
69
|
# File 'lib/conjoin/assets.rb', line 67
def accepted_assets
"(.*)\.(js|css|eot|svg|ttf|woff|png|gif|jpg|jpeg)$"
end
|
#asset_path(file) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/conjoin/assets.rb', line 41
def asset_path file
case file[/(\.[^.]+)$/]
when '.css', '.js'
path = "#{plugin.settings[:path] || '/'}#{cache_string}assets/#{file}"
else
path = "#{plugin.settings[:path] || '/'}#{cache_string}assets/images/#{file}"
end
"http#{req.env['SERVER_PORT'] == '443' ? 's' : ''}://#{req.env['HTTP_HOST']}#{path}"
end
|
#fa_icon(icon, options = {}) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/conjoin/assets.rb', line 58
def fa_icon icon, options = {}
options[:class] ||= ''
options[:class] += " fa fa-#{icon}"
mab do
i options
end
end
|
#image_tag(file, options = {}) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/conjoin/assets.rb', line 51
def image_tag file, options = {}
options[:src] = asset_path(file)
mab do
img options
end
end
|