diff --git a/features/builder.feature b/features/builder.feature index f30a03e2..ce99b3ee 100644 --- a/features/builder.feature +++ b/features/builder.feature @@ -13,4 +13,9 @@ Feature: Builder Then "stylesheets/test_less.css" should exist and include "666" Then "stylesheets/static.css" should exist and include "body" Then "_partial.html" should not exist + And cleanup built test app + + Scenario: Force relative assets + Given a built test app with flags "--relative" + Then "stylesheets/site.css" should exist and include "../" And cleanup built test app \ No newline at end of file diff --git a/features/step_definitions/builder_steps.rb b/features/step_definitions/builder_steps.rb index 3c6097dc..eb710dc1 100644 --- a/features/step_definitions/builder_steps.rb +++ b/features/step_definitions/builder_steps.rb @@ -6,6 +6,12 @@ Given /^a built test app$/ do `cd #{target} && MM_DIR="#{target}" #{build_cmd}` end +Given /^a built test app with flags "([^"]*)"$/ do |flags| + target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") + build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-build")) + `cd #{target} && MM_DIR="#{target}" #{build_cmd} #{flags}` +end + Given /^cleanup built test app$/ do target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build") FileUtils.rm_rf(target) diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index 68281c2f..6f9ddb5a 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -27,9 +27,15 @@ module Middleman include Thor::Actions include Middleman::ThorActions + class_option :relative, :type => :boolean, :aliases => "-r", :default => false, :desc => 'Override the config.rb file and force relative urls' + def initialize(*args) - Middleman::Server.new super + + Middleman::Server.new + if options.has_key?("relative") && options["relative"] + Middleman::Server.activate :relative_assets + end end def source_paths diff --git a/lib/middleman/templates/default/config.tt b/lib/middleman/templates/default/config.tt index cfef2135..eef911ff 100755 --- a/lib/middleman/templates/default/config.tt +++ b/lib/middleman/templates/default/config.tt @@ -51,10 +51,12 @@ configure :build do # Enable cache buster # activate :cache_buster + + # Use relative URLs + # activate :relative_assets # Generate ugly/obfuscated HTML from Haml # activate :ugly_haml - # Or use a different image path # set :http_path, "/Content/images/" diff --git a/lib/middleman/templates/html5/config.tt b/lib/middleman/templates/html5/config.tt index 7a916ea9..4add0262 100755 --- a/lib/middleman/templates/html5/config.tt +++ b/lib/middleman/templates/html5/config.tt @@ -39,6 +39,9 @@ configure :build do # Enable cache buster # activate :cache_buster + + # Use relative URLs + # activate :relative_assets # Generate ugly/obfuscated HTML from Haml # activate :ugly_haml diff --git a/lib/middleman/version.rb b/lib/middleman/version.rb index ee556552..09f8a48b 100644 --- a/lib/middleman/version.rb +++ b/lib/middleman/version.rb @@ -1,3 +1,3 @@ module Middleman - VERSION = "1.1.2" + VERSION = "1.1.3" end