maruku support

This commit is contained in:
tdreyno 2009-07-28 09:39:06 -07:00
parent e3751e1448
commit 6a54c80e6e
8 changed files with 39 additions and 17 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "vendor/sinatra-markaby"] [submodule "vendor/sinatra-markaby"]
path = vendor/sinatra-markaby path = vendor/sinatra-markaby
url = git://github.com/sbfaulkner/sinatra-markaby.git url = git://github.com/sbfaulkner/sinatra-markaby.git
[submodule "vendor/sinatra-maruku"]
path = vendor/sinatra-maruku
url = git://github.com/wbzyl/sinatra-maruku.git

View file

@ -14,6 +14,8 @@ begin
gem.executables = %w(sm-init sm-build sm-server) gem.executables = %w(sm-init sm-build sm-server)
gem.add_dependency("templater") gem.add_dependency("templater")
gem.add_dependency("sinatra") gem.add_dependency("sinatra")
gem.add_dependency("markaby")
gem.add_dependency("maruku")
gem.add_dependency("haml", ">=2.1.0") gem.add_dependency("haml", ">=2.1.0")
gem.add_dependency("chriseppstein-compass") gem.add_dependency("chriseppstein-compass")
end end

View file

@ -22,7 +22,7 @@ module Generators
if (args[0] === args[1]) if (args[0] === args[1])
newext = case File.extname(args.first) newext = case File.extname(args.first)
when '.haml' when '.haml', '.mab', '.maruku'
'.html' '.html'
when '.sass' when '.sass'
'.css' '.css'
@ -47,7 +47,7 @@ module Generators
file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', '')) file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', ''))
end end
glob! "views", %w(haml sass) glob! "views", %w(haml sass mab maruku)
end end
add :build, Builder add :build, Builder

View file

@ -4,10 +4,15 @@ require 'compass' #must be loaded before sinatra
require 'sinatra/base' require 'sinatra/base'
# Include markaby support # 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 class Middleman < Sinatra::Base
set :app_file, __FILE__ set :app_file, __FILE__
helpers Sinatra::Markaby
helpers Sinatra::Maruku
def self.run!(options={}, &block) def self.run!(options={}, &block)
set options set options
@ -41,21 +46,23 @@ class Middleman < Sinatra::Base
end end
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$/ if path.match /.html$/
haml(path.gsub('.html', '').to_sym) if File.exists? File.join(options.views, "#{template}.haml")
#markaby haml(template)
elsif File.exists? File.join(options.views, "#{template}.maruku")
maruku(template)
else
markaby(template)
end
elsif path.match /.css$/ elsif path.match /.css$/
content_type 'text/css', :charset => 'utf-8' content_type 'text/css', :charset => 'utf-8'
sass(path.gsub('.css', '').to_sym, Compass.sass_engine_options) sass(template, Compass.sass_engine_options)
end else
end
get /(.*)/ do |path|
path = path.gsub(%r{^/}, '')
path = "index.html" if path == ''
if !render_haml_or_sass(path)
pass pass
end end
end end

View file

@ -18,10 +18,18 @@ describe "Builder" do
FileUtils.rm_rf(File.join(@root_dir, "build")) FileUtils.rm_rf(File.join(@root_dir, "build"))
end 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 File.exists?("#{@root_dir}/build/index.html").should be_true
end end
it "should build maruku files" do
File.exists?("#{@root_dir}/build/maruku.html").should be_true
end
it "should build static files" do it "should build static files" do
File.exists?("#{@root_dir}/build/static.html").should be_true File.exists?("#{@root_dir}/build/static.html").should be_true
end end

View file

View file

@ -0,0 +1 @@
# Hello Maruku {.header}

1
vendor/sinatra-maruku vendored Submodule

@ -0,0 +1 @@
Subproject commit a83b646e62d07a83c27f508ab1775ef3d68d93af