middleman 3.0.0.alpha.2 → 3.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/.gitignore +2 -0
  2. data/.yardopts +5 -0
  3. data/CHANGELOG +5 -0
  4. data/README.md +3 -0
  5. data/Rakefile +0 -2
  6. data/bin/middleman +36 -33
  7. data/features/auto_layout.feature +37 -0
  8. data/features/builder.feature +1 -0
  9. data/features/chained_templates.feature +15 -0
  10. data/features/content_for.feature +16 -0
  11. data/features/directory_index.feature +1 -0
  12. data/features/front-matter.feature +2 -1
  13. data/features/partials.feature +35 -0
  14. data/features/support/env.rb +3 -3
  15. data/fixtures/chained-app/config.rb +0 -0
  16. data/fixtures/chained-app/data/article.yml +2 -0
  17. data/fixtures/chained-app/source/index.html.markdown.erb +8 -0
  18. data/fixtures/different-engine-layout/config.rb +0 -0
  19. data/fixtures/different-engine-layout/source/index.html.haml +1 -0
  20. data/fixtures/different-engine-layout/source/layout.erb +9 -0
  21. data/fixtures/engine-matching-layout/config.rb +0 -0
  22. data/fixtures/engine-matching-layout/source/index.html.erb +1 -0
  23. data/fixtures/engine-matching-layout/source/layout.erb +9 -0
  24. data/fixtures/indexable-app/source/.htaccess +1 -0
  25. data/fixtures/manual-layout-missing/config.rb +1 -0
  26. data/fixtures/manual-layout-missing/source/index.html.erb +1 -0
  27. data/fixtures/manual-layout-override/config.rb +3 -0
  28. data/fixtures/manual-layout-override/source/index.html.erb +1 -0
  29. data/fixtures/manual-layout-override/source/layouts/another.erb +9 -0
  30. data/fixtures/manual-layout-override/source/layouts/custom.erb +9 -0
  31. data/fixtures/manual-layout/config.rb +1 -0
  32. data/fixtures/manual-layout/source/index.html.erb +1 -0
  33. data/fixtures/manual-layout/source/layouts/custom.erb +9 -0
  34. data/fixtures/multiple-layouts/config.rb +0 -0
  35. data/fixtures/multiple-layouts/source/index.html.erb +1 -0
  36. data/fixtures/multiple-layouts/source/layout.erb +9 -0
  37. data/fixtures/multiple-layouts/source/layout.haml +6 -0
  38. data/fixtures/no-layout/config.rb +0 -0
  39. data/fixtures/no-layout/source/index.html.erb +1 -0
  40. data/fixtures/partials-app/config.rb +0 -0
  41. data/fixtures/partials-app/source/_locals.erb +1 -0
  42. data/fixtures/partials-app/source/_main.erb +1 -0
  43. data/fixtures/partials-app/source/_main.haml +1 -0
  44. data/fixtures/partials-app/source/index.html.erb +3 -0
  45. data/fixtures/partials-app/source/locals.html.erb +1 -0
  46. data/fixtures/partials-app/source/second.html.haml +3 -0
  47. data/fixtures/partials-app/source/shared/_footer.erb +1 -0
  48. data/fixtures/partials-app/source/shared/_header.erb +1 -0
  49. data/fixtures/partials-app/source/sub/_local.erb +1 -0
  50. data/fixtures/partials-app/source/sub/index.html.erb +3 -0
  51. data/fixtures/test-app/config.rb +6 -0
  52. data/fixtures/test-app/source/.htaccess +1 -0
  53. data/fixtures/test-app/source/content_for_erb.html.erb +5 -0
  54. data/fixtures/test-app/source/content_for_haml.html.haml +4 -0
  55. data/fixtures/test-app/source/content_for_slim.html.slim +4 -0
  56. data/fixtures/test-app/source/images/Chrome_Logo.svg +231 -0
  57. data/fixtures/test-app/source/images/cfb_tomb-perennial-energy.svgz +0 -0
  58. data/fixtures/test-app/source/index.html.haml +3 -0
  59. data/fixtures/test-app/source/layouts/content_for.erb +4 -0
  60. data/lib/middleman.rb +90 -105
  61. data/lib/middleman/base.rb +254 -239
  62. data/lib/middleman/builder.rb +51 -46
  63. data/lib/middleman/cache.rb +57 -0
  64. data/lib/middleman/cli.rb +7 -10
  65. data/lib/middleman/core_extensions/assets.rb +3 -3
  66. data/lib/middleman/core_extensions/compass.rb +25 -45
  67. data/lib/middleman/core_extensions/data.rb +14 -12
  68. data/lib/middleman/core_extensions/default_helpers.rb +11 -10
  69. data/lib/middleman/core_extensions/{features.rb → extensions.rb} +66 -20
  70. data/lib/middleman/core_extensions/front_matter.rb +16 -13
  71. data/lib/middleman/core_extensions/rendering.rb +224 -4
  72. data/lib/middleman/core_extensions/routing.rb +15 -12
  73. data/lib/middleman/core_extensions/sitemap.rb +6 -191
  74. data/lib/middleman/core_extensions/sprockets.rb +3 -2
  75. data/lib/middleman/extensions/asset_host.rb +34 -0
  76. data/lib/middleman/extensions/automatic_image_sizes.rb +38 -0
  77. data/lib/middleman/{features → extensions}/automatic_image_sizes/fastimage.rb +0 -0
  78. data/lib/middleman/extensions/cache_buster.rb +59 -0
  79. data/lib/middleman/extensions/directory_indexes.rb +62 -0
  80. data/lib/middleman/extensions/lorem.rb +130 -0
  81. data/lib/middleman/extensions/minify_css.rb +15 -0
  82. data/lib/middleman/{features → extensions}/minify_css/cssmin.rb +0 -0
  83. data/lib/middleman/extensions/minify_javascript.rb +54 -0
  84. data/lib/middleman/extensions/relative_assets.rb +46 -0
  85. data/lib/middleman/extensions/sitemap_tree.rb +38 -0
  86. data/lib/middleman/guard.rb +48 -35
  87. data/lib/middleman/renderers/erb.rb +3 -13
  88. data/lib/middleman/renderers/haml.rb +13 -0
  89. data/lib/middleman/renderers/liquid.rb +3 -3
  90. data/lib/middleman/renderers/markdown.rb +10 -12
  91. data/lib/middleman/renderers/sass.rb +3 -9
  92. data/lib/middleman/sitemap/page.rb +106 -0
  93. data/lib/middleman/sitemap/store.rb +141 -0
  94. data/lib/middleman/sitemap/template.rb +57 -0
  95. data/lib/middleman/step_definitions.rb +6 -0
  96. data/lib/middleman/step_definitions/builder_steps.rb +45 -0
  97. data/{features → lib/middleman}/step_definitions/generator_steps.rb +6 -6
  98. data/{features/step_definitions/middleman_steps.rb → lib/middleman/step_definitions/server_steps.rb} +3 -3
  99. data/lib/middleman/templates/default/source/index.html.erb +1 -1
  100. data/lib/middleman/version.rb +7 -1
  101. data/middleman-x86-mingw32.gemspec +1 -1
  102. data/middleman.gemspec +5 -3
  103. metadata +359 -381
  104. data/bin/mm-build +0 -9
  105. data/bin/mm-init +0 -9
  106. data/bin/mm-server +0 -9
  107. data/features/step_definitions/builder_steps.rb +0 -52
  108. data/features/tiny_src.feature +0 -15
  109. data/lib/middleman/features/asset_host.rb +0 -32
  110. data/lib/middleman/features/automatic_image_sizes.rb +0 -34
  111. data/lib/middleman/features/cache_buster.rb +0 -55
  112. data/lib/middleman/features/directory_indexes.rb +0 -59
  113. data/lib/middleman/features/lorem.rb +0 -126
  114. data/lib/middleman/features/minify_css.rb +0 -11
  115. data/lib/middleman/features/minify_javascript.rb +0 -50
  116. data/lib/middleman/features/relative_assets.rb +0 -42
  117. data/lib/middleman/features/sitemap_tree.rb +0 -34
