middleman-core 3.0.0 → 3.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.cane +2 -0
  2. data/.cane-exclusions.yml +5 -0
  3. data/Rakefile +1 -1
  4. data/bin/middleman +9 -55
  5. data/features/cli_extension.feature +1 -0
  6. data/features/frontmatter_page_settings.feature +11 -1
  7. data/features/instance_vars.feature +9 -0
  8. data/features/step_definitions/page_layout_steps.rb +3 -3
  9. data/features/strip_url.feature +40 -0
  10. data/features/support/env.rb +1 -1
  11. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  12. data/fixtures/basic-data-app/config.rb +1 -1
  13. data/fixtures/build-with-errors-app/config.rb +1 -1
  14. data/fixtures/clean-app/config-complications.rb +1 -1
  15. data/fixtures/clean-app/config.rb +1 -1
  16. data/fixtures/current-page-app/config.rb +1 -1
  17. data/fixtures/custom-layout-app/config.rb +1 -1
  18. data/fixtures/data-app/config.rb +1 -1
  19. data/fixtures/external-helpers/config.rb +1 -1
  20. data/fixtures/external-helpers/helpers/derp.rb +1 -1
  21. data/fixtures/external-helpers/helpers/four_helpers.rb +1 -1
  22. data/fixtures/external-helpers/helpers/one_helper.rb +1 -1
  23. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -1
  24. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  25. data/fixtures/feature-params-app/config.rb +1 -1
  26. data/fixtures/frontmatter-settings-app/config.rb +3 -1
  27. data/fixtures/frontmatter-settings-app/source/layouts/override.erb +2 -0
  28. data/fixtures/frontmatter-settings-app/source/override_layout.html.erb +4 -0
  29. data/fixtures/frontmatter-settings-app/source/page_mentioned.html.erb +4 -0
  30. data/fixtures/generator-test/config.rb +10 -10
  31. data/fixtures/glob-app/config.rb +1 -1
  32. data/fixtures/instance-vars-app/config.rb +7 -0
  33. data/fixtures/instance-vars-app/source/content.html.erb +2 -0
  34. data/fixtures/instance-vars-app/source/layout.erb +1 -0
  35. data/fixtures/large-build-app/config.rb +1 -1
  36. data/fixtures/large-build-app/source/images/Child folder/regular_file(example).txt +1 -1
  37. data/fixtures/large-build-app/source/images/Read me (example).txt +1 -1
  38. data/fixtures/manual-layout-missing/config.rb +1 -1
  39. data/fixtures/manual-layout-override/config.rb +1 -1
  40. data/fixtures/manual-layout/config.rb +1 -1
  41. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  42. data/fixtures/sinatra-app/config.rb +1 -1
  43. data/fixtures/strip-url-app/config.rb +0 -0
  44. data/fixtures/strip-url-app/source/index.html.erb +1 -0
  45. data/fixtures/strip-url-app/source/other.html.erb +1 -0
  46. data/fixtures/strip-url-app/source/subdir/index.html.erb +1 -0
  47. data/fixtures/traversal-app/config.rb +1 -1
  48. data/fixtures/wildcard-app/config.rb +1 -1
  49. data/lib/middleman-core.rb +3 -3
  50. data/lib/middleman-core/application.rb +12 -11
  51. data/lib/middleman-core/cli.rb +23 -10
  52. data/lib/middleman-core/cli/build.rb +65 -54
  53. data/lib/middleman-core/cli/bundler.rb +7 -7
  54. data/lib/middleman-core/cli/extension.rb +25 -12
  55. data/lib/middleman-core/cli/init.rb +19 -19
  56. data/lib/middleman-core/cli/server.rb +25 -16
  57. data/lib/middleman-core/core_extensions/builder.rb +3 -3
  58. data/lib/middleman-core/core_extensions/data.rb +28 -28
  59. data/lib/middleman-core/core_extensions/extensions.rb +24 -25
  60. data/lib/middleman-core/core_extensions/external_helpers.rb +7 -7
  61. data/lib/middleman-core/core_extensions/file_watcher.rb +41 -38
  62. data/lib/middleman-core/core_extensions/front_matter.rb +36 -33
  63. data/lib/middleman-core/core_extensions/rendering.rb +49 -46
  64. data/lib/middleman-core/core_extensions/request.rb +34 -33
  65. data/lib/middleman-core/core_extensions/routing.rb +17 -17
  66. data/lib/middleman-core/core_extensions/ruby_encoding.rb +1 -1
  67. data/lib/middleman-core/core_extensions/show_exceptions.rb +5 -5
  68. data/lib/middleman-core/extensions.rb +4 -4
  69. data/lib/middleman-core/load_paths.rb +56 -0
  70. data/lib/middleman-core/logger.rb +29 -0
  71. data/lib/middleman-core/preview_server.rb +35 -34
  72. data/lib/middleman-core/profiling.rb +58 -0
  73. data/lib/middleman-core/renderers/coffee_script.rb +8 -6
  74. data/lib/middleman-core/renderers/erb.rb +5 -5
  75. data/lib/middleman-core/renderers/haml.rb +5 -5
  76. data/lib/middleman-core/renderers/less.rb +14 -10
  77. data/lib/middleman-core/renderers/liquid.rb +7 -7
  78. data/lib/middleman-core/renderers/markdown.rb +13 -14
  79. data/lib/middleman-core/renderers/redcarpet.rb +31 -11
  80. data/lib/middleman-core/renderers/sass.rb +38 -22
  81. data/lib/middleman-core/renderers/slim.rb +15 -7
  82. data/lib/middleman-core/sitemap.rb +25 -28
  83. data/lib/middleman-core/sitemap/extensions/ignores.rb +13 -13
  84. data/lib/middleman-core/sitemap/extensions/on_disk.rb +12 -12
  85. data/lib/middleman-core/sitemap/extensions/proxies.rb +26 -20
  86. data/lib/middleman-core/sitemap/extensions/traversal.rb +10 -10
  87. data/lib/middleman-core/sitemap/resource.rb +47 -50
  88. data/lib/middleman-core/sitemap/store.rb +38 -36
  89. data/lib/middleman-core/step_definitions.rb +1 -1
  90. data/lib/middleman-core/step_definitions/builder_steps.rb +1 -1
  91. data/lib/middleman-core/step_definitions/middleman_steps.rb +3 -3
  92. data/lib/middleman-core/step_definitions/server_steps.rb +5 -5
  93. data/lib/middleman-core/templates.rb +12 -12
  94. data/lib/middleman-core/templates/default.rb +11 -11
  95. data/lib/middleman-core/templates/extension/Gemfile +14 -1
  96. data/lib/middleman-core/templates/extension/Rakefile +3 -1
  97. data/lib/middleman-core/templates/extension/features/support/env.rb +1 -1
  98. data/lib/middleman-core/templates/extension/gitignore +2 -0
  99. data/lib/middleman-core/templates/extension/lib/lib.rb +11 -11
  100. data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +1 -1
  101. data/lib/middleman-core/templates/html5.rb +10 -10
  102. data/lib/middleman-core/templates/html5/source/humans.txt +0 -0
  103. data/lib/middleman-core/templates/html5/source/robots.txt +0 -0
  104. data/lib/middleman-core/templates/local.rb +4 -4
  105. data/lib/middleman-core/templates/mobile.rb +3 -3
  106. data/lib/middleman-core/templates/mobile/source/humans.txt +0 -0
  107. data/lib/middleman-core/templates/mobile/source/robots.txt +0 -0
  108. data/lib/middleman-core/templates/shared/config.ru +1 -1
  109. data/lib/middleman-core/templates/shared/config.tt +10 -10
  110. data/lib/middleman-core/util.rb +30 -6
  111. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb +19 -19
  112. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +2 -2
  113. data/lib/middleman-core/vendor/hooks-0.2.0/test/hooks_test.rb +29 -29
  114. data/lib/middleman-core/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +11 -11
  115. data/lib/middleman-core/version.rb +1 -1
  116. data/lib/middleman/rack.rb +4 -0
  117. data/middleman-core-x86-mingw32.gemspec +38 -0
  118. data/middleman-core.gemspec +3 -2
  119. metadata +72 -11
