init file
This commit is contained in:
parent
b6633d4069
commit
fef7cb90ea
|
@ -3,6 +3,8 @@
|
|||
# Require app
|
||||
require 'rubygems'
|
||||
require 'templater'
|
||||
|
||||
MIDDLEMAN_BUILDER = true
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
|
||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'rack-test', 'lib', 'rack', 'test')
|
||||
|
||||
|
@ -36,7 +38,6 @@ module Generators
|
|||
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
|
||||
|
@ -54,8 +55,6 @@ module Generators
|
|||
add :build, Builder
|
||||
end
|
||||
|
||||
Middleman.set :root, Dir.pwd
|
||||
|
||||
# Monkey-patch to use a dynamic renderer
|
||||
class Templater::Actions::Template
|
||||
def render
|
||||
|
|
|
@ -19,6 +19,7 @@ module Generators
|
|||
File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'template')
|
||||
end
|
||||
|
||||
file :init, "init.rb"
|
||||
glob! :views
|
||||
glob! :public
|
||||
empty_directory :stylesheets, "public/stylesheets"
|
||||
|
|
|
@ -11,6 +11,10 @@ require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib
|
|||
|
||||
class Middleman < Sinatra::Base
|
||||
set :app_file, __FILE__
|
||||
set :static, true
|
||||
set :root, Dir.pwd
|
||||
set :environment, defined?(MIDDLEMAN_BUILDER) ? :build : :development
|
||||
|
||||
helpers Sinatra::Markaby
|
||||
helpers Sinatra::Maruku
|
||||
|
||||
|
@ -46,6 +50,13 @@ class Middleman < Sinatra::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Check for local config
|
||||
local_config = File.join(self.root, "init.rb")
|
||||
if File.exists? local_config
|
||||
puts "== Local config at: #{local_config}"
|
||||
class_eval File.read(local_config)
|
||||
end
|
||||
|
||||
get /(.*)/ do |path|
|
||||
path << "index.html" if path.match(%r{/$})
|
||||
path.gsub!(%r{^/}, '')
|
||||
|
|
17
lib/middleman/template/init.rb
Normal file
17
lib/middleman/template/init.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Helpers
|
||||
helpers do
|
||||
end
|
||||
|
||||
# Or inject more templating languages
|
||||
# helpers Sinatra::Markdown
|
||||
|
||||
# Build-specific configuration
|
||||
configure :build do
|
||||
Compass.configuration do |config|
|
||||
# For example, change the Compass output style for deployment
|
||||
# config.output_style = :compressed
|
||||
|
||||
# Or use a different image path
|
||||
# config.http_images_path = "/Content/images/"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue