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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,16 @@ module Middleman::CoreExtensions::FileWatcher
def registered(app)
app.extend ClassMethods
app.send :include, InstanceMethods
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|
next if File.directory?(path)
file_did_change(path.sub("#{root}/", ""))

View file

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

View file

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

View file

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

View file

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