middleman 3.0.0.alpha.3 → 3.0.0.alpha.4

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 +1 -2
  2. data/.yardopts +2 -0
  3. data/CHANGELOG.md +97 -0
  4. data/README.md +84 -13
  5. data/Rakefile +6 -2
  6. data/bin/middleman +5 -4
  7. data/features/builder.feature +7 -0
  8. data/features/clean_build.feature +11 -0
  9. data/features/current_page_request_path_backwards.feature +6 -0
  10. data/features/front-matter.feature +28 -1
  11. data/features/generator.feature +4 -4
  12. data/features/helpers_external.feature +6 -0
  13. data/features/helpers_lorem.feature +5 -0
  14. data/features/instance_vars.feature +20 -0
  15. data/features/markdown.feature +23 -3
  16. data/features/minify_css.feature +6 -1
  17. data/features/minify_javascript.feature +33 -1
  18. data/features/mount_rack.feature +8 -0
  19. data/features/partials.feature +7 -1
  20. data/features/preview_changes.feature +18 -0
  21. data/features/wildcard_page_helper.feature +19 -0
  22. data/fixtures/build-with-errors-app/config.rb +1 -0
  23. data/fixtures/build-with-errors-app/source/index.html.erb +1 -0
  24. data/fixtures/clean-app/source/index.html.haml +1 -6
  25. data/fixtures/clean-dir-app/config.rb +2 -0
  26. data/fixtures/clean-dir-app/source/about.html +1 -0
  27. data/fixtures/different-engine-partial/config.rb +0 -0
  28. data/fixtures/different-engine-partial/source/index.html.erb +1 -0
  29. data/fixtures/different-engine-partial/source/layouts/layout.erb +7 -0
  30. data/fixtures/different-engine-partial/source/shared/_footer.slim +1 -0
  31. data/fixtures/different-engine-partial/source/shared/_header.erb +1 -0
  32. data/fixtures/external-helpers/config.rb +4 -0
  33. data/fixtures/external-helpers/lib/hello_helper.rb +5 -0
  34. data/fixtures/external-helpers/source/index.html.erb +1 -0
  35. data/fixtures/instance-vars-app/config.rb +0 -0
  36. data/fixtures/instance-vars-app/source/_vartial.erb +5 -0
  37. data/fixtures/instance-vars-app/source/instance-var-set.html.erb +2 -0
  38. data/fixtures/instance-vars-app/source/layout.erb +3 -0
  39. data/fixtures/instance-vars-app/source/no-instance-var.html.erb +1 -0
  40. data/fixtures/markdown-app/config.rb +9 -0
  41. data/fixtures/markdown-app/source/autolink.html.markdown +5 -0
  42. data/fixtures/markdown-app/source/fenced_code_blocks.html.markdown +7 -0
  43. data/fixtures/markdown-app/source/index.html.markdown +4 -0
  44. data/fixtures/markdown-app/source/no_intra_emphasis.html.markdown +5 -0
  45. data/fixtures/markdown-app/source/smarty_pants.html.markdown +5 -0
  46. data/fixtures/markdown-app/source/space_after_headers.html.markdown +5 -0
  47. data/fixtures/markdown-app/source/strikethrough.html.markdown +5 -0
  48. data/fixtures/markdown-app/source/superscript.html.markdown +5 -0
  49. data/fixtures/markdown-app/source/tables.html.markdown +8 -0
  50. data/fixtures/passthrough-app/config.rb +17 -0
  51. data/fixtures/passthrough-app/source/.htaccess +1 -0
  52. data/fixtures/passthrough-app/source/inline-coffeescript.html.haml +3 -0
  53. data/fixtures/passthrough-app/source/inline-css.html.haml +4 -0
  54. data/fixtures/passthrough-app/source/inline-js.html.haml +7 -0
  55. data/fixtures/passthrough-app/source/javascripts/coffee_test.js.coffee +3 -0
  56. data/fixtures/passthrough-app/source/javascripts/js_test.js +8 -0
  57. data/fixtures/passthrough-app/source/stylesheets/site.css.sass +1 -0
  58. data/fixtures/preview-app/config.rb +0 -0
  59. data/fixtures/preview-app/source/content.html.erb +1 -0
  60. data/fixtures/preview-app/source/layout.erb +1 -0
  61. data/fixtures/sinatra-app/config.rb +11 -0
  62. data/fixtures/sinatra-app/source/index.html.erb +5 -0
  63. data/fixtures/test-app/config.rb +2 -2
  64. data/fixtures/test-app/source/front-matter-2.php.erb +7 -0
  65. data/fixtures/test-app/source/front-matter-change.html.erb +5 -0
  66. data/fixtures/test-app/source/index.html.slim +9 -0
  67. data/fixtures/test-app/source/javascripts/js_test.js +8 -0
  68. data/fixtures/test-app/source/lorem.html.erb +12 -0
  69. data/fixtures/test-app/source/request-path.html.erb +1 -0
  70. data/fixtures/wildcard-app/config.rb +1 -0
  71. data/fixtures/wildcard-app/source/admin/index.html.erb +1 -0
  72. data/fixtures/wildcard-app/source/admin/page.html.erb +1 -0
  73. data/fixtures/wildcard-app/source/index.html.erb +1 -0
  74. data/fixtures/wildcard-app/source/layouts/admin.erb +2 -0
  75. data/fixtures/wildcard-app/source/layouts/layout.erb +2 -0
  76. data/fixtures/wildcard-directory-index-app/config.rb +2 -0
  77. data/fixtures/wildcard-directory-index-app/source/admin/index.html.erb +1 -0
  78. data/fixtures/wildcard-directory-index-app/source/admin/page.html.erb +1 -0
  79. data/fixtures/wildcard-directory-index-app/source/index.html.erb +1 -0
  80. data/fixtures/wildcard-directory-index-app/source/layouts/admin.erb +2 -0
  81. data/fixtures/wildcard-directory-index-app/source/layouts/layout.erb +2 -0
  82. data/lib/middleman.rb +63 -8
  83. data/lib/middleman/base.rb +56 -12
  84. data/lib/middleman/builder.rb +18 -12
  85. data/lib/middleman/cli.rb +5 -5
  86. data/lib/middleman/core_extensions/assets.rb +12 -0
  87. data/lib/middleman/core_extensions/builder.rb +4 -4
  88. data/lib/middleman/core_extensions/extensions.rb +5 -51
  89. data/lib/middleman/core_extensions/front_matter.rb +30 -11
  90. data/lib/middleman/core_extensions/rendering.rb +18 -12
  91. data/lib/middleman/core_extensions/routing.rb +12 -0
  92. data/lib/middleman/core_extensions/show_exceptions.rb +16 -0
  93. data/lib/middleman/core_extensions/sitemap.rb +10 -4
  94. data/lib/middleman/extensions/minify_css.rb +4 -2
  95. data/lib/middleman/extensions/minify_javascript.rb +8 -6
  96. data/lib/middleman/guard.rb +80 -76
  97. data/lib/middleman/renderers/markdown.rb +8 -13
  98. data/lib/middleman/sitemap/page.rb +3 -2
  99. data/lib/middleman/sitemap/store.rb +3 -1
  100. data/lib/middleman/sitemap/template.rb +19 -5
  101. data/lib/middleman/step_definitions.rb +1 -0
  102. data/lib/middleman/step_definitions/builder_steps.rb +6 -1
  103. data/lib/middleman/step_definitions/generator_steps.rb +9 -13
  104. data/lib/middleman/step_definitions/middleman_steps.rb +13 -0
  105. data/lib/middleman/step_definitions/server_steps.rb +7 -0
  106. data/lib/middleman/templates.rb +42 -21
  107. data/lib/middleman/templates/default.rb +5 -0
  108. data/lib/middleman/templates/html5.rb +6 -0
  109. data/lib/middleman/templates/local.rb +5 -6
  110. data/lib/middleman/templates/mobile.rb +6 -0
  111. data/lib/middleman/version.rb +1 -1
  112. data/middleman-x86-mingw32.gemspec +1 -1
  113. data/middleman.gemspec +3 -2
  114. metadata +531 -242
  115. data/CHANGELOG +0 -98
  116. data/fixtures/test-app/source/index.html.haml +0 -9
  117. data/fixtures/test-app/source/markdown.html.markdown +0 -1
