diff --git a/Rakefile b/Rakefile index fe2e67b5..3fb53724 100644 --- a/Rakefile +++ b/Rakefile @@ -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") diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index 76d26fcb..bbc89fba 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -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" diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index af2e155d..db2094ec 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -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 diff --git a/lib/middleman/features.rb b/lib/middleman/features.rb index 18eac4e1..f0d3faae 100644 --- a/lib/middleman/features.rb +++ b/lib/middleman/features.rb @@ -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) diff --git a/lib/middleman/features/sprockets.rb b/lib/middleman/features/sprockets.rb deleted file mode 100644 index c1b50f14..00000000 --- a/lib/middleman/features/sprockets.rb +++ /dev/null @@ -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 } - - diff --git a/lib/middleman/features/sprockets/rack.rb b/lib/middleman/features/sprockets/rack.rb deleted file mode 100644 index c22a8b5e..00000000 --- a/lib/middleman/features/sprockets/rack.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index 6d1593b9..a992fb92 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/fixtures/sample/public/javascripts/to-be-included.js b/spec/fixtures/sample/public/javascripts/to-be-included.js deleted file mode 100755 index f90b7eb8..00000000 --- a/spec/fixtures/sample/public/javascripts/to-be-included.js +++ /dev/null @@ -1 +0,0 @@ -function() { return "combo"; }; \ No newline at end of file diff --git a/spec/fixtures/sample/views/javascripts/empty-with-include.js b/spec/fixtures/sample/views/javascripts/empty-with-include.js deleted file mode 100755 index 5b2bea44..00000000 --- a/spec/fixtures/sample/views/javascripts/empty-with-include.js +++ /dev/null @@ -1 +0,0 @@ -//= require \ No newline at end of file