data/.gitignore CHANGED
@@ -12,3 +12,5 @@ docs
12
12
  fixtures/test-app/build
13
13
  .*.swp
14
14
  build
15
+ doc
16
+ .yardoc
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ --exclude lib/middleman/vendor
3
+ --exclude lib/middleman/extensions/automatic_image_sizes/fastimage.rb
4
+ --exclude lib/middleman/extensions/minify_css/cssmin.rb
5
+ --no-private
data/CHANGELOG CHANGED
@@ -1,6 +1,11 @@
1
1
  3.0.pre
2
2
  ====
3
3
  Rewritten to work directly with Rack (Sinatra apps can still be mounted)
4
+ Sitemap maintains own state
5
+ New Extension Registration API
6
+ Remove old 1.x mm- binaries and messaging
7
+ New default layout functionality: https://github.com/tdreyno/middleman/issues/165
8
+ Enable chained templates outside of sprockets (file.html.markdown.erb)
4
9
 
5
10
  2.1.pre
6
11
  ====
data/README.md CHANGED
@@ -14,6 +14,9 @@ http://middlemanapp.com
14
14
 
15
15
  If you have questions, answers can be found on community forum: https://convore.com/middleman/
16
16
 
17
+ ## Generated Source Documentation
18
+ http://rubydoc.info/github/tdreyno/middleman/master/frames
19
+
17
20
  ## Copyright
