fix relative assets and sprockets js

This commit is contained in:
Thomas Reynolds 2011-11-18 17:37:01 -08:00
parent 7d9550e9ce
commit 4ceb9bab41
5 changed files with 36 additions and 46 deletions

View file

@ -27,11 +27,6 @@ module Middleman::CoreExtensions::DefaultHelpers
end
module Helpers
# TODO: Implement
def javascript_include_tag(path)
end
def auto_stylesheet_link_tag(separator="/")
auto_tag(:css, separator) do |path|
stylesheet_link_tag path

View file

@ -38,7 +38,7 @@ module Middleman::CoreExtensions::Sprockets
end
# add paths to js_env (vendor/assets/javascripts)
app.map "/#{self.js_dir}" do
map "/#{self.js_dir}" do
run js_env
end
end
@ -70,10 +70,7 @@ module Middleman::CoreExtensions::Sprockets
class MiddlemanEnvironment < ::Sprockets::Environment
def initialize(app)
full_path = app.views
full_path = File.join(app.root, app.views) unless app.views.include?(app.root)
super File.expand_path(full_path)
super app.source_dir
# Make the app context available to Sprockets
context_class.send(:define_method, :app) { app }
@ -93,9 +90,6 @@ module Middleman::CoreExtensions::Sprockets
def initialize(app)
super
# Disable css
# unregister_processor "text/css", ::Sprockets::DirectiveProcessor
self.js_compressor = app.js_compressor
# configure search paths
@ -112,9 +106,6 @@ module Middleman::CoreExtensions::Sprockets
def initialize(app)
super
# Disable js
# unregister_processor "application/javascript", ::Sprockets::DirectiveProcessor
self.css_compressor = app.css_compressor
# configure search paths

View file

@ -5,14 +5,20 @@ module Middleman::Features::RelativeAssets
config.relative_assets = true
end
app.register_asset_handler :relative_assets do |path, prefix|
app.send :include, InstanceMethods
end
alias :included :registered
end
module InstanceMethods
def asset_url(path, prefix="")
begin
prefix = self.images_dir if prefix == self.http_images_path
rescue
end
if path.include?("://")
self.before_asset_handler(:relative_assets, path, prefix)
super(path, prefix)
elsif path[0,1] == "/"
path
else
@ -33,6 +39,4 @@ module Middleman::Features::RelativeAssets
end
end
end
alias :included :registered
end
end