1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/core_extensions/sprockets.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

require "sprockets"
2011-08-03 00:58:20 -04:00
module Middleman::CoreExtensions::Sprockets
class << self
2011-08-09 14:08:46 -04:00
def registered(app)
2011-07-10 19:02:52 -04:00
app.set :js_compressor, false
2011-08-09 14:08:46 -04:00
app.after_configuration do
app.map "/#{app.js_dir}" do
run JavascriptEnvironment.new(app)
end
2011-07-10 19:02:52 -04:00
end
2011-08-09 14:12:20 -04:00
2011-07-10 19:02:52 -04:00
# app.map "/#{app.css_dir}" do
# run StylesheetEnvironment.new(app)
# end
end
alias :included :registered
end
2011-08-03 00:58:20 -04:00
class MiddlemanEnvironment < ::Sprockets::Environment
2011-07-10 19:02:52 -04:00
def initialize(app)
2011-07-13 20:34:41 -04:00
full_path = app.views
full_path = File.join(app.root, app.views) unless app.views.include?(app.root)
super File.expand_path(full_path)
2011-07-10 19:02:52 -04:00
end
end
class JavascriptEnvironment < MiddlemanEnvironment
def initialize(app)
super
# Disable css
unregister_processor "text/css", ::Sprockets::DirectiveProcessor
self.js_compressor = app.settings.js_compressor
# configure search paths
2011-07-13 20:34:41 -04:00
append_path app.js_dir
2011-08-03 00:58:20 -04:00
# jQuery for Sprockets
# begin
# require "jquery-rails"
# jquery-rails / vendor / assets / javascripts
# rescue LoadError
# end
end
end
2011-07-10 19:02:52 -04:00
# class StylesheetEnvironment < MiddlemanEnvironment
# def initialize(app)
# super
#
# # Disable js
# unregister_processor "application/javascript", ::Sprockets::DirectiveProcessor
#
# # configure search paths
# stylesheets_path = File.join(File.expand_path(app.views), app.css_dir)
# append_path stylesheets_path
# end
# end
end