18
21
 
19
22
  Copyright (c) 2010 Thomas Reynolds. See LICENSE for details.
data/Rakefile CHANGED
@@ -7,8 +7,6 @@ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
7
  t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
8
8
  end
9
9
 
10
- #$LOAD_PATH.unshift 'lib'
11
-
12
10
  require 'rake/testtask'
13
11
  require 'rake/clean'
14
12
 
data/bin/middleman CHANGED
@@ -8,48 +8,50 @@ require 'rubygems'
8
8
 
9
9
  module Middleman
10
10
  module ProjectLocator
11
- def self.locate_middleman_root!(args)
12
- cwd = Dir.pwd
11
+ class << self
12
+ def locate_middleman_root!(args)
13
+ cwd = Dir.pwd
13
14
 
14
- if !in_middleman_project? && !in_middleman_project_subdirectory?
15
- $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
16
- return
17
- end
15
+ if !in_middleman_project? && !in_middleman_project_subdirectory?
16
+ $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
17
+ return
18
+ end
18
19
 
19
- if in_middleman_project?
20
- did_locate_middleman_project(cwd, args)
21
- return
22
- end
20
+ if in_middleman_project?
21
+ did_locate_middleman_project(cwd, args)
22
+ return
23
+ end
23
24
 
24
- Dir.chdir("..") do
25
- # Recurse in a chdir block: if the search fails we want to be sure
26
- # the application is generated in the original working directory.
27
- locate_middleman_root!(args) unless cwd == Dir.pwd
25
+ Dir.chdir("..") do
26
+ # Recurse in a chdir block: if the search fails we want to be sure
27
+ # the application is generated in the original working directory.
28
+ locate_middleman_root!(args) unless cwd == Dir.pwd
29
+ end
30
+ rescue SystemCallError
31
+ # could not chdir, no problem just return
28
32
  end
29
- rescue SystemCallError
30
- # could not chdir, no problem just return
31
- end
32
33
 
33
- def self.in_middleman_project?
34
- File.exists?('config.rb')
35
- end
34
+ def in_middleman_project?
35
+ File.exists?('config.rb')
36
+ end
36
37
 
37
- def self.in_middleman_project_subdirectory?(path = Pathname.new(Dir.pwd))
38
- File.exists?(File.join(path, 'config.rb')) || !path.root? && in_middleman_project_subdirectory?(path.parent)
39
- end
38
+ def in_middleman_project_subdirectory?(path = Pathname.new(Dir.pwd))
39
+ File.exists?(File.join(path, 'config.rb')) || !path.root? && in_middleman_project_subdirectory?(path.parent)
40
+ end
40
41
 
41
- def self.did_locate_middleman_project(path, args)
42
- # Set up gems listed in the Gemfile.
43
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', path)
42
+ def did_locate_middleman_project(path, args)
43
+ # Set up gems listed in the Gemfile.
44
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', path)
44
45
 
