Move "set :fonts_dir" from "middleman-more" to "middleman-core".
This commit is contained in:
parent
939a3287d5
commit
cc1a741eb7
|
@ -11,19 +11,19 @@ require "middleman-core/vendor/hooks-0.2.0/lib/hooks"
|
||||||
require "middleman-core/sitemap"
|
require "middleman-core/sitemap"
|
||||||
|
|
||||||
require "middleman-core/core_extensions"
|
require "middleman-core/core_extensions"
|
||||||
|
|
||||||
# Core Middleman Class
|
# Core Middleman Class
|
||||||
module Middleman
|
module Middleman
|
||||||
class Application
|
class Application
|
||||||
# Uses callbacks
|
# Uses callbacks
|
||||||
include Hooks
|
include Hooks
|
||||||
|
|
||||||
# Before request hook
|
# Before request hook
|
||||||
define_hook :before
|
define_hook :before
|
||||||
|
|
||||||
# Ready (all loading and parsing of extensions complete) hook
|
# Ready (all loading and parsing of extensions complete) hook
|
||||||
define_hook :ready
|
define_hook :ready
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Mix-in helper methods. Accepts either a list of Modules
|
# Mix-in helper methods. Accepts either a list of Modules
|
||||||
# and/or a block to be evaluated
|
# and/or a block to be evaluated
|
||||||
|
@ -32,7 +32,7 @@ module Middleman
|
||||||
class_eval(&block) if block_given?
|
class_eval(&block) if block_given?
|
||||||
include(*extensions) if extensions.any?
|
include(*extensions) if extensions.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Access class-wide defaults
|
# Access class-wide defaults
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
|
@ -40,7 +40,7 @@ module Middleman
|
||||||
def defaults
|
def defaults
|
||||||
@defaults ||= {}
|
@defaults ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set class-wide defaults
|
# Set class-wide defaults
|
||||||
#
|
#
|
||||||
# @param [Symbol] key Unique key name
|
# @param [Symbol] key Unique key name
|
||||||
|
@ -49,13 +49,13 @@ module Middleman
|
||||||
def set(key, value=nil, &block)
|
def set(key, value=nil, &block)
|
||||||
@defaults ||= {}
|
@defaults ||= {}
|
||||||
@defaults[key] = value
|
@defaults[key] = value
|
||||||
|
|
||||||
@inst.set(key, value, &block) if @inst
|
@inst.set(key, value, &block) if @inst
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
delegate :helpers, :to => :"self.class"
|
delegate :helpers, :to => :"self.class"
|
||||||
|
|
||||||
# Set attributes (global variables)
|
# Set attributes (global variables)
|
||||||
#
|
#
|
||||||
# @param [Symbol] key Name of the attribue
|
# @param [Symbol] key Name of the attribue
|
||||||
|
@ -67,24 +67,24 @@ module Middleman
|
||||||
value = block if block_given?
|
value = block if block_given?
|
||||||
send(setter, value)
|
send(setter, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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
|
set :root, ENV["MM_ROOT"] || Dir.pwd
|
||||||
|
|
||||||
# Pathname-addressed root
|
# Pathname-addressed root
|
||||||
def root_path
|
def root_path
|
||||||
@_root_path ||= Pathname.new(root)
|
@_root_path ||= Pathname.new(root)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Name of the source directory
|
# Name of the source directory
|
||||||
# @return [String]
|
# @return [String]
|
||||||
set :source, "source"
|
set :source, "source"
|
||||||
|
|
||||||
# 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
|
set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
|
||||||
|
|
||||||
# Whether logging is active, disabled by default
|
# Whether logging is active, disabled by default
|
||||||
# @return [String]
|
# @return [String]
|
||||||
set :logging, false
|
set :logging, false
|
||||||
|
@ -96,19 +96,23 @@ module Middleman
|
||||||
# Location of javascripts within source.
|
# Location of javascripts within source.
|
||||||
# @return [String]
|
# @return [String]
|
||||||
set :js_dir, "javascripts"
|
set :js_dir, "javascripts"
|
||||||
|
|
||||||
# Location of stylesheets within source. Used by Compass.
|
# Location of stylesheets within source. Used by Compass.
|
||||||
# @return [String]
|
# @return [String]
|
||||||
set :css_dir, "stylesheets"
|
set :css_dir, "stylesheets"
|
||||||
|
|
||||||
# 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"
|
set :images_dir, "images"
|
||||||
|
|
||||||
|
# Location of fonts within source. Used by Compass.
|
||||||
|
# @return [String]
|
||||||
|
set :fonts_dir, "fonts"
|
||||||
|
|
||||||
# Where to build output files
|
# Where to build output files
|
||||||
# @return [String]
|
# @return [String]
|
||||||
set :build_dir, "build"
|
set :build_dir, "build"
|
||||||
|
|
||||||
# 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, "/"
|
set :http_prefix, "/"
|
||||||
|
@ -120,61 +124,61 @@ module Middleman
|
||||||
# Default layout name
|
# Default layout name
|
||||||
# @return [String, Symbold]
|
# @return [String, Symbold]
|
||||||
set :layout, :_auto_layout
|
set :layout, :_auto_layout
|
||||||
|
|
||||||
# Activate custom features and extensions
|
# Activate custom features and extensions
|
||||||
include Middleman::CoreExtensions::Extensions
|
include Middleman::CoreExtensions::Extensions
|
||||||
|
|
||||||
# Basic Rack Request Handling
|
# Basic Rack Request Handling
|
||||||
include Middleman::CoreExtensions::Request
|
include Middleman::CoreExtensions::Request
|
||||||
|
|
||||||
# Handle exceptions
|
# Handle exceptions
|
||||||
register Middleman::CoreExtensions::ShowExceptions
|
register Middleman::CoreExtensions::ShowExceptions
|
||||||
|
|
||||||
# Add Builder Callbacks
|
# Add Builder Callbacks
|
||||||
register Middleman::CoreExtensions::Builder
|
register Middleman::CoreExtensions::Builder
|
||||||
|
|
||||||
# Add Watcher Callbacks
|
# Add Watcher Callbacks
|
||||||
register Middleman::CoreExtensions::FileWatcher
|
register Middleman::CoreExtensions::FileWatcher
|
||||||
|
|
||||||
# Activate Data package
|
# Activate Data package
|
||||||
register Middleman::CoreExtensions::Data
|
register Middleman::CoreExtensions::Data
|
||||||
|
|
||||||
# Setup custom rendering
|
# Setup custom rendering
|
||||||
register Middleman::CoreExtensions::Rendering
|
register Middleman::CoreExtensions::Rendering
|
||||||
|
|
||||||
# Parse YAML from templates. Must be before sitemap so sitemap
|
# Parse YAML from templates. Must be before sitemap so sitemap
|
||||||
# extensions see updated frontmatter!
|
# extensions see updated frontmatter!
|
||||||
register Middleman::CoreExtensions::FrontMatter
|
register Middleman::CoreExtensions::FrontMatter
|
||||||
|
|
||||||
# Sitemap
|
# Sitemap
|
||||||
register Middleman::Sitemap
|
register Middleman::Sitemap
|
||||||
|
|
||||||
# Setup external helpers
|
# Setup external helpers
|
||||||
register Middleman::CoreExtensions::ExternalHelpers
|
register Middleman::CoreExtensions::ExternalHelpers
|
||||||
|
|
||||||
# with_layout and page routing
|
# with_layout and page routing
|
||||||
register Middleman::CoreExtensions::Routing
|
register Middleman::CoreExtensions::Routing
|
||||||
|
|
||||||
# Initialize the Middleman project
|
# Initialize the Middleman project
|
||||||
def initialize(&block)
|
def initialize(&block)
|
||||||
# Clear the static class cache
|
# Clear the static class cache
|
||||||
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.defaults.each { |k,v| set(k,v) }
|
self.class.superclass.defaults.each { |k,v| set(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?
|
||||||
|
|
||||||
# Build expanded source path once paths have been parsed
|
# Build expanded source path once paths have been parsed
|
||||||
path = root.dup
|
path = root.dup
|
||||||
source_path = ENV["MM_SOURCE"] || self.source
|
source_path = ENV["MM_SOURCE"] || self.source
|
||||||
path = File.join(root, source_path) unless source_path.empty?
|
path = File.join(root, source_path) unless source_path.empty?
|
||||||
set :source_dir, path
|
set :source_dir, path
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Shared cache instance
|
# Shared cache instance
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
|
@ -187,7 +191,7 @@ 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?; 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?; environment == :build; end
|
||||||
|
@ -205,7 +209,7 @@ module Middleman
|
||||||
def logging?
|
def logging?
|
||||||
logging
|
logging
|
||||||
end
|
end
|
||||||
|
|
||||||
# Expand a path to include the index file if it's a directory
|
# Expand a path to include the index file if it's a directory
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
|
@ -215,11 +219,11 @@ module Middleman
|
||||||
cache.fetch(:full_path, path) do
|
cache.fetch(:full_path, path) do
|
||||||
parts = path ? path.split('/') : []
|
parts = path ? path.split('/') : []
|
||||||
if parts.last.nil? || parts.last.split('.').length == 1
|
if parts.last.nil? || parts.last.split('.').length == 1
|
||||||
path = File.join(path, index_file)
|
path = File.join(path, index_file)
|
||||||
end
|
end
|
||||||
"/" + path.sub(%r{^/}, '')
|
"/" + path.sub(%r{^/}, '')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
module CoreExtensions
|
module CoreExtensions
|
||||||
|
|
||||||
# Forward the settings on config.rb and the result of registered
|
# Forward the settings on config.rb and the result of registered
|
||||||
# extensions to Compass
|
# extensions to Compass
|
||||||
module Compass
|
module Compass
|
||||||
|
|
||||||
# Extension registered
|
# Extension registered
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
# Once registered
|
# Once registered
|
||||||
def registered(app)
|
def registered(app)
|
||||||
# Require the library
|
# Require the library
|
||||||
require "compass"
|
require "compass"
|
||||||
|
|
||||||
# Where to look for fonts
|
# Hooks to manually update the compass config after we're
|
||||||
app.set :fonts_dir, "fonts"
|
|
||||||
|
|
||||||
# Hooks to manually update the compass config after we're
|
|
||||||
# done with it
|
# done with it
|
||||||
app.define_hook :compass_config
|
app.define_hook :compass_config
|
||||||
|
|
||||||
|
@ -35,14 +32,14 @@ module Middleman
|
||||||
# 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
|
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
|
config.relative_assets = false
|
||||||
|
|
||||||
# Default output style
|
# Default output style
|
||||||
config.output_style = :nested
|
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"]
|
config.line_comments = false if ENV["TEST"]
|
||||||
|
|
||||||
|
@ -50,10 +47,10 @@ module Middleman
|
||||||
config.asset_host(&asset_host)
|
config.asset_host(&asset_host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Call hook
|
# Call hook
|
||||||
run_hook :compass_config, ::Compass.configuration
|
run_hook :compass_config, ::Compass.configuration
|
||||||
|
|
||||||
# Tell Tilt to use it as well (for inline sass blocks)
|
# Tell Tilt to use it as well (for inline sass blocks)
|
||||||
::Tilt.register 'sass', CompassSassTemplate
|
::Tilt.register 'sass', CompassSassTemplate
|
||||||
::Tilt.prefer(CompassSassTemplate)
|
::Tilt.prefer(CompassSassTemplate)
|
||||||
|
@ -67,7 +64,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# A Compass template for Tilt
|
# A Compass template for Tilt
|
||||||
class CompassSassTemplate < ::Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
|
class CompassSassTemplate < ::Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
|
||||||
private
|
private
|
||||||
|
@ -75,13 +72,13 @@ module Middleman
|
||||||
super.merge(::Compass.configuration.to_sass_engine_options)
|
super.merge(::Compass.configuration.to_sass_engine_options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CompassScssTemplate < ::Middleman::Renderers::Sass::ScssPlusCSSFilenameTemplate
|
class CompassScssTemplate < ::Middleman::Renderers::Sass::ScssPlusCSSFilenameTemplate
|
||||||
private
|
private
|
||||||
def sass_options
|
def sass_options
|
||||||
super.merge(::Compass.configuration.to_sass_engine_options)
|
super.merge(::Compass.configuration.to_sass_engine_options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue