Sha256: 0bc07740030b1a7b932486dfe406d57dd09eefd1089bfcee281718b52aa14595
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
module AssetsHelper VER = Time.now.to_i.to_s def assets *opts return '' if opts.blank? html = '' opts.each do |name| name = name.to_s if name.end_with?('.css') html << assets_css(name) elsif name.end_with?('.js') html << assets_js(name) else path = Rails.root.to_s + '/app/assets/' + name css = Dir.glob(([:css] + AssetFormat::Css::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s }) js = Dir.glob(([:js] + AssetFormat::Js::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s }) html << assets(name + '.css') if css.length > 0 html << assets(name + '.js') if js.length > 0 end end html end private def assets_js url "<script src=\"#{asset_host}/#{url}\"></script>" end def assets_css url "<link rel=\"stylesheet\" href=\"#{asset_host}/#{url}\" />" end def asset_host unless Rails.configuration.action_controller[:asset_host].nil? host = Rails.configuration.action_controller[:asset_host].clone unless request.nil? host << (request.port == 80 ? '' : (':' << request.port.to_s)) end else host = '' end unless Rails.configuration.action_controller[:asset_path].nil? host << ('/' + Rails.configuration.action_controller[:asset_path]) else host << '/assets' end if Rails.env.production? && Rails.configuration.action_controller[:asset_version].nil? Rails.configuration.action_controller[:asset_version] = :now end unless Rails.configuration.action_controller[:asset_version].nil? if Rails.configuration.action_controller[:asset_version] == :now host << '/' << VER else host << '/' << Rails.configuration.action_controller[:asset_version].to_s end end host end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zfben_rails_assets-0.0.7 | app/helpers/assets_helper.rb |