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
@@ -4,12 +4,12 @@ require "thor/group"
4
4
 
5
5
  # Templates namespace
6
6
  module Middleman::Templates
7
-
7
+
8
8
  # Static methods
9
9
  class << self
10
-
10
+
11
11
  # Get list of registered templates and add new ones
12
- #
12
+ #
13
13
  # Middleman::Templates.register(:ext_name, klass)
14
14
  #
15
15
  # @param [Symbol] name The name of the template
@@ -20,15 +20,15 @@ module Middleman::Templates
20
20
  @_template_mappings[name] = klass if name && klass
21
21
  @_template_mappings
22
22
  end
23
-
23
+
24
24
  # Middleman::Templates.register(name, klass)
25
25
  alias :registered :register
26
26
  end
27
-
27
+
28
28
  # Base Template class. Handles basic options and paths.
29
29
  class Base < ::Thor::Group
30
30
  include Thor::Actions
31
-
31
+
32
32
  def initialize(names, options)
33
33
  super
34
34
  source_paths << File.join(File.dirname(__FILE__), 'templates')
@@ -36,25 +36,25 @@ module Middleman::Templates
36
36
 
37
37
  # Required path for the new project to be generated
38
38
  argument :location, :type => :string
39
-
39
+
40
40
  # Name of the template being used to generate the project.
41
41
  class_option :template, :default => "default"
42
-
42
+
43
43
  # Output a config.ru file for Rack if --rack is passed
44
44
  class_option :rack, :type => :boolean, :default => false
45
-
45
+
46
46
  # Write a Rack config.ru file for project
47
47
  # @return [void]
48
48
  def generate_rack!
49
49
  return unless options[:rack]
50
50
  template "shared/config.ru", File.join(location, "config.ru")
51
51
  end
52
-
52
+
53
53
  # Write a Bundler Gemfile file for project
54
54
  # @return [void]
55
55
  def generate_bundler!
56
56
  template "shared/Gemfile.tt", File.join(location, "Gemfile")
57
-
57
+
58
58
  inside(location) do
59
59
  ::Middleman::Cli::Bundle.new.invoke(:bundle)
60
60
  end unless ENV["TEST"]
@@ -62,7 +62,7 @@ module Middleman::Templates
62
62
 
63
63
  # Output a .gitignore file
64
64
  class_option :git, :type => :boolean, :default => true
65
-
65
+
66
66
  # Write a .gitignore file for project
67
67
  # @return [void]
68
68
  def generate_gitignore!
@@ -1,22 +1,22 @@
1
1
  # Default Middleman template
2
2
  class Middleman::Templates::Default < Middleman::Templates::Base
3
-
4
- class_option "css_dir",
5
- :default => "stylesheets",
3
+
4
+ class_option "css_dir",
5
+ :default => "stylesheets",
6
6
  :desc => 'The path to the css files'
7
- class_option "js_dir",
8
- :default => "javascripts",
7
+ class_option "js_dir",
8
+ :default => "javascripts",
9
9
  :desc => 'The path to the javascript files'
10
- class_option "images_dir",
11
- :default => "images",
10
+ class_option "images_dir",
11
+ :default => "images",
12
12
  :desc => 'The path to the image files'
13
-
13
+
14
14
  # Template files are relative to this file
15
15
  # @return [String]
16
16
  def self.source_root
17
17
  File.dirname(__FILE__)
18
18
  end
19
-
19
+
20
20
  # Actually output the files
21
21
  # @return [void]
22
22
  def build_scaffold!
@@ -31,8 +31,8 @@ class Middleman::Templates::Default < Middleman::Templates::Base
31
31
  empty_directory File.join(location, "source", options[:images_dir])
32
32
  copy_file "default/source/images/background.png", File.join(location, "source", options[:images_dir], "background.png")
33
33
  copy_file "default/source/images/middleman.png", File.join(location, "source", options[:images_dir], "middleman.png")
34
- end
34
+ end
35
35
  end
36
36
 
37
37
  # Register this template
38
- Middleman::Templates.register(:default, Middleman::Templates::Default)
38
+ Middleman::Templates.register(:default, Middleman::Templates::Default)
@@ -1,4 +1,17 @@
1
1
  source :rubygems
2
2
 
3
3
  # Specify your gem's dependencies in <%= name %>.gemspec
4
- gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "rake", "~> 0.9.2"
8
+ gem "rdoc", "~> 3.9"
9
+ gem "yard", "~> 0.8.0"
10
+ end
11
+
12
+ group :test do
13
+ gem "cucumber", "~> 1.2.0"
14
+ gem "fivemat"
15
+ gem "aruba", "~> 0.4.11"
16
+ gem "rspec", "~> 2.7"
17
+ end
@@ -9,4 +9,6 @@ end
9
9
 
