Module: CamaleonCms::RuntimeHtmlContentConcern
Instance Method Summary
collapse
#cama_content_after_draw, #cama_content_append, #cama_content_before_draw, #cama_content_init, #cama_content_prepend
Instance Method Details
#append_asset_content(content) ⇒ Object
40
41
42
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 40
def append_asset_content(content)
camaleon_html_helper_state[:assets_content] << content
end
|
#append_asset_libraries(libraries) ⇒ Object
Also known as:
cama_load_custom_assets
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 28
def append_asset_libraries(libraries)
state = camaleon_html_helper_state
libraries.each do |key, library|
state[:assets_libraries][key.to_sym] = if state[:assets_libraries].include?(key)
state[:assets_libraries][key.to_sym].merge(library)
else
library
end
end
end
|
#append_pre_asset_content(content) ⇒ Object
44
45
46
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 44
def append_pre_asset_content(content)
camaleon_html_helper_state[:pre_assets_content] << content
end
|
#breadcrumb_add(label, url = '', prepend = false) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 88
def breadcrumb_add(label, url = '', prepend = false)
breadcrumb_items =
if prepend
breadcrumb_items.unshift([label, url])
else
breadcrumb_items << [label, url]
end
end
|
#cama_draw_custom_assets ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 52
def cama_draw_custom_assets
state = camaleon_html_helper_state
cama_html_helpers_init if state[:assets_libraries].blank?
libs = []
state[:assets_libraries].each_value do |assets|
libs += assets[:css] if assets[:css].present?
end
stylesheets = libs.uniq
css = helpers.stylesheet_link_tag(*stylesheets, media: 'all')
libs = []
state[:assets_libraries].each_value do |assets|
libs += assets[:js] if assets[:js].present?
end
javascripts = libs.uniq
js = helpers.javascript_include_tag(*javascripts)
args = { stylesheets: stylesheets, javascripts: javascripts, js_html: js, css_html: css }
hooks_run('draw_custom_assets', args)
trusted_fragments = [args[:css_html], args[:js_html], *state[:assets_content]].filter_map do |fragment|
next if fragment.blank?
fragment.is_a?(ActiveSupport::SafeBuffer) ? fragment : fragment.to_s.html_safe
end
helpers.safe_join(trusted_fragments, "\n")
end
|
#cama_draw_pre_asset_contents ⇒ Object
48
49
50
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 48
def cama_draw_pre_asset_contents
camaleon_html_helper_state[:pre_assets_content].join('').html_safe
end
|
#cama_html_helpers_init ⇒ Object
12
13
14
15
16
17
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 12
def cama_html_helpers_init
state = camaleon_html_helper_state
state[:pre_assets_content] = []
state[:assets_libraries] = {}
state[:assets_content] = []
end
|
#cama_load_libraries(*keys) ⇒ Object
Also known as:
add_asset_library
19
20
21
22
23
24
25
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 19
def cama_load_libraries(*keys)
state = camaleon_html_helper_state
keys.each do |key|
library = cama_assets_libraries[key.to_sym]
state[:assets_libraries][key.to_sym] = library if library.present?
end
end
|
#theme_init ⇒ Object
80
81
82
83
84
85
86
|
# File 'app/controllers/concerns/camaleon_cms/runtime_html_content_concern.rb', line 80
def theme_init
breadcrumb_items = []
camaleon_theme_state[:front_breadcrumb] = breadcrumb_items
@_front_breadcrumb = breadcrumb_items
end
|