Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb
Instance Method Summary collapse
- #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_image_path(theme, source) ⇒ Object Also known as: theme_path_to_image
74 75 76 77 78 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 74 def theme_image_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/images").first file.nil? ? '' : file.data.url end |
#theme_image_tag(theme_id, source, options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 81 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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 19 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") # this caching appears to be deprecated, commenting out # if ActionController::Base.perform_caching && cache # joined_javascript_name = (cache == true ? "all" : cache) + ".js" # joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name) # paths = theme_compute_javascript_paths(theme, sources, recursive) # theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path) # raw theme_javascript_src_tag(theme, joined_javascript_name, options) # else 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
12 13 14 15 16 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 12 def theme_javascript_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/javascripts").first file.nil? ? '' : file.data.url end |
#theme_stylesheet_link_tag(theme_id, *sources) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 50 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") # this caching appears to be deprecated, commenting out # if ActionController::Base.perform_caching && cache # joined_stylesheet_name = (cache == true ? "all" : cache) + ".css" # joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name) # paths = theme_compute_stylesheet_paths(theme, sources, recursive) # theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path) # raw theme_stylesheet_tag(theme, joined_stylesheet_name, options) # else 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
43 44 45 46 47 |
# File 'lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb', line 43 def theme_stylesheet_path(theme, source) theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme) file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/stylesheets").first file.nil? ? '' : file.data.url end |