Switch over to new config methods

This commit is contained in:
Ben Hollis 2012-10-13 19:54:55 -07:00
parent 781fa1c65f
commit a50ca56fbc
22 changed files with 119 additions and 115 deletions

View file

@ -44,69 +44,69 @@ module Middleman
# Root project directory (overwritten in middleman build/server) # Root project directory (overwritten in middleman build/server)
# @return [String] # @return [String]
set :root, ENV["MM_ROOT"] || Dir.pwd config.define_setting :root, (ENV["MM_ROOT"] || Dir.pwd), 'Root project directory'
# Pathname-addressed root # Pathname-addressed root
def self.root_path def self.root_path
Pathname(root) Pathname(config[:root])
end end
delegate :root_path, :to => :"self.class" delegate :root_path, :to => :"self.class"
# Name of the source directory # Name of the source directory
# @return [String] # @return [String]
set :source, "source" config.define_setting :source, "source", 'Name of the source directory'
# Middleman environment. Defaults to :development, set to :build by the build process # Middleman environment. Defaults to :development, set to :build by the build process
# @return [String] # @return [String]
set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development config.define_setting :environment, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development), 'Middleman environment. Defaults to :development, set to :build by the build process'
# Which file should be used for directory indexes # Which file should be used for directory indexes
# @return [String] # @return [String]
set :index_file, "index.html" config.define_setting :index_file, "index.html", 'Which file should be used for directory indexes'
# Whether to strip the index file name off links to directory indexes # Whether to strip the index file name off links to directory indexes
# @return [Boolean] # @return [Boolean]
set :strip_index_file, true config.define_setting :strip_index_file, true, 'Whether to strip the index file name off links to directory indexes'
# Whether to include a trailing slash when stripping the index file # Whether to include a trailing slash when stripping the index file
# @return [Boolean] # @return [Boolean]
set :trailing_slash, true config.define_setting :trailing_slash, true, 'Whether to include a trailing slash when stripping the index file'
# Location of javascripts within source. # Location of javascripts within source.
# @return [String] # @return [String]
set :js_dir, "javascripts" config.define_setting :js_dir, "javascripts", 'Location of javascripts within source'
# Location of stylesheets within source. Used by Compass. # Location of stylesheets within source. Used by Compass.
# @return [String] # @return [String]
set :css_dir, "stylesheets" config.define_setting :css_dir, "stylesheets", 'Location of stylesheets within source'
# Location of images within source. Used by HTML helpers and Compass. # Location of images within source. Used by HTML helpers and Compass.
# @return [String] # @return [String]
set :images_dir, "images" config.define_setting :images_dir, "images", 'Location of images within source'
# Location of fonts within source. Used by Compass. # Location of fonts within source. Used by Compass.
# @return [String] # @return [String]
set :fonts_dir, "fonts" config.define_setting :fonts_dir, "fonts", 'Location of fonts within source'
# Where to build output files # Where to build output files
# @return [String] # @return [String]
set :build_dir, "build" config.define_setting :build_dir, "build", 'Where to build output files'
# Default prefix for building paths. Used by HTML helpers and Compass. # Default prefix for building paths. Used by HTML helpers and Compass.
# @return [String] # @return [String]
set :http_prefix, "/" config.define_setting :http_prefix, "/", 'Default prefix for building paths'
# Default string encoding for templates and output. # Default string encoding for templates and output.
# @return [String] # @return [String]
set :encoding, "utf-8" config.define_setting :encoding, "utf-8", 'Default string encoding for templates and output'
# Whether to catch and display exceptions # Whether to catch and display exceptions
# @return [Boolean] # @return [Boolean]
set :show_exceptions, true config.define_setting :show_exceptions, true, 'Whether to catch and display exceptions'
# Default layout name # Default layout name
# @return [String, Symbold] # @return [String, Symbold]
set :layout, :_auto_layout config.define_setting :layout, :_auto_layout, 'Default layout name'
# Activate custom features and extensions # Activate custom features and extensions
include Middleman::CoreExtensions::Extensions include Middleman::CoreExtensions::Extensions
@ -151,12 +151,12 @@ module Middleman
cache.clear cache.clear
# Setup the default values from calls to set before initialization # Setup the default values from calls to set before initialization
self.class.superclass.config.to_h.each { |k,v| self.class.set(k,v) } self.class.superclass.config.to_h.each { |k,v| self.class.config.define_setting(k,v) }
# Evaluate a passed block if given # Evaluate a passed block if given
instance_exec(&block) if block_given? instance_exec(&block) if block_given?
set :source, ENV["MM_SOURCE"] if ENV["MM_SOURCE"] config[:source] = ENV["MM_SOURCE"] if ENV["MM_SOURCE"]
super super
end end
@ -172,17 +172,17 @@ module Middleman
# Whether we're in development mode # Whether we're in development mode
# @return [Boolean] If we're in dev mode # @return [Boolean] If we're in dev mode
def development?; environment == :development; end def development?; config[:environment] == :development; end
# Whether we're in build mode # Whether we're in build mode
# @return [Boolean] If we're in build mode # @return [Boolean] If we're in build mode
def build?; environment == :build; end def build?; config[:environment] == :build; end
# The full path to the source directory # The full path to the source directory
# #
# @return [String] # @return [String]
def source_dir def source_dir
File.join(root, source) File.join(config[:root], config[:source])
end end
delegate :logger, :instrument, :to => ::Middleman::Util delegate :logger, :instrument, :to => ::Middleman::Util
@ -205,7 +205,7 @@ module Middleman
if !resource if !resource
# Try it with /index.html at the end # Try it with /index.html at the end
indexed_path = File.join(path.sub(%r{/$}, ''), index_file) indexed_path = File.join(path.sub(%r{/$}, ''), config[:index_file])
resource = sitemap.find_resource_by_destination_path(indexed_path) resource = sitemap.find_resource_by_destination_path(indexed_path)
end end

