Load from root bundler when running from git

This commit is contained in:
Thomas Reynolds 2012-05-26 14:15:36 -07:00
parent 1d90d03dd8
commit 3b847696ff
4 changed files with 127 additions and 116 deletions

View file

@ -25,8 +25,14 @@ end
# If we've found the root, try to setup Bundler # If we've found the root, try to setup Bundler
if ENV["MM_ROOT"] if ENV["MM_ROOT"]
# Set up gems listed in the Gemfile. root_gemfile = File.expand_path('Gemfile', ENV["MM_ROOT"])
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', ENV["MM_ROOT"]) ENV['BUNDLE_GEMFILE'] ||= root_gemfile
if !File.exists?(ENV['BUNDLE_GEMFILE'])
git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + "Gemfile"
ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s
end
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
end end
@ -34,11 +40,11 @@ end
require "middleman-core/extensions" require "middleman-core/extensions"
::Middleman.load_extensions_in_path ::Middleman.load_extensions_in_path
require "middleman-core/cli"
# Default command is server # Default command is server
ARGV.unshift("server") if ARGV.length < 1 || ARGV.first.include?("-") ARGV.unshift("server") if ARGV.length < 1 || ARGV.first.include?("-")
require "middleman-core/cli"
# Start the CLI # Start the CLI
if ENV["MM_ROOT"] if ENV["MM_ROOT"]
# Change directory to the root # Change directory to the root

View file

@ -137,7 +137,10 @@ module Middleman
instance_eval File.read(local_config), local_config, 1 instance_eval File.read(local_config), local_config, 1
end end
activate(:sprockets) if autoload_sprockets if autoload_sprockets
require "middleman-sprockets"
activate(:sprockets)
end
run_hook :build_config if build? run_hook :build_config if build?
run_hook :development_config if development? run_hook :development_config if development?

View file

@ -88,7 +88,7 @@ module Middleman
extensions = rubygems_latest_specs.select do |spec| extensions = rubygems_latest_specs.select do |spec|
spec_has_file?(spec, EXTENSION_FILE) spec_has_file?(spec, EXTENSION_FILE)
end end
extensions.each do |spec| extensions.each do |spec|
require spec.name require spec.name
end end

View file

@ -4,141 +4,143 @@ require "middleman-core"
libdir = File.expand_path(File.dirname(__FILE__)) libdir = File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
module Middleman::More module Middleman
module More
# Setup extension # Setup extension
class << self class << self
# Once registered # Once registered
def registered(app, options={}) def registered(app, options={})
### ###
# Setup renderers # Setup renderers
### ###
# CoffeeScript Support # CoffeeScript Support
require "middleman-more/renderers/coffee_script" require "middleman-more/renderers/coffee_script"
Middleman::Application.register Middleman::Renderers::CoffeeScript Middleman::Application.register Middleman::Renderers::CoffeeScript
# Haml Support # Haml Support
require "middleman-more/renderers/haml" require "middleman-more/renderers/haml"
Middleman::Application.register Middleman::Renderers::Haml Middleman::Application.register Middleman::Renderers::Haml
# Sass Support # Sass Support
require "middleman-more/renderers/sass" require "middleman-more/renderers/sass"
Middleman::Application.register Middleman::Renderers::Sass Middleman::Application.register Middleman::Renderers::Sass
# Markdown Support # Markdown Support
require "middleman-more/renderers/markdown" require "middleman-more/renderers/markdown"
Middleman::Application.register Middleman::Renderers::Markdown Middleman::Application.register Middleman::Renderers::Markdown
# Liquid Support # Liquid Support
require "middleman-more/renderers/liquid" require "middleman-more/renderers/liquid"
Middleman::Application.register Middleman::Renderers::Liquid Middleman::Application.register Middleman::Renderers::Liquid
# Slim Support # Slim Support
require "middleman-more/renderers/slim" require "middleman-more/renderers/slim"
Middleman::Application.register Middleman::Renderers::Slim Middleman::Application.register Middleman::Renderers::Slim
### ###
# Setup Core Extensions # Setup Core Extensions
### ###
# Setup default helpers # Setup default helpers
require "middleman-more/core_extensions/default_helpers" require "middleman-more/core_extensions/default_helpers"
Middleman::Application.register Middleman::CoreExtensions::DefaultHelpers Middleman::Application.register Middleman::CoreExtensions::DefaultHelpers
# Setup asset path pipeline # Setup asset path pipeline
require "middleman-more/core_extensions/assets" require "middleman-more/core_extensions/assets"
Middleman::Application.register Middleman::CoreExtensions::Assets Middleman::Application.register Middleman::CoreExtensions::Assets
# i18n # i18n
require "i18n" require "i18n"
app.after_configuration do app.after_configuration do
# This is for making the tests work - since the tests # This is for making the tests work - since the tests
# don't completely reload middleman, I18n.load_path can get # don't completely reload middleman, I18n.load_path can get
# polluted with paths from other test app directories that don't # polluted with paths from other test app directories that don't
# exist anymore. # exist anymore.
::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}} ::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}}
::I18n.reload! ::I18n.reload!
end end
Middleman::Extensions.register(:i18n) do Middleman::Extensions.register(:i18n) do
require "middleman-more/core_extensions/i18n" require "middleman-more/core_extensions/i18n"
Middleman::CoreExtensions::I18n Middleman::CoreExtensions::I18n
end end
# Compass framework # Compass framework
require "middleman-more/core_extensions/compass" require "middleman-more/core_extensions/compass"
Middleman::Application.register Middleman::CoreExtensions::Compass Middleman::Application.register Middleman::CoreExtensions::Compass
### ###
# Setup Optional Extensions # Setup Optional Extensions
### ###
# CacheBuster adds a query string to assets in dynamic templates to avoid # CacheBuster adds a query string to assets in dynamic templates to avoid
# browser caches failing to update to your new content. # browser caches failing to update to your new content.
Middleman::Extensions.register(:cache_buster) do Middleman::Extensions.register(:cache_buster) do
require "middleman-more/extensions/cache_buster" require "middleman-more/extensions/cache_buster"
Middleman::Extensions::CacheBuster Middleman::Extensions::CacheBuster
end end
# MinifyCss compresses CSS # MinifyCss compresses CSS
Middleman::Extensions.register(:minify_css) do Middleman::Extensions.register(:minify_css) do
require "middleman-more/extensions/minify_css" require "middleman-more/extensions/minify_css"
Middleman::Extensions::MinifyCss Middleman::Extensions::MinifyCss
end end
# MinifyJavascript compresses JS # MinifyJavascript compresses JS
Middleman::Extensions.register(:minify_javascript) do Middleman::Extensions.register(:minify_javascript) do
require "middleman-more/extensions/minify_javascript" require "middleman-more/extensions/minify_javascript"
Middleman::Extensions::MinifyJavascript Middleman::Extensions::MinifyJavascript
end end
# RelativeAssets allow any asset path in dynamic templates to be either # RelativeAssets allow any asset path in dynamic templates to be either
# relative to the root of the project or use an absolute URL. # relative to the root of the project or use an absolute URL.
Middleman::Extensions.register(:relative_assets) do Middleman::Extensions.register(:relative_assets) do
require "middleman-more/extensions/relative_assets" require "middleman-more/extensions/relative_assets"
Middleman::Extensions::RelativeAssets Middleman::Extensions::RelativeAssets
end end
# GZIP assets and pages during build # GZIP assets and pages during build
Middleman::Extensions.register(:gzip) do Middleman::Extensions.register(:gzip) do
require "middleman-more/extensions/gzip" require "middleman-more/extensions/gzip"
Middleman::Extensions::Gzip Middleman::Extensions::Gzip
end end
# AssetHash appends a hash of the file contents to the assets filename # AssetHash appends a hash of the file contents to the assets filename
# to avoid browser caches failing to update to your new content. # to avoid browser caches failing to update to your new content.
Middleman::Extensions.register(:asset_hash) do Middleman::Extensions.register(:asset_hash) do
require "middleman-more/extensions/asset_hash" require "middleman-more/extensions/asset_hash"
Middleman::Extensions::AssetHash Middleman::Extensions::AssetHash
end end
# AssetHost allows you to setup multiple domains to host your static # AssetHost allows you to setup multiple domains to host your static
# assets. Calls to asset paths in dynamic templates will then rotate # assets. Calls to asset paths in dynamic templates will then rotate
# through each of the asset servers to better spread the load. # through each of the asset servers to better spread the load.
Middleman::Extensions.register(:asset_host) do Middleman::Extensions.register(:asset_host) do
require "middleman-more/extensions/asset_host" require "middleman-more/extensions/asset_host"
Middleman::Extensions::AssetHost Middleman::Extensions::AssetHost
end end
# Provide Apache-style index.html files for directories # Provide Apache-style index.html files for directories
Middleman::Extensions.register(:directory_indexes) do Middleman::Extensions.register(:directory_indexes) do
require "middleman-more/extensions/directory_indexes" require "middleman-more/extensions/directory_indexes"
Middleman::Extensions::DirectoryIndexes Middleman::Extensions::DirectoryIndexes
end end
# Lorem provides a handful of helpful prototyping methods to generate # Lorem provides a handful of helpful prototyping methods to generate
# words, paragraphs, fake images, names and email addresses. # words, paragraphs, fake images, names and email addresses.
require "middleman-more/extensions/lorem" require "middleman-more/extensions/lorem"
Middleman::Application.register Middleman::Extensions::Lorem Middleman::Application.register Middleman::Extensions::Lorem
# AutomaticImageSizes inspects the images used in your dynamic templates # AutomaticImageSizes inspects the images used in your dynamic templates
# and automatically adds width and height attributes to their HTML # and automatically adds width and height attributes to their HTML
# elements. # elements.
Middleman::Extensions.register(:automatic_image_sizes) do Middleman::Extensions.register(:automatic_image_sizes) do
require "middleman-more/extensions/automatic_image_sizes" require "middleman-more/extensions/automatic_image_sizes"
Middleman::Extensions::AutomaticImageSizes Middleman::Extensions::AutomaticImageSizes
end
end end
end end
end end