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