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