@@ -0,0 +1,8 @@
1
+ Feature: Support Rack apps mounted using map
2
+
3
+ Scenario: Mounted Rack App at /sinatra
4
+ Given the Server is running at "sinatra-app"
5
+ When I go to "/"
6
+ Then I should see "Hello World (Middleman)"
7
+ When I go to "/sinatra/"
8
+ Then I should see "Hello World (Sinatra)"
@@ -32,4 +32,10 @@ Feature: Provide Sane Defaults for Partial Behavior
32
32
  Scenario: Partials can be passed locals
33
33
  Given the Server is running at "partials-app"
34
34
  When I go to "/locals.html"
35
- Then I should see "Local var is bar"
35
+ Then I should see "Local var is bar"
36
+
37
+ Scenario: Partial and Layout use different engines
38
+ Given the Server is running at "different-engine-partial"
39
+ When I go to "/index.html"
40
+ Then I should see "ERb Header"
41
+ And I should see "Slim Footer"
@@ -0,0 +1,18 @@
1
+ Feature: Preview Changes
2
+ In order to run quickly, we should update internal caches on file changes
3
+
4
+ Scenario: A template changes contents during preview
5
+ Given the Server is running at "preview-app"
6
+ And the file "source/content.html.erb" has the contents
7
+ """
8
+ Hello World
9
+ """
10
+ When I go to "/content.html"
11
+ Then I should see "Hello World"
12
+ And the file "source/content.html.erb" has the contents
13
+ """
14
+ Hola Mundo
15
+ """
16
+ When I go to "/content.html"
17
+ Then I should see "Hola Mundo"
18
+
@@ -0,0 +1,19 @@
1
+ Feature: Wildcards in Page helper
2
+
3
+ Scenario: Setting the layout for a folder
4
+ Given the Server is running at "wildcard-app"
5
+ When I go to "/index.html"
6
+ Then I should see "Normal Layout"
7
+ When I go to "/admin/index.html"
8
+ Then I should see "Admin Layout"
9
+ When I go to "/admin/page.html"
10
+ Then I should see "Admin Layout"
11
+
12
+ Scenario: Setting the layout for a folder
13
+ Given the Server is running at "wildcard-directory-index-app"
14
+ When I go to "/"
15
+ Then I should see "Normal Layout"
16
+ When I go to "/admin/"
17
+ Then I should see "Admin Layout"
18
+ When I go to "/admin/page.html"
19
+ Then I should see "Admin Layout"
@@ -0,0 +1 @@
1
+ set :layout, false
@@ -0,0 +1 @@
1
+ <%= error_error_error %>
@@ -1,6 +1 @@
1
- %h1 Welcome
2
-
3
- :markdown
4
- ## H2
5
-
6
- Paragraph
1
+ h1 Welcome
@@ -0,0 +1,2 @@
1
+
2
+ activate :directory_indexes
@@ -0,0 +1 @@
1
+ Fun times
@@ -0,0 +1,7 @@
1
+ <%= partial 'shared/header' %>
2
+
3
+ <div id="main">
4
+ <%= yield %>
5
+ </div>
6
+
7
+ <%= partial 'shared/footer' %>
@@ -0,0 +1 @@
1
+ <header>ERb Header</header>
@@ -0,0 +1,4 @@
1
+ require "lib/hello_helper"
2
+ helpers HelloHelper
3
+
4
+ page "/", :layout => false
@@ -0,0 +1,5 @@
1
+ module HelloHelper
2
+ def hello
3
+ "Hello World"
4
+ end
5
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ <% if @my_var %>
2
+ My var is here!
3
+ <% else %>
4
+ No var...
5
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <% @my_var = 100 %>
2
+ <%= partial 'vartial' %>
@@ -0,0 +1,3 @@
1
+ Var is <%= @my_var %>
2
+
3
+ <%= yield %>
@@ -0,0 +1 @@
1
+ <%= partial 'vartial' %>
@@ -0,0 +1,9 @@
1
+ set :markdown, :smartypants => true,
2
+ :no_intra_emphasis => true,
3
+ :tables => true,
4
+ :fenced_code_blocks => true,
5
+ :autolink => true,
6
+ :strikethrough => true,
7
+ :lax_html_blocks => true,
8
+ :space_after_headers => true,
9
+ :superscript => true
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ http://example.com
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ ~~~~~~~~~~~~~~~~~~~~~
6
+ a one-line code block
7
+ ~~~~~~~~~~~~~~~~~~~~~
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+ Hello World
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ foo_bar_baz
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ "Hello"
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ #this is my header
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ ~~Nope~~
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ this is the 2^(nd) time
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ First Header | Second Header
6
+ ------------- | -------------
7
+ Content Cell | Content Cell
8
+ Content Cell | Content Cell
@@ -0,0 +1,17 @@
1
+ module ::PassThrough
2
+ def self.compress(data)
3
+ data
4
+ end
5
+ end
6
+
7
+ set :js_compressor, ::PassThrough
8
+ set :css_compressor, ::PassThrough
9
+
10
+ activate :minify_javascript
11
+ activate :minify_css
12
+
13
+ with_layout false do
14
+ page "/inline-css.html"
15
+ page "/inline-js.html"
16
+ page "/inline-coffeescript.html"
17
+ end
@@ -0,0 +1 @@
1
+ # I'm an htaccess file!
@@ -0,0 +1,3 @@
1
+ :coffeescript
2
+ race = (winner, runners...) ->
3
+ print winner, runners
@@ -0,0 +1,4 @@
1
+ :sass
2
+ body
3
+ test: style
4
+ good: deal
@@ -0,0 +1,7 @@
1
+ :javascript
2
+ ;(function() {
3
+ this;
4
+ should();
5
+ all.be();
6
+ on = { one: line };
7
+ })();
@@ -0,0 +1,3 @@
1
+ # Splats:
2
+ race = (winner, runners...) ->
3
+ print winner, runners
@@ -0,0 +1,8 @@
1
+ var race;
2
+ var __slice = Array.prototype.slice;
3
+
4
+ race = function() {
5
+ var runners, winner;
6
+ winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
7
+ return print(winner, runners);
8
+ };
@@ -0,0 +1 @@
1
+ @import "compass/reset"
File without changes
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,11 @@
1
+ require "sinatra"
2
+
3
+ class MySinatra < Sinatra::Base
4
+ get "/" do
5
+ "Hello World (Sinatra)"
6
+ end
7
+ end
8
+
9
+ map "/sinatra" do
10
+ run MySinatra
11
+ end
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ Hello World (Middleman)
@@ -1,4 +1,3 @@
1
- require "maruku"
2
1
  require "slim"