45
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
46
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
46
47
 
47
- start_cli!(args)
48
- end
48
+ start_cli!(args)
49
+ end
49
50
 
50
- def self.start_cli!(args)
51
- require 'middleman'
52
- Middleman::CLI.start(args)
51
+ def start_cli!(args)
52
+ require 'middleman'
53
+ Middleman::CLI.start(args)
54
+ end
53
55
  end
54
56
  end
55
57
  end
@@ -59,7 +61,8 @@ args = ARGV.dup
59
61
  ARG_ALIASES = {
60
62
  "s" => "server",
61
63
  "b" => "build",
62
- "i" => "init"
64
+ "i" => "init",
65
+ "w" => "watch"
63
66
  }
64
67
 
65
68
  if ARG_ALIASES.has_key?(args[0])
@@ -0,0 +1,37 @@
1
+ Feature: Provide Sane Defaults for Layout Behavior
2
+
3
+ Scenario: Template and Layout of same engine exist
4
+ Given the Server is running at "engine-matching-layout"
5
+ When I go to "/index.html"
6
+ Then I should see "Comment in layout"
7
+
8
+ Scenario: Template and Layout of different engine
9
+ Given the Server is running at "different-engine-layout"
10
+ When I go to "/index.html"
11
+ Then I should see "Comment in layout"
12
+
13
+ Scenario: Multiple layouts exist, prefer same engine
14
+ Given the Server is running at "multiple-layouts"
15
+ When I go to "/index.html"
16
+ Then I should see "ERb Comment in layout"
17
+
18
+ Scenario: No layout exists
19
+ Given the Server is running at "no-layout"
20
+ When I go to "/index.html"
21
+ Then I should not see "Comment in layout"
22
+
23
+ Scenario: Manually set default layout in config (exists)
24
+ Given the Server is running at "manual-layout"
25
+ When I go to "/index.html"
26
+ Then I should see "Custom Comment in layout"
27
+
28
+ Scenario: Manually set default layout in config (does not exist)
29
+ Given the Server is running at "manual-layout-missing"
30
+ When I go to "/index.html"
31
+ Then I should see "Error"
32
+
33
+ Scenario: Overwrite manual layout
34
+ Given the Server is running at "manual-layout-override"
35
+ When I go to "/index.html"
36
+ Then I should see "Another Comment in layout"
37
+
@@ -15,6 +15,7 @@ Feature: Builder
15
15
  Then "spaces in file.html" should exist at "test-app" and include "spaces"
16
16
  Then "images/Read me (example).txt" should exist at "test-app"
17
17
  Then "images/Child folder/regular_file(example).txt" should exist at "test-app"
18
+ Then ".htaccess" should exist at "test-app"
18
19
 
19
20
  Scenario: Build glob
20
21
  Given a built app at "glob-app" with flags "--glob '*.css'"
@@ -0,0 +1,15 @@
1
+ Feature: Templates should be chainable
2
+ In order to insert variables and data in "static" engines
3
+
4
+ Scenario: Data in Erb in Markdown
5
+ Given the Server is running at "chained-app"
6
+ When I go to "/index.html"
7
+ Then I should see "Title</h1>"
8
+ And I should see "Subtitle</h2>"
9
+ And I should see "Sup</h3>"
10
+
11
+ Scenario: Build chained template
12
+ Given a built app at "chained-app"
13
+ Then "index.html" should exist at "chained-app" and include "Title</h1>"
14
+ Then "index.html" should exist at "chained-app" and include "Subtitle</h2>"
15
+ Then "index.html" should exist at "chained-app" and include "Sup</h3>"
@@ -0,0 +1,16 @@
1
+ Feature: Support content_for and yield_content helpers
2
+
3
+ Scenario: content_for works as expected in erb
4
+ Given the Server is running at "test-app"
5
+ When I go to "/content_for_erb.html"
6
+ Then I should see "In Layout: I am the yielded content erb"
7
+
8
+ Scenario: content_for works as expected in haml
9
+ Given the Server is running at "test-app"
10
+ When I go to "/content_for_haml.html"
11
+ Then I should see "In Layout: I am the yielded content haml"
12
+
13
+ Scenario: content_for works as expected in slim
14
+ Given the Server is running at "test-app"
15
+ When I go to "/content_for_slim.html"
16
+ Then I should see "In Layout: I am the yielded content slim"
@@ -11,6 +11,7 @@ Feature: Directory Index
11
11
  Then "needs_index.html" should not exist at "indexable-app"