10
10
  require 'rake/clean'
11
11
 
12
- task :test => ["cucumber"]
12
+ task :test => ["cucumber"]
13
+
14
+ task :default => :test
@@ -1,4 +1,4 @@
1
1
  PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
2
  require "middleman-core"
3
3
  require "middleman-core/step_definitions"
4
- require File.join(PROJECT_ROOT_PATH, 'lib', '<%= name %>')
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', '<%= name %>')
@@ -0,0 +1,2 @@
1
+ # Ignore bundler lock file
2
+ Gemfile.lock
@@ -4,22 +4,22 @@ require "middleman-core"
4
4
  # Extension namespace
5
5
  module MyExtension
6
6
  class << self
7
-
7
+
8
8
  # Called when user `activate`s your extension
9
9
  def registered(app, options={})
10
10
  # Setup extension-specific config
11
11
  app.set :config_variable, false
12
-
12
+
13
13
  # Include class methods
14
14
  # app.extend ClassMethods
15
-
15
+
16
16
  # Include instance methods
17
17
  # app.send :include, InstanceMethods
18
-
18
+
19
19
  app.after_configuration do
20
20
  # Do something
21
-
22
- # config_variable is now either the default or the user's
21
+
22
+ # config_variable is now either the default or the user's
23
23
  # setting from config.rb
24
24
  end
25
25
  end
@@ -30,20 +30,20 @@ module MyExtension
30
30
  # def a_class_method
31
31
  # end
32
32
  # end
33
-
33
+
34
34
  # module InstanceMethods
35
35
  # def an_instance_method
36
36
  # end
37
37
  # end
38
-
38
+
39
39
  end
40
40
 
41
41
 
42
42
  # Register extensions which can be activated
43
43
  # Make sure we have the version of Middleman we expect
44
44
  # ::Middleman::Extensions.register(:extension_name) do
45
- #
45
+ #
46
46
  # # Return the extension module
47
47
  # ::MyExtension
48
- #
49
- # end
48
+ #
49
+ # end
@@ -1 +1 @@
1
- require "<%= name %>"
1
+ require "<%= name %>"
@@ -1,22 +1,22 @@
1
1
  # HTML5 Boilerplate template
2
2
  class Middleman::Templates::Html5 < Middleman::Templates::Base
3
-
4
- class_option "css_dir",
5
- :default => "css",
3
+
4
+ class_option "css_dir",
5
+ :default => "css",
6
6
  :desc => 'The path to the css files'
7
- class_option "js_dir",
8
- :default => "js",
7
+ class_option "js_dir",
8
+ :default => "js",
9
9
  :desc => 'The path to the javascript files'
10
- class_option "images_dir",
11
- :default => "img",
10
+ class_option "images_dir",
11
+ :default => "img",
12
12
  :desc => 'The path to the image files'
13
-
13
+
14
14
  # Templates are relative to this file
15
15
  # @return [String]
16
16
  def self.source_root
17
17
  File.dirname(__FILE__)
18
18
  end
19
-
19
+
20
20
  # Output the files
21
21
  # @return [void]
22
22
  def build_scaffold!
@@ -27,4 +27,4 @@ class Middleman::Templates::Html5 < Middleman::Templates::Base
27
27
  end
28
28
 
29
29
  # Register the template
30
- Middleman::Templates.register(:html5, Middleman::Templates::Html5)
30
+ Middleman::Templates.register(:html5, Middleman::Templates::Html5)
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  # Local templates
2
2
  class Middleman::Templates::Local < Middleman::Templates::Base
3
-
3
+
4
4
  # Look for templates in ~/.middleman
5
5
  # @return [String]
6
6
  def self.source_root
@@ -11,15 +11,15 @@ class Middleman::Templates::Local < Middleman::Templates::Base
11
11
  # @return [void]
12
12
  def build_scaffold!
13
13
  directory options[:template].to_s, location
14
- end
14
+ end
15
15
  end
16
16
 
17
17
  # Iterate over the directories in the templates path and register each one.
18
18
  Dir[File.join(Middleman::Templates::Local.source_root, "*")].each do |dir|
19
19
  next unless File.directory?(dir)
20
-
20
+
21
21
  template_file = File.join(dir, "template.rb")
22
-
22
+
23
23
  if File.exists?(template_file)
24
24
  require template_file
25
25
  else
@@ -1,6 +1,6 @@
1
1
  # Mobile HTML5 Boilerplate
2
2
  class Middleman::Templates::Mobile < Middleman::Templates::Base
3
-
3
+
4
4
  # Slightly different paths
5
5
  class_option :css_dir, :default => "css"