data/.cane ADDED
@@ -0,0 +1,2 @@
1
+ --exclusions-file .cane-exclusions.yml
2
+ --no-doc
@@ -0,0 +1,5 @@
1
+ style:
2
+ - lib/middleman-core/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb
3
+ - lib/middleman-core/vendor/hooks-0.2.0/test/hooks_test.rb
4
+ - lib/middleman-core/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb
5
+ - lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding:utf-8
2
2
  RAKE_ROOT = __FILE__
3
3
 
4
- GEM_NAME = "middleman-core"
4
+ GEM_NAME = ENV["NAME"] || "middleman-core"
5
5
 
6
6
  require 'rubygems'
7
7
  require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
data/bin/middleman CHANGED
@@ -7,65 +7,19 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
7
7
  moredir = File.expand_path(File.join(File.dirname(File.dirname(libdir)), "middleman-more", "lib", "middleman-more"))
8
8
  $LOAD_PATH.unshift(moredir) unless $LOAD_PATH.include?(moredir)
9
9
 
10
- # Core Pathname library used for traversal
11
- require "pathname"
12
-
13
- # Recursive method to find config.rb
14
- def locate_root(cwd = Pathname.new(Dir.pwd))
15
- return cwd.to_s if (cwd + 'config.rb').exist?
16
- return false if cwd.root?
17
- locate_root(cwd.parent)
18
- end
19
-
20
- # Only look for config.rb if MM_ROOT isn't set
21
- if !ENV["MM_ROOT"] && found_path = locate_root
22
- ENV["MM_ROOT"] = found_path
23
- end
24
-
25
- is_bundler_setup = false
26
-
27
- # If we've found the root, try to setup Bundler
28
- if ENV["MM_ROOT"]
29
-
30
- root_gemfile = File.expand_path('Gemfile', ENV["MM_ROOT"])
31
- ENV['BUNDLE_GEMFILE'] ||= root_gemfile
32
-
33
- if !File.exists?(ENV['BUNDLE_GEMFILE'])
34
- git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + "Gemfile"
35
- ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s
36
- end
37
-
38
- if File.exists?(ENV['BUNDLE_GEMFILE'])
39
- is_bundler_setup = true
40
- require 'bundler/setup'
41
- end
10
+ require 'middleman-core/profiling'
11
+ if ARGV.include? '--profile'
12
+ Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new
42
13
  end
