diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index db6a2895..c2c8b5ea 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -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 diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index a8410862..fed9880c 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -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| diff --git a/lib/middleman/core_extensions/default_helpers.rb b/lib/middleman/core_extensions/default_helpers.rb index 63096ae9..841a25b8 100644 --- a/lib/middleman/core_extensions/default_helpers.rb +++ b/lib/middleman/core_extensions/default_helpers.rb @@ -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 diff --git a/lib/middleman/core_extensions/features.rb b/lib/middleman/core_extensions/features.rb index 4d2608b5..de10b181 100644 --- a/lib/middleman/core_extensions/features.rb +++ b/lib/middleman/core_extensions/features.rb @@ -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 diff --git a/lib/middleman/core_extensions/file_watcher.rb b/lib/middleman/core_extensions/file_watcher.rb index c2d8efe7..cb8f8107 100644 --- a/lib/middleman/core_extensions/file_watcher.rb +++ b/lib/middleman/core_extensions/file_watcher.rb @@ -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}/", "")) diff --git a/lib/middleman/core_extensions/rendering.rb b/lib/middleman/core_extensions/rendering.rb index 549d25a4..537cbcca 100644 --- a/lib/middleman/core_extensions/rendering.rb +++ b/lib/middleman/core_extensions/rendering.rb @@ -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 diff --git a/lib/middleman/core_extensions/sitemap.rb b/lib/middleman/core_extensions/sitemap.rb index 27346928..f779bf2c 100644 --- a/lib/middleman/core_extensions/sitemap.rb +++ b/lib/middleman/core_extensions/sitemap.rb @@ -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,24 +199,26 @@ 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) - + path = file_to_path(file) add_path(path) if path && !path_exists?(path) 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) diff --git a/lib/middleman/core_extensions/sprockets.rb b/lib/middleman/core_extensions/sprockets.rb index 5645432d..27b9b53c 100644 --- a/lib/middleman/core_extensions/sprockets.rb +++ b/lib/middleman/core_extensions/sprockets.rb @@ -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 diff --git a/lib/middleman/features/minify_javascript.rb b/lib/middleman/features/minify_javascript.rb index ef17daa9..5295bc8c 100755 --- a/lib/middleman/features/minify_javascript.rb +++ b/lib/middleman/features/minify_javascript.rb @@ -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