3
2
  require "liquid"
4
3
  require "coffee-filter"
@@ -22,7 +21,8 @@ with_layout :content_for do
22
21
  end
23
22
 
24
23
  with_layout false do
25
- page "/markdown.html"
24
+ page "/request-path.html"
25
+ page "/lorem.html"
26
26
  page "/relative_image.html"
27
27
  page "/inline-css.html"
28
28
  page "/inline-js.html"
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: false
3
+ title: This is the title
4
+ ---
5
+
6
+ <h1><%= data.page.title %></h1>
7
+ <?php echo "sup"; ?>
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Hola Mundo
3
+ layout: false
4
+ ---
5
+ <%= data.page.title %>
@@ -0,0 +1,9 @@
1
+ h1 Welcome
2
+
3
+ == image_tag "Chrome_Logo.svg"
4
+ == image_tag "cfb_tomb-perennial-energy.svgz"
5
+
6
+ markdown:
7
+ ## H2
8
+
9
+ Paragraph
@@ -0,0 +1,8 @@
1
+ var race;
2
+ var __slice = Array.prototype.slice;
3
+
4
+ race = function() {
5
+ var runners, winner;
6
+ winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
7
+ return print(winner, runners);
8
+ };
@@ -0,0 +1,12 @@
1
+ <%= lorem.word %>
2
+ <%= lorem.words(5) %>
3
+ <%= lorem.sentence %>
4
+ <%= lorem.sentences(2) %>
5
+ <%= lorem.paragraph %>
6
+ <%= lorem.paragraphs(2) %>
7
+ <%= lorem.date %>
8
+ <%= lorem.name %>
9
+ <%= lorem.first_name %>
10
+ <%= lorem.last_name %>
11
+ <%= lorem.email %>
12
+ <%= lorem.image(100) %>
@@ -0,0 +1 @@
1
+ <%= current_path == request.path %>
@@ -0,0 +1 @@
1
+ page "/admin/*", :layout => :admin
@@ -0,0 +1,2 @@
1
+ Admin Layout
2
+ <%= yield %>
@@ -0,0 +1,2 @@
1
+ Normal Layout
2
+ <%= yield %>
@@ -0,0 +1,2 @@
1
+ activate :directory_indexes
2
+ page "/admin/*", :layout => :admin
@@ -0,0 +1,2 @@
1
+ Admin Layout
2
+ <%= yield %>
@@ -0,0 +1,2 @@
1
+ Normal Layout
2
+ <%= yield %>
@@ -5,12 +5,12 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
5
5
  # Top-level Middleman object