14
+ Middleman::Profiling.start
43
15
 
44
- # Automatically discover extensions in RubyGems
45
- require "middleman-core/extensions"
46
-
47
- if is_bundler_setup
48
- Bundler.require
49
- else
50
- ::Middleman.load_extensions_in_path
51
- end
16
+ require "middleman-core/load_paths"
17
+ Middleman.setup_load_paths
52
18
 
53
19
  require "middleman-core/cli"
54
20
 
55
- # Change flag to a module
56
- ARGV.unshift("help") if ARGV.delete("--help")
57
-
58
- # Default command is server
59
- if ARGV[0] != "help" && (ARGV.length < 1 || ARGV.first.include?("-"))
60
- ARGV.unshift("server")
61
- end
21
+ # Change directory to the root
22
+ Dir.chdir(ENV["MM_ROOT"]) if ENV["MM_ROOT"]
62
23
 
63
24
  # Start the CLI
64
- if ENV["MM_ROOT"]
65
- # Change directory to the root
66
- Dir.chdir(ENV["MM_ROOT"]) do
67
- Middleman::Cli::Base.start
68
- end
69
- else
70
- Middleman::Cli::Base.start
71
- end
25
+ Middleman::Cli::Base.start
@@ -11,3 +11,4 @@ Feature: Middleman New Extension CLI
11
11
  | features/support/env.rb |
12
12
  | lib/middleman_extension.rb |
13
13
  | lib/my-extension-library.rb |
14
+ | .gitignore |
@@ -6,7 +6,7 @@ Feature: Setting page settings through frontmatter
6
6
  And the file "build/alternate_layout.html" should contain "Alternate layout"
7
7
  And the following files should not exist:
8
8
  | build/ignored.html |
9
-
9
+
10
10
  Scenario: Setting layout, ignoring, and disabling directory indexes through frontmatter (preview)
11
11
  Given the Server is running at "frontmatter-settings-app"
12
12
  When I go to "/alternate_layout.html"
