middleman-core 4.3.0.rc.4 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cucumber.yml +2 -2
- data/features/builder.feature +1 -1
- data/features/chained_templates.feature +0 -7
- data/features/coffee-script.feature +1 -1
- data/features/collections.feature +2 -2
- data/features/console.feature +1 -1
- data/features/data.feature +31 -0
- data/features/extension_api_deprecations.feature +3 -1
- data/features/extension_hooks.feature +3 -1
- data/features/helpers_external.feature +1 -17
- data/features/i18n_link_to.feature +0 -23
- data/features/i18n_mixed_sources.feature +0 -8
- data/features/i18n_preview.feature +1 -30
- data/features/ignore.feature +11 -67
- data/features/ignore_already_minified.feature +1 -1
- data/features/markdown.feature +1 -0
- data/features/minify_javascript.feature +35 -35
- data/features/mount_rack.feature +0 -1
- data/features/page-id.feature +2 -2
- data/features/partials.feature +1 -1
- data/features/relative_assets_helpers_only.feature +6 -4
- data/features/scss-support.feature +6 -1
- data/features/support/env.rb +5 -5
- data/features/tilde_directories.feature +2 -0
- data/features/unicode_filenames.feature +1 -1
- data/fixtures/asset-hash-app/config.rb +1 -0
- data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
- data/fixtures/asset-hash-minified-app/config.rb +1 -1
- data/fixtures/asset-hash-prefix/config.rb +2 -1
- data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-source-map/config.rb +1 -0
- data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
- data/fixtures/asset-host-app/config.rb +1 -1
- data/fixtures/auto-css-app/config.rb +2 -2
- data/fixtures/auto-js-app/config.rb +2 -2
- data/fixtures/auto-js-directory-index-app/config.rb +1 -1
- data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
- data/fixtures/basic-data-app/config.rb +2 -2
- data/fixtures/capture-html-app/config.rb +4 -4
- data/fixtures/clean-app/config-complications.rb +6 -6
- data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
- data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
- data/fixtures/clean-app/config.rb +6 -6
- data/fixtures/clean-dir-app/config.rb +1 -0
- data/fixtures/clean-nested-app/config.rb +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/content-for-app/config.rb +4 -4
- data/fixtures/dynamic-pages-app/config.rb +26 -25
- data/fixtures/ember-cli-app/config.rb +4 -4
- data/fixtures/env-app/environments/development.rb +1 -1
- data/fixtures/env-app/environments/production.rb +1 -1
- data/fixtures/env-app/source/stylesheets/site.css.scss +1 -1
- data/fixtures/extension-hooks-app/config.rb +8 -8
- data/fixtures/external-helpers/config.rb +2 -2
- data/fixtures/external-helpers/helpers/derp.rb +1 -3
- data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
- data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
- data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
- data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
- data/fixtures/external-pipeline-error/config.rb +4 -4
- data/fixtures/feature-params-app/config.rb +1 -1
- data/fixtures/frontmatter-app/config.rb +1 -1
- data/fixtures/generator-test/config.rb +15 -1
- data/fixtures/glob-app/config.rb +1 -1
- data/fixtures/i-8859-1-app/config.rb +1 -1
- data/fixtures/i18n-force-locale/config.rb +4 -4
- data/fixtures/i18n-mixed-sources/config.rb +1 -1
- data/fixtures/i18n-test-app/locales/en.yml +1 -7
- data/fixtures/i18n-test-app/locales/es.yml +1 -2
- data/fixtures/import-app/config.rb +3 -3
- data/fixtures/indexable-app/config.rb +3 -3
- data/fixtures/large-build-app/config.rb +1 -1
- data/fixtures/manual-layout-override/config.rb +1 -1
- data/fixtures/missing-tilt-library-app/config.rb +2 -2
- data/fixtures/more-traversal-app/config.rb +4 -4
- data/fixtures/multiple-data-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
- data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
- data/fixtures/padrino-helpers-app/config.rb +1 -1
- data/fixtures/page-classes-app/config.rb +2 -2
- data/fixtures/page-helper-layout-block-app/config.rb +1 -1
- data/fixtures/page-id-app/config-proc.rb +4 -4
- data/fixtures/page-id-app/config.rb +3 -3
- data/fixtures/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
- data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
- data/fixtures/partials-app/source/_locals.erb +1 -1
- data/fixtures/partials-app/source/locals.html.erb +1 -1
- data/fixtures/proxy-pages-app/config.rb +14 -13
- data/fixtures/sass-assets-path-app/config.rb +2 -2
- data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
- data/fixtures/sinatra-app/config.rb +6 -6
- data/fixtures/traversal-app/config.rb +4 -4
- data/fixtures/v4-extension-callbacks/config.rb +2 -2
- data/fixtures/wildcard-app/config.rb +1 -1
- data/fixtures/wildcard-directory-index-app/config.rb +1 -1
- data/lib/middleman/rack.rb +7 -0
- data/lib/middleman-core/application.rb +9 -10
- data/lib/middleman-core/builder.rb +21 -50
- data/lib/middleman-core/callback_manager.rb +1 -1
- data/lib/middleman-core/config_context.rb +2 -2
- data/lib/middleman-core/configuration.rb +5 -5
- data/lib/middleman-core/contracts.rb +2 -2
- data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
- data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
- data/lib/middleman-core/core_extensions/collections.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +11 -11
- data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
- data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
- data/lib/middleman-core/core_extensions/i18n.rb +23 -44
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
- data/lib/middleman-core/core_extensions/routing.rb +1 -1
- data/lib/middleman-core/core_extensions.rb +2 -2
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver.rb +1 -1
- data/lib/middleman-core/extension.rb +32 -34
- data/lib/middleman-core/extension_manager.rb +2 -6
- data/lib/middleman-core/extensions/asset_hash.rb +22 -24
- data/lib/middleman-core/extensions/asset_host.rb +10 -10
- data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
- data/lib/middleman-core/extensions/cache_buster.rb +2 -2
- data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +9 -14
- data/lib/middleman-core/extensions/gzip.rb +6 -8
- data/lib/middleman-core/extensions/lorem.rb +9 -9
- data/lib/middleman-core/extensions/minify_css.rb +16 -14
- data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
- data/lib/middleman-core/extensions/relative_assets.rb +8 -8
- data/lib/middleman-core/extensions.rb +7 -8
- data/lib/middleman-core/file_renderer.rb +6 -7
- data/lib/middleman-core/load_paths.rb +10 -13
- data/lib/middleman-core/logger.rb +4 -3
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server/checks.rb +1 -1
- data/lib/middleman-core/preview_server/information.rb +13 -13
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
- data/lib/middleman-core/preview_server/server_information.rb +1 -1
- data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +1 -1
- data/lib/middleman-core/preview_server/server_url.rb +1 -1
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
- data/lib/middleman-core/preview_server.rb +25 -25
- data/lib/middleman-core/rack.rb +1 -1
- data/lib/middleman-core/renderers/coffee_script.rb +2 -2
- data/lib/middleman-core/renderers/haml.rb +4 -8
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +2 -3
- data/lib/middleman-core/renderers/markdown.rb +7 -7
- data/lib/middleman-core/renderers/redcarpet.rb +2 -2
- data/lib/middleman-core/renderers/sass.rb +23 -26
- data/lib/middleman-core/renderers/sass_functions.rb +14 -17
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
- data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -2
- data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/traversal.rb +25 -80
- data/lib/middleman-core/sitemap/resource.rb +20 -21
- data/lib/middleman-core/sitemap/store.rb +6 -6
- data/lib/middleman-core/sources/source_watcher.rb +11 -17
- data/lib/middleman-core/sources.rb +12 -12
- data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
- data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
- data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
- data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
- data/lib/middleman-core/template_context.rb +10 -17
- data/lib/middleman-core/template_renderer.rb +33 -35
- data/lib/middleman-core/util/binary.rb +1 -3
- data/lib/middleman-core/util/data.rb +22 -12
- data/lib/middleman-core/util/files.rb +3 -3
- data/lib/middleman-core/util/paths.rb +44 -47
- data/lib/middleman-core/util/rack.rb +3 -3
- data/lib/middleman-core/util/uri_templates.rb +0 -1
- data/lib/middleman-core/util.rb +2 -2
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +3 -3
- data/middleman-core.gemspec +13 -12
- data/spec/middleman-core/callbacks_spec.rb +14 -15
- data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
- data/spec/middleman-core/dns_resolver_spec.rb +6 -6
- data/spec/middleman-core/util_spec.rb +86 -81
- data/spec/spec_helper.rb +6 -1
- data/spec/support/given.rb +15 -11
- metadata +59 -76
- data/features/multiple-sources-reload.feature +0 -40
- data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
- data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
- data/fixtures/i18n-default-app/source/name.html.erb +0 -1
- data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
- data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
- data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
- data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +0 -1
@@ -1,2 +1,2 @@
|
|
1
|
-
page
|
2
|
-
page
|
1
|
+
page "/sub1/page-classes.html", layout: false
|
2
|
+
page "/sub1/sub2/page-classes.html", layout: false
|
@@ -1,7 +1,7 @@
|
|
1
|
-
%w
|
2
|
-
proxy "/#{n}.html",
|
1
|
+
%w(1 2 3).each do |n|
|
2
|
+
proxy "/#{n}.html", "/index.html", id: "page#{n}"
|
3
3
|
end
|
4
4
|
|
5
|
-
page
|
5
|
+
page "/overwrites/*", id: :"something-else"
|
6
6
|
|
7
|
-
config[:page_id_generator] = ->(path)
|
7
|
+
config[:page_id_generator] = ->(path){ path + "-foo" }
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
Local
|
1
|
+
Local var is <%= foo %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= partial 'locals', locals: { foo: '
|
1
|
+
<%= partial 'locals', locals: { foo: 'bar' } %>
|
@@ -1,17 +1,18 @@
|
|
1
|
-
|
2
|
-
proxy
|
3
|
-
proxy
|
4
|
-
proxy
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
proxy "/fake.html", "/real.html", layout: false
|
3
|
+
proxy "fake2.html", "/real.html", layout: false
|
4
|
+
proxy "fake3.html", "real.html", layout: false
|
5
|
+
proxy "/fake4.html", "real.html", layout: false
|
5
6
|
|
6
|
-
proxy
|
7
|
-
proxy
|
8
|
-
proxy
|
9
|
-
proxy
|
7
|
+
proxy "/target_ignore.html", "/should_be_ignored3.html", ignore: true
|
8
|
+
proxy "target_ignore2.html", "/should_be_ignored6.html", ignore: true
|
9
|
+
proxy "target_ignore3.html", "should_be_ignored7.html", ignore: true
|
10
|
+
proxy "/target_ignore4.html", "should_be_ignored8.html", ignore: true
|
10
11
|
|
11
|
-
%w
|
12
|
-
proxy "/fake/#{num}.html",
|
13
|
-
proxy "fake2/#{num}.html",
|
14
|
-
proxy "fake3/#{num}.html",
|
12
|
+
%w(one two).each do |num|
|
13
|
+
proxy "/fake/#{num}.html", "/real/index.html", ignore: true, locals: { num: num }
|
14
|
+
proxy "fake2/#{num}.html", "/real/index.html", ignore: true, locals: { num: num }
|
15
|
+
proxy "fake3/#{num}.html", "real/index.html", ignore: true, locals: { num: num }
|
15
16
|
end
|
16
17
|
|
17
|
-
proxy
|
18
|
+
proxy "明日がある.html", "/real.html", layout: false
|
@@ -0,0 +1 @@
|
|
1
|
+
@include invalid-mixin;
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "sinatra"
|
2
2
|
|
3
3
|
class MySinatra < Sinatra::Base
|
4
|
-
get
|
5
|
-
|
4
|
+
get "/" do
|
5
|
+
"Hello World (Sinatra)"
|
6
6
|
end
|
7
|
-
get
|
8
|
-
|
7
|
+
get "/derp.html" do
|
8
|
+
"De doo"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
map
|
12
|
+
map "/sinatra" do
|
13
13
|
run MySinatra
|
14
14
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
proxy
|
2
|
-
proxy
|
1
|
+
proxy "/sub/fake.html", "/proxied.html", ignore: true
|
2
|
+
proxy "/sub/fake2.html", "/proxied.html", ignore: true
|
3
3
|
|
4
|
-
proxy
|
5
|
-
proxy
|
4
|
+
proxy "/directory-indexed/fake.html", "/proxied.html", ignore: true
|
5
|
+
proxy "/directory-indexed/fake2.html", "/proxied.html", ignore: true
|
@@ -7,7 +7,7 @@ class ExtensionOne < ::Middleman::Extension
|
|
7
7
|
|
8
8
|
attr_reader :extension_two_was_activated
|
9
9
|
|
10
|
-
def initialize(app, options_hash
|
10
|
+
def initialize(app, options_hash={})
|
11
11
|
super
|
12
12
|
|
13
13
|
after_extension_activated :extension_two do
|
@@ -27,7 +27,7 @@ class ExtensionTwo < ::Middleman::Extension
|
|
27
27
|
|
28
28
|
attr_reader :extension_one_was_activated
|
29
29
|
|
30
|
-
def initialize(app, options_hash
|
30
|
+
def initialize(app, options_hash={})
|
31
31
|
super
|
32
32
|
|
33
33
|
after_extension_activated :extension_one do
|
@@ -1 +1 @@
|
|
1
|
-
page
|
1
|
+
page "/admin/*", layout: :admin
|
@@ -1,2 +1,2 @@
|
|
1
1
|
activate :directory_indexes
|
2
|
-
page
|
2
|
+
page "/admin/*", layout: :admin
|
data/lib/middleman/rack.rb
CHANGED
@@ -2,4 +2,11 @@ require 'middleman-core/load_paths'
|
|
2
2
|
::Middleman.setup_load_paths
|
3
3
|
|
4
4
|
require 'middleman-core'
|
5
|
+
require 'middleman-core/rack'
|
5
6
|
require 'middleman-core/application'
|
7
|
+
|
8
|
+
module Middleman
|
9
|
+
def self.server
|
10
|
+
::Middleman::Rack.new(::Middleman::Application.new)
|
11
|
+
end
|
12
|
+
end
|
@@ -53,7 +53,7 @@ module Middleman
|
|
53
53
|
# An anonymous subclass of ::Middleman::TemplateContext
|
54
54
|
attr_reader :template_context_class
|
55
55
|
|
56
|
-
# An instance of the above
|
56
|
+
# An instance of the above anonymouse class.
|
57
57
|
attr_reader :generic_template_context
|
58
58
|
|
59
59
|
Contract ::Middleman::Configuration::ConfigurationManager
|
@@ -158,11 +158,11 @@ module Middleman
|
|
158
158
|
|
159
159
|
# Which file extensions have a layout by default.
|
160
160
|
# @return [Array.<String>]
|
161
|
-
define_setting :extensions_with_layout, %w
|
161
|
+
define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.'
|
162
162
|
|
163
163
|
# Which file extensions are "assets."
|
164
164
|
# @return [Array.<String>]
|
165
|
-
define_setting :asset_extensions, %w
|
165
|
+
define_setting :asset_extensions, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map), 'Which file extensions are treated as assets.'
|
166
166
|
|
167
167
|
# Default string encoding for templates and output.
|
168
168
|
# @return [String]
|
@@ -182,7 +182,7 @@ module Middleman
|
|
182
182
|
ignored = false
|
183
183
|
|
184
184
|
file[:relative_path].ascend do |f|
|
185
|
-
if
|
185
|
+
if f.basename.to_s =~ %r{^_[^_]}
|
186
186
|
ignored = true
|
187
187
|
break
|
188
188
|
end
|
@@ -345,14 +345,13 @@ module Middleman
|
|
345
345
|
|
346
346
|
# Clean up missing Tilt exts
|
347
347
|
def prune_tilt_templates!
|
348
|
-
|
349
|
-
mapping.lazy_map.each_key do |key|
|
348
|
+
::Tilt.default_mapping.lazy_map.each_key do |key|
|
350
349
|
begin
|
351
|
-
|
350
|
+
::Tilt[".#{key}"]
|
352
351
|
rescue LoadError, NameError
|
352
|
+
::Tilt.default_mapping.lazy_map.delete(key)
|
353
353
|
end
|
354
354
|
end
|
355
|
-
mapping.lazy_map.clear
|
356
355
|
end
|
357
356
|
|
358
357
|
# Whether we're in a specific mode
|
@@ -439,10 +438,10 @@ module Middleman
|
|
439
438
|
#
|
440
439
|
# @deprecated Prefer accessing settings through "config".
|
441
440
|
#
|
442
|
-
# @param [Symbol] key Name of the
|
441
|
+
# @param [Symbol] key Name of the attribue
|
443
442
|
# @param value Attribute value
|
444
443
|
# @return [void]
|
445
|
-
def set(key, value
|
444
|
+
def set(key, value=nil, &block)
|
446
445
|
logger.warn "Warning: `set :#{key}` is deprecated. Use `config[:#{key}] =` instead."
|
447
446
|
|
448
447
|
value = block if block_given?
|
@@ -21,17 +21,17 @@ module Middleman
|
|
21
21
|
def_delegator :@app, :logger
|
22
22
|
|
23
23
|
# Sort order, images, fonts, js/css and finally everything else.
|
24
|
-
SORT_ORDER = %w
|
24
|
+
SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css).freeze
|
25
25
|
|
26
26
|
# Create a new Builder instance.
|
27
27
|
# @param [Middleman::Application] app The app to build.
|
28
28
|
# @param [Hash] opts The builder options
|
29
|
-
def initialize(app, opts
|
29
|
+
def initialize(app, opts={})
|
30
30
|
@app = app
|
31
31
|
@source_dir = Pathname(File.join(@app.root, @app.config[:source]))
|
32
32
|
@build_dir = Pathname(@app.config[:build_dir])
|
33
33
|
|
34
|
-
if
|
34
|
+
if @build_dir.expand_path.relative_path_from(@source_dir).to_s =~ /\A[.\/]+\Z/
|
35
35
|
raise ":build_dir (#{@build_dir}) cannot be a parent of :source_dir (#{@source_dir})"
|
36
36
|
end
|
37
37
|
|
@@ -133,40 +133,11 @@ module Middleman
|
|
133
133
|
|
134
134
|
Contract ResourceList => ResourceList
|
135
135
|
def output_resources(resources)
|
136
|
-
res_count = resources.count
|
137
|
-
|
138
|
-
return resources if res_count.zero?
|
139
|
-
|
140
136
|
results = if @parallel
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
offset = 0
|
146
|
-
ranges = []
|
147
|
-
|
148
|
-
while offset < res_count
|
149
|
-
end_r = offset + min_parts
|
150
|
-
|
151
|
-
if remainder.positive?
|
152
|
-
end_r += 1
|
153
|
-
remainder -= 1
|
154
|
-
end
|
155
|
-
|
156
|
-
range = offset...end_r
|
157
|
-
offset = end_r
|
158
|
-
ranges << range
|
159
|
-
end
|
160
|
-
|
161
|
-
outputs = Parallel.map(ranges, in_processes: processes) do |r|
|
162
|
-
resources[r].map!(&method(:output_resource))
|
163
|
-
end
|
164
|
-
|
165
|
-
outputs.flatten!
|
166
|
-
outputs
|
167
|
-
else
|
168
|
-
resources.map(&method(:output_resource))
|
169
|
-
end
|
137
|
+
::Parallel.map(resources, &method(:output_resource))
|
138
|
+
else
|
139
|
+
resources.map(&method(:output_resource))
|
140
|
+
end
|
170
141
|
|
171
142
|
@has_error = true if results.any? { |r| r == false }
|
172
143
|
|
@@ -175,11 +146,11 @@ module Middleman
|
|
175
146
|
next unless p.exist?
|
176
147
|
|
177
148
|
# handle UTF-8-MAC filename on MacOS
|
178
|
-
cleaned_name = if RUBY_PLATFORM
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
149
|
+
cleaned_name = if RUBY_PLATFORM =~ /darwin/
|
150
|
+
p.to_s.encode('UTF-8', 'UTF-8-MAC')
|
151
|
+
else
|
152
|
+
p
|
153
|
+
end
|
183
154
|
|
184
155
|
@to_clean.delete(Pathname(cleaned_name))
|
185
156
|
end
|
@@ -213,8 +184,8 @@ module Middleman
|
|
213
184
|
])
|
214
185
|
file.binmode
|
215
186
|
file.write(contents)
|
216
|
-
File.chmod(0o644, file)
|
217
187
|
file.close
|
188
|
+
File.chmod(0o644, file)
|
218
189
|
file
|
219
190
|
end
|
220
191
|
|
@@ -228,14 +199,14 @@ module Middleman
|
|
228
199
|
source = write_tempfile(output_file, source.to_s) if source.is_a? String
|
229
200
|
|
230
201
|
method, source_path = if source.is_a? Tempfile
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
202
|
+
[::FileUtils.method(:mv), source.path]
|
203
|
+
else
|
204
|
+
[::FileUtils.method(:cp), source.to_s]
|
205
|
+
end
|
235
206
|
|
236
207
|
mode = which_mode(output_file, source_path)
|
237
208
|
|
238
|
-
if
|
209
|
+
if mode == :created || mode == :updated
|
239
210
|
::FileUtils.mkdir_p(output_file.dirname)
|
240
211
|
method.call(source_path, output_file.to_s)
|
241
212
|
end
|
@@ -268,7 +239,7 @@ module Middleman
|
|
268
239
|
return false
|
269
240
|
end
|
270
241
|
end
|
271
|
-
rescue
|
242
|
+
rescue => e
|
272
243
|
trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
|
273
244
|
return false
|
274
245
|
end
|
@@ -296,7 +267,7 @@ module Middleman
|
|
296
267
|
|
297
268
|
# handle UTF-8-MAC filename on MacOS
|
298
269
|
@to_clean = @to_clean.map do |path|
|
299
|
-
if RUBY_PLATFORM
|
270
|
+
if RUBY_PLATFORM =~ /darwin/
|
300
271
|
Pathname(path.to_s.encode('UTF-8', 'UTF-8-MAC'))
|
301
272
|
else
|
302
273
|
Pathname(path)
|
@@ -324,7 +295,7 @@ module Middleman
|
|
324
295
|
end
|
325
296
|
|
326
297
|
Contract Symbol, Or[String, Pathname], Maybe[String] => Any
|
327
|
-
def trigger(event_type, target, extra
|
298
|
+
def trigger(event_type, target, extra=nil)
|
328
299
|
@events[event_type] ||= []
|
329
300
|
@events[event_type] << target
|
330
301
|
|
@@ -47,7 +47,7 @@ module Middleman
|
|
47
47
|
end
|
48
48
|
|
49
49
|
Contract Or[Symbol, ArrayOf[Symbol]], Maybe[ArrayOf[Any]], Maybe[RespondTo[:instance_exec]] => Any
|
50
|
-
def execute(keys, args
|
50
|
+
def execute(keys, args=[], scope=self)
|
51
51
|
callbacks = callbacks_for(keys)
|
52
52
|
callbacks_count = callbacks.length + @subscribers.length
|
53
53
|
|
@@ -16,7 +16,7 @@ module Middleman
|
|
16
16
|
@template_context_class = template_context_class
|
17
17
|
|
18
18
|
@callbacks = ::Middleman::CallbackManager.new
|
19
|
-
@callbacks.install_methods!(self,
|
19
|
+
@callbacks.install_methods!(self, [:before_build, :after_build, :configure, :after_configuration, :ready])
|
20
20
|
|
21
21
|
# Trigger internal callbacks when app level are executed.
|
22
22
|
app.subscribe_to_callbacks(&method(:execute_callbacks))
|
@@ -49,7 +49,7 @@ module Middleman
|
|
49
49
|
instance_eval File.read(other_config), other_config, 1
|
50
50
|
end
|
51
51
|
|
52
|
-
def set(key, default
|
52
|
+
def set(key, default=nil, &block)
|
53
53
|
config.define_setting(key, default) unless config.defines_setting?(key)
|
54
54
|
@app.config[key] = block_given? ? block : default
|
55
55
|
end
|
@@ -43,15 +43,15 @@ module Middleman
|
|
43
43
|
if defines_setting?(method) && args.empty?
|
44
44
|
self[method]
|
45
45
|
elsif method.to_s =~ /^(\w+)=$/ && args.size == 1
|
46
|
-
self[
|
46
|
+
self[$1.to_sym] = args[0]
|
47
47
|
else
|
48
48
|
super
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
# Needed so that method_missing makes sense
|
53
|
-
def respond_to?(method, include_private
|
54
|
-
super || defines_setting?(method) || (method =~ /^(\w+)=$/ && defines_setting?(
|
53
|
+
def respond_to?(method, include_private=false)
|
54
|
+
super || defines_setting?(method) || (method =~ /^(\w+)=$/ && defines_setting?($1))
|
55
55
|
end
|
56
56
|
|
57
57
|
# Does this configuration manager know about the setting identified by key?
|
@@ -71,7 +71,7 @@ module Middleman
|
|
71
71
|
# @param [String] description A human-readable description of what the option does
|
72
72
|
# @param [Hash] options Additional options.
|
73
73
|
# @return [ConfigSetting]
|
74
|
-
def define_setting(key, default
|
74
|
+
def define_setting(key, default=nil, description=nil, options={})
|
75
75
|
raise "Setting #{key} doesn't exist" if @finalized
|
76
76
|
raise "Setting #{key} already defined" if @settings.key?(key)
|
77
77
|
raise 'Setting key must be a Symbol' unless key.is_a? Symbol
|
@@ -127,7 +127,7 @@ module Middleman
|
|
127
127
|
# Additional config.
|
128
128
|
attr_accessor :options
|
129
129
|
|
130
|
-
def initialize(key, default, description, options
|
130
|
+
def initialize(key, default, description, options={})
|
131
131
|
@value_set = false
|
132
132
|
self.key = key
|
133
133
|
self.default = default
|
@@ -2,9 +2,9 @@ module Middleman
|
|
2
2
|
module CoreExtensions
|
3
3
|
module Collections
|
4
4
|
class LazyCollectorStep < BasicObject
|
5
|
-
DELEGATE =
|
5
|
+
DELEGATE = [:hash, :eql?].freeze
|
6
6
|
|
7
|
-
def initialize(name, args, block, parent
|
7
|
+
def initialize(name, args, block, parent=nil)
|
8
8
|
@name = name
|
9
9
|
@args = args
|
10
10
|
@block = block
|
@@ -19,19 +19,19 @@ module Middleman
|
|
19
19
|
@parent.leaves
|
20
20
|
end
|
21
21
|
|
22
|
-
def value(ctx
|
22
|
+
def value(ctx=nil)
|
23
23
|
data = @parent.value(ctx)
|
24
24
|
|
25
25
|
original_block = @block
|
26
26
|
|
27
27
|
if original_block
|
28
28
|
b = if ctx
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
::Proc.new do |*args|
|
30
|
+
ctx.instance_exec(*args, &original_block)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
original_block
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
data.send(@name, *@args.deep_dup, &b)
|
@@ -8,12 +8,12 @@ module Middleman
|
|
8
8
|
return to_enum(__method__, per_page) unless block_given?
|
9
9
|
|
10
10
|
parts = if per_page.respond_to? :call
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
per_page.call(dup)
|
12
|
+
else
|
13
|
+
each_slice(per_page).reduce([]) do |sum, items|
|
14
|
+
sum << items
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
18
|
num_pages = parts.length
|
19
19
|
collection = self
|