middleman 2.0.0.rc92 → 2.0.0.rc93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -1
 - data/Rakefile +1 -40
 - data/bin/middleman +8 -0
 - data/bin/mm-build +2 -7
 - data/bin/mm-init +2 -27
 - data/bin/mm-server +2 -46
 - data/features/asset_host.feature +2 -2
 - data/features/automatic_image_sizes.feature +2 -2
 - data/features/builder.feature +16 -16
 - data/features/cache_buster.feature +4 -4
 - data/features/coffee-script.feature +3 -3
 - data/features/data.feature +1 -1
 - data/features/directory_index.feature +27 -0
 - data/features/dynamic_pages.feature +18 -9
 - data/features/front-matter.feature +1 -1
 - data/features/helpers_auto_javascript_include_tag.feature +5 -5
 - data/features/helpers_auto_stylesheet_link_tag.feature +5 -5
 - data/features/helpers_page_classes.feature +3 -3
 - data/features/minify_css.feature +2 -2
 - data/features/minify_javascript.feature +3 -3
 - data/features/padrino_helpers.feature +1 -1
 - data/features/page_alias_and_layouts.feature +5 -5
 - data/features/relative_assets.feature +6 -6
 - data/features/scss-support.feature +2 -2
 - data/features/sinatra.feature +1 -1
 - data/features/slim.feature +1 -1
 - data/features/sprockets.feature +1 -1
 - data/features/step_definitions/builder_steps.rb +22 -17
 - data/features/step_definitions/generator_steps.rb +1 -1
 - data/features/step_definitions/middleman_steps.rb +3 -1
 - data/features/step_definitions/page_layout_steps.rb +0 -2
 - data/features/support/env.rb +0 -1
 - data/features/tiny_src.feature +2 -2
 - data/fixtures/indexable-app/config.rb +2 -0
 - data/fixtures/indexable-app/source/a_folder/needs_index.html +1 -0
 - data/fixtures/indexable-app/source/leave_me_alone.html +1 -0
 - data/fixtures/indexable-app/source/needs_index.html +1 -0
 - data/fixtures/test-app/config.rb +4 -0
 - data/fixtures/test-app/source/a_folder/needs_index.html +1 -0
 - data/fixtures/test-app/source/needs_index.html +1 -0
 - data/fixtures/test-app/source/should_be_ignored.html +1 -0
 - data/fixtures/test-app/source/should_be_ignored2.html +1 -0
 - data/fixtures/test-app/source/should_be_ignored3.html +1 -0
 - data/lib/middleman.rb +10 -8
 - data/lib/middleman/base.rb +25 -2
 - data/lib/middleman/builder.rb +23 -10
 - data/lib/middleman/cli.rb +84 -0
 - data/lib/middleman/core_extensions/routing.rb +22 -2
 - data/lib/middleman/features/blog.rb +0 -1
 - data/lib/middleman/features/directory_indexes.rb +50 -0
 - data/lib/middleman/guard.rb +7 -3
 - data/lib/middleman/version.rb +1 -1
 - data/middleman.gemspec +9 -9
 - metadata +110 -88
 - data/bin/mm-migrate +0 -5
 
    
        data/features/minify_css.feature
    CHANGED
    
    | 
         @@ -8,7 +8,7 @@ Feature: Minify CSS 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              Scenario: Rendering external css with the feature disabled
         
     | 
| 
       10 
10 
     | 
    
         
             
                Given "minify_css" feature is "disabled"
         
     | 
| 
       11 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 11 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       12 
12 
     | 
    
         
             
                When I go to "/stylesheets/site.css"
         
     | 
| 
       13 
13 
     | 
    
         
             
                Then I should see "55" lines
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
         @@ -19,6 +19,6 @@ Feature: Minify CSS 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              Scenario: Rendering external css with the feature enabled
         
     | 
| 
       21 
21 
     | 
    
         
             
                Given "minify_css" feature is "enabled"
         
     | 
| 
       22 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 22 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       23 
23 
     | 
    
         
             
                When I go to "/stylesheets/site.css"
         
     | 
| 
       24 
24 
     | 
    
         
             
                Then I should see "1" lines
         
     | 
| 
         @@ -6,18 +6,18 @@ Feature: Minify Javascript 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              Scenario: Rendering inline js with the feature disabled
         
     | 
| 
       8 
8 
     | 
    
         
             
                Given "minify_javascript" feature is "disabled"
         
     | 
| 
       9 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 9 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       10 
10 
     | 
    
         
             
                When I go to "/inline-js.html"
         
     | 
| 
       11 
11 
     | 
    
         
             
                Then I should see "10" lines
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              Scenario: Rendering inline js with the feature enabled
         
     | 
| 
       14 
14 
     | 
    
         
             
                Given "minify_javascript" feature is "enabled"
         
     | 
| 
       15 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 15 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       16 
16 
     | 
    
         
             
                When I go to "/inline-js.html"
         
     | 
| 
       17 
17 
     | 
    
         
             
                Then I should see "5" lines
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              Scenario: Rendering inline js (coffeescript) with the feature enabled
         
     | 
| 
       20 
20 
     | 
    
         
             
                Given "minify_javascript" feature is "enabled"
         
     | 
| 
       21 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 21 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       22 
22 
     | 
    
         
             
                When I go to "/inline-coffeescript.html"
         
     | 
| 
       23 
23 
     | 
    
         
             
                Then I should see "5" lines
         
     | 
| 
         @@ -2,7 +2,7 @@ Feature: Built-in macro view helpers 
     | 
|
| 
       2 
2 
     | 
    
         
             
              In order to simplify generating HTML
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              Scenario: Using the link_to helper
         
     | 
| 
       5 
     | 
    
         
            -
                Given the Server is running
         
     | 
| 
      
 5 
     | 
    
         
            +
                Given the Server is running at "test-app"
         
     | 
| 
       6 
6 
     | 
    
         
             
                When I go to "/padrino_test.html"
         
     | 
| 
       7 
7 
     | 
    
         
             
                And I should see 'href="test2.com"'
         
     | 
| 
       8 
8 
     | 
    
         
             
                And I should see 'src="/images/test2.png"'
         
     | 
| 
         @@ -3,19 +3,19 @@ Feature: Custom layouts 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              Scenario: Using custom :layout attribute
         
     | 
| 
       5 
5 
     | 
    
         
             
                Given page "/custom-layout.html" has layout "custom"
         
     | 
| 
       6 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 6 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       7 
7 
     | 
    
         
             
                When I go to "/custom-layout.html"
         
     | 
| 
       8 
8 
     | 
    
         
             
                Then I should see "Custom Layout"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              Scenario: Using with_layout block
         
     | 
| 
       11 
11 
     | 
    
         
             
                Given "/custom-layout.html" with_layout block has layout "custom"
         
     | 
| 
       12 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 12 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       13 
13 
     | 
    
         
             
                When I go to "/custom-layout.html"
         
     | 
| 
       14 
14 
     | 
    
         
             
                Then I should see "Custom Layout"
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              Scenario: Using custom :layout attribute with folders
         
     | 
| 
       17 
17 
     | 
    
         
             
                Given page "/custom-layout-dir/" has layout "custom"
         
     | 
| 
       18 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 18 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       19 
19 
     | 
    
         
             
                When I go to "/custom-layout-dir"
         
     | 
| 
       20 
20 
     | 
    
         
             
                Then I should see "Custom Layout"
         
     | 
| 
       21 
21 
     | 
    
         
             
                When I go to "/custom-layout-dir/"
         
     | 
| 
         @@ -25,7 +25,7 @@ Feature: Custom layouts 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              Scenario: Using custom :layout attribute with folders
         
     | 
| 
       27 
27 
     | 
    
         
             
                Given page "/custom-layout-dir" has layout "custom"
         
     | 
| 
       28 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 28 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       29 
29 
     | 
    
         
             
                When I go to "/custom-layout-dir"
         
     | 
| 
       30 
30 
     | 
    
         
             
                Then I should see "Custom Layout"
         
     | 
| 
       31 
31 
     | 
    
         
             
                When I go to "/custom-layout-dir/"
         
     | 
| 
         @@ -35,7 +35,7 @@ Feature: Custom layouts 
     | 
|
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
              Scenario: Using custom :layout attribute with folders
         
     | 
| 
       37 
37 
     | 
    
         
             
                Given page "/custom-layout-dir/index.html" has layout "custom"
         
     | 
| 
       38 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 38 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       39 
39 
     | 
    
         
             
                When I go to "/custom-layout-dir"
         
     | 
| 
       40 
40 
     | 
    
         
             
                Then I should see "Custom Layout"
         
     | 
| 
       41 
41 
     | 
    
         
             
                When I go to "/custom-layout-dir/"
         
     | 
| 
         @@ -3,26 +3,26 @@ Feature: Relative Assets 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              Scenario: Rendering css with the feature disabled
         
     | 
| 
       5 
5 
     | 
    
         
             
                Given "relative_assets" feature is "disabled"
         
     | 
| 
       6 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 6 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       7 
7 
     | 
    
         
             
                When I go to "/stylesheets/relative_assets.css"
         
     | 
| 
       8 
8 
     | 
    
         
             
                Then I should not see "url('../"
         
     | 
| 
       9 
9 
     | 
    
         
             
                And I should see "/images/blank.gif"
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              Scenario: Rendering html with the feature disabled
         
     | 
| 
       12 
12 
     | 
    
         
             
                Given "relative_assets" feature is "disabled"
         
     | 
| 
       13 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 13 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       14 
14 
     | 
    
         
             
                When I go to "/relative_image.html"
         
     | 
| 
       15 
15 
     | 
    
         
             
                Then I should see "/images/blank.gif"
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              Scenario: Rendering css with the feature enabled
         
     | 
| 
       18 
18 
     | 
    
         
             
                Given "relative_assets" feature is "enabled"
         
     | 
| 
       19 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 19 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       20 
20 
     | 
    
         
             
                When I go to "/stylesheets/relative_assets.css"
         
     | 
| 
       21 
21 
     | 
    
         
             
                Then I should see "url('../images/blank.gif"
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              Scenario: Rendering html with the feature disabled
         
     | 
| 
       24 
24 
     | 
    
         
             
                Given "relative_assets" feature is "enabled"
         
     | 
| 
       25 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 25 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       26 
26 
     | 
    
         
             
                When I go to "/relative_image.html"
         
     | 
| 
       27 
27 
     | 
    
         
             
                Then I should not see "/images/blank.gif"
         
     | 
| 
       28 
28 
     | 
    
         
             
                And I should see "images/blank.gif"
         
     | 
| 
         @@ -30,14 +30,14 @@ Feature: Relative Assets 
     | 
|
| 
       30 
30 
     | 
    
         
             
              Scenario: Rendering html with a custom images_dir
         
     | 
| 
       31 
31 
     | 
    
         
             
                Given "relative_assets" feature is "enabled"
         
     | 
| 
       32 
32 
     | 
    
         
             
                And "images_dir" is set to "img"
         
     | 
| 
       33 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 33 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       34 
34 
     | 
    
         
             
                When I go to "/stylesheets/relative_assets.css"
         
     | 
| 
       35 
35 
     | 
    
         
             
                Then I should see "url('../img/blank.gif"
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
              Scenario: Rendering css with a custom images_dir
         
     | 
| 
       38 
38 
     | 
    
         
             
                Given "relative_assets" feature is "enabled"
         
     | 
| 
       39 
39 
     | 
    
         
             
                And "images_dir" is set to "img"
         
     | 
| 
       40 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 40 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       41 
41 
     | 
    
         
             
                When I go to "/relative_image.html"
         
     | 
| 
       42 
42 
     | 
    
         
             
                Then I should not see "/images/blank.gif"
         
     | 
| 
       43 
43 
     | 
    
         
             
                Then I should not see "/img/blank.gif"
         
     | 
| 
         @@ -2,11 +2,11 @@ Feature: Support SCSS Syntax 
     | 
|
| 
       2 
2 
     | 
    
         
             
             In order to offer an alternative when writing Sass
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
             Scenario: Rendering scss
         
     | 
| 
       5 
     | 
    
         
            -
               Given the Server is running
         
     | 
| 
      
 5 
     | 
    
         
            +
               Given the Server is running at "test-app"
         
     | 
| 
       6 
6 
     | 
    
         
             
               When I go to "/stylesheets/site_scss.css"
         
     | 
| 
       7 
7 
     | 
    
         
             
               Then I should see "html"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
             Scenario: Rendering scss
         
     | 
| 
       10 
     | 
    
         
            -
               Given the Server is running
         
     | 
| 
      
 10 
     | 
    
         
            +
               Given the Server is running at "test-app"
         
     | 
| 
       11 
11 
     | 
    
         
             
               When I go to "/stylesheets/layout.css"
         
     | 
| 
       12 
12 
     | 
    
         
             
               Then I should see "html"
         
     | 
    
        data/features/sinatra.feature
    CHANGED
    
    
    
        data/features/slim.feature
    CHANGED
    
    
    
        data/features/sprockets.feature
    CHANGED
    
    
| 
         @@ -1,34 +1,39 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            Given /^a built  
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 3 
     | 
    
         
            +
            Given /^a built app at "([^"]*)"$/ do |path|
         
     | 
| 
      
 4 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 5 
     | 
    
         
            +
              target = File.join(root, "fixtures", path)
         
     | 
| 
      
 6 
     | 
    
         
            +
              build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
         
     | 
| 
      
 7 
     | 
    
         
            +
              `cd #{target} && #{build_cmd}`
         
     | 
| 
       7 
8 
     | 
    
         
             
            end
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
      
 10 
     | 
    
         
            +
            Then /^cleanup built app at "([^"]*)"$/ do |path|
         
     | 
| 
      
 11 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 12 
     | 
    
         
            +
              target = File.join(root, "fixtures", path, "build")
         
     | 
| 
      
 13 
     | 
    
         
            +
              FileUtils.rm_rf(target)
         
     | 
| 
       13 
14 
     | 
    
         
             
            end
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            Given /^ 
     | 
| 
       16 
     | 
    
         
            -
              target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app" 
     | 
| 
       17 
     | 
    
         
            -
               
     | 
| 
      
 16 
     | 
    
         
            +
            Given /^a built test app with flags "([^"]*)"$/ do |flags|
         
     | 
| 
      
 17 
     | 
    
         
            +
              target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
         
     | 
| 
      
 18 
     | 
    
         
            +
              build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "middleman build"))
         
     | 
| 
      
 19 
     | 
    
         
            +
              `cd #{target} && #{build_cmd} #{flags}`
         
     | 
| 
       18 
20 
     | 
    
         
             
            end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            Then /^"([^"]*)" should exist$/ do |target_file 
     | 
| 
       21 
     | 
    
         
            -
               
     | 
| 
      
 22 
     | 
    
         
            +
            Then /^"([^"]*)" should exist at "([^"]*)"$/ do |target_file, path|
         
     | 
| 
      
 23 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 24 
     | 
    
         
            +
              target = File.join(root, "fixtures", path, "build", target_file)
         
     | 
| 
       22 
25 
     | 
    
         
             
              File.exists?(target).should be_true
         
     | 
| 
       23 
26 
     | 
    
         
             
            end
         
     | 
| 
       24 
27 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
            Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected|
         
     | 
| 
       26 
     | 
    
         
            -
               
     | 
| 
      
 28 
     | 
    
         
            +
            Then /^"([^"]*)" should exist at "([^"]*)" and include "([^"]*)"$/ do |target_file, path, expected|
         
     | 
| 
      
 29 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 30 
     | 
    
         
            +
              target = File.join(root, "fixtures", path, "build", target_file)
         
     | 
| 
       27 
31 
     | 
    
         
             
              File.exists?(target).should be_true
         
     | 
| 
       28 
32 
     | 
    
         
             
              File.read(target).should include(expected)
         
     | 
| 
       29 
33 
     | 
    
         
             
            end
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
            Then /^"([^"]*)" should not exist$/ do |target_file|
         
     | 
| 
       32 
     | 
    
         
            -
               
     | 
| 
      
 35 
     | 
    
         
            +
            Then /^"([^"]*)" should not exist at "([^"]*)"$/ do |target_file, path|
         
     | 
| 
      
 36 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 37 
     | 
    
         
            +
              target = File.join(root, "fixtures", path, "build", target_file)
         
     | 
| 
       33 
38 
     | 
    
         
             
              File.exists?(target).should be_false
         
     | 
| 
       34 
39 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,7 +2,7 @@ require 'fileutils' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Given /^generated directory at "([^\"]*)"$/ do |dirname|
         
     | 
| 
       4 
4 
     | 
    
         
             
              target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
         
     | 
| 
       5 
     | 
    
         
            -
              init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", " 
     | 
| 
      
 5 
     | 
    
         
            +
              init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "middleman init"))
         
     | 
