Module: MongodbLogger::AssetHelpers

Defined in:
lib/mongodb_logger/server/helpers/sprokets.rb

Instance Method Summary collapse

Instance Method Details

#asset_data_uri(source) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/mongodb_logger/server/helpers/sprokets.rb', line 11

def asset_data_uri(source)
  unless Assets.instance.find_asset(source).nil?
    asset  = Assets.instance.find_asset(source)
    base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "")
    "data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
  end
end

#asset_path(source) ⇒ Object


8
9
10
# File 'lib/mongodb_logger/server/helpers/sprokets.rb', line 8

def asset_path(source)
  "#{request.env['SCRIPT_NAME']}/assets/#{Assets.instance.find_asset(source).digest_path}" unless Assets.instance.find_asset(source).nil?
end