View file

@ -83,7 +83,7 @@ module Middleman::Cli
# @return [Middleman::Application] # @return [Middleman::Application]
def shared_instance(verbose=false, instrument=false) def shared_instance(verbose=false, instrument=false)
@_shared_instance ||= ::Middleman::Application.server.inst do @_shared_instance ||= ::Middleman::Application.server.inst do
set :environment, :build config[:environment] = :build
logger(verbose ? 0 : 1, instrument) logger(verbose ? 0 : 1, instrument)
end end
end end

View file

@ -30,7 +30,7 @@ module Middleman
# old Middleman. # old Middleman.
# #
# @deprecated Prefer accessing settings through "config". # @deprecated Prefer accessing settings through "config".
def method_missing(method) def method_missing(method, *args)
if config.defines_setting? method if config.defines_setting? method
config[method] config[method]
else else
@ -71,7 +71,7 @@ module Middleman
# old Middleman. # old Middleman.
# #
# @deprecated Prefer accessing settings through "config". # @deprecated Prefer accessing settings through "config".
def method_missing(method) def method_missing(method, *args)
if config.defines_setting? method if config.defines_setting? method
config[method] config[method]
else else
@ -128,7 +128,7 @@ module Middleman
if defines_setting?(method) && args.size == 0 if defines_setting?(method) && args.size == 0
self[method] self[method]
elsif method =~ /^(\w+)=$/ && args.size == 1 elsif method =~ /^(\w+)=$/ && args.size == 1
self[$1] = args[0] self[$1.to_sym] = args[0]
else else
super super
end end
@ -190,9 +190,17 @@ module Middleman
end end
end end
# An individual configuration setting, with an optional default and description.
# Also models whether or not a value has been set.
class ConfigSetting class ConfigSetting
attr_accessor :key, :default, :description # The name of this setting
attr_writer :value attr_accessor :key
# The default value for this setting
attr_accessor :default
# A human-friendly description of the setting
attr_accessor :description
def initialize(key, default, description) def initialize(key, default, description)
@value_set = false @value_set = false
@ -201,15 +209,20 @@ module Middleman
self.description = description self.description = description
end end
# The user-supplied value for this setting, overriding the default
def value=(value) def value=(value)
@value = value @value = value
@value_set = true @value_set = true
end end
# The effective value of the setting, which may be the default
# if the user has not set a value themselves. Note that even if the
# user sets the value to nil it will override the default.
def value def value
value_set? ? @value : default value_set? ? @value : default
end end
# Whether or not there has been a value set beyond the default
def value_set? def value_set?
@value_set @value_set
end end

