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
@@ -1,26 +1,26 @@
1
1
  # CLI Module
2
2
  module Middleman::Cli
3
-
3
+
4
4
  # A initializing Bundler
5
5
  class Bundle < Thor
6
6
  include Thor::Actions
7
7
  check_unknown_options!
8
-
8
+
9
9
  namespace :bundle
10
-
10
+
11
11
  desc "bundle", "Setup initial bundle", :hide => true
12
-
12
+
13
13
  # The setup task
14
14
  def bundle
15
15
  run('bundle install --without development test')#, :capture => true)
16
16
  end
17
17
  end
18
-
18
+
19
19
  # A upgrading Bundler
20
20
  class Upgrade < Thor
21
21
  include Thor::Actions
22
22
  check_unknown_options!
23
-
23
+
24
24
  namespace :upgrade
25
25
 
26
26
  desc "upgrade", "Upgrade installed bundle"
@@ -32,7 +32,7 @@ module Middleman::Cli
32
32
  end
33
33
  end
34
34
  end
35
-
35
+
36
36
  # Map "u" to "upgrade"
37
37
  Base.map({
38
38
  "u" => "upgrade"
@@ -1,22 +1,29 @@
1
1
  # CLI Module
2
2
  module Middleman::Cli
3
-
3
+
4
4
  # A thor task for creating new projects
5
5
  class Extension < Thor
6
6
  include Thor::Actions
7
-
7
+
8
8
  check_unknown_options!
9
-
9
+
10
10
  namespace :extension
11
-
11
+
12
12
  # Required path for the new project to be generated
13
13
  argument :name, :type => :string
14
-
15
- desc "extension [options]", "Create Middleman extension scaffold NAME"
16
14
 
15
+ # Template files are relative to this file
16
+ # @return [String]
17
+ def self.source_root
18
+ File.join(File.dirname(__FILE__), "..", "templates", "extension")
19
+ end
20
+
21
+ desc "extension [options]", "Create Middleman extension scaffold NAME"
22
+
17
23
  # The extension task
18
24
  # @param [String] name
19
25
  def extension
26
+ generate_gitignore!
20
27
  template "Rakefile", File.join(name, "Rakefile")
21
28
  template "gemspec", File.join(name, "#{name}.gemspec")
22
29
  template "Gemfile", File.join(name, "Gemfile")
@@ -25,12 +32,18 @@ module Middleman::Cli
25
32
  template "features/support/env.rb", File.join(name, "features", "support", "env.rb")
26
33
  empty_directory File.join(name, "fixtures")
27
34
  end
28
-
29
- # Template files are relative to this file
30
- # @return [String]
31
- def self.source_root
32
- File.join(File.dirname(__FILE__), "..", "templates", "extension")
33
- end
35
+
36
+ # Output a .gitignore file
37
+ class_option :git, :type => :boolean, :default => true
38
+
39
+ no_tasks {
40
+ # Write a .gitignore file for project
41
+ # @return [void]
42
+ def generate_gitignore!
43
+ return unless options[:git]
44
+ copy_file "gitignore", File.join(name, ".gitignore")
45
+ end
46
+ }
34
47
 
35
48
  end
36
49
  end
@@ -2,35 +2,35 @@ require "middleman-core/templates"
2
2
 
3
3
  # CLI Module
4
4
  module Middleman::Cli
5
-
5
+
6
6
  # A thor task for creating new projects
7
7
  class Init < Thor
8
8
  check_unknown_options!
9
-
9
+
10
10
  namespace :init
11
-
11
+
12
12
  desc "init NAME [options]", "Create new project NAME"
13
13
  available_templates = ::Middleman::Templates.registered.keys.join(", ")
14
- method_option "template",
15
- :aliases => "-T",
14
+ method_option "template",
15
+ :aliases => "-T",
16
16
  :default => "default",
17
17
  :desc => "Use a project template: #{available_templates}"
18
- method_option "css_dir",
19
- # :default => "stylesheets",
18
+ method_option "css_dir",
19
+ # :default => "stylesheets",
20
20
  :desc => 'The path to the css files'
21
- method_option "js_dir",
22
- # :default => "javascripts",
21
+ method_option "js_dir",
22
+ # :default => "javascripts",
23
23
  :desc => 'The path to the javascript files'
24
- method_option "images_dir",
25
- # :default => "images",
24
+ method_option "images_dir",
25
+ # :default => "images",
26
26
  :desc => 'The path to the image files'
27
- method_option "rack",
28
- :type => :boolean,
29
- :default => false,
27
+ method_option "rack",
28
+ :type => :boolean,
29
+ :default => false,
30
30
  :desc => 'Include a config.ru file'
31
- method_option "bundler",
32
- :type => :boolean,
33
- :default => false,
31
+ method_option "bundler",
32
+ :type => :boolean,
33
+ :default => false,
34
34
  :desc => 'Create a Gemfile and use Bundler to manage gems'
35
35
  # The init task
36
36
  # @param [String] name
@@ -39,7 +39,7 @@ module Middleman::Cli
39
39
  unless ::Middleman::Templates.registered.has_key?(key)
40
40
  raise Thor::Error.new "Unknown project template '#{key}'"
41
41
  end
42
-
42
+
43
43
  thor_group = ::Middleman::Templates.registered[key]
44
44
  thor_group.new([name], options).invoke_all
45
45
  end
@@ -48,7 +48,7 @@ module Middleman::Cli
48
48
  def self.exit_on_failure?
49
49
  true
50
50
  end
51
-
51
+
52
52
  # Map "i", "new" and "n" to "init"
53
53
  Base.map({
54
54
  "i" => "init",
@@ -1,40 +1,48 @@
1
1
  # CLI Module
2
2
  module Middleman::Cli
3
-
3
+
4
4
  # Server thor task
5
5
  class Server < Thor
6
6
  check_unknown_options!
7
-
7
+
8
8
  namespace :server
9
-
9
+
10
10
  desc "server [options]", "Start the preview server"
11
11
  method_option :environment,
12
- :aliases => "-e",
13
- :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
12
+ :aliases => "-e",
13
+ :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
14
14
  :desc => "The environment Middleman will run under"
15
15
  method_option :host,
16
16
  :type => :string,
17
17
  :aliases => "-h",
18
- :default => "0.0.0.0",
18
+ :default => "0.0.0.0",
19
19
  :desc => "Bind to HOST address"
20
20
  method_option :port,
21
- :aliases => "-p",
22
- :default => "4567",
21
+ :aliases => "-p",
22
+ :default => "4567",
23
23
  :desc => "The port Middleman will listen on"
24
24
  method_option :verbose,
25
- :type => :boolean,
25
+ :type => :boolean,
26
26
  :default => false,
27
27
  :desc => 'Print debug messages'
28
- method_option "disable-watcher",
29
- :type => :boolean,
28
+ method_option :instrument,
29
+ :type => :string,
30
+ :default => false,
31
+ :desc => 'Print instrument messages'
32
+ method_option "disable-watcher",
33
+ :type => :boolean,
30
34
  :default => false,
31
35
  :desc => 'Disable the file change and delete watcher process'
32
-
36
+ method_option :profile,
37
+ :type => :boolean,
38
+ :default => false,
39
+ :desc => 'Generate profiling report for server startup'
40
+
33
41
  # Start the server
34
42
  def server
35
43
  require "middleman-core"
36
44
  require "middleman-core/preview_server"
37
-
45
+
38
46
  if !ENV["MM_ROOT"]
39
47
  puts "== Could not find a Middleman project config.rb"
40
48
  puts "== Treating directory as a static site to be served"
@@ -47,9 +55,10 @@ module Middleman::Cli
47
55
  :host => options["host"],
48
56
  :environment => options["environment"],
49
57
  :debug => options["verbose"],
58
+ :instrumenting => options["instrument"],
50
59
  :"disable-watcher" => options["disable-watcher"]
51
60
  }
52
-
61
+
53
62
  puts "== The Middleman is loading"
54
63
  ::Middleman::PreviewServer.start(params)
55
64
  end
@@ -57,8 +66,8 @@ module Middleman::Cli
57
66
 
58
67
  def self.exit_on_failure?
59
68
  true
60
- end
61
-
69
+ end
70
+
62
71
  # Map "s" to "server"
63
72
  Base.map({ "s" => "server" })
64
73
  end
@@ -1,9 +1,9 @@
1
1
  module Middleman
2
2
  module CoreExtensions
3
-
3
+
4
4
  # Convenience methods to allow config.rb to talk to the Builder
5
5
  module Builder
6
-
6
+
7
7
  # Extension registered
8
8
  class << self
9
9
  # @private
@@ -14,4 +14,4 @@ module Middleman
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -1,10 +1,10 @@
1
1
  module Middleman
2
2
  module CoreExtensions
3
-
3
+
4
4
  # The data extension parses YAML and JSON files in the data/ directory
5
5
  # and makes them available to config.rb, templates and extensions
6
6
  module Data
7
-
7
+
8
8
  # Extension registered
9
9
  class << self
10
10
  # @private
@@ -12,13 +12,13 @@ module Middleman
12
12
  # Data formats
13
13
  require "yaml"
14
14
  require "active_support/json"
15
-
15
+
16
16
  app.set :data_dir, "data"
17
17
  app.send :include, InstanceMethods
18
18
  end
19
19
  alias :included :registered
20
20
  end
21
-
21
+
22
22
  # Instance methods
23
23
  module InstanceMethods
24
24
  # Setup data files before anything else so they are available when
@@ -27,14 +27,14 @@ module Middleman
27
27
  self.files.changed DataStore.matcher do |file|
28
28
  self.data.touch_file(file) if file.match(%r{^#{self.data_dir}\/})
29
29
  end
30
-
30
+
31
31
  self.files.deleted DataStore.matcher do |file|
32
32
  self.data.remove_file(file) if file.match(%r{^#{self.data_dir}\/})
33
33
  end
34
-
34
+
35
35
  super
36
36
  end
37
-
37
+
38
38
  # The data object
39
39
  #
40
40
  # @return [DataStore]
@@ -42,13 +42,13 @@ module Middleman
42
42
  @_data ||= DataStore.new(self)
43
43
  end
44
44
  end
45
-
45
+
46
46
  # The core logic behind the data extension.
47
47
  class DataStore
48
-
48
+
49
49
  # Static methods
50
50
  class << self
51
-
51
+
52
52
  # The regex which tells Middleman which files are for data
53
53
  #
54
54
  # @return [Regexp]
@@ -56,7 +56,7 @@ module Middleman
56
56
  %r{[\w-]+\.(yml|yaml|json)$}
57
57
  end
58
58
  end
59
-
59
+
60
60
  # Store static data hash
61
61
  #
62
62
  # @param [Symbol] name Name of the data, used for namespacing
@@ -78,7 +78,7 @@ module Middleman
78
78
  @_callback_sources[name.to_s] = proc unless name.nil? || proc.nil?
79
79
  @_callback_sources
80
80
  end
81
-
81
+
82
82
  # Setup data store
83
83
  #
84
84
  # @param [Middleman::Application] app The current instance of Middleman
@@ -86,7 +86,7 @@ module Middleman
86
86
  @app = app
87
87
  @local_data = {}
88
88
  end
89
-
89
+
90
90
  # Update the internal cache for a given file path
91
91
  #
92
92
  # @param [String] file The file to be re-parsed
@@ -95,7 +95,7 @@ module Middleman
95
95
  file = File.expand_path(file, @app.root)
96
96
  extension = File.extname(file)
97
97
  basename = File.basename(file, extension)
98
-
98
+
99
99
  if %w(.yaml .yml).include?(extension)
100
100
  data = YAML.load_file(file)
101
101
  elsif extension == ".json"
@@ -106,7 +106,7 @@ module Middleman
106
106
 
107
107
  @local_data[basename] = ::Middleman::Util.recursively_enhance(data)
108
108
  end
109
-
109
+
110
110
  # Remove a given file from the internal cache
111
111
  #
112
112
  # @param [String] file The file to be cleared
@@ -116,26 +116,26 @@ module Middleman
116
116
  basename = File.basename(file, extension)
117
117
  @local_data.delete(basename) if @local_data.has_key?(basename)
118
118
  end
119
-
119
+
120
120
  # Get a hash hash from either internal static data or a callback
121
121
  #
122
122
  # @param [String, Symbol] path The name of the data namespace
123
123
  # @return [Hash, nil]
124
124
  def data_for_path(path)
125
125
  response = nil
126
-
126
+
127
127
  @@local_sources ||= {}
128
128
  @@callback_sources ||= {}
129
-
129
+
130
130
  if self.store.has_key?(path.to_s)
131
131
  response = self.store[path.to_s]
132
132
  elsif self.callbacks.has_key?(path.to_s)
133
133
  response = self.callbacks[path.to_s].call()
134
134
  end
135
-
135
+
136
136
  response
137
137
  end
138
-
138
+
139
139
  # "Magically" find namespaces of data if they exist
140
140
  #
141
141
  # @param [String] path The namespace to search for
@@ -145,36 +145,36 @@ module Middleman
145
145
  return @local_data[path.to_s]
146
146
  else
147
147
  result = data_for_path(path)
148
-
148
+
149
149
  if result
150
150
  return ::Middleman::Util.recursively_enhance(result)
151
151
  end
152
152
  end
153
-
153
+
154
154
  super
155
155
  end
156
-
156
+
157
157
  # Convert all the data into a static hash
158
158
  #
159
159
  # @return [Hash]
160
160
  def to_h
161
161
  data = {}
162
-
162
+
163
163
  self.store.each do |k, v|
164
164
  data[k] = data_for_path(k)
165
165
  end
166
-
166
+
167
167
  self.callbacks.each do |k, v|
168
168
  data[k] = data_for_path(k)
169
169
  end
170
-
170
+
171
171
  (@local_data || {}).each do |k, v|
172
172
  data[k] = v
173
173
  end
174
-
174
+
175
175
  data
176
176
  end
177
177
  end
178
178
  end
179
179
  end
180
- end
180
+ end