From 39046ce029d04a5685380f13b347cd6edab1671d Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 10 Feb 2012 23:36:06 -0800 Subject: [PATCH 01/12] Remove unused methods from Sitemap::Store. If these end up being needed again it'd be better to just filter the #pages list. --- .../lib/middleman-core/sitemap/store.rb | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index f307b82d..f1c19575 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -107,42 +107,6 @@ module Middleman::Sitemap false end - # Get a list of ignored paths - # @return [Array] - def ignored_paths - pages.select(&:ignored?).map(&:path) - end - - # Whether the given path is generic - # @param [String] path - # @return [Boolean] - def generic?(path) - generic_paths.include?(normalize_path(path)) - end - - # Get a list of generic paths - # @return [Array] - def generic_paths - app.cache.fetch :generic_paths do - pages.select(&:generic?).map(&:path) - end - end - - # Whether the given path is proxied - # @param [String] path - # @return [Boolean] - def proxied?(path) - proxied_paths.include?(normalize_path(path)) - end - - # Get a list of proxied paths - # @return [Array] - def proxied_paths - app.cache.fetch :proxied_paths do - pages.select(&:proxy?).map(&:path) - end - end - # Remove a file from the store # @param [String] file # @return [void] From f5edfa75dfccd4df7ea7c8803f7d73c672ebf2e7 Mon Sep 17 00:00:00 2001 From: Piotr Usewicz Date: Sat, 11 Feb 2012 09:35:49 +0000 Subject: [PATCH 02/12] Fix whitespace --- middleman-core/lib/middleman-core.rb | 74 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/middleman-core/lib/middleman-core.rb b/middleman-core/lib/middleman-core.rb index b8053dcd..3ddf3925 100755 --- a/middleman-core/lib/middleman-core.rb +++ b/middleman-core/lib/middleman-core.rb @@ -24,70 +24,70 @@ module Middleman JRUBY = !!(RbConfig::CONFIG["RUBY_INSTALL_NAME"] =~ /^jruby/i) unless const_defined?(:JRUBY) DARWIN = RbConfig::CONFIG['target_os'] =~ /darwin/i unless const_defined?(:DARWIN) LINUX = RbConfig::CONFIG['target_os'] =~ /linux/i unless const_defined?(:LINUX) - + # Auto-load modules on-demand autoload :Base, "middleman-core/base" autoload :Cache, "middleman-core/cache" autoload :Templates, "middleman-core/templates" autoload :Watcher, "middleman-core/watcher" - + module Cli autoload :Base, "middleman-core/cli" autoload :Build, "middleman-core/cli/build" autoload :Init, "middleman-core/cli/init" autoload :Server, "middleman-core/cli/server" end - + # Custom Renderers module Renderers autoload :ERb, "middleman-core/renderers/erb" end - + module Sitemap autoload :Store, "middleman-core/sitemap/store" autoload :Page, "middleman-core/sitemap/page" autoload :Template, "middleman-core/sitemap/template" end - + module CoreExtensions # File Change Notifier autoload :FileWatcher, "middleman-core/core_extensions/file_watcher" - + # In-memory Sitemap autoload :Sitemap, "middleman-core/core_extensions/sitemap" - + # Add Builder callbacks autoload :Builder, "middleman-core/core_extensions/builder" - + # Custom Feature API autoload :Extensions, "middleman-core/core_extensions/extensions" - + # Asset Path Pipeline autoload :Assets, "middleman-core/core_extensions/assets" - + # Data looks at the data/ folder for YAML files and makes them available # to dynamic requests. autoload :Data, "middleman-core/core_extensions/data" - + # Parse YAML from templates autoload :FrontMatter, "middleman-core/core_extensions/front_matter" - + # External helpers looks in the helpers/ folder for helper modules autoload :ExternalHelpers, "middleman-core/core_extensions/external_helpers" - + # DefaultHelpers are the built-in dynamic template helpers. autoload :DefaultHelpers, "middleman-core/core_extensions/default_helpers" # Extended version of Padrino's rendering autoload :Rendering, "middleman-core/core_extensions/rendering" - + # Pass custom options to views autoload :Routing, "middleman-core/core_extensions/routing" - + # Catch and show exceptions at the Rack level autoload :ShowExceptions, "middleman-core/core_extensions/show_exceptions" end - + module Extensions # Provide Apache-style index.html files for directories autoload :DirectoryIndexes, "middleman-core/extensions/directory_indexes" @@ -95,18 +95,18 @@ module Middleman # Lorem provides a handful of helpful prototyping methods to generate # words, paragraphs, fake images, names and email addresses. autoload :Lorem, "middleman-core/extensions/lorem" - + # AutomaticImageSizes inspects the images used in your dynamic templates # and automatically adds width and height attributes to their HTML # elements. autoload :AutomaticImageSizes, "middleman-core/extensions/automatic_image_sizes" - + # AssetHost allows you to setup multiple domains to host your static # assets. Calls to asset paths in dynamic templates will then rotate # through each of the asset servers to better spread the load. autoload :AssetHost, "middleman-core/extensions/asset_host" end - + module Extensions class << self def registered @@ -114,9 +114,9 @@ module Middleman end def register(name, namespace=nil, version=nil, &block) - # If we've already got a matching extension that passed the + # If we've already got a matching extension that passed the # version check, bail out. - return if registered.has_key?(name.to_sym) && + return if registered.has_key?(name.to_sym) && !registered[name.to_sym].is_a?(String) if block_given? @@ -154,12 +154,12 @@ module Middleman end end end - + # Where to look in gems for extensions to auto-register EXTENSION_FILE = File.join("lib", "middleman_extension.rb") unless const_defined?(:EXTENSION_FILE) - + class << self - + # Recursively convert a normal Hash into a HashWithIndifferentAccess # # @private @@ -181,7 +181,7 @@ module Middleman data end end - + # Automatically load extensions from available RubyGems # which contain the EXTENSION_FILE # @@ -190,12 +190,12 @@ module Middleman extensions = rubygems_latest_specs.select do |spec| spec_has_file?(spec, EXTENSION_FILE) end - + extensions.each do |spec| require spec.name end end - + # Backwards compatible means of finding all the latest gemspecs # available on the system # @@ -209,7 +209,7 @@ module Middleman ::Gem.source_index.latest_specs end end - + # Where a given Gem::Specification has a specific file. Used # to discover extensions and Sprockets-supporting gems. # @@ -221,9 +221,9 @@ module Middleman full_path = File.join(spec.full_gem_path, path) File.exists?(full_path) end - + # Create a new Class which is based on Middleman::Base - # Used to create a safe sandbox into which extensions and + # Used to create a safe sandbox into which extensions and # configuration can be included later without impacting # other classes and instances. # @@ -231,34 +231,34 @@ module Middleman def server(&block) Class.new(Middleman::Base) end - + # Creates a new Rack::Server # # @param [Hash] options to pass to Rack::Server.new # @return [Rack::Server] def start_server(options={}) require "webrick" - + opts = { :Port => options[:port] || 4567, :Host => options[:host] || "0.0.0.0", :AccessLog => [] } - + opts[:Logger] = WEBrick::Log::new("/dev/null", 7) if !options[:logging] - + app_class = options[:app] ||= ::Middleman.server.inst opts[:app] = app_class - + # Disable for Beta 1. See if people notice. # require "thin" # ::Thin::Logging.silent = !options[:logging] # opts[:server] = 'thin' opts[:server] = 'webrick' - + server = ::Rack::Server.new(opts) server.start server end end -end \ No newline at end of file +end From cf991bfb89df372709efbc65f875f17c2e011700 Mon Sep 17 00:00:00 2001 From: Piotr Usewicz Date: Sat, 11 Feb 2012 09:39:45 +0000 Subject: [PATCH 03/12] Fix middleman init --bundler Closes #265. --- middleman-core/lib/middleman-core.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/middleman-core/lib/middleman-core.rb b/middleman-core/lib/middleman-core.rb index 3ddf3925..09403671 100755 --- a/middleman-core/lib/middleman-core.rb +++ b/middleman-core/lib/middleman-core.rb @@ -18,6 +18,8 @@ end # Simple callback library require "middleman-core/vendor/hooks-0.2.0/lib/hooks" +require "middleman-core/version" + # Top-level Middleman object module Middleman WINDOWS = !!(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i) unless const_defined?(:WINDOWS) From baaa3fd14832b404c8089122a91aa4fc16a6cc47 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 12 Feb 2012 10:10:59 -0800 Subject: [PATCH 04/12] change little piece of frontmatter logic --- .../lib/middleman-core/core_extensions/front_matter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index f1fdcb80..6437b000 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -187,6 +187,8 @@ module Middleman::CoreExtensions::FrontMatter def parse_front_matter(content) yaml_regex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m if content =~ yaml_regex + content = content[($1.size + $2.size)..-1] + begin data = YAML.load($1) rescue => e @@ -194,7 +196,6 @@ module Middleman::CoreExtensions::FrontMatter return false end - content = content.split(yaml_regex).last else return false end From 5842bf8e5b23cf84b432ebdaf4260b8d66a00b29 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 12 Feb 2012 11:45:42 -0800 Subject: [PATCH 05/12] allow extensionless files to be previewed and built. fixes #270, but requires alternative layouts be placed in a layouts/ directory now. --- Gemfile | 7 ++- Rakefile | 10 ++-- gem_rake_helper.rb | 4 +- middleman-core/features/builder.feature | 1 - .../features/extensionless_text_files.feature | 58 +++++++++++++++++++ .../extensionless-text-files-app/config.rb | 0 .../extensionless-text-files-app/source/CNAME | 1 + .../source/LICENSE | 1 + .../source/README | 1 + .../source/index.html | 1 + .../source/{ => layouts}/alternate.erb | 0 .../middleman-core/core_extensions/sitemap.rb | 6 +- .../lib/middleman-core/sitemap/store.rb | 5 +- middleman-core/middleman-core.gemspec | 4 +- middleman-more/middleman-more.gemspec | 2 +- 15 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 middleman-core/features/extensionless_text_files.feature create mode 100644 middleman-core/fixtures/extensionless-text-files-app/config.rb create mode 100644 middleman-core/fixtures/extensionless-text-files-app/source/CNAME create mode 100644 middleman-core/fixtures/extensionless-text-files-app/source/LICENSE create mode 100644 middleman-core/fixtures/extensionless-text-files-app/source/README create mode 100644 middleman-core/fixtures/extensionless-text-files-app/source/index.html rename middleman-core/fixtures/frontmatter-settings-app/source/{ => layouts}/alternate.erb (100%) diff --git a/Gemfile b/Gemfile index 59a0f87a..3a355227 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ group :development do gem "rake", "~> 0.9.2" gem "rspec", "~> 2.7" gem "rdoc", "~> 3.9" - gem "yard" + # gem "yard" end group :test do @@ -15,8 +15,9 @@ group :test do gem "slim" gem "coffee-filter", "~> 0.1.1" gem "liquid", "~> 2.2" - gem "jquery-rails" - gem "bootstrap-rails", "0.0.5" + gem "jquery-rails", "~> 2.0.0" + # gem "bootstrap-rails", "0.0.5" + # gem "zurb-foundation" end gem "middleman-core", :path => "middleman-core" diff --git a/Rakefile b/Rakefile index 47e21e80..1435472a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'rubygems' unless defined?(Gem) # require 'fileutils' unless defined?(FileUtils) require 'rake' -require 'yard' +# require 'yard' require File.expand_path("../middleman-core/lib/middleman-core/version.rb", __FILE__) @@ -84,7 +84,7 @@ end desc "Run tests for all middleman gems" task :default => :test -desc "Generate documentation" -task :doc do - YARD::CLI::Yardoc.new.run -end \ No newline at end of file +# desc "Generate documentation" +# task :doc do +# YARD::CLI::Yardoc.new.run +# end \ No newline at end of file diff --git a/gem_rake_helper.rb b/gem_rake_helper.rb index d4fe0f51..fe3ea4b4 100644 --- a/gem_rake_helper.rb +++ b/gem_rake_helper.rb @@ -1,7 +1,7 @@ require 'rubygems' unless defined?(Gem) require 'rake' require 'cucumber/rake/task' -require 'yard' +# require 'yard' require 'bundler' Bundler::GemHelper.install_tasks :name => GEM_NAME @@ -20,6 +20,6 @@ Cucumber::Rake::Task.new(:test, 'Run features that should pass') do |t| t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" end -YARD::Rake::YardocTask.new +# YARD::Rake::YardocTask.new task :default => :test \ No newline at end of file diff --git a/middleman-core/features/builder.feature b/middleman-core/features/builder.feature index 2bc6dc62..f833b8bc 100644 --- a/middleman-core/features/builder.feature +++ b/middleman-core/features/builder.feature @@ -17,7 +17,6 @@ Feature: Builder Then the following files should not exist: | _partial | | layout | - | other_layout | | layouts/custom | | layouts/content_for | diff --git a/middleman-core/features/extensionless_text_files.feature b/middleman-core/features/extensionless_text_files.feature new file mode 100644 index 00000000..a544f2e0 --- /dev/null +++ b/middleman-core/features/extensionless_text_files.feature @@ -0,0 +1,58 @@ +Feature: Text Files Without Extensions Should Build and Preview + + Scenario: Building Text Files without directory indexes + + Given a fixture app "extensionless-text-files-app" + And a file named "config.rb" with: + """ + """ + And a successfully built app at "extensionless-text-files-app" + When I cd to "build" + Then the following files should exist: + | CNAME | + | LICENSE | + | README | + + Scenario: Building Text Files with directory indexes + + Given a fixture app "extensionless-text-files-app" + And a file named "config.rb" with: + """ + activate :directory_indexes + """ + And a successfully built app at "extensionless-text-files-app" + When I cd to "build" + Then the following files should exist: + | CNAME | + | LICENSE | + | README | + Then the following files should not exist: + | CNAME/index.html | + | LICENSE/index.html | + | README/index.html | + + Scenario: Previewing Text Files without directory indexes + Given "directory_indexes" feature is "disabled" + Given the Server is running at "extensionless-text-files-app" + When I go to "/CNAME" + Then I should see "test.github.com" + When I go to "/LICENSE" + Then I should see "You have the right to remain classy." + When I go to "/README" + Then I should see "Bork bork bork" + + Scenario: Previewing Text Files with directory indexes + Given "directory_indexes" feature is "enabled" + Given the Server is running at "extensionless-text-files-app" + When I go to "/CNAME" + Then I should see "test.github.com" + When I go to "/LICENSE" + Then I should see "You have the right to remain classy." + When I go to "/README" + Then I should see "Bork bork bork" + # When I go to "/CNAME/index.html" + # Then I should see "File Not Found" + # When I go to "/LICENSE/index.html" + # Then I should see "File Not Found" + # When I go to "/README/index.html" + # Then I should see "File Not Found" \ No newline at end of file diff --git a/middleman-core/fixtures/extensionless-text-files-app/config.rb b/middleman-core/fixtures/extensionless-text-files-app/config.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/fixtures/extensionless-text-files-app/source/CNAME b/middleman-core/fixtures/extensionless-text-files-app/source/CNAME new file mode 100644 index 00000000..c8dc4813 --- /dev/null +++ b/middleman-core/fixtures/extensionless-text-files-app/source/CNAME @@ -0,0 +1 @@ +test.github.com \ No newline at end of file diff --git a/middleman-core/fixtures/extensionless-text-files-app/source/LICENSE b/middleman-core/fixtures/extensionless-text-files-app/source/LICENSE new file mode 100644 index 00000000..8bf82c48 --- /dev/null +++ b/middleman-core/fixtures/extensionless-text-files-app/source/LICENSE @@ -0,0 +1 @@ +You have the right to remain classy. \ No newline at end of file diff --git a/middleman-core/fixtures/extensionless-text-files-app/source/README b/middleman-core/fixtures/extensionless-text-files-app/source/README new file mode 100644 index 00000000..44c2bac0 --- /dev/null +++ b/middleman-core/fixtures/extensionless-text-files-app/source/README @@ -0,0 +1 @@ +Bork bork bork \ No newline at end of file diff --git a/middleman-core/fixtures/extensionless-text-files-app/source/index.html b/middleman-core/fixtures/extensionless-text-files-app/source/index.html new file mode 100644 index 00000000..0b90e2b8 --- /dev/null +++ b/middleman-core/fixtures/extensionless-text-files-app/source/index.html @@ -0,0 +1 @@ +sup \ No newline at end of file diff --git a/middleman-core/fixtures/frontmatter-settings-app/source/alternate.erb b/middleman-core/fixtures/frontmatter-settings-app/source/layouts/alternate.erb similarity index 100% rename from middleman-core/fixtures/frontmatter-settings-app/source/alternate.erb rename to middleman-core/fixtures/frontmatter-settings-app/source/layouts/alternate.erb diff --git a/middleman-core/lib/middleman-core/core_extensions/sitemap.rb b/middleman-core/lib/middleman-core/core_extensions/sitemap.rb index 4366d976..188b26c1 100644 --- a/middleman-core/lib/middleman-core/core_extensions/sitemap.rb +++ b/middleman-core/lib/middleman-core/core_extensions/sitemap.rb @@ -19,8 +19,12 @@ module Middleman::CoreExtensions::Sitemap # Files starting with an underscore, but not a double-underscore :partials => proc { |file, path| (file.match(/\/_/) && !file.match(/\/__/)) }, + :layout => proc { |file, path| + file.match(/^source\/layout\./) || file.match(/^source\/layouts\//) + }, + # Files without any output extension (layouts, partials) - :extensionless => proc { |file, path| !path.match(/\./) }, + # :extensionless => proc { |file, path| !path.match(/\./) }, } # Include instance methods diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index f1c19575..245c74d4 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -88,7 +88,10 @@ module Middleman::Sitemap def page_by_destination(destination_path) # TODO: memoize this destination_path = normalize_path(destination_path) - pages.find {|p| p.destination_path == destination_path } + pages.find do |p| + p.destination_path == destination_path || + p.destination_path == destination_path.sub("/#{@app.index_file}", "") + end end # Whether a path is ignored diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 09df535b..9876ce08 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.require_path = "lib" # Core - s.add_dependency("rack", ["~> 1.3.5"]) + s.add_dependency("rack", ["~> 1.4.0"]) s.add_dependency("tilt", ["~> 1.3.1"]) # Builder @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.add_dependency("thor", ["~> 0.14.0"]) # Helpers - s.add_dependency("activesupport", ["~> 3.1.0"]) + s.add_dependency("activesupport", ["~> 3.2.0"]) # Watcher s.add_dependency("fssm", ["~> 0.2.8"]) diff --git a/middleman-more/middleman-more.gemspec b/middleman-more/middleman-more.gemspec index b982be44..7c1560b9 100644 --- a/middleman-more/middleman-more.gemspec +++ b/middleman-more/middleman-more.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| s.add_dependency("sass", ["~> 3.1.7"]) s.add_dependency("compass", ["0.12.rc.1"]) s.add_dependency("coffee-script", ["~> 2.2.0"]) - s.add_dependency("execjs", ["~> 1.2.7"]) + s.add_dependency("execjs", ["~> 1.2"]) s.add_dependency("sprockets", ["~> 2.1.0"]) s.add_dependency("sprockets-sass", ["~> 0.6.0"]) s.add_dependency("redcarpet", ["~> 2.0.0"]) From 740d4a913f9915c5871330b5113b3959a8f5c40d Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 12 Feb 2012 11:51:29 -0800 Subject: [PATCH 06/12] change compass sprites messaging exit --- middleman-more/features/compass-sprites.feature | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-more/features/compass-sprites.feature b/middleman-more/features/compass-sprites.feature index e4c060a6..2de35eb1 100644 --- a/middleman-more/features/compass-sprites.feature +++ b/middleman-more/features/compass-sprites.feature @@ -1,4 +1,6 @@ Feature: Compass sprites should be generated on build and copied Scenario: Building a clean site with sprites Given a successfully built app at "compass-sprites-app" - Then the output should contain "images/icon-" \ No newline at end of file + When I cd to "build" + Then the following files should exist: + | images/icon-s1a8aa64128.png | \ No newline at end of file From c9b4edcc0a3fb9fd4da43af78cedd50351479205 Mon Sep 17 00:00:00 2001 From: Vasily Fedoseyev Date: Tue, 14 Feb 2012 00:17:32 +0400 Subject: [PATCH 07/12] Add project vendored css and js into sprockets paths --- .../core_extensions/sprockets.rb | 94 +++++++------------ 1 file changed, 34 insertions(+), 60 deletions(-) diff --git a/middleman-more/lib/middleman-more/core_extensions/sprockets.rb b/middleman-more/lib/middleman-more/core_extensions/sprockets.rb index cc1acaf8..c0f1c996 100644 --- a/middleman-more/lib/middleman-more/core_extensions/sprockets.rb +++ b/middleman-more/lib/middleman-more/core_extensions/sprockets.rb @@ -3,68 +3,42 @@ require "sprockets" # Sprockets extension module Middleman::CoreExtensions::Sprockets - + # Setup extension class << self - + # Once registered def registered(app) # Default compression to off app.set :js_compressor, false app.set :css_compressor, false - + # Once Middleman is setup app.ready do - # Create sprockets env for JS + # Create sprockets env for JS and CSS js_env = Middleman::CoreExtensions::Sprockets::JavascriptEnvironment.new(self) + css_env = Middleman::CoreExtensions::Sprockets::StylesheetEnvironment.new(self) - # Add any gems with vendor/assets/javascripts to paths - vendor_dir = File.join("vendor", "assets", "javascripts") - gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec| - ::Middleman.spec_has_file?(spec, vendor_dir) - end.each do |spec| - js_env.append_path File.join(spec.full_gem_path, vendor_dir) - end + # Add any gems with (vendor|app|.)/assets/javascripts to paths + # also add similar directories from project root (like in rails) + root_paths = [%w{ app }, %w{ assets }, %w{ vendor }, %w{ app assets }, %w{ vendor assets }] + try_js_paths = root_paths.map{|rp| File.join(rp, 'javascripts')} + try_css_paths = root_paths.map{|rp| File.join(rp, 'stylesheets')} - # Add any gems with app/assets/javascripts to paths - app_dir = File.join("app", "assets", "javascripts") - gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec| - ::Middleman.spec_has_file?(spec, app_dir) - end.each do |spec| - js_env.append_path File.join(spec.full_gem_path, app_dir) - end - - # Intercept requests to /javascripts and pass to sprockets - map "/#{js_dir}" do - run js_env + { try_js_paths => js_env, try_css_paths => css_env }.each do |paths, env| + ([root] + ::Middleman.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path| + paths.map{|p| File.join(root_path, p)}. + select{|p| File.directory?(p)}. + each{|path| env.append_path(path)} + end end # Setup Sprockets Sass options sass.each { |k, v| ::Sprockets::Sass.options[k] = v } - - # Create sprockets env for CSS - css_env = Middleman::CoreExtensions::Sprockets::StylesheetEnvironment.new(self) - - # Add any gems with vendor/assets/stylesheets to paths - vendor_dir = File.join("vendor", "assets", "stylesheets") - gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec| - ::Middleman.spec_has_file?(spec, vendor_dir) - end.each do |spec| - css_env.append_path File.join(spec.full_gem_path, vendor_dir) - end - - # Add any gems with app/assets/stylesheets to paths - app_dir = File.join("app", "assets", "stylesheets") - gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec| - ::Middleman.spec_has_file?(spec, app_dir) - end.each do |spec| - css_env.append_path File.join(spec.full_gem_path, app_dir) - end - - # Intercept requests to /stylesheets and pass to sprockets - map("/#{css_dir}") do - run css_env - end + + # Intercept requests to /javascripts and /stylesheets and pass to sprockets + map("/#{js_dir}") { run js_env } + map("/#{css_dir}"){ run css_env } end end alias :included :registered @@ -76,7 +50,7 @@ module Middleman::CoreExtensions::Sprockets def initialize(app) @app = app super app.source_dir - + # Make the app context available to Sprockets context_class.send(:define_method, :app) { app } context_class.class_eval do @@ -89,26 +63,26 @@ module Middleman::CoreExtensions::Sprockets end end end - + # During development, don't use the asset cache def find_asset(path, options = {}) expire_index! if @app.development? super end end - + # Javascript specific environment class JavascriptEnvironment < MiddlemanEnvironment - + # Init def initialize(app) super - + expire_index! # Remove old compressor unregister_bundle_processor 'application/javascript', :js_compressor - + # Register compressor from config register_bundle_processor 'application/javascript', :js_compressor do |context, data| if context.pathname.to_s =~ /\.min\./ @@ -117,30 +91,30 @@ module Middleman::CoreExtensions::Sprockets app.js_compressor.compress(data) end end if app.js_compressor - + # configure search paths append_path app.js_dir end - + # Clear cache on error def javascript_exception_response(exception) expire_index! super(exception) end end - + # CSS specific environment class StylesheetEnvironment < MiddlemanEnvironment - + # Init def initialize(app) super - + expire_index! # Remove old compressor unregister_bundle_processor 'text/css', :css_compressor - + # Register compressor from config register_bundle_processor 'text/css', :css_compressor do |context, data| if context.pathname.to_s =~ /\.min\./ @@ -149,11 +123,11 @@ module Middleman::CoreExtensions::Sprockets app.css_compressor.compress(data) end end if app.css_compressor - + # configure search paths append_path app.css_dir end - + # Clear cache on error def css_exception_response(exception) expire_index! From 7458acae4d57337621f4ea1c3e77375ef89884d6 Mon Sep 17 00:00:00 2001 From: Vasily Fedoseyev Date: Fri, 17 Feb 2012 03:22:48 +0400 Subject: [PATCH 08/12] add test for vendored js --- middleman-more/features/sprockets_gems.feature | 9 +++++++-- .../sprockets-app/source/library/js/vendored_include.js | 1 + .../vendor/assets/javascripts/vendored_js.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 middleman-more/fixtures/sprockets-app/source/library/js/vendored_include.js create mode 100644 middleman-more/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js diff --git a/middleman-more/features/sprockets_gems.feature b/middleman-more/features/sprockets_gems.feature index 2e2e4d09..38e5e2bc 100644 --- a/middleman-more/features/sprockets_gems.feature +++ b/middleman-more/features/sprockets_gems.feature @@ -3,8 +3,13 @@ Feature: Sprockets Gems Given the Server is running at "sprockets-app" When I go to "/library/js/jquery_include.js" Then I should see "var jQuery =" - + # Scenario: Sprockets can pull CSS from gem # Given the Server is running at "sprockets-app" # When I go to "/library/css/bootstrap_include.css" - # Then I should see "Bootstrap" \ No newline at end of file + # Then I should see "Bootstrap" + + Scenario: Sprockets can pull js from vendored assets + Given the Server is running at "sprockets-app" + When I go to "/library/js/vendored_include.js" + Then I should see "var vendored_js_included = true;" \ No newline at end of file diff --git a/middleman-more/fixtures/sprockets-app/source/library/js/vendored_include.js b/middleman-more/fixtures/sprockets-app/source/library/js/vendored_include.js new file mode 100644 index 00000000..c73b504a --- /dev/null +++ b/middleman-more/fixtures/sprockets-app/source/library/js/vendored_include.js @@ -0,0 +1 @@ +//= require "vendored_js" \ No newline at end of file diff --git a/middleman-more/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js b/middleman-more/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js new file mode 100644 index 00000000..b27f81d8 --- /dev/null +++ b/middleman-more/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js @@ -0,0 +1 @@ +var vendored_js_included = true; \ No newline at end of file From 3cabbcf5a4df0b2810ebc8859bf198db0991eb1a Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 18 Feb 2012 09:02:16 -0800 Subject: [PATCH 09/12] test jruby --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3f6d0093..973cd828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ rvm: - 1.8.7 - 1.9.2 - 1.9.3 + - jruby script: "bundle exec rake test" branches: From 4e4e835bf5cea15cf6f345cc6f4fd80f9569ada0 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 18 Feb 2012 10:00:54 -0800 Subject: [PATCH 10/12] basic pid file --- CHANGELOG.md | 1 + middleman-core/lib/middleman-core/watcher.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d86ee96..6bb9df06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * Serve purely static folders directly (without source/ and config.rb) * Set ignored files and disable directory_indexes from YAML frontmatter * Automatically load helper modules in helpers/ directory +* Add pid for cleanup 2.0.14 ==== diff --git a/middleman-core/lib/middleman-core/watcher.rb b/middleman-core/lib/middleman-core/watcher.rb index aa5ecec3..8888d9b6 100644 --- a/middleman-core/lib/middleman-core/watcher.rb +++ b/middleman-core/lib/middleman-core/watcher.rb @@ -3,6 +3,8 @@ require "net/http" require "win32/process" if ::Middleman::WINDOWS +require "fileutils" + module Middleman class Watcher class << self @@ -63,12 +65,26 @@ module Middleman if @options[:"disable-watcher"] bootup else + pid_name = ".mm-pid-#{@options[:port]||4567}" + + if File.exists?(pid_name) + current_pid = File.open(pid_name, 'rb') { |f| f.read } + begin + Process.kill("INT", -current_pid.to_i) + rescue + ensure + FileUtils.rm(pid_name) + end + end + @server_job = fork { trap("INT") { exit(0) } trap("TERM") { exit(0) } trap("QUIT") { exit(0) } bootup } + + File.open(pid_name, "w+") { |f| f.write(Process.getpgrp) } end end From 5b2381f6eb21c2fef86d714e217e8234d7a6d5e8 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 18 Feb 2012 10:04:28 -0800 Subject: [PATCH 11/12] sorry jruby --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 973cd828..f7f410b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ rvm: - 1.8.7 - 1.9.2 - 1.9.3 - - jruby + # - jruby script: "bundle exec rake test" branches: From d69ae55fa810338eaee97c06f038dc0ed5e94646 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 18 Feb 2012 21:51:02 -0800 Subject: [PATCH 12/12] new forum --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3dc76eff..11af304e 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,9 @@ http://rubydoc.info/github/middleman/middleman # Community -The official community forum is available on Convore at: +The official community forum is available at: - https://convore.com/middleman/ + http://forum.middlemanapp.com/ # Bug Reports