View file

@ -13,7 +13,7 @@ module Middleman
require "yaml" require "yaml"
require "active_support/json" require "active_support/json"
app.set :data_dir, "data" app.config.define_setting :data_dir, "data", "The directory data files are stored in"
app.send :include, InstanceMethods app.send :include, InstanceMethods
end end
alias :included :registered alias :included :registered
@ -24,12 +24,12 @@ module Middleman
# Setup data files before anything else so they are available when # Setup data files before anything else so they are available when
# parsing config.rb # parsing config.rb
def initialize def initialize
self.files.changed DataStore.matcher do |file| files.changed DataStore.matcher do |file|
self.data.touch_file(file) if file.match(%r{^#{self.data_dir}\/}) data.touch_file(file) if file.match(%r{^#{config[:data_dir]}\/})
end end
self.files.deleted DataStore.matcher do |file| files.deleted DataStore.matcher do |file|
self.data.remove_file(file) if file.match(%r{^#{self.data_dir}\/}) data.remove_file(file) if file.match(%r{^#{config[data_dir]}\/})
end end
super super

View file

@ -42,11 +42,8 @@ module Middleman
app.define_hook :build_config app.define_hook :build_config
app.define_hook :development_config app.define_hook :development_config
if ENV["AUTOLOAD_SPROCKETS"] app.config.define_setting :autoload_sprockets, true, 'Automatically load sprockets at startup?'
app.set :autoload_sprockets, (ENV["AUTOLOAD_SPROCKETS"] == "true") app.config[:autoload_sprockets] = (ENV["AUTOLOAD_SPROCKETS"] == "true") if ENV["AUTOLOAD_SPROCKETS"]
else
app.set :autoload_sprockets, true
end
app.extend ClassMethods app.extend ClassMethods
app.send :include, InstanceMethods app.send :include, InstanceMethods
@ -134,7 +131,7 @@ module Middleman
instance_eval File.read(local_config), local_config, 1 instance_eval File.read(local_config), local_config, 1
end end
if autoload_sprockets if config[:autoload_sprockets]
begin begin
require "middleman-sprockets" require "middleman-sprockets"
activate(:sprockets) activate(:sprockets)

View file

@ -9,20 +9,20 @@ module Middleman
# once registered # once registered
def registered(app) def registered(app)
# Setup a default helpers paths # Setup a default helpers paths
app.set :helpers_dir, "helpers" app.config.define_setting :helpers_dir, "helpers", 'Directory to autoload helper modules from'
app.set :helpers_filename_glob, "**{,/*/**}/*.rb" app.config.define_setting :helpers_filename_glob, "**.rb", 'Glob pattern for matching helper ruby files'
app.set :helpers_filename_to_module_name_proc, Proc.new { |filename| app.config.define_setting :helpers_filename_to_module_name_proc, Proc.new { |filename|
basename = File.basename(filename, File.extname(filename)) basename = File.basename(filename, File.extname(filename))
basename.camelcase basename.camelcase
} }, 'Proc implementing the conversion from helper filename to module name'
# After config # After config
app.after_configuration do app.after_configuration do
helpers_path = File.expand_path(helpers_dir, root) helpers_path = File.expand_path(config[:helpers_dir], config[:root])
next unless File.exists?(helpers_path) next unless File.exists?(helpers_path)
Dir[File.join(helpers_path, helpers_filename_glob)].each do |filename| Dir[File.join(helpers_path, config[:helpers_filename_glob])].each do |filename|
module_name = helpers_filename_to_module_name_proc.call(filename) module_name = config[:helpers_filename_to_module_name_proc].call(filename)
next unless module_name next unless module_name
require filename require filename

View file

@ -257,7 +257,7 @@ module Middleman
extension_class = ::Tilt[ext] extension_class = ::Tilt[ext]
::Tilt.mappings.each do |ext, engines| ::Tilt.mappings.each do |ext, engines|
next unless engines.include? extension_class next unless engines.include? extension_class
engine_options = respond_to?(ext.to_sym) ? send(ext.to_sym) : {} engine_options = config[ext.to_sym] || {}
options.merge!(engine_options) options.merge!(engine_options)
end end

View file

@ -30,10 +30,10 @@ module Middleman
def with_layout(layout_name, &block) def with_layout(layout_name, &block)
old_layout = layout old_layout = layout
set :layout, layout_name config[:layout] = layout_name
instance_exec(&block) if block_given? instance_exec(&block) if block_given?
ensure ensure
set :layout, old_layout config[:layout] = old_layout
end end
# The page method allows the layout to be set on a specific path # The page method allows the layout to be set on a specific path

View file

@ -71,7 +71,7 @@ module Middleman
opts = @options opts = @options
@app =::Middleman::Application.server.inst do @app =::Middleman::Application.server.inst do
if opts[:environment] if opts[:environment]
set :environment, opts[:environment].to_sym config[:environment] = opts[:environment].to_sym
end end
logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false) logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)

View file

@ -8,8 +8,8 @@ module Middleman
# once registered # once registered
def registered(app) def registered(app)
# Setup a default ERb engine # Setup a default ERb engine
app.set :erb_engine, :erb app.config.define_setting :erb_engine, :erb, 'The engine to use for rendering ERb templates'
app.set :erb_engine_prefix, ::Tilt app.config.define_setting :erb_engine_prefix, ::Tilt, 'The parent module for ERb template engines'
app.before_configuration do app.before_configuration do
template_extensions :erb => :html template_extensions :erb => :html
@ -19,14 +19,14 @@ module Middleman
app.after_configuration do app.after_configuration do
# Find the user's prefered engine # Find the user's prefered engine
# Convert symbols to classes # Convert symbols to classes
if erb_engine.is_a? Symbol if config[:erb_engine].is_a? Symbol
engine = engine.to_s engine = engine.to_s
engine = engine == "erb" ? "ERB" : engine.camelize engine = engine == "erb" ? "ERB" : engine.camelize
erb_engine = erb_engine_prefix.const_get("#{engine}Template") config[:erb_engine] = config[:erb_engine_prefix].const_get("#{engine}Template")
end end
# Tell Tilt to use the preferred engine # Tell Tilt to use the preferred engine
::Tilt.prefer(erb_engine) ::Tilt.prefer(config[:erb_engine])
end end
end end
alias :included :registered alias :included :registered

View file

@ -11,8 +11,8 @@ module Middleman
# Once registered # Once registered
def registered(app) def registered(app)
# Default sass options # Default less options
app.set :less, {} app.config.define_setting :less, {}, 'LESS compiler options'
app.before_configuration do app.before_configuration do
template_extensions :less => :css template_extensions :less => :css

View file

@ -10,8 +10,8 @@ module Middleman
# Once registered # Once registered
def registered(app) def registered(app)
# Set our preference for a markdown engine # Set our preference for a markdown engine
app.set :markdown_engine, :maruku app.config.define_setting :markdown_engine, :maruku, 'Preferred markdown engine'
app.set :markdown_engine_prefix, ::Tilt app.config.define_setting :markdown_engine_prefix, ::Tilt, 'The parent module for markdown template engines'
app.before_configuration do app.before_configuration do
template_extensions :markdown => :html, template_extensions :markdown => :html,
@ -26,24 +26,24 @@ module Middleman
begin begin
# Look for the user's preferred engine # Look for the user's preferred engine
if markdown_engine == :redcarpet if config[:markdown_engine] == :redcarpet
require "middleman-core/renderers/redcarpet" require "middleman-core/renderers/redcarpet"
::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate) ::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate)
elsif !markdown_engine.nil? elsif !config[:markdown_engine].nil?
# Map symbols to classes # Map symbols to classes
markdown_engine_klass = if markdown_engine.is_a? Symbol markdown_engine_klass = if config[:markdown_engine].is_a? Symbol
engine = markdown_engine.to_s engine = config[:markdown_engine].to_s
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
markdown_engine_prefix.const_get("#{engine}Template") config[:markdown_engine_prefix].const_get("#{engine}Template")
else else
markdown_engine_prefix config[:markdown_engine_prefix]
end end
# Tell tilt to use that engine # Tell tilt to use that engine
::Tilt.prefer(markdown_engine_klass) ::Tilt.prefer(markdown_engine_klass)
end end
rescue LoadError rescue LoadError
logger.warn "Requested Markdown engine (#{markdown_engine}) not found. Maybe the gem needs to be installed and required?" logger.warn "Requested Markdown engine (#{config[:markdown_engine]}) not found. Maybe the gem needs to be installed and required?"
end end
end end
end end

