From 250c87ef61b5f5c49bf5dc4ea1294959764ecaef Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 9 Mar 2014 17:50:34 -0700 Subject: [PATCH 01/10] move livereload init into dev block --- middleman-core/lib/middleman-core/templates/shared/config.tt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/templates/shared/config.tt b/middleman-core/lib/middleman-core/templates/shared/config.tt index f96e0a26..4311ac38 100755 --- a/middleman-core/lib/middleman-core/templates/shared/config.tt +++ b/middleman-core/lib/middleman-core/templates/shared/config.tt @@ -36,7 +36,9 @@ # activate :automatic_image_sizes # Reload the browser automatically whenever files change -# activate :livereload +# configure :development do +# activate :livereload +# end # Methods defined in the helpers block are available in templates # helpers do From 58616ce4866d899c9e5916afb411cf777bca5732 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 3 Mar 2014 23:07:32 -0800 Subject: [PATCH 02/10] pry-debugger is not available on Ruby 2.1 --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index a055afd7..8f6a7402 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,6 @@ platforms :ruby do gem 'therubyracer' gem 'redcarpet', '~> 3.1' gem 'pry', :require => false, :group => :development - gem 'pry-debugger', :require => false, :group => :development end platforms :jruby do From a88f12a2623563e928fa50b5e7daac5ae714dcd4 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 13 Mar 2014 20:32:25 -0700 Subject: [PATCH 03/10] Apply fix from 32716f37293cb2ddeeb939d81648a30b2221cd92 - avoid loading middleman-core unless needed. Fixes #1203 --- middleman-core/lib/middleman-core/cli/build.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index dde2a1b2..d2f300ec 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -1,6 +1,3 @@ -require 'middleman-core' -require 'middleman-core/logger' - require 'fileutils' require 'set' @@ -50,6 +47,9 @@ module Middleman::Cli raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?' end + require 'middleman-core' + require 'middleman-core/logger' + # Use Rack::Test for inspecting a running server for output require 'rack' require 'rack/test' From 8eb544a3e7907b4a411e771a40b3fe91103fdeb4 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Mon, 17 Mar 2014 00:18:48 -0400 Subject: [PATCH 04/10] Travis ci update Test on 2.1.1 Dont allow failures on 2.1.x --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 520228b1..63f5c943 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby bundler_args: --without development rvm: - ruby-head + - 2.1.1 - 2.1.0 - 2.0.0 - 1.9.3 @@ -10,7 +11,6 @@ matrix: fast_finish: true allow_failures: - rvm: ruby-head - - rvm: 2.1.0 - rvm: jruby-19mode env: TEST=true before_install: git submodule update --init --recursive From 67689e60d24677ac3c38678df3abc287dc2ac341 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 18 Mar 2014 21:17:50 -0700 Subject: [PATCH 05/10] Prevent the file watcher from recursively enumerating into paths that it should ignore. This should fix the issue in #1197 as well as provide a performance boost when starting 'middleman server'. --- .../core_extensions/file_watcher.rb | 21 ++++++----- .../lib/middleman-core/preview_server.rb | 2 ++ middleman-core/lib/middleman-core/util.rb | 36 +++++++++++-------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index fbe39c1f..14cac4ae 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -7,12 +7,12 @@ module Middleman module FileWatcher IGNORE_LIST = [ - /^bin\//, - /^\.bundle\//, - /^vendor\//, - /^\.sass-cache\//, - /^\.cache\//, - /^\.git\//, + /^bin(\/|$)/, + /^\.bundle(\/|$)/, + /^vendor(\/|$)/, + /^\.sass-cache(\/|$)/, + /^\.cache(\/|$)/, + /^\.git(\/|$)/, /^\.gitignore$/, /\.DS_Store/, /^\.rbenv-.*$/, @@ -38,7 +38,7 @@ module Middleman end app.after_configuration do - config[:file_watcher_ignore] << %r{^#{config[:build_dir]}\/} + config[:file_watcher_ignore] << %r{^#{config[:build_dir]}(\/|$)} end # After config, load everything else @@ -99,7 +99,6 @@ module Middleman # @return [void] def did_change(path) path = Pathname(path) - return if ignored?(path) logger.debug "== File Change: #{path}" @known_paths << path self.run_callbacks(path, :changed) @@ -111,7 +110,6 @@ module Middleman # @return [void] def did_delete(path) path = Pathname(path) - return if ignored?(path) logger.debug "== File Deletion: #{path}" @known_paths.delete(path) self.run_callbacks(path, :deleted) @@ -131,7 +129,7 @@ module Middleman glob = (path + '**').to_s subset = @known_paths.select { |p| p.fnmatch(glob) } - ::Middleman::Util.all_files_under(path).each do |filepath| + ::Middleman::Util.all_files_under(path, &method(:ignored?)).each do |filepath| next if only_new && subset.include?(filepath) subset.delete(filepath) @@ -156,7 +154,6 @@ module Middleman @known_paths.include?(p) end - protected # Whether this path is ignored # @param [Pathname] path # @return [Boolean] @@ -165,6 +162,8 @@ module Middleman app.config[:file_watcher_ignore].any? { |r| path =~ r } end + protected + # Notify callbacks for a file given an array of callbacks # # @param [Pathname] path The file that was changed diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index 0fceb8ea..9ce1248b 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -133,10 +133,12 @@ module Middleman @webrick.stop else added_and_modified.each do |path| + next if app.files.ignored?(path) app.files.did_change(path) end removed.each do |path| + next if app.files.ignored?(path) app.files.did_delete(path) end end diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 02892775..102b51e7 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -28,7 +28,7 @@ module Middleman return false if Tilt.registered?(ext.sub('.', '')) dot_ext = (ext.to_s[0] == ?.) ? ext.dup : ".#{ext}" - + if mime = ::Rack::Mime.mime_type(dot_ext, nil) !nonbinary_mime?(mime) else @@ -113,21 +113,27 @@ module Middleman end end - # Get a recusive list of files inside a set of paths. + # Get a recusive list of files inside a path. # Works with symlinks. # - # @param paths Some paths string or Pathname - # @return [Array] An array of filenames - def all_files_under(*paths) - paths.flat_map do |p| - path = Pathname(p) + # @param path Some path string or Pathname + # @param ignore A proc/block that returns true if a given path should be ignored - if a path + # is ignored, nothing below it will be searched either. + # @return [Array] An array of Pathnames for each file (no directories) + def all_files_under(path, &ignore) + path = Pathname(path) - if path.directory? - all_files_under(*path.children) - elsif path.file? - path - end - end.compact + return [] if ignore && ignore.call(path) + + if path.directory? + path.children.flat_map do |child| + all_files_under(child, &ignore) + end.compact + elsif path.file? + [path] + else + [] + end end # Given a source path (referenced either absolutely or relatively) @@ -248,7 +254,7 @@ module Middleman s.each_byte do |c| return true if binary_bytes.include?(c) end - + false end @@ -278,4 +284,4 @@ module Middleman end end end -end \ No newline at end of file +end From f71a0951ef691f7a3e100b3c23e312911ef683c4 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 18 Mar 2014 22:41:37 -0700 Subject: [PATCH 06/10] Add tzinfo-data for Windows users --- .../lib/middleman-core/templates/shared/Gemfile.tt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/templates/shared/Gemfile.tt b/middleman-core/lib/middleman-core/templates/shared/Gemfile.tt index 5bc18919..ec8e0fc9 100644 --- a/middleman-core/lib/middleman-core/templates/shared/Gemfile.tt +++ b/middleman-core/lib/middleman-core/templates/shared/Gemfile.tt @@ -8,4 +8,7 @@ gem "middleman", "~><%= Middleman::VERSION %>" gem "middleman-livereload", "~> 3.1.0" # For faster file watcher updates on Windows: -gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] \ No newline at end of file +gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] + +# Windows does not come with time zone data +gem "tzinfo-data", platforms: [:mswin, :mingw] From ae1edd482fc013992f9c070b9c94e41ef755ae76 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 14:38:18 -0800 Subject: [PATCH 07/10] upgrade to newest activesupport --- middleman-core/lib/middleman-core/application.rb | 1 - middleman-core/lib/middleman-core/logger.rb | 4 ++-- middleman-core/middleman-core.gemspec | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index c0ea9d07..3bd1eab1 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -11,7 +11,6 @@ require 'i18n' # Use ActiveSupport JSON require 'active_support/json' require 'active_support/core_ext/integer/inflections' -require 'active_support/core_ext/float/rounding' # Simple callback library require 'hooks' diff --git a/middleman-core/lib/middleman-core/logger.rb b/middleman-core/lib/middleman-core/logger.rb index d8b23c9f..3ab3581e 100644 --- a/middleman-core/lib/middleman-core/logger.rb +++ b/middleman-core/lib/middleman-core/logger.rb @@ -1,12 +1,12 @@ # Use the Ruby/Rails logger require 'active_support/notifications' -require 'active_support/buffered_logger' +require 'active_support/logger' require 'thread' module Middleman # The Middleman Logger - class Logger < ActiveSupport::BufferedLogger + class Logger < ActiveSupport::Logger def self.singleton(*args) if !@_logger || args.length > 0 diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 2729e790..be2bf08d 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_dependency("thor", [">= 0.15.2", "< 2.0"]) # Helpers - s.add_dependency("activesupport", ["~> 3.2.6"]) + s.add_dependency("activesupport", ["~> 4.0.1"]) # Watcher s.add_dependency("listen", ["~> 1.1"]) From fde93ffed4a1e88787d0ae7c6644ede94f653583 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 20 Mar 2014 10:02:18 -0700 Subject: [PATCH 08/10] add node_modules to filewatcher ignore --- .../lib/middleman-core/core_extensions/file_watcher.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index 14cac4ae..7cb0567a 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -10,6 +10,7 @@ module Middleman /^bin(\/|$)/, /^\.bundle(\/|$)/, /^vendor(\/|$)/, + /^node_modules(\/|$)/, /^\.sass-cache(\/|$)/, /^\.cache(\/|$)/, /^\.git(\/|$)/, From 0a6c80d22386675067d6e691f5d8dc37239f74c4 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 23 Mar 2014 16:49:22 -0700 Subject: [PATCH 09/10] Don't attempt to load local templates if HOME is not set --- middleman-core/lib/middleman-core/templates.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/templates.rb b/middleman-core/lib/middleman-core/templates.rb index ba0e9d3e..207edf6a 100644 --- a/middleman-core/lib/middleman-core/templates.rb +++ b/middleman-core/lib/middleman-core/templates.rb @@ -96,7 +96,9 @@ require 'middleman-core/templates/mobile' require 'middleman-more/templates/smacss' # Local templates -require 'middleman-core/templates/local' +if ENV['HOME'] # Sometimes HOME doesn't exist, in which case there's no point to local templates + require 'middleman-core/templates/local' +end # Barebones template require 'middleman-core/templates/empty' From bb5b4054ff1931af5ebfb33abd73de757b9faa19 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 23 Mar 2014 23:35:12 -0700 Subject: [PATCH 10/10] Don't bother processing asset hash on ignored resources. On a large project with a lot of Sprockets dependencies that were mostly ignored, this brought the build down from 30 minutes to 1 minute --- middleman-core/lib/middleman-more/extensions/asset_hash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/middleman-core/lib/middleman-more/extensions/asset_hash.rb b/middleman-core/lib/middleman-more/extensions/asset_hash.rb index c417446a..014364c7 100644 --- a/middleman-core/lib/middleman-more/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-more/extensions/asset_hash.rb @@ -41,6 +41,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension def manipulate_single_resource(resource) return unless options.exts.include?(resource.ext) return if ignored_resource?(resource) + return if resource.ignored? # Render through the Rack interface so middleware and mounted apps get a shot response = @rack_client.get(URI.escape(resource.destination_path), {}, { 'bypass_asset_hash' => 'true' })