| 
       6 
6 
     | 
    
         
             
              `cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}`
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -15,8 +15,10 @@ Given /^current environment is "([^\"]*)"$/ do |env| 
     | 
|
| 
       15 
15 
     | 
    
         
             
              @current_env = env.to_sym
         
     | 
| 
       16 
16 
     | 
    
         
             
            end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            Given /^the Server is running$/ do
         
     | 
| 
      
 18 
     | 
    
         
            +
            Given /^the Server is running at "([^\"]*)"$/ do |app_path|
         
     | 
| 
       19 
19 
     | 
    
         
             
              @server ||= Middleman.server
         
     | 
| 
      
 20 
     | 
    
         
            +
              root = File.dirname(File.dirname(File.dirname(__FILE__)))
         
     | 
| 
      
 21 
     | 
    
         
            +
              @server.set :root, File.join(root, "fixtures", app_path)
         
     | 
| 
       20 
22 
     | 
    
         
             
              @browser = Rack::Test::Session.new(Rack::MockSession.new(@server.new))
         
     | 
| 
       21 
23 
     | 
    
         
             
            end
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
         @@ -1,12 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
         
     | 
| 
       2 
2 
     | 
    
         
             
              @server ||= Middleman.server
         
     | 
| 
       3 
     | 
    
         
            -
              @server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
         
     | 
| 
       4 
3 
     | 
    
         
             
              @server.page(url, :layout => layout.to_sym)
         
     | 
| 
       5 
4 
     | 
    
         
             
            end
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
6 
     | 
    
         
             
            Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
         
     | 
| 
       8 
7 
     | 
    
         
             
              @server ||= Middleman.server
         
     | 
| 
       9 
     | 
    
         
            -
              @server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
         
     | 
| 
       10 
8 
     | 
    
         
             
              @server.with_layout(layout.to_sym) do
         
     | 
| 
       11 
9 
     | 
    
         
             
                page(url)
         
     | 
| 
       12 
10 
     | 
    
         
             
              end
         
     | 
    
        data/features/support/env.rb
    CHANGED
    
    
    
        data/features/tiny_src.feature
    CHANGED
    
    | 
         @@ -4,12 +4,12 @@ Feature: Tiny Src 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              Scenario: Rendering html with the feature disabled
         
     | 
| 
       6 
6 
     | 
    
         
             
                Given "tiny_src" feature is "disabled"
         
     | 
| 
       7 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 7 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       8 
8 
     | 
    
         
             
                When I go to "/tiny_src.html"
         
     | 
| 
       9 
9 
     | 
    
         
             
                Then I should see "http://test.com/image.jpg"
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              Scenario: Rendering html with the feature enabled
         
     | 
| 
       12 
12 
     | 
    
         
             
                Given "tiny_src" feature is "enabled"
         
     | 
| 
       13 
     | 
    
         
            -
                And the Server is running
         
     | 
| 
      
 13 
     | 
    
         
            +
                And the Server is running at "test-app"
         
     | 
| 
       14 
14 
     | 
    
         
             
                When I go to "/tiny_src.html"
         
     | 
| 
       15 
15 
     | 
    
         
             
                Then I should see "http://i.tinysrc.mobi/http://test.com/image.jpg"
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Indexable
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Stay away
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Indexable
         
     | 
    
        data/fixtures/test-app/config.rb
    CHANGED
    
    | 
         @@ -1,5 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            page "/fake.html", :proxy => "/real.html", :layout => false
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ignore "/should_be_ignored.html"
         
     | 
| 
      
 4 
     | 
    
         
            +
            page "/should_be_ignored2.html", :ignore => true
         
     | 
| 
      
 5 
     | 
    
         
            +
            page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       3 
7 
     | 
    
         
             
            %w(one two).each do |num|
         
     | 
| 
       4 
8 
     | 
    
         
             
              page "/fake/#{num}.html", :proxy => "/real/index.html" do
         
     | 
