diff --git a/.gitignore b/.gitignore index 00c0b86e..77685543 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ coverage rdoc pkg +.sass-cache +*.gemspec \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index d612a279..3ce13bf3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "vendor/sinatra-maruku"] path = vendor/sinatra-maruku url = git://github.com/wbzyl/sinatra-maruku.git +[submodule "vendor/rack-test"] + path = vendor/rack-test + url = git://github.com/brynary/rack-test.git diff --git a/bin/mm-build b/bin/mm-build index 80852c3f..606b9211 100755 --- a/bin/mm-build +++ b/bin/mm-build @@ -3,8 +3,8 @@ # Require app require 'rubygems' require 'templater' -require 'open-uri' require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman') +require File.join(File.dirname(__FILE__), '..', 'vendor', 'rack-test', 'lib', 'rack', 'test') module Generators extend Templater::Manifold @@ -19,7 +19,7 @@ module Generators def self.template(name, *args, &block) return if args.first.include?('layout') return if File.basename(args.first)[0,1] == '_' - + if (args[0] === args[1]) newext = case File.extname(args.first) when '.haml', '.mab', '.maruku' @@ -31,11 +31,12 @@ module Generators end args[1] = args[0].gsub(File.extname(args.first), newext).gsub('views/', '') end - + super(name, *args, &block) end def self.file(name, *args, &block) + puts args.inspect args[1] = args[0].gsub('views/', '') if (args[0] === args[1]) super(name, *args, &block) end @@ -53,16 +54,16 @@ module Generators add :build, Builder end -# Monkey-patch to use a dynamic renderer, not just ERb +Middleman.set :root, Dir.pwd + +# Monkey-patch to use a dynamic renderer class Templater::Actions::Template def render - return "" - #request_path = destination.gsub(File.join(Dir.pwd, 'build'), "") - #Rack Handler + request_path = destination.gsub(File.join(Dir.pwd, 'build'), "") + browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman)) + browser.get(request_path) + browser.last_response.body end end -# Start app -#Middleman.run!(:root => Dir.pwd) do - Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV)) -#end \ No newline at end of file +Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV)) \ No newline at end of file diff --git a/lib/middleman.rb b/lib/middleman.rb index 2f7b4cb1..dce63b66 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -56,8 +56,10 @@ class Middleman < Sinatra::Base haml(template) elsif File.exists? File.join(options.views, "#{template}.maruku") maruku(template) - else + elsif File.exists? File.join(options.views, "#{template}.mab") markaby(template) + else + pass end elsif path.match /.css$/ content_type 'text/css', :charset => 'utf-8' diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index 7a34845f..a23f7c91 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -20,18 +20,22 @@ describe "Builder" do it "should build markaby files" do File.exists?("#{@root_dir}/build/markaby.html").should be_true + File.read("#{@root_dir}/build/markaby.html").should include("