View file

@ -12,16 +12,16 @@ module Middleman
# Once registered # Once registered
def registered(app) def registered(app)
# Default sass options # Default sass options
app.set :sass, {} app.config.define_setting :sass, {}, 'Sass engine options'
# Location of SASS .sass_cache directory. # Location of SASS .sass_cache directory.
# @return [String] # @return [String]
# set :sass_cache_path, "/tmp/middleman-app-name/sass_cache" app.config.define_setting :sass_cache_path, nil, 'Location of sass cache' # runtime compile of path
app.set(:sass_cache_path) { File.join(app.root_path, '.sass_cache') } # runtime compile of path
app.before_configuration do app.before_configuration do
template_extensions :scss => :css, template_extensions :scss => :css,
:sass => :css :sass => :css
config[:sass_cache_path] = File.join(app.root_path, '.sass_cache')
end end
# Tell Tilt to use it as well (for inline sass blocks) # Tell Tilt to use it as well (for inline sass blocks)
@ -76,11 +76,11 @@ module Middleman
more_opts = { :filename => eval_file, :line => line, :syntax => syntax } more_opts = { :filename => eval_file, :line => line, :syntax => syntax }
if @context.is_a?(::Middleman::Application) && file if @context.is_a?(::Middleman::Application) && file
location_of_sass_file = File.expand_path(@context.source, @context.root) location_of_sass_file = @context.source_dir
parts = basename.split('.') parts = basename.split('.')
parts.pop parts.pop
more_opts[:css_filename] = File.join(location_of_sass_file, @context.css_dir, parts.join(".")) more_opts[:css_filename] = File.join(location_of_sass_file, @context.config[:css_dir], parts.join("."))
end end
options.merge(more_opts) options.merge(more_opts)

