fix minify js, re-enable build init, parse data before config.rb, everything else after

This commit is contained in:
Thomas Reynolds 2011-11-19 14:49:08 -08:00
parent 61052de807
commit 8c4471fc40
9 changed files with 31 additions and 25 deletions

View file

@ -11,6 +11,7 @@ class Middleman::Base
include Hooks include Hooks
define_hook :before define_hook :before
define_hook :ready define_hook :ready
define_hook :initialized
class << self class << self
def reset! def reset!
@ -149,7 +150,6 @@ class Middleman::Base
# Parse YAML from templates # Parse YAML from templates
register Middleman::CoreExtensions::FrontMatter register Middleman::CoreExtensions::FrontMatter
define_hook :initialized
def initialize(&block) def initialize(&block)
self.class.superclass.defaults.each do |k, v| self.class.superclass.defaults.each do |k, v|
set(k, v) set(k, v)
@ -282,10 +282,8 @@ public
path = file.dup path = file.dup
end_of_the_line = false end_of_the_line = false
while !end_of_the_line while !end_of_the_line
file_extension = File.extname(path) if !Tilt[path].nil?
path = path.sub(File.extname(path), "")
if ::Tilt.mappings.has_key?(file_extension.gsub(/^\./, ""))
path = path.sub(file_extension, "")
else else
end_of_the_line = true end_of_the_line = true
end end

View file

@ -39,7 +39,7 @@ module Middleman
@shared_rack ||= begin @shared_rack ||= begin
mock = ::Rack::MockSession.new(SHARED_SERVER.to_rack_app) mock = ::Rack::MockSession.new(SHARED_SERVER.to_rack_app)
sess = ::Rack::Test::Session.new(mock) sess = ::Rack::Test::Session.new(mock)
# response = sess.get("__middleman__") response = sess.get("__middleman__")
sess sess
end end
end end
@ -133,17 +133,16 @@ module Middleman
end end
def execute! def execute!
paths = @app.sitemap.all_paths.sort do |a, b| sort_order = %w(.png .jpeg .jpg .gif .bmp .ico .woff .otf .ttf .eot .js .css)
a_dir = a.split("/").first
b_dir = b.split("/").first
if a_dir == @app.images_dir paths = @app.sitemap.all_paths.sort do |a, b|
-1 a_ext = File.extname(a)
elsif b_dir == @app.images_dir b_ext = File.extname(b)
1
else a_idx = sort_order.index(a_ext) || 100
0 b_idx = sort_order.index(b_ext) || 100
end
a_idx <=> b_idx
end end
paths.each do |path| paths.each do |path|

View file

@ -86,8 +86,7 @@ module Middleman::CoreExtensions::DefaultHelpers
source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/ source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/
result_path = source if source =~ %r{^/} # absolute path result_path = source if source =~ %r{^/} # absolute path
result_path ||= asset_url(source, asset_folder) result_path ||= asset_url(source, asset_folder)
timestamp = asset_timestamp(result_path) "#{result_path}"
"#{result_path}#{timestamp}"
end end
end end
end end

View file

@ -72,7 +72,6 @@ module Middleman::CoreExtensions::Features
# #
# activate MyFeatureModule # activate MyFeatureModule
def activate(feature) def activate(feature)
$stderr.puts "Activate: #{feature}"
if feature.is_a? Symbol if feature.is_a? Symbol
feature = feature.to_s feature = feature.to_s
end end

View file

@ -5,7 +5,16 @@ module Middleman::CoreExtensions::FileWatcher
def registered(app) def registered(app)
app.extend ClassMethods app.extend ClassMethods
app.send :include, InstanceMethods app.send :include, InstanceMethods
app.before_configuration do app.before_configuration do
data_path = File.join(root, data_dir)
Find.find(data_path) do |path|
next if File.directory?(path)
file_did_change(path.sub("#{root}/", ""))
end if File.exists?(data_path)
end
app.ready do
Find.find(root) do |path| Find.find(root) do |path|
next if File.directory?(path) next if File.directory?(path)
file_did_change(path.sub("#{root}/", "")) file_did_change(path.sub("#{root}/", ""))

View file

@ -1,6 +1,8 @@
module Middleman::CoreExtensions::Rendering module Middleman::CoreExtensions::Rendering
class << self class << self
def registered(app) def registered(app)
require "coffee_script"
# Activate custom renderers # Activate custom renderers
app.register Middleman::Renderers::Sass app.register Middleman::Renderers::Sass
app.register Middleman::Renderers::Markdown app.register Middleman::Renderers::Markdown

View file

@ -192,7 +192,6 @@ module Middleman::CoreExtensions::Sitemap
end end
def file_to_path(file) def file_to_path(file)
@source ||= File.expand_path(@app.views, @app.root)
file = File.expand_path(file, @app.root) file = File.expand_path(file, @app.root)
prefix = @source + "/" prefix = @source + "/"
@ -200,24 +199,26 @@ module Middleman::CoreExtensions::Sitemap
path = file.sub(prefix, "") path = file.sub(prefix, "")
path = @app.extensionless_path(path) path = @app.extensionless_path(path)
@source_map[path] = file @source_map[path] = file
path path
end end
def add_file(file) def add_file(file)
return false if file == @source || return false if file == @source ||
file.match(/^\./) ||
file.match(/\/\./) || file.match(/\/\./) ||
(file.match(/\/_/) && !file.match(/\/__/)) || (file.match(/\/_/) && !file.match(/\/__/)) ||
File.directory?(file) File.directory?(file)
path = file_to_path(file) path = file_to_path(file)
add_path(path) if path && !path_exists?(path) add_path(path) if path && !path_exists?(path)
end end
def add_path(path) def add_path(path)
return false if path == "layout" || return false if path.match(%r{^layout}) ||
path.match(/^layouts/) path.match(%r{^layouts/})
# @app.logger.debug :sitemap_update, Time.now, path if @app.logging? # @app.logger.debug :sitemap_update, Time.now, path if @app.logging?
set_path(path) set_path(path)

View file

@ -5,7 +5,6 @@ require "sprockets"
module Middleman::CoreExtensions::Sprockets module Middleman::CoreExtensions::Sprockets
class << self class << self
def registered(app) def registered(app)
app.define_hook :before_sprockets
app.set :js_compressor, false app.set :js_compressor, false
app.set :css_compressor, false app.set :css_compressor, false

View file

@ -3,7 +3,7 @@ module Middleman::Features::MinifyJavascript
def registered(app) def registered(app)
require 'uglifier' require 'uglifier'
app.after_configuration do app.after_configuration do
app.set :js_compressor, ::Uglifier.new set :js_compressor, ::Uglifier.new
end end
app.use InlineJavascriptRack app.use InlineJavascriptRack
end end