Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb
Instance Method Summary collapse
-
#theme_font_include(theme_id, font_file_name, options = {}) ⇒ Object
theme_font_include(theme_id, font_file_name, options={}) @param1: theme_id(string) @param2: font_file_name(string) @param3: options = { sources: [ ‘font1’, format: ‘format1’, ‘font2’, format: ‘format2’ ], font_family: ‘FontFamilyName’, font_style: normal, font_weight: normal, font_stretch: ”, unicode_range: ”, apply_to: ” }.
- #theme_image_path(theme, source) ⇒ Object (also: #theme_path_to_image)
- #theme_image_tag(theme_id, source, options = {}) ⇒ Object
- #theme_javascript_include_tag(theme_id, *sources) ⇒ Object
- #theme_javascript_path(theme, source) ⇒ Object (also: #theme_path_to_javascript)
- #theme_stylesheet_link_tag(theme_id, *sources) ⇒ Object
- #theme_stylesheet_path(theme, source) ⇒ Object (also: #theme_path_to_stylesheet)
Instance Method Details
#theme_font_include(theme_id, font_file_name, options = {}) ⇒ Object
theme_font_include(theme_id, font_file_name, options={}) @param1: theme_id(string) @param2: font_file_name(string) @param3: options =
sources: [
{url: 'font1', format: 'format1',
'font2', format: 'format2'
],
font_family: 'FontFamilyName',
font_style: normal,
font_weight: normal,
font_stretch: '',
unicode_range: '',
apply_to: ''
}
114 115 116 117 118 119 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 114 def theme_font_include(theme_id, font_file_name, ={}) theme = controller.website.themes.find_by_theme_id(theme_id) return("could not find theme with the id #{theme_id}") unless theme theme_font_src_tag(theme, font_file_name, ) end |
#theme_image_path(theme, source) ⇒ Object Also known as: theme_path_to_image
67 68 69 70 71 72 73 74 75 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 67 def theme_image_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) name, directory = name_and_path_from_source(source, "#{theme.url}/images") file = theme.files.where('name = ? and directory = ?', name, directory).first file.nil? ? '' : file.data.url end |
#theme_image_tag(theme_id, source, options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 79 def theme_image_tag(theme_id, source, = {}) theme = controller.website.themes.find_by_theme_id(theme_id) return("could not find theme with the id #{theme_id}") unless theme .symbolize_keys! [:src] = theme_path_to_image(theme, source) [:alt] ||= File.basename([:src], '.*').split('.').first.to_s.capitalize if size = .delete(:size) [:width], [:height] = size.split("x") if size =~ %r{^\d+x\d+$} end if mouseover = .delete(:mouseover) [:onmouseover] = "this.src='#{theme_image_path(theme, mouseover)}'" [:onmouseout] = "this.src='#{theme_image_path(theme, [:src])}'" end tag("img", ) end |
#theme_javascript_include_tag(theme_id, *sources) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 25 def theme_javascript_include_tag(theme_id, *sources) theme = controller.website.themes.find_by_theme_id(theme_id) return("could not find theme with the id #{theme_id}") unless theme = sources..stringify_keys cache = .delete("cache") recursive = .delete("recursive") sources = (theme, sources, recursive).collect do |source| theme_javascript_src_tag(theme, source, ) end.join("\n") raw sources #end end |
#theme_javascript_path(theme, source) ⇒ Object Also known as: theme_path_to_javascript
13 14 15 16 17 18 19 20 21 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 13 def theme_javascript_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) name, directory = name_and_path_from_source(source, "#{theme.url}/javascripts") file = theme.files.where('name = ? and directory = ?', name, directory).first file.nil? ? '' : file.data.url end |
#theme_stylesheet_link_tag(theme_id, *sources) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 52 def theme_stylesheet_link_tag(theme_id, *sources) theme = controller.website.themes.find_by_theme_id(theme_id) return("could not find theme with the id #{theme_id}") unless theme = sources..stringify_keys cache = .delete("cache") recursive = .delete("recursive") sources = (theme, sources, recursive).collect do |source| theme_stylesheet_tag(theme, source, ) end.join("\n") raw sources #end end |
#theme_stylesheet_path(theme, source) ⇒ Object Also known as: theme_path_to_stylesheet
40 41 42 43 44 45 46 47 48 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 40 def theme_stylesheet_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) name, directory = name_and_path_from_source(source, "#{theme.url}/stylesheets") file = theme.files.where('name = ? and directory = ?', name, directory).first file.nil? ? '' : file.data.url end |