mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
re-order some callbacks
This commit is contained in:
parent
0ef8de6106
commit
9ac114406f
8 changed files with 25 additions and 31 deletions
|
@ -168,7 +168,7 @@ module Middleman
|
||||||
:AccessLog => []
|
:AccessLog => []
|
||||||
}
|
}
|
||||||
|
|
||||||
app_class = options[:app] ||= ::Middleman.server.new
|
app_class = options[:app] ||= ::Middleman.server.inst
|
||||||
opts[:app] = app_class
|
opts[:app] = app_class
|
||||||
opts[:server] = 'thin'
|
opts[:server] = 'thin'
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@ class Middleman::Base
|
||||||
# Ready (all loading and parsing of extensions complete) hook
|
# Ready (all loading and parsing of extensions complete) hook
|
||||||
define_hook :ready
|
define_hook :ready
|
||||||
|
|
||||||
# Initialized (after initialized() runs)
|
|
||||||
define_hook :initialized
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
# Reset Rack setup
|
# Reset Rack setup
|
||||||
|
@ -49,7 +46,11 @@ class Middleman::Base
|
||||||
# @private
|
# @private
|
||||||
# @return [Middleman::Base]
|
# @return [Middleman::Base]
|
||||||
def inst(&block)
|
def inst(&block)
|
||||||
@inst ||= new(&block)
|
@inst ||= begin
|
||||||
|
mm = new(&block)
|
||||||
|
mm.run_hook :ready
|
||||||
|
mm
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return built Rack app
|
# Return built Rack app
|
||||||
|
@ -243,9 +244,6 @@ class Middleman::Base
|
||||||
set :source_dir, File.join(root, source)
|
set :source_dir, File.join(root, source)
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
# Run initialized callbacks
|
|
||||||
run_hook :initialized
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Shared cache instance
|
# Shared cache instance
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Middleman::CoreExtensions::DefaultHelpers
|
||||||
|
|
||||||
app.helpers Helpers
|
app.helpers Helpers
|
||||||
|
|
||||||
app.initialized do
|
app.ready do
|
||||||
::I18n.load_path = Dir["#{File.join(root, 'locales', '*.yml')}"]
|
::I18n.load_path = Dir["#{File.join(root, 'locales', '*.yml')}"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Middleman::CoreExtensions::Extensions
|
||||||
app.define_hook :before_configuration
|
app.define_hook :before_configuration
|
||||||
app.define_hook :build_config
|
app.define_hook :build_config
|
||||||
app.define_hook :development_config
|
app.define_hook :development_config
|
||||||
|
|
||||||
app.extend ClassMethods
|
app.extend ClassMethods
|
||||||
app.send :include, InstanceMethods
|
app.send :include, InstanceMethods
|
||||||
|
|
||||||
|
@ -164,8 +165,6 @@ module Middleman::CoreExtensions::Extensions
|
||||||
puts "== Extension: #{ext}"
|
puts "== Extension: #{ext}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
run_hook :ready
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,36 +11,37 @@ module Middleman::CoreExtensions::FrontMatter
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def initialize
|
def initialize
|
||||||
|
super
|
||||||
|
|
||||||
file_changed FrontMatter.matcher do |file|
|
file_changed FrontMatter.matcher do |file|
|
||||||
frontmatter.touch_file(file)
|
frontmatter.touch_file(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
file_deleted do |file|
|
file_deleted do |file|
|
||||||
frontmatter.remove_file(file)
|
frontmatter.remove_file(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
provides_metadata FrontMatter.matcher do |path|
|
provides_metadata FrontMatter.matcher do |path|
|
||||||
relative_path = path.sub(source_dir, "")
|
relative_path = path.sub(source_dir, "")
|
||||||
|
|
||||||
data = if frontmatter.has_data?(relative_path)
|
data = if frontmatter.has_data?(relative_path)
|
||||||
frontmatter.data(relative_path).first
|
frontmatter.data(relative_path).first
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Forward remaining data to helpers
|
# Forward remaining data to helpers
|
||||||
data_content("page", data)
|
data_content("page", data)
|
||||||
|
|
||||||
%w(layout layout_engine).each do |opt|
|
%w(layout layout_engine).each do |opt|
|
||||||
if data.has_key?(opt)
|
if data.has_key?(opt)
|
||||||
data[opt.to_sym] = data.delete(opt)
|
data[opt.to_sym] = data.delete(opt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
{ :options => data }
|
{ :options => data }
|
||||||
end
|
end
|
||||||
|
|
||||||
super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def frontmatter
|
def frontmatter
|
||||||
|
|
|
@ -26,12 +26,12 @@ module Middleman::CoreExtensions::Rendering
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def initialize
|
def initialize
|
||||||
|
super
|
||||||
|
|
||||||
file_changed %r{^source/} do |file|
|
file_changed %r{^source/} do |file|
|
||||||
path = File.expand_path(file, root)
|
path = File.expand_path(file, root)
|
||||||
cache.remove(:raw_template, path)
|
cache.remove(:raw_template, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_template(path, locs={}, opts={})
|
def render_template(path, locs={}, opts={})
|
||||||
|
|
|
@ -11,6 +11,8 @@ module Middleman::CoreExtensions::Sitemap
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def initialize
|
def initialize
|
||||||
|
super
|
||||||
|
|
||||||
file_changed do |file|
|
file_changed do |file|
|
||||||
sitemap.touch_file(file)
|
sitemap.touch_file(file)
|
||||||
end
|
end
|
||||||
|
@ -18,8 +20,6 @@ module Middleman::CoreExtensions::Sitemap
|
||||||
file_deleted do |file|
|
file_deleted do |file|
|
||||||
sitemap.remove_file(file)
|
sitemap.remove_file(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sitemap
|
def sitemap
|
||||||
|
|
|
@ -3,15 +3,11 @@ module Middleman::Renderers::Haml
|
||||||
def registered(app)
|
def registered(app)
|
||||||
require "haml"
|
require "haml"
|
||||||
app.send :include, ::Haml::Helpers
|
app.send :include, ::Haml::Helpers
|
||||||
app.send :include, InstanceMethods
|
|
||||||
|
app.ready do
|
||||||
|
init_haml_helpers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
alias :included :registered
|
alias :included :registered
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
|
||||||
def initialize
|
|
||||||
super
|
|
||||||
init_haml_helpers
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue