Removed Sprockets support. I suggest using a client-side tool like StealJS or RequireJS

This commit is contained in:
tdreyno 2010-09-04 23:45:19 -07:00
parent 5523a10d9b
commit a81d300532
9 changed files with 12 additions and 94 deletions

View file

@ -17,7 +17,6 @@ begin
gem.add_dependency("thin", "~>1.2.0")
gem.add_dependency("shotgun", "~>0.8.0")
gem.add_dependency("templater", "~>1.0.0")
gem.add_dependency("sprockets", "~>1.0.0")
gem.add_dependency("sinatra", "~>1.0")
gem.add_dependency("sinatra-content-for", "~>0.2.0")
gem.add_dependency("rack-test", "~>0.5.0")
@ -27,7 +26,7 @@ begin
gem.add_dependency("json_pure", "~>1.4.0")
gem.add_dependency("smusher", "~>0.4.5")
gem.add_dependency("compass-slickmap", "~>0.3.0")
gem.add_dependency("livereload", "~>1.4.0")
# gem.add_dependency("livereload", "~>1.4.0")
gem.add_development_dependency("rspec")
gem.add_development_dependency("cucumber")

View file

@ -14,7 +14,6 @@ module Middleman
set :sessions, false
set :logging, false
set :environment, ENV['MM_ENV'] || :development
set :supported_formats, %w(erb)
set :index_file, "index.html"
set :js_dir, "javascripts"
set :css_dir, "stylesheets"

View file

@ -1,9 +1,13 @@
require 'middleman/base'
require 'templater'
require 'middleman/templater+dynamic_renderer.rb'
# Placeholder for any methods the builder needs to abstract to allow feature integration
module Middleman
class Builder < ::Templater::Generator
@@template_extensions = ::Tilt.mappings.keys << "js"
# Define source and desintation
def self.source_root; Dir.pwd; end
def destination_root; File.join(Dir.pwd, Middleman::Base.build_dir); end
@ -28,7 +32,8 @@ module Middleman
def self.file(name, *args, &block)
file_ext = File.extname(args[0])
return if Middleman::Base.supported_formats.include? file_ext[1..file_ext.length]
return unless ::Tilt[file_ext].nil?
if (args[0] === args[1])
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "").gsub("#{File.basename(Middleman::Base.public)}/", "")
@ -37,9 +42,8 @@ module Middleman
end
def self.init!
glob! File.basename(Middleman::Base.public), Middleman::Base.supported_formats
glob! File.basename(Middleman::Base.views), %w(sass js)
glob! File.basename(Middleman::Base.views), Middleman::Base.supported_formats - %w(sass js)
glob! File.basename(Middleman::Base.public), @@template_extensions
glob! File.basename(Middleman::Base.views), @@template_extensions
end
def after_run

View file

@ -14,25 +14,24 @@ module Middleman
feature_class = @@features[feature_name]
feature_class.new(scope) unless feature_class.nil?
end
def self.all
@@features
end
end
end
# livereload
%w(asset_host
automatic_image_sizes
cache_buster
default_helpers
livereload
minify_css
minify_javascript
relative_assets
slickmap
smush_pngs
sprockets
ugly_haml).each do |feature|
require File.join("middleman/features", feature)

View file

@ -1,13 +0,0 @@
class Middleman::Features::Sprockets
def initialize(app)
require "middleman/features/sprockets/rack"
app.use Middleman::Rack::Sprockets,
:root => Middleman::Base.root,
:load_path => [ File.join("public", Middleman::Base.js_dir),
File.join("views", Middleman::Base.js_dir) ]
end
end
Middleman::Features.register :sprockets, Middleman::Features::Sprockets, { :auto_enable => true }

View file

@ -1,64 +0,0 @@
require 'sprockets'
module Middleman
module Rack
class Sprockets
def initialize(app, options={})
@app = app
@options = options
end
def call(env)
if env["PATH_INFO"].match(/\.js$/)
public_file_path = File.join(Middleman::Base.public, env["PATH_INFO"])
view_file_path = File.join(Middleman::Base.views, env["PATH_INFO"])
source_file = ::Rack::File.new(Middleman::Base.public) if File.exists?(public_file_path)
source_file = ::Rack::File.new(Middleman::Base.views) if File.exists?(view_file_path)
if source_file
status, headers, response = source_file.call(env)
secretary = ::Sprockets::Secretary.new(@options.merge( :source_files => [ response.path ] ))
response = secretary.concatenation.to_s
headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
return [status, headers, response]
end
end
@app.call(env)
end
end
end
end
# Sprockets ruby 1.9 duckpunch
module Sprockets
class SourceFile
def source_lines
@lines ||= begin
lines = []
comments = []
File.open(pathname.absolute_location, 'rb') do |file|
file.each do |line|
lines << line = SourceLine.new(self, line, file.lineno)
if line.begins_pdoc_comment? || comments.any?
comments << line
end
if line.ends_multiline_comment?
if line.ends_pdoc_comment?
comments.each { |l| l.comment! }
end
comments.clear
end
end
end
lines
end
end
end
end

View file

@ -59,8 +59,4 @@ describe "Builder" do
it "should not build partial files" do
File.exists?("#{@root_dir}/build/_partial.html").should be_false
end
it "should combine javascript" do
File.read("#{@root_dir}/build/javascripts/empty-with-include.js").should include("combo")
end
end

View file

@ -1 +0,0 @@
function() { return "combo"; };

View file

@ -1 +0,0 @@
//= require <to-be-included>