From fef7cb90eac7cc54c160f02934274f647b406fa2 Mon Sep 17 00:00:00 2001 From: tdreyno Date: Wed, 29 Jul 2009 10:39:00 -0700 Subject: [PATCH] init file --- bin/mm-build | 5 ++--- bin/mm-init | 3 ++- lib/middleman.rb | 13 ++++++++++++- lib/middleman/template/init.rb | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 lib/middleman/template/init.rb diff --git a/bin/mm-build b/bin/mm-build index 7236c06a..904323e3 100755 --- a/bin/mm-build +++ b/bin/mm-build @@ -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 diff --git a/bin/mm-init b/bin/mm-init index 24b47cf9..0a9f4728 100755 --- a/bin/mm-init +++ b/bin/mm-init @@ -18,7 +18,8 @@ module Generators def self.source_root File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'template') end - + + file :init, "init.rb" glob! :views glob! :public empty_directory :stylesheets, "public/stylesheets" diff --git a/lib/middleman.rb b/lib/middleman.rb index c26a351b..4954b63f 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -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 @@ -45,7 +49,14 @@ class Middleman < Sinatra::Base config.http_images_path = "/images/" 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{^/}, '') diff --git a/lib/middleman/template/init.rb b/lib/middleman/template/init.rb new file mode 100644 index 00000000..2b73e856 --- /dev/null +++ b/lib/middleman/template/init.rb @@ -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 \ No newline at end of file