| 
       5 
9 
     | 
    
         
             
                @num = num
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Indexable
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Indexable
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <h1>Ignore me!</h1>
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <h1>Ignore me! 2</h1>
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <h1>Ignore me! 3</h1>
         
     | 
    
        data/lib/middleman.rb
    CHANGED
    
    | 
         @@ -8,10 +8,10 @@ 
     | 
|
| 
       8 
8 
     | 
    
         
             
            #
         
     | 
| 
       9 
9 
     | 
    
         
             
            # To accomplish its goals, Middleman supports provides access to:
         
     | 
| 
       10 
10 
     | 
    
         
             
            # 
         
     | 
| 
       11 
     | 
    
         
            -
            #### Command-line  
     | 
| 
       12 
     | 
    
         
            -
            # * ** 
     | 
| 
       13 
     | 
    
         
            -
            # * ** 
     | 
| 
       14 
     | 
    
         
            -
            # * ** 
     | 
| 
      
 11 
     | 
    
         
            +
            #### Command-line tool:
         
     | 
| 
      
 12 
     | 
    
         
            +
            # * **middleman init**: A tool for creating to new static sites.
         
     | 
| 
      
 13 
     | 
    
         
            +
            # * **middleman server**: A tool for rapidly developing your static site.
         
     | 
| 
      
 14 
     | 
    
         
            +
            # * **middleman build**: A tool for exporting your site into optimized HTML, CSS & JS.
         
     | 
| 
       15 
15 
     | 
    
         
             
            #
         
     | 
| 
       16 
16 
     | 
    
         
             
            #### Tons of templating languages including:
         
     | 
| 
       17 
17 
     | 
    
         
             
            # * ERB                        (.erb)
         
     | 
| 
         @@ -51,13 +51,10 @@ 
     | 
|
| 
       51 
51 
     | 
    
         
             
            # [Email the users group]: http://groups.google.com/group/middleman-users
         
     | 
| 
       52 
52 
     | 
    
         
             
            # [Submit bug reports]:    https://github.com/tdreyno/middleman/issues
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
            # Setup  
     | 
| 
      
 54 
     | 
    
         
            +
            # Setup our load paths
         
     | 
| 
       55 
55 
     | 
    
         
             
            libdir = File.dirname(__FILE__)
         
     | 
| 
       56 
56 
     | 
    
         
             
            $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
            # Require Rubygems (probably not necessary)
         
     | 
| 
       59 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
58 
     | 
    
         
             
            # We're riding on Sinatra, so let's include it.
         
     | 
| 
       62 
59 
     | 
    
         
             
            require "sinatra/base"
         
     | 
| 
       63 
60 
     | 
    
         | 
| 
         @@ -66,6 +63,8 @@ module Middleman 
     | 
|
| 
       66 
63 
     | 
    
         
             
              # Auto-load modules on-demand
         
     | 
| 
       67 
64 
     | 
    
         
             
              autoload :Base,      "middleman/base"
         
     | 
| 
       68 
65 
     | 
    
         
             
              autoload :Builder,   "middleman/builder"
         
     | 
| 
      
 66 
     | 
    
         
            +
              autoload :CLI,       "middleman/cli"
         
     | 
| 
      
 67 
     | 
    
         
            +
              autoload :Templates, "middleman/templates"
         
     | 
| 
       69 
68 
     | 
    
         
             
              autoload :Guard,     "middleman/guard"
         
     | 
| 
       70 
69 
     | 
    
         | 
| 
       71 
70 
     | 
    
         
             
              # Custom Renderers
         
     | 
| 
         @@ -150,6 +149,9 @@ module Middleman 
     | 
|
| 
       150 
149 
     | 
    
         | 
| 
       151 
150 
     | 
    
         
             
                # Automatically resize images for mobile devises
         
     | 
| 
       152 
151 
     | 
    
         
             
                # autoload :TinySrc,             "middleman/features/tiny_src"
         
     | 
| 
      
 152 
     | 
    
         
            +
                
         
     | 
| 
      
 153 
     | 
    
         
            +
                # Automatically convert filename.html files into filename/index.html
         
     | 
