diff --git a/.gitmodules b/.gitmodules index 65ed706c..d612a279 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/sinatra-markaby"] path = vendor/sinatra-markaby url = git://github.com/sbfaulkner/sinatra-markaby.git +[submodule "vendor/sinatra-maruku"] + path = vendor/sinatra-maruku + url = git://github.com/wbzyl/sinatra-maruku.git diff --git a/Rakefile b/Rakefile index f88e9bb2..eab43e7c 100644 --- a/Rakefile +++ b/Rakefile @@ -14,6 +14,8 @@ begin gem.executables = %w(sm-init sm-build sm-server) gem.add_dependency("templater") gem.add_dependency("sinatra") + gem.add_dependency("markaby") + gem.add_dependency("maruku") gem.add_dependency("haml", ">=2.1.0") gem.add_dependency("chriseppstein-compass") end diff --git a/bin/mm-build b/bin/mm-build index 4e6cbb7a..80852c3f 100755 --- a/bin/mm-build +++ b/bin/mm-build @@ -22,7 +22,7 @@ module Generators if (args[0] === args[1]) newext = case File.extname(args.first) - when '.haml' + when '.haml', '.mab', '.maruku' '.html' when '.sass' '.css' @@ -47,7 +47,7 @@ module Generators file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', '')) end - glob! "views", %w(haml sass) + glob! "views", %w(haml sass mab maruku) end add :build, Builder diff --git a/lib/middleman.rb b/lib/middleman.rb index c60c856f..2f7b4cb1 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -4,10 +4,15 @@ require 'compass' #must be loaded before sinatra require 'sinatra/base' # Include markaby support -require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra', 'markaby') +require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-markaby', 'lib', 'sinatra', 'markaby') + +# Include maruku support +require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib', 'sinatra', 'maruku') class Middleman < Sinatra::Base set :app_file, __FILE__ + helpers Sinatra::Markaby + helpers Sinatra::Maruku def self.run!(options={}, &block) set options @@ -41,21 +46,23 @@ class Middleman < Sinatra::Base end end - def render_haml_or_sass(path) + get /(.*)/ do |path| + path << "index.html" if path.match(%r{/$}) + path.gsub!(%r{^/}, '') + + template = path.gsub(File.extname(path), '').to_sym if path.match /.html$/ - haml(path.gsub('.html', '').to_sym) - #markaby + if File.exists? File.join(options.views, "#{template}.haml") + haml(template) + elsif File.exists? File.join(options.views, "#{template}.maruku") + maruku(template) + else + markaby(template) + end elsif path.match /.css$/ content_type 'text/css', :charset => 'utf-8' - sass(path.gsub('.css', '').to_sym, Compass.sass_engine_options) - end - end - - get /(.*)/ do |path| - path = path.gsub(%r{^/}, '') - path = "index.html" if path == '' - - if !render_haml_or_sass(path) + sass(template, Compass.sass_engine_options) + else pass end end diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index 41635ff3..7a34845f 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -18,10 +18,18 @@ describe "Builder" do FileUtils.rm_rf(File.join(@root_dir, "build")) end - it "should build normal files" do + it "should build markaby files" do + File.exists?("#{@root_dir}/build/markaby.html").should be_true + end + + it "should build haml files" do File.exists?("#{@root_dir}/build/index.html").should be_true end - + + it "should build maruku files" do + File.exists?("#{@root_dir}/build/maruku.html").should be_true + end + it "should build static files" do File.exists?("#{@root_dir}/build/static.html").should be_true end diff --git a/spec/fixtures/sample/views/markaby.mab b/spec/fixtures/sample/views/markaby.mab new file mode 100644 index 00000000..e69de29b diff --git a/spec/fixtures/sample/views/maruku.maruku b/spec/fixtures/sample/views/maruku.maruku new file mode 100644 index 00000000..9eab2091 --- /dev/null +++ b/spec/fixtures/sample/views/maruku.maruku @@ -0,0 +1 @@ +# Hello Maruku {.header} \ No newline at end of file diff --git a/vendor/sinatra-maruku b/vendor/sinatra-maruku new file mode 160000 index 00000000..a83b646e --- /dev/null +++ b/vendor/sinatra-maruku @@ -0,0 +1 @@ +Subproject commit a83b646e62d07a83c27f508ab1775ef3d68d93af