6
6
  class_option :js_dir, :default => "js"
@@ -11,7 +11,7 @@ class Middleman::Templates::Mobile < Middleman::Templates::Base
11
11
  def self.source_root
12
12
  File.dirname(__FILE__)
13
13
  end
14
-
14
+
15
15
  # Output the files
16
16
  # @return [void]
17
17
  def build_scaffold!
@@ -22,4 +22,4 @@ class Middleman::Templates::Mobile < Middleman::Templates::Base
22
22
  end
23
23
 
24
24
  # Register the template
25
- Middleman::Templates.register(:mobile, Middleman::Templates::Mobile)
25
+ Middleman::Templates.register(:mobile, Middleman::Templates::Mobile)
@@ -1,4 +1,4 @@
1
1
  require 'rubygems'
2
- require 'middleman'
2
+ require 'middleman/rack'
3
3
 
4
4
  run Middleman.server
@@ -1,9 +1,9 @@
1
- ###
1
+ ###
2
2
  # Compass
3
3
  ###
4
4
 
5
5
  # Susy grids in Compass
6
- # First: gem install compass-susy-plugin
6
+ # First: gem install susy --pre
7
7
  # require 'susy'
8
8
 
9
9
  # Change Compass configuration
@@ -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/*"
@@ -72,21 +72,21 @@ set :images_dir, '<%= options[:images_dir] -%>'
72
72
  configure :build do
73
73
  # For example, change the Compass output style for deployment
74
74
  # activate :minify_css
75
-
75
+
76
76
  # Minify Javascript on build
77
77
  # activate :minify_javascript
78
-
78
+
79
79
  # Enable cache buster
80
80
  # activate :cache_buster
81
-
81
+
82
82
  # Use relative URLs
83
83
  # activate :relative_assets
84
-
84
+
85
85
  # Compress PNGs after build
86
86
  # First: gem install middleman-smusher
87
87
  # require "middleman-smusher"
88
88
  # activate :smusher
89
-
89
+
90
90
  # Or use a different image path
91
91
  # set :http_path, "/Content/images/"
92
92
  end
@@ -1,3 +1,9 @@
1
+ # Our custom logger
2
+ require "middleman-core/logger"
3
+
4
+ # For instrumenting
5
+ require "active_support/notifications"
6
+
1
7
  # Using Thor's indifferent hash access
2
8
  require "thor"
3
9
 
@@ -5,8 +11,26 @@ require "thor"
5
11
  require "pathname"
6
12
 
7
13
  module Middleman
14
+
8
15
  module Util
9
-
16
+
17
+ # The logger
18
+ #
19
+ # @return [Middleman::Logger] The logger
20
+ def self.logger(*args)
21
+ if !@_logger || args.length > 0
22
+ @_logger = ::Middleman::Logger.new(*args)
23
+ end
24
+
25
+ @_logger
26
+ end
27
+
28
+ # Facade for ActiveSupport/Notification
29
+ def self.instrument(name, payload={}, &block)
30
+ name << ".middleman" unless name =~ /\.middleman$/
31
+ ::ActiveSupport::Notifications.instrument(name, payload, &block)
32
+ end
33
+
10
34
  # Recursively convert a normal Hash into a HashWithIndifferentAccess
11
35
  #
12
36
  # @private
@@ -28,13 +52,13 @@ module Middleman
28
52
  data
29
53
  end
30
54
  end
31
-
55
+
32
56
  # Normalize a path to not include a leading slash
33
57
  # @param [String] path
34
58
  # @return [String]
35
59
  def self.normalize_path(path)
36
60
  # The tr call works around a bug in Ruby's Unicode handling
37
- path.sub(/^\//, "").tr('','')
61
+ path.sub(/^\//, "").tr('','')
38
62
  end
39
63
 
40
64
  # Extract the text of a Rack response as a string.
@@ -55,7 +79,7 @@ module Middleman
55
79
  response.to_s
56
80
  end
57
81
  end
58
-
82
+
59
83
  # Takes a matcher, which can be a literal string
60
84
  # or a string containing glob expressions, or a
61
85
  # regexp, or a proc, or anything else that responds
@@ -74,7 +98,7 @@ module Middleman
74
98
  File.fnmatch(matcher.to_s, path)
75
99
  end
76
100
  end
77
-
101
+
78
102
  # Get a recusive list of files inside a set of paths.
79
103
  # Works with symlinks.
80
104
  #
@@ -105,7 +129,7 @@ module Middleman
105
129
  end
106
130
 
107
131
  # Whether the key is in the cache
108
- #
132
+ #
109
133
  # @param key Anything Hash can use as a key
110
134
  # @return [Boolean]
111
135
  def has_key?(key)