| 
      
 154 
     | 
    
         
            +
                autoload :DirectoryIndexes,    "middleman/features/directory_indexes"
         
     | 
| 
       153 
155 
     | 
    
         
             
              end
         
     | 
| 
       154 
156 
     | 
    
         | 
| 
       155 
157 
     | 
    
         
             
              def self.server(&block)
         
     | 
    
        data/lib/middleman/base.rb
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ module Middleman::Base 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                  # Basic Sinatra config
         
     | 
| 
       8 
8 
     | 
    
         
             
                  app.set :app_file,    __FILE__
         
     | 
| 
       9 
     | 
    
         
            -
                  app.set :root,         
     | 
| 
      
 9 
     | 
    
         
            +
                  app.set :root,        Dir.pwd
         
     | 
| 
       10 
10 
     | 
    
         
             
                  app.set :sessions,    false
         
     | 
| 
       11 
11 
     | 
    
         
             
                  app.set :logging,     false
         
     | 
| 
       12 
12 
     | 
    
         
             
                  app.set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
         
     | 
| 
         @@ -86,7 +86,9 @@ module Middleman::Base 
     | 
|
| 
       86 
86 
     | 
    
         
             
                    request_path = request.path_info.gsub("%20", " ")
         
     | 
| 
       87 
87 
     | 
    
         
             
                    result = resolve_template(request_path, :raise_exceptions => false)
         
     | 
| 
       88 
88 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
                     
     | 
| 
      
 89 
     | 
    
         
            +
                    should_be_ignored = !(request["is_proxy"]) && settings.excluded_paths.include?("/#{request_path}")
         
     | 
| 
      
 90 
     | 
    
         
            +
                    
         
     | 
| 
      
 91 
     | 
    
         
            +
                    if result && !should_be_ignored
         
     | 
| 
       90 
92 
     | 
    
         
             
                      extensionless_path, template_engine = result
         
     | 
| 
       91 
93 
     | 
    
         | 
| 
       92 
94 
     | 
    
         
             
                      # Return static files
         
     | 
| 
         @@ -119,6 +121,27 @@ module Middleman::Base 
     | 
|
| 
       119 
121 
     | 
    
         
             
                  super(option, value, &nil)
         
     | 
| 
       120 
122 
     | 
    
         
             
                end
         
     | 
| 
       121 
123 
     | 
    
         | 
| 
      
 124 
     | 
    
         
            +
                def build_reroute(&block)
         
     | 
| 
      
 125 
     | 
    
         
            +
                  @build_rerouters ||= []
         
     | 
| 
      
 126 
     | 
    
         
            +
                  @build_rerouters << block
         
     | 
| 
      
 127 
     | 
    
         
            +
                end
         
     | 
| 
      
 128 
     | 
    
         
            +
                
         
     | 
| 
      
 129 
     | 
    
         
            +
                def reroute_builder(desination, request_path)
         
     | 
| 
      
 130 
     | 
    
         
            +
                  @build_rerouters ||= []
         
     | 
| 
      
 131 
     | 
    
         
            +
                  
         
     | 
| 
      
 132 
     | 
    
         
            +
                  result = [desination, request_path]
         
     | 
| 
      
 133 
     | 
    
         
            +
                  
         
     | 
| 
      
 134 
     | 
    
         
            +
                  @build_rerouters.each do |block|
         
     | 
| 
      
 135 
     | 
    
         
            +
                    output = block.call(desination, request_path)
         
     | 
| 
      
 136 
     | 
    
         
            +
                    if output
         
     | 
| 
      
 137 
     | 
    
         
            +
                      result = output
         
     | 
| 
      
 138 
     | 
    
         
            +
                      break
         
     | 
| 
      
 139 
     | 
    
         
            +
                    end
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
                  
         
     | 
| 
      
 142 
     | 
    
         
            +
                  result
         
     | 
| 
      
 143 
     | 
    
         
            +
                end
         
     | 
| 
      
 144 
     | 
    
         
            +
                
         
     | 
| 
       122 
145 
     | 
    
         
             
                def before_processing(&block)
         
     | 
| 
       123 
146 
     | 
    
         
             
                  @before_processes ||= []
         
     | 
| 
       124 