6
6
  module Middleman
7
7
  # Auto-load modules on-demand
8
- autoload :Base, "middleman/base"
9
- autoload :Cache, "middleman/cache"
10
- autoload :Builder, "middleman/builder"
11
- autoload :CLI, "middleman/cli"
12
- autoload :Templates, "middleman/templates"
13
- autoload :Guard, "middleman/guard"
8
+ autoload :Base, "middleman/base"
9
+ autoload :Cache, "middleman/cache"
10
+ autoload :Builder, "middleman/builder"
11
+ autoload :CLI, "middleman/cli"
12
+ autoload :Templates, "middleman/templates"
13
+ autoload :Guard, "middleman/guard"
14
14
 
15
15
  # Custom Renderers
16
16
  module Renderers
@@ -57,13 +57,16 @@ module Middleman
57
57
  autoload :Rendering, "middleman/core_extensions/rendering"
58
58
 
59
59
  # Compass framework for Sass
60
- autoload :Compass, "middleman/core_extensions/compass"
60
+ autoload :Compass, "middleman/core_extensions/compass"
61
61
 
62
62
  # Sprockets 2
63
- autoload :Sprockets, "middleman/core_extensions/sprockets"
63
+ autoload :Sprockets, "middleman/core_extensions/sprockets"
64
64
 