12
12
  Then "a_folder/needs_index.html" should not exist at "indexable-app"
13
13
  Then "leave_me_alone/index.html" should not exist at "indexable-app"
14
+ Then ".htaccess" should exist at "indexable-app"
14
15
 
15
16
  Scenario: Preview normal file
16
17
  Given the Server is running at "indexable-app"
@@ -4,4 +4,5 @@ Feature: YAML Front Matter
4
4
  Scenario: Rendering html
5
5
  Given the Server is running at "test-app"
6
6
  When I go to "/front-matter.html"
7
- Then I should see "<h1>This is the title</h1>"
7
+ Then I should see "<h1>This is the title</h1>"
8
+ Then I should not see "---"
@@ -0,0 +1,35 @@
1
+ Feature: Provide Sane Defaults for Partial Behavior
2
+
3
+ Scenario: Finds shared partials relative to the root
4
+ Given the Server is running at "partials-app"
5
+ When I go to "/index.html"
6
+ Then I should see "Header"
7
+ And I should see "Footer"
8
+
9
+ Scenario: Finds shared partials relative to the root (sub)
10
+ Given the Server is running at "partials-app"
11
+ When I go to "/sub/index.html"
12
+ Then I should see "Header"
13
+ And I should see "Footer"
14
+
15
+ Scenario: Prefers partials of the same engine type
16
+ Given the Server is running at "partials-app"
17
+ When I go to "/index.html"
18
+ Then I should see "ERb Main"
19
+
20
+ Scenario: Prefers partials of the same engine type
21
+ Given the Server is running at "partials-app"
22
+ When I go to "/second.html"
23
+ Then I should see "Haml Main"
24
+ And I should see "Header"
25
+ And I should see "Footer"
26
+
27
+ Scenario: Finds partial relative to template
28
+ Given the Server is running at "partials-app"
29
+ When I go to "/sub/index.html"
30
+ Then I should see "Local Partial"
31
+
32
+ Scenario: Partials can be passed locals
33
+ Given the Server is running at "partials-app"
34
+ When I go to "/locals.html"
35
+ Then I should see "Local var is bar"
@@ -1,3 +1,3 @@
1
- root_path = File.dirname(File.dirname(File.dirname(__FILE__)))
2
- require File.join(root_path, 'lib', 'middleman')
3
- require "rack/test"
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman')
3
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman', 'step_definitions')
File without changes
@@ -0,0 +1,2 @@
1
+ title: "Title"
2
+ subtitle: "Subtitle"
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: false
3
+ sup: "Sup"
4
+ ---
5
+
6
+ # <%= data.article.title %>
7
+ ## <%= data.article.subtitle %>
8
+ ### <%= data.page.sup %>
File without changes
@@ -0,0 +1 @@
1
+ %h1 Welcome
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1 @@
1
+ # I'm an htaccess file!
@@ -0,0 +1 @@
1
+ set :layout, :custom
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,3 @@
1
+ set :layout, :custom
2
+
3
+ page "/", :layout => :another
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Another Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Custom Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1 @@
1
+ set :layout, :custom
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Custom Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- ERb Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,6 @@
1
+ %html
2
+ %head
3
+ %title My Sample Site
4
+ / Haml Comment in layout
5
+ %body
6
+ = yield
File without changes
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
File without changes
@@ -0,0 +1 @@
1
+ Local var is <%= foo %>
@@ -0,0 +1 @@
1
+ ERb Main
@@ -0,0 +1 @@
1
+ Haml Main
@@ -0,0 +1,3 @@
1
+ <%= partial "shared/header" %>
2
+ <%= partial "main" %>
3
+ <%= partial "shared/footer" %>