147 
     | 
    
         
             
                  @before_processes << block
         
     | 
    
        data/lib/middleman/builder.rb
    CHANGED
    
    | 
         @@ -3,8 +3,9 @@ require "thor/group" 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'rack/test'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            SHARED_SERVER = Middleman.server
         
     | 
| 
      
 6 
     | 
    
         
            +
            SHARED_SERVER.set :environment, :build
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            module Middleman 
     | 
| 
      
 8 
     | 
    
         
            +
            module Middleman
         
     | 
| 
       8 
9 
     | 
    
         
             
              module ThorActions
         
     | 
| 
       9 
10 
     | 
    
         
             
                def tilt_template(source, *args, &block)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  config = args.last.is_a?(Hash) ? args.pop : {}
         
     | 
| 
         @@ -12,14 +13,17 @@ module Middleman 
     | 
|
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
                  # source  = File.expand_path(find_in_source_paths(source.to_s))
         
     | 
| 
       14 
15 
     | 
    
         
             
                  context = instance_eval('binding')
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  @@rack_test ||= ::Rack::Test::Session.new(::Rack::MockSession.new(SHARED_SERVER))
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                  request_path = destination.sub(/^#{SHARED_SERVER.build_dir}/, "")
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  begin        
         
     | 
| 
      
 20 
     | 
    
         
            +
                    destination, request_page = SHARED_SERVER.reroute_builder(destination, request_path)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  
         
     | 
| 
      
 22 
     | 
    
         
            +
                    create_file destination, nil, config do
         
     | 
| 
      
 23 
     | 
    
         
            +
                      Middleman::Builder.shared_rack.get(request_path.gsub(/\s/, "%20"))
         
     | 
| 
      
 24 
     | 
    
         
            +
                      Middleman::Builder.shared_rack.last_response.body
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rescue
         
     | 
| 
       23 
27 
     | 
    
         
             
                  end
         
     | 
| 
       24 
28 
     | 
    
         
             
                end
         
     | 
| 
       25 
29 
     | 
    
         
             
              end
         
     | 
| 
         @@ -28,13 +32,20 @@ module Middleman 
     | 
|
| 
       28 
32 
     | 
    
         
             
                include Thor::Actions
         
     | 
| 
       29 
33 
     | 
    
         
             
                include Middleman::ThorActions
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                def self.shared_rack
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @shared_rack ||= begin  
         
     | 
| 
      
 37 
     | 
    
         
            +
                    mock = ::Rack::MockSession.new(SHARED_SERVER)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    sess = ::Rack::Test::Session.new(mock)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    sess.get("/")
         
     | 
| 
      
 40 
     | 
    
         
            +
                    sess
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
                
         
     | 
| 
       31 
44 
     | 
    
         
             
                class_option :relative, :type => :boolean, :aliases => "-r", :default => false, :desc => 'Override the config.rb file and force relative urls'
         
     | 
| 
       32 
45 
     | 
    
         | 
| 
       33 
46 
     | 
    
         
             
                def initialize(*args)
         
     | 
| 
       34 
47 
     | 
    
         
             
                  super
         
     | 
| 
       35 
48 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  SHARED_SERVER.new
         
     | 
| 
       37 
     | 
    
         
            -
                  
         
     | 
| 
       38 
49 
     | 
    
         
             
                  if options.has_key?("relative") && options["relative"]
         
     | 
| 
       39 
50 
     | 
    
         
             
                    SHARED_SERVER.activate :relative_assets
         
     | 
| 
       40 
51 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -47,6 +58,8 @@ module Middleman 
     | 
|
| 
       47 
58 
     | 
    
         
             
                end
         
     | 
| 
       48 
59 
     | 
    
         | 
| 
       49 
60 
     | 
    
         
             
                def build_all_files
         
     | 
| 
      
 61 
     | 
    
         
            +
                  self.class.shared_rack
         
     | 
| 
      
 62 
     | 
    
         
            +
                  
         
     | 
| 
       50 
63 
     | 
    
         
             
                  action Directory.new(self, SHARED_SERVER.views, SHARED_SERVER.build_dir, { :force => true })
         
     | 
| 
       51 
64 
     | 
    
         | 
| 
       52 
65 
     | 
    
         
             
                  SHARED_SERVER.proxied_paths.each do |url, proxy|
         
     |