require 'oj'
require "sinatra/asset_helpers/version"
module Sinatra
module AssetHelpers
module Helpers
def asset_url_for(filename)
return filename if filename =~ /^http|https|\//
halt 500, "Invalid path (#{settings.manifest_path}) to manifest.json" unless File.exists? settings.manifest_path
manifest = Oj.load(File.open(settings.manifest_path, 'r'))
file = manifest[filename]
"#{settings.assets_host}/#{settings.assets_path}/#{file}"
end
def stylesheet_tag(filename, media = 'screen')
%Q()
end
def javascript_tag(filename)
%Q()
end
def image_tag(filename, alt = '', title = '')
%Q()
end
end
def self.registered(app)
app.helpers AssetHelpers::Helpers
app.set :assets_path, 'assets'
app.set :assets_host, ENV['ASSETS_HOST']
app.set :manifest_path, File.join(app.settings.root, 'public/assets/manifest.json')
end
end
end