65
65
  # Pass custom options to views
66
66
  autoload :Routing, "middleman/core_extensions/routing"
67
+
68
+ # Catch and show exceptions at the Rack level
69
+ autoload :ShowExceptions, "middleman/core_extensions/show_exceptions"
67
70
  end
68
71
 
69
72
  module Extensions
@@ -100,6 +103,52 @@ module Middleman
100
103
 
101
104
  # Organize the sitemap as a tree
102
105
  autoload :SitemapTree, "middleman/extensions/sitemap_tree"
106
+
107
+ class << self
108
+ def registered
109
+ @_registered ||= {}
110
+ end
111
+
112
+ def register(name, namespace=nil, version=nil, &block)
113
+ # If we've already got a matching extension that passed the
114
+ # version check, bail out.
115
+ return if registered.has_key?(name.to_sym) &&
116
+ !registered[name.to_sym].is_a?(String)
117
+
118
+ if block_given?
119
+ version = namespace
120
+ end
121
+
122
+ passed_version_check = true
123
+ if !version.nil?
124
+ requirement = ::Gem::Requirement.create(version)
125
+ if !requirement.satisfied_by?(Middleman::GEM_VERSION)
126
+ passed_version_check = false
127
+ end
128
+ end
129
+
130
+ registered[name.to_sym] = if !passed_version_check
131
+ "== #{name} failed version check. Requested #{version}, got #{Middleman::VERSION}"
132
+ elsif block_given?
133
+ block
134
+ elsif namespace
135
+ namespace
136
+ end
137
+ end
138
+
139
+ def load(name)
140
+ name = name.to_sym
141
+ return nil unless registered.has_key?(name)
142
+
143
+ extension = registered[name]
144
+ if extension.is_a?(Proc)
145
+ extension = extension.call() || nil
146
+ registered[name] = extension
147
+ end
148
+
149
+ extension
150
+ end
151
+ end
103
152
  end
104
153
 
105
154
  # Where to look in gems for extensions to auto-register
@@ -107,6 +156,12 @@ module Middleman
107
156
 
108
157
  class << self
109
158
 
159
+ # Where to look for custom templates
160
+ # @returns [String]
161
+ def templates_path
162
+ File.join(File.expand_path("~/"), ".middleman")
163
+ end
164
+
110
165
  # Automatically load extensions from available RubyGems
111
166
  # which contain the EXTENSION_FILE
112
167
  #