From 73bcd4c12f4873674e2e6ee9261b6db7da8085fc Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 16 Jan 2012 20:35:28 -0800 Subject: [PATCH 01/10] rearrange some watcher stuff --- middleman-core/lib/middleman-core/watcher.rb | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/middleman-core/lib/middleman-core/watcher.rb b/middleman-core/lib/middleman-core/watcher.rb index 28fbbb9a..aa5ecec3 100644 --- a/middleman-core/lib/middleman-core/watcher.rb +++ b/middleman-core/lib/middleman-core/watcher.rb @@ -40,6 +40,7 @@ module Middleman $LOAD_PATH << File.expand_path('../../middleman-core/vendor/linux/lib', __FILE__) end + register_signal_handlers start end @@ -63,7 +64,9 @@ module Middleman bootup else @server_job = fork { - Signal.trap(::Middleman::WINDOWS ? :KILL : :TERM) { exit! } + trap("INT") { exit(0) } + trap("TERM") { exit(0) } + trap("QUIT") { exit(0) } bootup } end @@ -95,8 +98,8 @@ module Middleman puts "== The Middleman is shutting down" if !@options[:"disable-watcher"] Process.kill(::Middleman::WINDOWS ? :KILL : :TERM, @server_job) - Process.wait @server_job - @server_job = nil + # Process.wait @server_job + # @server_job = nil end end @@ -134,6 +137,13 @@ module Middleman end private + # Trap the interupt signal and shut down FSSM (and thus the server) smoothly + def register_signal_handlers + trap("INT") { stop; exit(0) } + trap("TERM") { stop; exit(0) } + trap("QUIT") { stop; exit(0) } + end + # Whether the passed files are config.rb, lib/*.rb or helpers # @param [Array] paths Array of paths to check # @return [Boolean] Whether the server needs to reload @@ -151,10 +161,4 @@ module Middleman Net::HTTP.post_form(uri, {}.merge(params)) end end -end - -# Trap the interupt signal and shut down FSSM (and thus the server) smoothly -trap(::Middleman::Watcher.kill_command) do - ::Middleman::Watcher.singleton.stop - exit(0) end \ No newline at end of file From 251a2e0eb3f114049d883a999cbf55a502c8e326 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 31 Jan 2012 21:30:45 -0800 Subject: [PATCH 02/10] add failing tests for compass relative assets --- .../lib/middleman-core/cli/build.rb | 4 ++ .../features/relative_assets.feature | 43 ++++++++++++++++--- .../fixtures/relative-assets-app/config.rb | 1 + .../middleman-more/core_extensions/compass.rb | 16 +++---- .../middleman-more/extensions/cache_buster.rb | 2 +- .../middleman-more/extensions/minify_css.rb | 2 +- .../extensions/minify_javascript.rb | 2 +- .../extensions/relative_assets.rb | 2 +- middleman-more/middleman-more.gemspec | 2 +- 9 files changed, 55 insertions(+), 19 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index 1f28ae5c..fc6913e4 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -31,6 +31,10 @@ module Middleman::Cli :aliases => "-g", :default => nil, :desc => 'Build a subset of the project' + method_option :verbose, + :type => :boolean, + :default => false, + :desc => 'Print debug messages' # Core build Thor command # @return [void] diff --git a/middleman-more/features/relative_assets.feature b/middleman-more/features/relative_assets.feature index cbf19ef6..ad936a8c 100644 --- a/middleman-more/features/relative_assets.feature +++ b/middleman-more/features/relative_assets.feature @@ -1,12 +1,21 @@ Feature: Relative Assets In order easily switch between relative and absolute paths - Scenario: Rendering css with the feature disabled + Scenario: Previewing css with the feature disabled Given "relative_assets" feature is "disabled" And the Server is running at "relative-assets-app" When I go to "/stylesheets/relative_assets.css" Then I should not see "url('../" - And I should see "/images/blank.gif" + And I should see "url('/images/blank.gif')" + + Scenario: Building css with the feature disabled + Given a fixture app "relative-assets-app" + And a file named "config.rb" with: + """ + """ + Given a successfully built app at "relative-assets-app" + When I cd to "build" + Then the file "stylesheets/relative_assets.css" should contain "url('/images/blank.gif')" Scenario: Rendering html with the feature disabled Given "relative_assets" feature is "disabled" @@ -20,6 +29,16 @@ Feature: Relative Assets When I go to "/stylesheets/relative_assets.css" Then I should see "url('../images/blank.gif" + Scenario: Building css with the feature enabled + Given a fixture app "relative-assets-app" + And a file named "config.rb" with: + """ + activate :relative_assets + """ + Given a successfully built app at "relative-assets-app" + When I cd to "build" + Then the file "stylesheets/relative_assets.css" should contain "url('../images/blank.gif')" + Scenario: Rendering html with the feature enabled Given "relative_assets" feature is "enabled" And the Server is running at "relative-assets-app" @@ -28,13 +47,24 @@ Feature: Relative Assets And I should see "images/blank.gif" Scenario: Rendering html with a custom images_dir - Given "relative_assets" feature is "enabled" + Given "css" feature is "enabled" And "images_dir" is set to "img" And the Server is running at "relative-assets-app" When I go to "/stylesheets/relative_assets.css" - Then I should see "url('../img/blank.gif" + Then I should see "url('../img/blank.gif')" - Scenario: Rendering css with a custom images_dir + Scenario: Building css with a custom images_dir + Given a fixture app "relative-assets-app" + And a file named "config.rb" with: + """ + set :images_dir, "img" + activate :relative_assets + """ + Given a successfully built app at "relative-assets-app" + When I cd to "build" + Then the file "stylesheets/relative_assets.css" should contain "url('../img/blank.gif')" + + Scenario: Rendering html with a custom images_dir Given "relative_assets" feature is "enabled" And "images_dir" is set to "img" And the Server is running at "relative-assets-app" @@ -43,8 +73,9 @@ Feature: Relative Assets Then I should not see "/img/blank.gif" And I should see "img/blank.gif" + Scenario: Rendering scss with the feature enabled Given "relative_assets" feature is "enabled" And the Server is running at "fonts-app" When I go to "/stylesheets/fonts.css" - Then I should see "url('../fonts/StMarie" \ No newline at end of file + Then I should see "url('../fonts/StMarie-Thin.otf" \ No newline at end of file diff --git a/middleman-more/fixtures/relative-assets-app/config.rb b/middleman-more/fixtures/relative-assets-app/config.rb index e69de29b..b4efaffc 100644 --- a/middleman-more/fixtures/relative-assets-app/config.rb +++ b/middleman-more/fixtures/relative-assets-app/config.rb @@ -0,0 +1 @@ +activate :relative_assets \ No newline at end of file diff --git a/middleman-more/lib/middleman-more/core_extensions/compass.rb b/middleman-more/lib/middleman-more/core_extensions/compass.rb index 55215075..ab251aef 100644 --- a/middleman-more/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-more/lib/middleman-more/core_extensions/compass.rb @@ -58,14 +58,14 @@ module Middleman::CoreExtensions::Compass end # Change paths when in build mode. Required for relative paths - configure :build do - ::Compass.configuration do |config| - config.environment = :production - config.css_dir = File.join(build_dir, css_dir) - config.images_dir = File.join(build_dir, images_dir) - config.fonts_dir = File.join(build_dir, fonts_dir) - end - end + # configure :build do + # ::Compass.configuration do |config| + # config.environment = :production + # config.css_dir = File.join(build_dir, css_dir) + # config.images_dir = File.join(build_dir, images_dir) + # config.fonts_dir = File.join(build_dir, fonts_dir) + # end + # end run_hook :compass_config, ::Compass.configuration run_hook :after_compass_config diff --git a/middleman-more/lib/middleman-more/extensions/cache_buster.rb b/middleman-more/lib/middleman-more/extensions/cache_buster.rb index d1d595f4..647406fe 100755 --- a/middleman-more/lib/middleman-more/extensions/cache_buster.rb +++ b/middleman-more/lib/middleman-more/extensions/cache_buster.rb @@ -70,5 +70,5 @@ module Middleman::Extensions end # Register the extension - register :cache_buster, CacheBuster + # register :cache_buster, CacheBuster end \ No newline at end of file diff --git a/middleman-more/lib/middleman-more/extensions/minify_css.rb b/middleman-more/lib/middleman-more/extensions/minify_css.rb index a9fa6680..a7a8c0b9 100644 --- a/middleman-more/lib/middleman-more/extensions/minify_css.rb +++ b/middleman-more/lib/middleman-more/extensions/minify_css.rb @@ -22,5 +22,5 @@ module Middleman::Extensions end # Register extension - register :minify_css, MinifyCss + # register :minify_css, MinifyCss end \ No newline at end of file diff --git a/middleman-more/lib/middleman-more/extensions/minify_javascript.rb b/middleman-more/lib/middleman-more/extensions/minify_javascript.rb index e6df04ab..390e60b3 100755 --- a/middleman-more/lib/middleman-more/extensions/minify_javascript.rb +++ b/middleman-more/lib/middleman-more/extensions/minify_javascript.rb @@ -73,5 +73,5 @@ module Middleman::Extensions end # Register extension - register :minify_javascript, MinifyJavascript + # register :minify_javascript, MinifyJavascript end \ No newline at end of file diff --git a/middleman-more/lib/middleman-more/extensions/relative_assets.rb b/middleman-more/lib/middleman-more/extensions/relative_assets.rb index 56695efb..4c779ff9 100755 --- a/middleman-more/lib/middleman-more/extensions/relative_assets.rb +++ b/middleman-more/lib/middleman-more/extensions/relative_assets.rb @@ -58,5 +58,5 @@ module Middleman::Extensions end # Register extension - register :relative_assets, RelativeAssets + # register :relative_assets, RelativeAssets end \ No newline at end of file diff --git a/middleman-more/middleman-more.gemspec b/middleman-more/middleman-more.gemspec index 44c2b138..29ca0f52 100644 --- a/middleman-more/middleman-more.gemspec +++ b/middleman-more/middleman-more.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_dependency("uglifier", ["~> 1.2.0"]) s.add_dependency("haml", ["~> 3.1.0"]) s.add_dependency("sass", ["~> 3.1.7"]) - s.add_dependency("compass", ["~> 0.11.3"]) + s.add_dependency("compass", ["0.12.rc.0"]) s.add_dependency("coffee-script", ["~> 2.2.0"]) s.add_dependency("execjs", ["~> 1.2.7"]) s.add_dependency("sprockets", ["~> 2.1.0"]) From 1fc97d9d7bbe8edb5d54c64d2870bb7d40569e08 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 31 Jan 2012 22:15:45 -0800 Subject: [PATCH 03/10] A minor simplification of Sitemap::Store#path - it can no longer take a block --- middleman-core/lib/middleman-core/sitemap/store.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 9071f1b6..18987019 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -47,18 +47,16 @@ module Middleman::Sitemap # @param [String] target # @return [void] def proxy(path, target) - page(path) { proxy_to(target.sub(%r{^/}, "")) } + page(path).proxy_to(target.sub(%r{^/}, "")) app.cache.remove(:proxied_paths) end # Get a page instance for a given path # @param [String] path # @return [Middleman::Sitemap::Page] - def page(path, &block) + def page(path) path = path.sub(/^\//, "").gsub("%20", " ") - @pages[path] = ::Middleman::Sitemap::Page.new(self, path) unless @pages.has_key?(path) - @pages[path].instance_exec(&block) if block_given? - @pages[path] + @pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) } end # Loop over known pages From 2eec7e11baee0a8e800a7cdb726718a18a2f2b30 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 31 Jan 2012 22:38:39 -0800 Subject: [PATCH 04/10] Refactor protected method normalize_path out of Sitemap::Store --- .../lib/middleman-core/sitemap/store.rb | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 18987019..8ff847b8 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -22,7 +22,7 @@ module Middleman::Sitemap # @param [String] path # @return [Boolean] def exists?(path) - @pages.has_key?(path.sub(/^\//, "")) + @pages.has_key?(normalize_path(path)) end # Ignore a path or add an ignore callback @@ -30,10 +30,10 @@ module Middleman::Sitemap # @return [void] def ignore(path=nil, &block) if !path.nil? && path.include?("*") - path_clean = path.sub(/^\//, "") + path_clean = normalize_path(path) @ignored_globs << path_clean unless @ignored_globs.include?(path_clean) elsif path.is_a? String - path_clean = path.sub(/^\//, "") + path_clean = normalize_path(path) @ignored_paths << path_clean unless @ignored_paths.include?(path_clean) elsif path.is_a? Regexp @ignored_regexes << path unless @ignored_regexes.include?(path) @@ -47,7 +47,7 @@ module Middleman::Sitemap # @param [String] target # @return [void] def proxy(path, target) - page(path).proxy_to(target.sub(%r{^/}, "")) + page(path).proxy_to(normalize_path(target)) app.cache.remove(:proxied_paths) end @@ -55,13 +55,13 @@ module Middleman::Sitemap # @param [String] path # @return [Middleman::Sitemap::Page] def page(path) - path = path.sub(/^\//, "").gsub("%20", " ") + path = normalize_path(path) @pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) } end # Loop over known pages # @return [void] - def each(&block) + def each @pages.each do |k, v| yield k, v end @@ -77,9 +77,7 @@ module Middleman::Sitemap # @param [String] path # @return [Boolean] def ignored?(path) - path_clean = path.sub(/^\//, "") - - # $stderr.puts path_clean, @ignored_globs, @ignored_paths + path_clean = normalize_path(path) return true if @ignored_paths.include?(path_clean) return true if @ignored_globs.any? { |g| File.fnmatch(g, path_clean) } @@ -99,7 +97,7 @@ module Middleman::Sitemap # @param [String] path # @return [Boolean] def generic?(path) - generic_paths.include?(path.sub(/^\//, "")) + generic_paths.include?(normalize_path(path)) end # Get a list of generic paths @@ -114,7 +112,7 @@ module Middleman::Sitemap # @param [String] path # @return [Boolean] def proxied?(path) - proxied_paths.include?(path.sub(/^\//, "")) + proxied_paths.include?(normalize_path(path)) end # Get a list of proxied paths @@ -132,7 +130,7 @@ module Middleman::Sitemap path = file_to_path(file) return false unless path - path = path.sub(/^\//, "") + path = normalize_path(path) if @pages.has_key?(path) page(path).delete() @pages.delete(path) @@ -187,7 +185,7 @@ module Middleman::Sitemap # Get a path without templating extensions # @param [String] file - # @param [String] + # @return [String] def extensionless_path(file) app.cache.fetch(:extensionless_path, file) do path = file.dup @@ -204,5 +202,12 @@ module Middleman::Sitemap path end end + + # Normalize a path to not include a leading slash + # @param [String] path + # @return [String] + def normalize_path(path) + path.sub(/^\//, "").gsub("%20", " ") + end end end From a41bf57f2d2a4a3bde22acba4e7004999a501230 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 31 Jan 2012 22:57:55 -0800 Subject: [PATCH 05/10] Clarify in the documentation what "path" means for Sitemap::Store and Sitemap::Page --- middleman-core/lib/middleman-core/sitemap/page.rb | 4 +++- middleman-core/lib/middleman-core/sitemap/store.rb | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 8a8fab81..33af034e 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -6,6 +6,8 @@ module Middleman::Sitemap # @return [Middleman::Sitemap::Store] attr_accessor :store + # The source path of this page (relative to the source directory, + # without template extensions) # @return [String] attr_accessor :path @@ -263,4 +265,4 @@ module Middleman::Sitemap store.app end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 8ff847b8..f7f96abf 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -2,6 +2,11 @@ module Middleman::Sitemap # The Store class + # + # The Store manages a collection of Page objects, which represent + # individual items in the sitemap. Pages are indexed by "source path", + # which is the path relative to the source directory, minus any template + # extensions. All "path" parameters used in this class are source paths. class Store # @return [Middleman::Base] @@ -26,7 +31,7 @@ module Middleman::Sitemap end # Ignore a path or add an ignore callback - # @param [String, Regexp] path + # @param [String, Regexp] path, path glob expression, or path regex # @return [void] def ignore(path=nil, &block) if !path.nil? && path.include?("*") @@ -60,6 +65,7 @@ module Middleman::Sitemap end # Loop over known pages + # @yield [path, page] # @return [void] def each @pages.each do |k, v| From 4ce6913baf41f4d068a275b372c58d02df8a085b Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 31 Jan 2012 23:43:05 -0800 Subject: [PATCH 06/10] The beginnings of refactoring page rerouting. Added methods to Sitemap::Store and Sitemap::Page to collect and execute reroute callbacks, and rework builder to use page methods (simplifying it greatly in the process). All tests that don't involve directory indexes pass - next step is to make the directory index extension register its callbacks with Sitemap::Store#reroute. --- .../lib/middleman-core/cli/build.rb | 31 +++++++++---------- .../middleman-core/core_extensions/builder.rb | 11 ++++--- .../extensions/directory_indexes.rb | 7 ++--- .../lib/middleman-core/sitemap/page.rb | 9 ++++++ .../lib/middleman-core/sitemap/store.rb | 14 +++++++++ 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index 1f28ae5c..45d61c35 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -95,25 +95,17 @@ module Middleman::Cli # Ignore following method desc "", "", :hide => true - # Render a template to a file. + # Render a page to a file. # - # @param [String] source - # @param [String] destination - # @param [Hash] config - # @return [String] the actual destination file path that was created - def tilt_template(source, destination, config={}) + # @param [Middleman::Sitemap::Page] page + # @return [void] + def tilt_template(page) build_dir = self.class.shared_instance.build_dir - request_path = destination.sub(/^#{build_dir}/, "") - config[:force] = true begin - destination, request_path = self.class.shared_instance.reroute_builder(destination, request_path) - - response = self.class.shared_rack.get(request_path.gsub(/\s/, "%20")) - - create_file(destination, response.body, config) - - destination + response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20")) + output_file = File.join(self.class.shared_instance.build_dir, page.destination_path) + create_file(output_file, response.body, { :force => true }) rescue say_status :error, destination, :red abort @@ -221,7 +213,10 @@ module Middleman::Cli # Loop over all the paths and build them. paths.each do |path| + puts "SOURCE: #{path}" + file_source = path + # TODO: OMG use pathnames? file_destination = File.join(given_destination, file_source.gsub(source, '.')) file_destination.gsub!('/./', '/') @@ -231,11 +226,13 @@ module Middleman::Cli next end + page = @app.sitemap.page(file_source) + next if @config[:glob] && !File.fnmatch(@config[:glob], file_source) - file_destination = base.tilt_template(file_source, file_destination) + base.tilt_template(page) - @cleaning_queue.delete(Pathname.new(file_destination).realpath) if cleaning? + @cleaning_queue.delete(Pathname.new(page.destination_path).realpath) if cleaning? end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/builder.rb b/middleman-core/lib/middleman-core/core_extensions/builder.rb index 5ba2b160..7f67222b 100644 --- a/middleman-core/lib/middleman-core/core_extensions/builder.rb +++ b/middleman-core/lib/middleman-core/core_extensions/builder.rb @@ -16,7 +16,8 @@ module Middleman::CoreExtensions::Builder # Build Class Methods module ClassMethods # Get a list of callbacks which can modify a files build path - # + # Each callback takes a destination path and a request path and + # returns a new destination path, or false if it doesn't want to reroute. # @return [Array] def build_reroute(&block) @build_rerouters ||= [] @@ -29,14 +30,14 @@ module Middleman::CoreExtensions::Builder module InstanceMethods # Run through callbacks and get the new values # - # @param [String] destination The current destination of the built file - # @param [String] request_path The current request path of the file - # @return [Array] The new values + # @param [String] destination The current destination path of the built file + # @param [String] request_path The request path of the file + # @return [String] The new destination path def reroute_builder(destination, request_path) result = [destination, request_path] build_reroute.each do |block| - output = instance_exec(destination, request_path, &block) + output = block.call(destination, request_path) if output result = output break diff --git a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb index 1c8ea2df..52264097 100644 --- a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb @@ -74,10 +74,7 @@ module Middleman::Extensions elsif frontmatter_ignore false else - [ - destination.sub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path), - request_path - ] + destination.sub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path), end end end @@ -110,4 +107,4 @@ module Middleman::Extensions # Register the extension register :directory_indexes, DirectoryIndexes -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 33af034e..2fc1c9b2 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -187,6 +187,15 @@ module Middleman::Sitemap def relative_path self.source_file ? self.source_file.sub(app.source_dir, '') : nil end + + # Get the destination path, relative to the build directory. + # This path can be affected by proxy callbacks. + # @return [String] + def destination_path + store.reroute_callbacks.inject(self.path) do |destination, callback| + callback.call(destination) + end + end # This page's frontmatter # @return [Hash, nil] diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index f7f96abf..f7471916 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -21,6 +21,7 @@ module Middleman::Sitemap @ignored_globs = [] @ignored_regexes = [] @ignored_callbacks = [] + @reroute_callbacks = [] end # Check to see if we know about a specific path @@ -47,6 +48,19 @@ module Middleman::Sitemap end end + # Add a callback that will be run with each page's destination path + # and can produce a new destination path or pass through the old one. + # @return [void] + def reroute(&block) + @reroute_callbacks << block if block_given? + end + + # The list of reroute callbacks + # @return [Array] + def reroute_callbacks + @reroute_callbacks + end + # Setup a proxy from a path to a target # @param [String] path # @param [String] target From ca1f3ddf833df43919170dce3945b663e5514d54 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 2 Feb 2012 21:47:54 -0800 Subject: [PATCH 07/10] Directory indexes now work during build, with the exception of .htaccess files. --- .../lib/middleman-core/cli/build.rb | 4 +- .../middleman-core/core_extensions/routing.rb | 4 +- .../middleman-core/core_extensions/sitemap.rb | 6 +-- .../extensions/directory_indexes.rb | 49 ++++++++++--------- .../lib/middleman-core/sitemap/page.rb | 2 +- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index 45d61c35..c3bae1d2 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -101,10 +101,10 @@ module Middleman::Cli # @return [void] def tilt_template(page) build_dir = self.class.shared_instance.build_dir + output_file = File.join(self.class.shared_instance.build_dir, page.output_file_path) begin response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20")) - output_file = File.join(self.class.shared_instance.build_dir, page.destination_path) create_file(output_file, response.body, { :force => true }) rescue say_status :error, destination, :red @@ -228,6 +228,8 @@ module Middleman::Cli page = @app.sitemap.page(file_source) + puts "DEST: #{page.destination_path}" + next if @config[:glob] && !File.fnmatch(@config[:glob], file_source) base.tilt_template(page) diff --git a/middleman-core/lib/middleman-core/core_extensions/routing.rb b/middleman-core/lib/middleman-core/core_extensions/routing.rb index d5ec1808..6be37409 100644 --- a/middleman-core/lib/middleman-core/core_extensions/routing.rb +++ b/middleman-core/lib/middleman-core/core_extensions/routing.rb @@ -64,7 +64,7 @@ module Middleman::CoreExtensions::Routing # Setup proxy if opts.has_key?(:proxy) - reroute(url, opts[:proxy]) + proxy(url, opts[:proxy]) if opts.has_key?(:ignore) && opts[:ignore] ignore(opts[:proxy]) @@ -89,4 +89,4 @@ module Middleman::CoreExtensions::Routing end end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core/core_extensions/sitemap.rb b/middleman-core/lib/middleman-core/core_extensions/sitemap.rb index a2c7e6b9..4366d976 100644 --- a/middleman-core/lib/middleman-core/core_extensions/sitemap.rb +++ b/middleman-core/lib/middleman-core/core_extensions/sitemap.rb @@ -74,10 +74,10 @@ module Middleman::CoreExtensions::Sitemap # @param [String] url # @param [String] target # @return [void] - def reroute(*args) + def proxy(*args) sitemap.proxy(*args) end - + # Register a handler to provide metadata on a file path # @param [Regexp] matcher # @return [Array>] @@ -96,4 +96,4 @@ module Middleman::CoreExtensions::Sitemap @_provides_metadata_for_path end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb index 52264097..aa1d8e5f 100644 --- a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb @@ -12,6 +12,8 @@ module Middleman::Extensions # Include methods app.send :include, InstanceMethods + # TODO: unify these + # Before requests app.before do prefix = @original_path.sub(/\/$/, "") @@ -51,41 +53,40 @@ module Middleman::Extensions end end - # Basically does the same as above, but in build mode - app.build_reroute do |destination, request_path| - index_ext = File.extname(index_file) - new_index_path = "/#{index_file}" - frontmatter_ignore = false + app.after_configuration do + # Basically does the same as above, but in build mode + sitemap.reroute do |destination, page| + new_index_path = "/#{index_file}" + frontmatter_ignore = false - # Check for file and frontmatter - if sitemap.exists?(request_path) - p = sitemap.page(request_path) - d = p.data - if !d.nil? + # Check for file and frontmatter + d = page.data + if !page.data.nil? frontmatter_ignore = d.has_key?("directory_index") && d["directory_index"] == false end - end - # Only reroute if not ignored - if ignored_directory_indexes.include?(request_path) - false - elsif request_path =~ /#{new_index_path}$/ - false - elsif frontmatter_ignore - false - else - destination.sub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path), + # Only reroute if not ignored + request_path = page.request_path + if ignored_directory_indexes.include? page + destination + elsif request_path.end_with? new_index_path + destination + elsif frontmatter_ignore + destination + else + index_ext = File.extname(index_file) + destination.chomp(File.extname(index_file)) + new_index_path + end end end end - + alias :included :registered end - # Directory indexes instance methods module InstanceMethods # A list of pages which will not use directory indexes - # @return [Array] + # @return [Array] def ignored_directory_indexes @_ignored_directory_indexes ||= [] end @@ -97,7 +98,7 @@ module Middleman::Extensions # @return [void] def page(url, options={}, &block) if options.has_key?(:directory_index) && !options["directory_index"] - ignored_directory_indexes << url + ignored_directory_indexes << sitemap.page(url) else super end diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 2fc1c9b2..48d20c24 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -193,7 +193,7 @@ module Middleman::Sitemap # @return [String] def destination_path store.reroute_callbacks.inject(self.path) do |destination, callback| - callback.call(destination) + callback.call(destination, self) end end From e27e0cdd446c6e2426b4ea07d9ca2538632d7a93 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 3 Feb 2012 00:14:49 -0800 Subject: [PATCH 08/10] Directory indexes work completely now, in preview and with dotfiles. --- middleman-core/lib/middleman-core/base.rb | 2 +- .../lib/middleman-core/cli/build.rb | 30 +++++++------------ .../extensions/directory_indexes.rb | 18 +++++++---- .../lib/middleman-core/sitemap/store.rb | 4 ++- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/middleman-core/lib/middleman-core/base.rb b/middleman-core/lib/middleman-core/base.rb index 8c9d02a4..e7269e0c 100644 --- a/middleman-core/lib/middleman-core/base.rb +++ b/middleman-core/lib/middleman-core/base.rb @@ -494,4 +494,4 @@ protected end res['Content-Type'] = mime_type end -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index c3bae1d2..95ec6d00 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -101,13 +101,14 @@ module Middleman::Cli # @return [void] def tilt_template(page) build_dir = self.class.shared_instance.build_dir - output_file = File.join(self.class.shared_instance.build_dir, page.output_file_path) + output_file = File.join(self.class.shared_instance.build_dir, page.destination_path) begin response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20")) create_file(output_file, response.body, { :force => true }) rescue - say_status :error, destination, :red + say_status :error, output_file, :red + puts $! abort end end @@ -201,6 +202,8 @@ module Middleman::Cli # Sort paths to be built by the above order. This is primarily so Compass can # find files in the build folder when it needs to generate sprites for the # css files + + # TODO: deal with pages, not paths paths = @app.sitemap.all_paths.sort do |a, b| a_ext = File.extname(a) b_ext = File.extname(b) @@ -213,28 +216,15 @@ module Middleman::Cli # Loop over all the paths and build them. paths.each do |path| - puts "SOURCE: #{path}" + page = @app.sitemap.page(path) - file_source = path - # TODO: OMG use pathnames? - file_destination = File.join(given_destination, file_source.gsub(source, '.')) - file_destination.gsub!('/./', '/') - - if @app.sitemap.proxied?(file_source) - file_source = @app.sitemap.page(file_source).proxied_to - elsif @app.sitemap.page(file_source).ignored? - next - end - - page = @app.sitemap.page(file_source) - - puts "DEST: #{page.destination_path}" - - next if @config[:glob] && !File.fnmatch(@config[:glob], file_source) + next if page.ignored? + next if @config[:glob] && !File.fnmatch(@config[:glob], path) base.tilt_template(page) - @cleaning_queue.delete(Pathname.new(page.destination_path).realpath) if cleaning? + output_path = File.join(@destination, page.destination_path) + @cleaning_queue.delete(Pathname.new(output_path).realpath) if cleaning? end end end diff --git a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb index aa1d8e5f..963e89d7 100644 --- a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb @@ -12,14 +12,15 @@ module Middleman::Extensions # Include methods app.send :include, InstanceMethods - # TODO: unify these + # TODO: unify these by replacing the "before" thing with a + # lookup by destination_path # Before requests app.before do prefix = @original_path.sub(/\/$/, "") indexed_path = prefix + "/" + index_file extensioned_path = prefix + File.extname(index_file) - + is_ignored = false fm_ignored = false @@ -36,13 +37,15 @@ module Middleman::Extensions end else # Otherwise check this extension for list of ignored indexes - is_ignored = ignored_directory_indexes.include?(extensioned_path) + if sitemap.exists?(extensioned_path) + is_ignored = ignored_directory_indexes.include?(sitemap.page(extensioned_path)) + end end # If we're going to remap to a directory index if !sitemap.exists?(indexed_path) && !is_ignored && !fm_ignored parts = @original_path.split("/") - last_part = parts.last + last_part = parts.last || '' last_part_ext = File.extname(last_part) # Change the request @@ -65,16 +68,19 @@ module Middleman::Extensions frontmatter_ignore = d.has_key?("directory_index") && d["directory_index"] == false end + index_ext = File.extname(index_file) + # Only reroute if not ignored request_path = page.request_path if ignored_directory_indexes.include? page destination - elsif request_path.end_with? new_index_path + elsif request_path == index_file || request_path.end_with?(new_index_path) destination elsif frontmatter_ignore destination + elsif index_ext != File.extname(request_path) + destination else - index_ext = File.extname(index_file) destination.chomp(File.extname(index_file)) + new_index_path end end diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index f7471916..e69cfd3c 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -103,7 +103,9 @@ module Middleman::Sitemap return true if @ignored_globs.any? { |g| File.fnmatch(g, path_clean) } return true if @ignored_regexes.any? { |r| r.match(path_clean) } return true if @ignored_callbacks.any? { |b| b.call(path_clean) } - + + # TODO: We should also check ignored_sitemap_matchers here + false end From e136fab77ca0a1cd204f04bc574878c01618c226 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 4 Feb 2012 23:07:02 -0800 Subject: [PATCH 09/10] Use a page_by_destination lookup to make rerouting work both ways, in build and during preview server. --- .../features/wildcard_page_helper.feature | 2 +- middleman-core/lib/middleman-core/base.rb | 12 ++--- .../extensions/directory_indexes.rb | 52 ++----------------- .../lib/middleman-core/sitemap/page.rb | 5 +- .../lib/middleman-core/sitemap/store.rb | 9 +++- 5 files changed, 22 insertions(+), 58 deletions(-) diff --git a/middleman-core/features/wildcard_page_helper.feature b/middleman-core/features/wildcard_page_helper.feature index baa75556..5ac7a25e 100644 --- a/middleman-core/features/wildcard_page_helper.feature +++ b/middleman-core/features/wildcard_page_helper.feature @@ -15,5 +15,5 @@ Feature: Wildcards in Page helper Then I should see "Normal Layout" When I go to "/admin/" Then I should see "Admin Layout" - When I go to "/admin/page.html" + When I go to "/admin/page/" Then I should see "Admin Layout" \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/base.rb b/middleman-core/lib/middleman-core/base.rb index e7269e0c..7ab77383 100644 --- a/middleman-core/lib/middleman-core/base.rb +++ b/middleman-core/lib/middleman-core/base.rb @@ -370,13 +370,13 @@ class Middleman::Base # Run before callbacks run_hook :before - - # Return 404 if not in sitemap - return not_found unless sitemap.exists?(@request_path) - + # Get the page object for this path - sitemap_page = sitemap.page(@request_path) - + sitemap_page = sitemap.page_by_destination(@request_path) + + # Return 404 if not in sitemap + return not_found unless sitemap_page + # Return 404 if this path is specifically ignored return not_found if sitemap_page.ignored? diff --git a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb index 963e89d7..4c591c9d 100644 --- a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb @@ -12,52 +12,8 @@ module Middleman::Extensions # Include methods app.send :include, InstanceMethods - # TODO: unify these by replacing the "before" thing with a - # lookup by destination_path - - # Before requests - app.before do - prefix = @original_path.sub(/\/$/, "") - indexed_path = prefix + "/" + index_file - extensioned_path = prefix + File.extname(index_file) - - is_ignored = false - fm_ignored = false - - # If the sitemap knows about the path - if sitemap.exists?(@original_path) - # Inspect frontmatter - d = sitemap.page(@original_path).data - - # Allow the frontmatter to ignore a directory index - if !d.nil? && d.has_key?("directory_index") && d["directory_index"] == false - fm_ignored = true - else - next - end - else - # Otherwise check this extension for list of ignored indexes - if sitemap.exists?(extensioned_path) - is_ignored = ignored_directory_indexes.include?(sitemap.page(extensioned_path)) - end - end - - # If we're going to remap to a directory index - if !sitemap.exists?(indexed_path) && !is_ignored && !fm_ignored - parts = @original_path.split("/") - last_part = parts.last || '' - last_part_ext = File.extname(last_part) - - # Change the request - if last_part_ext.blank? - # This is a folder, redirect to index - @request_path = extensioned_path - end - end - end - app.after_configuration do - # Basically does the same as above, but in build mode + # Register a reroute transform that turns regular paths into indexed paths sitemap.reroute do |destination, page| new_index_path = "/#{index_file}" frontmatter_ignore = false @@ -71,14 +27,14 @@ module Middleman::Extensions index_ext = File.extname(index_file) # Only reroute if not ignored - request_path = page.request_path + path = page.path if ignored_directory_indexes.include? page destination - elsif request_path == index_file || request_path.end_with?(new_index_path) + elsif path == index_file || path.end_with?(new_index_path) destination elsif frontmatter_ignore destination - elsif index_ext != File.extname(request_path) + elsif index_ext != File.extname(path) destination else destination.chomp(File.extname(index_file)) + new_index_path diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 48d20c24..b14faca7 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -43,9 +43,9 @@ module Middleman::Sitemap # @return [String] def request_path if proxy? - store.page(proxied_to).path + store.page(proxied_to).destination_path else - path + destination_path end end @@ -192,6 +192,7 @@ module Middleman::Sitemap # This path can be affected by proxy callbacks. # @return [String] def destination_path + # TODO: memoize this value store.reroute_callbacks.inject(self.path) do |destination, callback| callback.call(destination, self) end diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index e69cfd3c..b14dac67 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -77,6 +77,13 @@ module Middleman::Sitemap path = normalize_path(path) @pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) } end + + # Find a page given its destination path + def page_by_destination(destination_path) + # TODO: memoize this + destination_path = normalize_path(destination_path) + @pages.values.find {|p| p.destination_path == destination_path } + end # Loop over known pages # @yield [path, page] @@ -86,7 +93,7 @@ module Middleman::Sitemap yield k, v end end - + # Get all known paths # @return [Array] def all_paths From 8286879f36b19edc0e52cbc76a8872fdc3ed15f4 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 5 Feb 2012 11:43:19 -0800 Subject: [PATCH 10/10] sprockets-sass was overwriting image-url and breaking relative assets. Fixes #256 --- middleman-core/bin/middleman | 13 +++--- .../lib/middleman-core/cli/build.rb | 5 ++- .../core_extensions/extensions.rb | 12 ++--- .../features/relative_assets.feature | 6 +-- .../fixtures/relative-assets-app/config.rb | 2 +- .../middleman-more/core_extensions/compass.rb | 45 ++++--------------- .../extensions/relative_assets.rb | 1 + .../lib/middleman-more/renderers/sass.rb | 5 ++- middleman-more/middleman-more.gemspec | 2 +- 9 files changed, 35 insertions(+), 56 deletions(-) diff --git a/middleman-core/bin/middleman b/middleman-core/bin/middleman index c4d46e36..e37fd292 100755 --- a/middleman-core/bin/middleman +++ b/middleman-core/bin/middleman @@ -33,17 +33,16 @@ end # Default command is server ARGV.unshift("server") if ARGV.length < 1 || ARGV.first.include?("-") -# Require Middleman -require 'middleman-core' - begin - # Rubygems - require "middleman-more" + # Local + require File.expand_path(File.join(File.dirname(File.dirname(libdir)), "middleman-more", "lib", "middleman-more")) rescue LoadError begin - # Local - require File.expand_path(File.join(File.dirname(File.dirname(libdir)), "middleman-more", "lib", "middleman-more")) + # Rubygems + require "middleman-more" rescue LoadError + # Require Middleman + require 'middleman-core' end end diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index c2e0f567..a16fd4b1 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -44,6 +44,8 @@ module Middleman::Cli exit(1) end + self.class.shared_instance(options["verbose"] || false) + if options.has_key?("relative") && options["relative"] self.class.shared_instance.activate :relative_assets end @@ -65,9 +67,10 @@ module Middleman::Cli # Middleman::Base singleton # # @return [Middleman::Base] - def shared_instance + def shared_instance(verbose=false) @_shared_instance ||= ::Middleman.server.inst do set :environment, :build + set :logging, verbose end end diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 5bee01b0..10affbd9 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -97,17 +97,17 @@ module Middleman::CoreExtensions::Extensions # @param [Symbol, Module] ext Which extension to activate # @return [void] def activate(ext, options={}, &block) - if !ext.is_a?(Module) - ext = ::Middleman::Extensions.load(ext.to_sym) + ext_module = if ext.is_a?(Module) + ext + else + ::Middleman::Extensions.load(ext.to_sym) end - if ext.nil? + if ext_module.nil? puts "== Unknown Extension: #{ext}" - elsif ext.is_a?(String) - puts ext else puts "== Activating: #{ext}" if logging? - self.class.register(ext, options, &block) + self.class.register(ext_module, options, &block) end end diff --git a/middleman-more/features/relative_assets.feature b/middleman-more/features/relative_assets.feature index ad936a8c..ba06de53 100644 --- a/middleman-more/features/relative_assets.feature +++ b/middleman-more/features/relative_assets.feature @@ -6,7 +6,7 @@ Feature: Relative Assets And the Server is running at "relative-assets-app" When I go to "/stylesheets/relative_assets.css" Then I should not see "url('../" - And I should see "url('/images/blank.gif')" + And I should see "/images/blank.gif')" Scenario: Building css with the feature disabled Given a fixture app "relative-assets-app" @@ -46,8 +46,8 @@ Feature: Relative Assets Then I should not see "/images/blank.gif" And I should see "images/blank.gif" - Scenario: Rendering html with a custom images_dir - Given "css" feature is "enabled" + Scenario: Rendering css with a custom images_dir + Given "relative_assets" feature is "enabled" And "images_dir" is set to "img" And the Server is running at "relative-assets-app" When I go to "/stylesheets/relative_assets.css" diff --git a/middleman-more/fixtures/relative-assets-app/config.rb b/middleman-more/fixtures/relative-assets-app/config.rb index b4efaffc..88ce0817 100644 --- a/middleman-more/fixtures/relative-assets-app/config.rb +++ b/middleman-more/fixtures/relative-assets-app/config.rb @@ -1 +1 @@ -activate :relative_assets \ No newline at end of file +# activate :relative_assets \ No newline at end of file diff --git a/middleman-more/lib/middleman-more/core_extensions/compass.rb b/middleman-more/lib/middleman-more/core_extensions/compass.rb index ab251aef..872da23b 100644 --- a/middleman-more/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-more/lib/middleman-more/core_extensions/compass.rb @@ -16,39 +16,16 @@ module Middleman::CoreExtensions::Compass app.after_configuration do ::Compass.configuration do |config| - config.project_path = root + config.project_path = source_dir config.environment = :development config.cache_path = File.join(root, ".sass-cache") - config.sass_dir = File.join(source, css_dir) - config.css_dir = File.join(source, css_dir) - config.javascripts_dir = File.join(source, js_dir) - config.fonts_dir = File.join(source, fonts_dir) - config.images_dir = File.join(source, images_dir) - - config.http_images_path = if respond_to? :http_images_path - http_images_path - else - File.join(http_prefix, images_dir) - end - - config.http_stylesheets_path = if respond_to? :http_css_path - http_css_path - else - File.join(http_prefix, css_dir) - end - - config.http_javascripts_path = if respond_to? :http_js_path - http_js_path - else - File.join(http_prefix, js_dir) - end + config.sass_dir = css_dir + config.css_dir = css_dir + config.javascripts_dir = js_dir + config.fonts_dir = fonts_dir + config.images_dir = images_dir + config.http_path = http_prefix - config.http_fonts_path = if respond_to? :http_fonts_path - http_fonts_path - else - File.join(http_prefix, fonts_dir) - end - config.asset_cache_buster :none config.output_style = :nested @@ -57,13 +34,9 @@ module Middleman::CoreExtensions::Compass end end - # Change paths when in build mode. Required for relative paths - # configure :build do + # if build? # ::Compass.configuration do |config| - # config.environment = :production - # config.css_dir = File.join(build_dir, css_dir) - # config.images_dir = File.join(build_dir, images_dir) - # config.fonts_dir = File.join(build_dir, fonts_dir) + # config.environment = :production # end # end diff --git a/middleman-more/lib/middleman-more/extensions/relative_assets.rb b/middleman-more/lib/middleman-more/extensions/relative_assets.rb index 4c779ff9..1f694eee 100755 --- a/middleman-more/lib/middleman-more/extensions/relative_assets.rb +++ b/middleman-more/lib/middleman-more/extensions/relative_assets.rb @@ -17,6 +17,7 @@ module Middleman::Extensions # Include instance methods app.send :include, InstanceMethods end + alias :included :registered end diff --git a/middleman-more/lib/middleman-more/renderers/sass.rb b/middleman-more/lib/middleman-more/renderers/sass.rb index b8eccd2c..af82197f 100644 --- a/middleman-more/lib/middleman-more/renderers/sass.rb +++ b/middleman-more/lib/middleman-more/renderers/sass.rb @@ -1,7 +1,10 @@ # Pull in gems -require "sass" require "sprockets" require "sprockets-sass" +require "sass" + +# Stick with Compass' asset functions +Sprockets::Sass.add_sass_functions = false # Sass renderer module Middleman::Renderers::Sass diff --git a/middleman-more/middleman-more.gemspec b/middleman-more/middleman-more.gemspec index 29ca0f52..b982be44 100644 --- a/middleman-more/middleman-more.gemspec +++ b/middleman-more/middleman-more.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_dependency("uglifier", ["~> 1.2.0"]) s.add_dependency("haml", ["~> 3.1.0"]) s.add_dependency("sass", ["~> 3.1.7"]) - s.add_dependency("compass", ["0.12.rc.0"]) + 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("sprockets", ["~> 2.1.0"])