@@ -31,3 +31,13 @@ Feature: Setting page settings through frontmatter
31
31
  """
32
32
  When I go to "/ignored.html"
33
33
  Then I should see "This file is no longer ignored."
34
+
35
+ Scenario: Overriding layout through frontmatter
36
+ Given the Server is running at "frontmatter-settings-app"
37
+ When I go to "/override_layout.html"
38
+ Then I should see "Layout in use: Override"
39
+
40
+ Scenario: Setting layout through frontmatter even if page is mentioned in config
41
+ Given the Server is running at "frontmatter-settings-app"
42
+ When I go to "/page_mentioned.html"
43
+ Then I should see "Layout in use: Override"
@@ -0,0 +1,9 @@
1
+ Feature: Instance Variables
2
+ Scenario: A dynamic page template using instance variables
3
+ Given the Server is running at "instance-vars-app"
4
+ When I go to "/a.html"
5
+ Then I should see "A: 'set'"
6
+ Then I should see "B: ''"
7
+ When I go to "/b.html"
8
+ Then I should see "A: ''"
9
+ Then I should see "B: 'set'"
@@ -1,7 +1,7 @@
1
1
  Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
2
2
  @initialize_commands ||= []
3
- @initialize_commands << lambda {
4
- page(url, :layout => layout.to_sym)
3
+ @initialize_commands << lambda {
4
+ page(url, :layout => layout.to_sym)
5
5
  }
6
6
  end
7
7
 
@@ -12,4 +12,4 @@ Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
12
12
  page(url)
13
13
  end
14
14
  }
15
- end
15
+ end
@@ -0,0 +1,40 @@
1
+ Feature: Strip the index_file from urls
2
+
3
+ Scenario: Default behaviour, strip with trailing slash
4
+ Given the Server is running at "strip-url-app"
5
+ When I go to "/"
6
+ Then I should see "URL: '/'"
7
+ When I go to "/index.html"
8
+ Then I should see "URL: '/'"
9
+ When I go to "/other.html"
10
+ Then I should see "URL: '/other.html'"
11
+ When I go to "/subdir/index.html"
12
+ Then I should see "URL: '/subdir/'"
13
+
14
+ Scenario: Trailing slash off
15
+ Given a fixture app "strip-url-app"
16
+ And a file named "config.rb" with:
17
+ """
18
+ set :trailing_slash, false
19
+ """
20
+ And the Server is running
21
+ When I go to "/"
22
+ Then I should see "URL: '/'"
23
+ When I go to "/other.html"
24
+ Then I should see "URL: '/other.html'"
25
+ When I go to "/subdir/index.html"
26
+ Then I should see "URL: '/subdir'"
27
+
28
+ Scenario: Strip index off
29
+ Given a fixture app "strip-url-app"
30
+ And a file named "config.rb" with:
31
+ """
32
+ set :strip_index_file, false
33
+ """
34
+ And the Server is running
35
+ When I go to "/"
36
+ Then I should see "URL: '/index.html'"
37
+ When I go to "/other.html"
38
+ Then I should see "URL: '/other.html'"
39
+ When I go to "/subdir/index.html"
40
+ Then I should see "URL: '/subdir/index.html'"
@@ -3,4 +3,4 @@ ENV["AUTOLOAD_SPROCKETS"] = "false"
3
3
 
4
4
  PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
5
5
  require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-core')
6
- require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-core', 'step_definitions')
6
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-core', 'step_definitions')
@@ -1 +1 @@
1
- set :automatic_directory_matcher, "--"
1
+ set :automatic_directory_matcher, "--"
@@ -1,4 +1,4 @@
1
1
  with_layout false do
2
2
  page "/data.html"
3
3
  page "/data3.html"
4
- end
4
+ end
@@ -1 +1 @@
1
- set :layout, false
1
+ set :layout, false
@@ -8,4 +8,4 @@ page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => tru
8
8
  page "/fake/#{num}.html", :proxy => "/real/index.html" do
9
9
  @num = num
10
10
  end
11
- end
11
+ end
@@ -8,4 +8,4 @@ page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => tru
8
8
  page "/fake/#{num}.html", :proxy => "/real/index.html" do
9
9
  @num = num
10
10
  end
11
- end
11
+ end
@@ -1,3 +1,3 @@
1
1
  with_layout false do
2
2
  page "/request-path.html"
3
- end
3
+ end
@@ -1 +1 @@
1
- set :erb, :layout_engine => :str
1
+ set :erb, :layout_engine => :str
@@ -1,3 +1,3 @@
1
1
  data.pages.each do |p|
2
2
  page p.from, :proxy => p.to
3
- end
3
+ end
@@ -1,4 +1,4 @@
1
1
  require "lib/hello_helper"
2
2
  helpers HelloHelper
3
3
 
4
- page "/", :layout => false
4
+ page "/", :layout => false
@@ -1,3 +1,3 @@
1
1
  module Derp
2
2
  def three; "Three"; end
3
- end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module FourHelpers
2
2
  def four; "Four"; end
3
- end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module OneHelper
2
2
  def one; "One"; end
3
- end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module YetAnotherThingy
2
2
  def two; "Two"; end
3
- end
3
+ end
@@ -2,4 +2,4 @@ module HelloHelper
2
2
  def hello
3
3
  "Hello World"
4
4
  end
5
- end
5
+ end
@@ -9,4 +9,4 @@ module ExtensionA
9
9
  end
10
10
  end
11
11
 
12
- activate ExtensionA, :hello => "world", :hola => "mundo"
12
+ activate ExtensionA, :hello => "world", :hola => "mundo"
@@ -1,2 +1,4 @@
1
1
  # Proxy ignored.html, which should ignore itself through a frontmatter
2
- page 'proxied.html', :proxy => 'ignored.html'
2
+ page 'proxied.html', :proxy => 'ignored.html'
3
+ page 'override_layout.html', :layout => :alternate
4
+ page 'page_mentioned.html'
@@ -0,0 +1,2 @@
1
+ <%= yield %>
2
+ Override.
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: override
3
+ ---
4
+ Layout in use:
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: override
3
+ ---
4
+ Layout in use:
@@ -1,4 +1,4 @@
1
- ###
1
+ ###
2
2
  # Compass
3
3
  ###
4
4
 
@@ -16,13 +16,13 @@
16
16
  ###
17
17
 
18
18
  # Per-page layout changes:
19
- #
19
+ #
20
20
  # With no layout
21
21
  # page "/path/to/file.html", :layout => false
22
- #
22
+ #
23
23
  # With alternative layout
24
24
  # page "/path/to/file.html", :layout => :otherlayout
25
- #
25
+ #
26
26
  # A path which all have the same layout
27
27
  # with_layout :admin do
28
28
  # page "/admin/*"
@@ -60,21 +60,21 @@
60
60
  configure :build do
61
61
  # For example, change the Compass output style for deployment
62
62
  # activate :minify_css
63
-
63
+
64
64
  # Minify Javascript on build
65
65
  # activate :minify_javascript
66
-
66
+
67
67
  # Enable cache buster
68
68
  # activate :cache_buster
69
-
69
+
70
70
  # Use relative URLs
71
71
  # activate :relative_assets
72
-
72
+
73
73
  # Compress PNGs after build
74
74
  # First: gem install middleman-smusher
75
75
  # require "middleman-smusher"
76
76
  # activate :smusher
77
-
77
+
78
78
  # Or use a different image path
79
79
  # set :http_path, "/Content/images/"
80
- end
80
+ end
@@ -1 +1 @@
1
- page "/index.html", :layout => false
1
+ page "/index.html", :layout => false
@@ -0,0 +1,7 @@
1
+ page "a.html", :proxy => 'content.html', :ignore => true do
2
+ @a = "set"
3
+ end
4
+
5
+ page "b.html", :proxy => 'content.html', :ignore => true do
6
+ @b = "set"
7
+ end
@@ -0,0 +1,2 @@
1
+ A: '<%= @a %>'
2
+ B: '<%= @b %>'
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -1,3 +1,3 @@
1
1
  with_layout false do
2
2
  page "/spaces in file.html"
3
- end
3
+ end
@@ -1 +1 @@
1
- README
1
+ README
@@ -1 +1 @@
1
- set :layout, :custom
1
+ set :layout, :custom
@@ -1,3 +1,3 @@
1
1
  set :layout, :custom
2
2
 
3
- page "/", :layout => :another
3
+ page "/", :layout => :another
@@ -1 +1 @@
1
- set :layout, :custom
1
+ set :layout, :custom
@@ -3,4 +3,4 @@ page "/path/*", :layout => "alt"
3
3
  # Doesn't work, and shouldn't
4
4
  # page "/path/*" do
5
5
  # set :layout, "alt"
6
- # end
6
+ # end
@@ -8,4 +8,4 @@ end
8
8
 
9
9
  map "/sinatra" do
10
10
  run MySinatra
11
- end
11
+ end
File without changes
@@ -0,0 +1 @@
1
+ URL: '<%= current_page.url %>'
@@ -0,0 +1 @@
1
+ URL: '<%= current_page.url %>'