View file

@ -20,10 +20,10 @@ module Middleman
app.register Middleman::Sitemap::Extensions::Ignores app.register Middleman::Sitemap::Extensions::Ignores
# Set to automatically convert some characters into a directory # Set to automatically convert some characters into a directory
app.set :automatic_directory_matcher, nil app.config.define_setting :automatic_directory_matcher, nil, 'Set to automatically convert some characters into a directory'
# Setup callbacks which can exclude paths from the sitemap # Setup callbacks which can exclude paths from the sitemap
app.set :ignored_sitemap_matchers, { app.config.define_setting :ignored_sitemap_matchers, {
# dotfiles and folders in the root # dotfiles and folders in the root
:root_dotfiles => proc { |file| file.match(%r{^\.}) }, :root_dotfiles => proc { |file| file.match(%r{^\.}) },
@ -38,7 +38,7 @@ module Middleman
:layout => proc { |file| :layout => proc { |file|
file.match(%r{^source/layout\.}) || file.match(%r{^source/layouts/}) file.match(%r{^source/layout\.}) || file.match(%r{^source/layouts/})
} }
} }, 'Callbacks that can exclude paths from the sitemap'
# Include instance methods # Include instance methods
app.send :include, InstanceMethods app.send :include, InstanceMethods

View file

@ -7,9 +7,6 @@ module MyExtension
# Called when user `activate`s your extension # Called when user `activate`s your extension
def registered(app, options={}) def registered(app, options={})
# Setup extension-specific config
app.set :config_variable, false
# Include class methods # Include class methods
# app.extend ClassMethods # app.extend ClassMethods
@ -18,9 +15,6 @@ module MyExtension
app.after_configuration do app.after_configuration do
# Do something # Do something
# config_variable is now either the default or the user's
# setting from config.rb
end end
end end
alias :included :registered alias :included :registered

View file

@ -33,7 +33,7 @@ module Middleman
if resource = sitemap.find_resource_by_path(path) if resource = sitemap.find_resource_by_path(path)
resource.url resource.url
else else
File.join(http_prefix, path) File.join(config[:http_prefix], path)
end end
end end
end end

View file

@ -19,38 +19,38 @@ module Middleman
# Location of SASS/SCSS files external to source directory. # Location of SASS/SCSS files external to source directory.
# @return [Array] # @return [Array]
# set :sass_assets_paths, ["#{root}/assets/sass/", "/path/2/external/sass/repository/"] # config[:sass_assets_paths] = ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
app.set :sass_assets_paths, [] app.config.define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files'
app.after_configuration do app.after_configuration do
::Compass.configuration do |config| ::Compass.configuration do |compass_config|
config.project_path = source_dir compass_config.project_path = source_dir
config.environment = :development compass_config.environment = :development
config.cache_path = sass_cache_path compass_config.cache_path = config[:sass_cache_path]
config.sass_dir = css_dir compass_config.sass_dir = config[:css_dir]
config.additional_import_paths = sass_assets_paths compass_config.additional_import_paths = config[:sass_assets_paths]
config.css_dir = css_dir compass_config.css_dir = config[:css_dir]
config.javascripts_dir = js_dir compass_config.javascripts_dir = config[:js_dir]
config.fonts_dir = fonts_dir compass_config.fonts_dir = config[:fonts_dir]
config.images_dir = images_dir compass_config.images_dir = config[:images_dir]
config.http_path = http_prefix compass_config.http_path = config[:http_prefix]
# Disable this initially, the cache_buster extension will # Disable this initially, the cache_buster extension will
# re-enable it if requested. # re-enable it if requested.
config.asset_cache_buster :none compass_config.asset_cache_buster :none
# Disable this initially, the relative_assets extension will # Disable this initially, the relative_assets extension will
# re-enable it if requested. # re-enable it if requested.
config.relative_assets = false compass_config.relative_assets = false
# Default output style # Default output style
config.output_style = :nested compass_config.output_style = :nested
# No line-comments in test mode (changing paths mess with sha1) # No line-comments in test mode (changing paths mess with sha1)
config.line_comments = false if ENV["TEST"] compass_config.line_comments = false if ENV["TEST"]
if respond_to?(:asset_host) && asset_host.is_a?(Proc) if config.defines_setting?(:asset_host) && config[:asset_host].is_a?(Proc)
config.asset_host(&asset_host) compass_config.asset_host(&config[:asset_host])
end end
end end

View file

@ -20,7 +20,7 @@ module Middleman
app.helpers Helpers app.helpers Helpers
app.set :relative_links, false app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
end end
alias :included :registered alias :included :registered
end end
@ -110,7 +110,7 @@ module Middleman
# :relative option which, if set to true, will produce # :relative option which, if set to true, will produce
# relative URLs instead of absolute URLs. You can also add # relative URLs instead of absolute URLs. You can also add
# #
# set :relative_links, true # config[:relative_links] = true
# #
# to config.rb to have all links default to relative. # to config.rb to have all links default to relative.
def link_to(*args, &block) def link_to(*args, &block)
@ -136,10 +136,10 @@ module Middleman
resource = sitemap.find_resource_by_path(url) resource = sitemap.find_resource_by_path(url)
# Allow people to turn on relative paths for all links with set :relative_links, true # Allow people to turn on relative paths for all links with config[:relative_links] = true
# but still override on a case by case basis with the :relative parameter. # but still override on a case by case basis with the :relative parameter.
effective_relative = relative || false effective_relative = relative || false
if relative.nil? && relative_links if relative.nil? && config[:relative_links]
effective_relative = true effective_relative = true
end end

View file

@ -9,11 +9,11 @@ module Middleman
# Once registerd # Once registerd
def registered(app, options={}) def registered(app, options={})
app.set :locales_dir, "locales" app.config.define_setting :locales_dir, "locales", 'The directory holding your locale configurations'
# Needed for helpers as well # Needed for helpers as well
app.after_configuration do app.after_configuration do
locales_glob = File.join(locales_dir, "*.yml"); locales_glob = File.join(config[:locales_dir], "*.yml");
::I18n.load_path += Dir[File.join(root, locales_glob)] ::I18n.load_path += Dir[File.join(root, locales_glob)]
::I18n.reload! ::I18n.reload!

View file

@ -11,7 +11,7 @@ module Middleman
# Once registered # Once registered
def registered(app) def registered(app)
# Default to no host # Default to no host
app.set :asset_host, false app.config.define_setting :asset_host, false, 'The asset host to use, or false for no asset host, or a Proc to determine asset host'
# Include methods # Include methods
app.send :include, InstanceMethods app.send :include, InstanceMethods
@ -30,12 +30,12 @@ module Middleman
# @return [String] # @return [String]
def asset_url(path, prefix="") def asset_url(path, prefix="")
original_output = super original_output = super
return original_output unless asset_host return original_output unless config[:asset_host]
asset_prefix = if asset_host.is_a?(Proc) asset_prefix = if config[:asset_host].is_a?(Proc)
asset_host.call(original_output) config[:asset_host].call(original_output)
elsif asset_host.is_a?(String) elsif config[:asset_host].is_a?(String)
asset_host config[:asset_host]
end end
File.join(asset_prefix, original_output) File.join(asset_prefix, original_output)

View file

@ -10,13 +10,13 @@ module Middleman
# Once registered # Once registered
def registered(app, options={}) def registered(app, options={})
app.set :css_compressor, false app.config.define_setting :css_compressor, nil, 'Set the CSS compressor to use. Deprecated in favor of the :compressor option when activating :minify_css'
ignore = Array(options[:ignore]) << /\.min\./ ignore = Array(options[:ignore]) << /\.min\./
inline = options[:inline] || false inline = options[:inline] || false
app.after_configuration do app.after_configuration do
chosen_compressor = css_compressor || options[:compressor] || begin chosen_compressor = config[:css_compressor] || options[:compressor] || begin
require "middleman-more/extensions/minify_css/rainpress" require "middleman-more/extensions/minify_css/rainpress"
::Rainpress ::Rainpress
end end

View file

@ -10,7 +10,7 @@ module Middleman
# Once registered # Once registered
def registered(app, options={}) def registered(app, options={})
app.set :js_compressor, false app.config.define_setting :js_compressor, nil, 'Set the JS compressor to use. Deprecated in favor of the :compressor option when activating :minify_js'
ignore = Array(options[:ignore]) << /\.min\./ ignore = Array(options[:ignore]) << /\.min\./
inline = options[:inline] || false inline = options[:inline] || false