middleman-core 4.3.0.rc.1 → 4.3.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +0 -1
- data/cucumber.yml +2 -2
- data/features/asset_hash.feature +2 -2
- data/features/collections.feature +2 -2
- data/features/i18n_mixed_sources.feature +8 -0
- data/features/markdown.feature +0 -1
- data/features/multiple-sources-reload.feature +40 -0
- data/features/partials.feature +1 -1
- data/features/support/env.rb +4 -1
- data/features/tilde_directories.feature +0 -2
- data/features/unicode_filenames.feature +1 -1
- data/fixtures/asset-hash-app/config.rb +0 -1
- 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-prefix/config.rb +1 -2
- data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-source-map/config.rb +0 -1
- 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 +0 -1
- 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/destination-dir-different-from-source-dir-name/external/page.html.erb +1 -0
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +2 -0
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +1 -0
- data/fixtures/dynamic-pages-app/config.rb +25 -26
- 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/extension-hooks-app/config.rb +8 -8
- data/fixtures/external-helpers/config.rb +2 -2
- data/fixtures/external-helpers/helpers/derp.rb +3 -1
- data/fixtures/external-helpers/helpers/four_helpers.rb +3 -1
- data/fixtures/external-helpers/helpers/one_helper.rb +3 -1
- data/fixtures/external-helpers/helpers/yet_another_thingy.rb +3 -1
- 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/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-mixed-sources/source/c/d/index.html.erb +9 -0
- data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +9 -0
- 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-destination-dir/config.rb +2 -0
- data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +1 -0
- data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +1 -0
- data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
- data/fixtures/multiple-sources-without-destination-dir/config.rb +1 -0
- data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +1 -0
- data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +1 -0
- 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/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 +13 -14
- data/fixtures/sass-assets-path-app/config.rb +2 -2
- 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-core.rb +3 -3
- data/lib/middleman-core/application.rb +5 -5
- data/lib/middleman-core/builder.rb +20 -20
- 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.rb +1 -1
- 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/data.rb +10 -10
- data/lib/middleman-core/core_extensions/default_helpers.rb +26 -22
- 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 +24 -24
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +10 -7
- data/lib/middleman-core/core_extensions/routing.rb +1 -1
- data/lib/middleman-core/dns_resolver.rb +1 -1
- 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/extension.rb +26 -25
- data/lib/middleman-core/extension_manager.rb +1 -1
- data/lib/middleman-core/extensions.rb +8 -7
- data/lib/middleman-core/extensions/asset_hash.rb +24 -22
- 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 +14 -9
- data/lib/middleman-core/extensions/gzip.rb +7 -5
- data/lib/middleman-core/extensions/lorem.rb +9 -9
- data/lib/middleman-core/extensions/minify_css.rb +9 -9
- data/lib/middleman-core/extensions/minify_javascript.rb +10 -10
- data/lib/middleman-core/extensions/relative_assets.rb +8 -8
- data/lib/middleman-core/file_renderer.rb +6 -5
- data/lib/middleman-core/load_paths.rb +10 -10
- data/lib/middleman-core/logger.rb +2 -3
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server.rb +21 -22
- 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_url.rb +1 -1
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
- 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 +1 -4
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +2 -1
- 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 +5 -5
- data/lib/middleman-core/renderers/sass_functions.rb +5 -5
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -4
- 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 +2 -1
- 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 +80 -25
- data/lib/middleman-core/sitemap/resource.rb +21 -20
- data/lib/middleman-core/sitemap/store.rb +3 -3
- data/lib/middleman-core/sources.rb +12 -12
- data/lib/middleman-core/sources/source_watcher.rb +16 -10
- data/lib/middleman-core/step_definitions/builder_steps.rb +23 -23
- data/lib/middleman-core/step_definitions/commandline_steps.rb +5 -5
- data/lib/middleman-core/step_definitions/middleman_steps.rb +13 -14
- data/lib/middleman-core/step_definitions/server_steps.rb +14 -16
- data/lib/middleman-core/template_context.rb +17 -10
- data/lib/middleman-core/template_renderer.rb +34 -32
- data/lib/middleman-core/util.rb +2 -2
- data/lib/middleman-core/util/binary.rb +3 -1
- data/lib/middleman-core/util/data.rb +2 -2
- data/lib/middleman-core/util/files.rb +2 -2
- data/lib/middleman-core/util/paths.rb +47 -44
- data/lib/middleman-core/util/rack.rb +3 -3
- data/lib/middleman-core/util/uri_templates.rb +1 -0
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +3 -2
- data/spec/middleman-core/callbacks_spec.rb +15 -14
- data/spec/middleman-core/core_extensions/data_spec.rb +70 -74
- data/spec/middleman-core/dns_resolver_spec.rb +6 -6
- data/spec/middleman-core/util_spec.rb +81 -86
- data/spec/support/given.rb +11 -15
- metadata +44 -6
@@ -3,11 +3,11 @@ require 'addressable/uri'
|
|
3
3
|
class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
4
4
|
option :host, nil, 'The asset host to use or a Proc to determine asset host', required: true
|
5
5
|
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
|
6
|
-
option :sources, %w
|
6
|
+
option :sources, %w[.css .htm .html .js .php .xhtml], 'List of extensions that are searched for bustable assets.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for host rewrites'
|
9
9
|
|
10
|
-
def initialize(app, options_hash={}, &block)
|
10
|
+
def initialize(app, options_hash = {}, &block)
|
11
11
|
super
|
12
12
|
|
13
13
|
app.rewrite_inline_urls id: :asset_host,
|
@@ -24,16 +24,16 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
|
24
24
|
relative_path = uri.path[0..0] != '/'
|
25
25
|
|
26
26
|
full_asset_path = if relative_path
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
dirpath.join(asset_path).to_s
|
28
|
+
else
|
29
|
+
asset_path
|
30
|
+
end
|
31
31
|
|
32
32
|
asset_prefix = if options[:host].is_a?(Proc)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
options[:host].call(full_asset_path)
|
34
|
+
elsif options[:host].is_a?(String)
|
35
|
+
options[:host]
|
36
|
+
end
|
37
37
|
|
38
38
|
File.join(asset_prefix, full_asset_path)
|
39
39
|
end
|
@@ -4,7 +4,7 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
|
4
4
|
# Override default image_tag helper to automatically insert alt tag
|
5
5
|
# containing image name.
|
6
6
|
|
7
|
-
def image_tag(path, params={})
|
7
|
+
def image_tag(path, params = {})
|
8
8
|
unless path.include?('://')
|
9
9
|
params[:alt] ||= ''
|
10
10
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Automatic Image Sizes extension
|
2
2
|
class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
3
|
-
def initialize(app, options_hash={}, &block)
|
3
|
+
def initialize(app, options_hash = {}, &block)
|
4
4
|
super
|
5
5
|
|
6
6
|
# Include 3rd-party fastimage library
|
@@ -14,7 +14,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
|
14
14
|
# @param [String] path
|
15
15
|
# @param [Hash] params
|
16
16
|
# @return [String]
|
17
|
-
def image_tag(path, params={})
|
17
|
+
def image_tag(path, params = {})
|
18
18
|
if !params.key?(:width) && !params.key?(:height) && !path.include?('://')
|
19
19
|
real_path = path.dup
|
20
20
|
real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/')
|
@@ -36,7 +36,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
|
36
36
|
params[:height] = height
|
37
37
|
rescue FastImage::UnknownImageType
|
38
38
|
# No message, it's just not supported
|
39
|
-
rescue
|
39
|
+
rescue StandardError
|
40
40
|
warn "Couldn't determine dimensions for image #{path}: #{$ERROR_INFO.message}"
|
41
41
|
end
|
42
42
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# The Cache Buster extension
|
2
2
|
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
3
3
|
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
|
4
|
-
option :sources, %w
|
4
|
+
option :sources, %w[.css .htm .html .js .php .xhtml], 'List of extensions that are searched for bustable assets.'
|
5
5
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
6
6
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
7
7
|
|
8
|
-
def initialize(app, options_hash={}, &block)
|
8
|
+
def initialize(app, options_hash = {}, &block)
|
9
9
|
super
|
10
10
|
|
11
11
|
app.rewrite_inline_urls id: :cache_buster,
|
@@ -11,7 +11,7 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
|
|
11
11
|
index_file = app.config[:index_file]
|
12
12
|
new_index_path = "/#{index_file}"
|
13
13
|
|
14
|
-
extensions = %w
|
14
|
+
extensions = %w[.htm .html .php .xhtml]
|
15
15
|
|
16
16
|
resources.each do |resource|
|
17
17
|
# Check if it would be pointless to reroute
|
@@ -7,13 +7,12 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|
7
7
|
option :latency, 0.25, 'Latency between refreshes of source'
|
8
8
|
option :disable_background_execution, false, "Don't run the command in a separate background thread"
|
9
9
|
|
10
|
-
def initialize(app, config={}, &block)
|
10
|
+
def initialize(app, config = {}, &block)
|
11
11
|
super
|
12
12
|
|
13
13
|
return if app.mode?(:config)
|
14
14
|
|
15
15
|
require 'servolux'
|
16
|
-
require 'thread'
|
17
16
|
require 'fileutils'
|
18
17
|
|
19
18
|
source_path = File.expand_path(options[:source], app.root)
|
@@ -41,12 +40,12 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def reload!
|
44
|
-
|
45
|
-
logger.info "== Stopping: `#{options[:command]}`"
|
43
|
+
return unless @current_thread
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
logger.info "== Stopping: `#{options[:command]}`"
|
46
|
+
|
47
|
+
@current_thread.stop
|
48
|
+
@current_thread = nil
|
50
49
|
end
|
51
50
|
|
52
51
|
def watch_command!(async)
|
@@ -58,9 +57,12 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|
58
57
|
@current_thread.start
|
59
58
|
|
60
59
|
watch_thread = Thread.new do
|
61
|
-
|
60
|
+
buf = @current_thread.io.gets
|
61
|
+
|
62
|
+
while buf
|
62
63
|
without_newline = buf.sub(/\n$/, '')
|
63
64
|
logger.info "== External: #{without_newline}" unless without_newline.empty?
|
65
|
+
buf = @current_thread.io.gets
|
64
66
|
end
|
65
67
|
|
66
68
|
@current_thread.wait
|
@@ -80,9 +82,12 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|
80
82
|
private
|
81
83
|
|
82
84
|
def print_command(stdout)
|
83
|
-
|
85
|
+
buf = stdout.gets
|
86
|
+
|
87
|
+
while buf
|
84
88
|
without_newline = buf.sub(/\n$/, '')
|
85
89
|
logger.info "== External: #{without_newline}" unless without_newline.empty?
|
90
|
+
buf = stdout.gets
|
86
91
|
end
|
87
92
|
end
|
88
93
|
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# to .css, .htm, .html, .js, and .xhtml
|
11
11
|
#
|
12
12
|
class Middleman::Extensions::Gzip < ::Middleman::Extension
|
13
|
-
option :exts, %w
|
13
|
+
option :exts, %w[.css .htm .html .js .svg .xhtml], 'File extensions to Gzip when building.'
|
14
14
|
option :ignore, [], 'Patterns to avoid gzipping'
|
15
15
|
option :overwrite, false, 'Overwrite original files instead of adding .gz extension.'
|
16
16
|
|
@@ -18,13 +18,12 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|
18
18
|
include ::Padrino::Helpers::NumberHelpers
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(app, options_hash={})
|
21
|
+
def initialize(app, options_hash = {})
|
22
22
|
super
|
23
23
|
|
24
24
|
require 'zlib'
|
25
25
|
require 'stringio'
|
26
26
|
require 'find'
|
27
|
-
require 'thread'
|
28
27
|
end
|
29
28
|
|
30
29
|
def after_build(builder)
|
@@ -43,8 +42,11 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|
43
42
|
out_queue = Queue.new
|
44
43
|
num_threads.times.each do
|
45
44
|
Thread.new do
|
46
|
-
|
45
|
+
path = in_queue.pop
|
46
|
+
|
47
|
+
while path
|
47
48
|
out_queue << gzip_file(path.to_s)
|
49
|
+
path = in_queue.pop
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -63,7 +65,7 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|
63
65
|
next unless output_filename
|
64
66
|
|
65
67
|
total_savings += (old_size - new_size)
|
66
|
-
size_change_word = (old_size - new_size)
|
68
|
+
size_change_word = (old_size - new_size).positive? ? 'smaller' : 'larger'
|
67
69
|
builder.trigger :created, "#{output_filename} (#{NumberHelpers.new.number_to_human_size((old_size - new_size).abs)} #{size_change_word})"
|
68
70
|
end
|
69
71
|
|
@@ -11,7 +11,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
11
11
|
# @param [String] size
|
12
12
|
# @param [Hash] options
|
13
13
|
# @return [String]
|
14
|
-
def placekitten(size, options={})
|
14
|
+
def placekitten(size, options = {})
|
15
15
|
options[:domain] = 'http://placekitten.com'
|
16
16
|
lorem.image(size, options)
|
17
17
|
end
|
@@ -44,7 +44,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
44
44
|
module LoremObject
|
45
45
|
class << self
|
46
46
|
# Words for use in lorem text
|
47
|
-
WORDS = %w
|
47
|
+
WORDS = %w[alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat].freeze
|
48
48
|
|
49
49
|
# Get one placeholder word
|
50
50
|
# @return [String]
|
@@ -94,10 +94,10 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
94
94
|
# Get a placeholder date
|
95
95
|
# @param [String] fmt
|
96
96
|
# @return [String]
|
97
|
-
def date(fmt='%a %b %d, %Y')
|
98
|
-
y = rand(
|
99
|
-
m = rand(12)
|
100
|
-
d = rand(31)
|
97
|
+
def date(fmt = '%a %b %d, %Y')
|
98
|
+
y = rand(1990..2009)
|
99
|
+
m = rand(1..12)
|
100
|
+
d = rand(1..31)
|
101
101
|
Time.local(y, m, d).strftime(fmt)
|
102
102
|
end
|
103
103
|
|
@@ -135,7 +135,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
135
135
|
# @return [String]
|
136
136
|
def email
|
137
137
|
delimiters = ['_', '-', '']
|
138
|
-
domains = %w
|
138
|
+
domains = %w[gmail.com yahoo.com hotmail.com email.com live.com me.com mac.com aol.com fastmail.com mail.com]
|
139
139
|
username = name.gsub(/[^\w]/, delimiters[rand(delimiters.size)])
|
140
140
|
"#{username}@#{domains[rand(domains.size)]}".downcase
|
141
141
|
end
|
@@ -144,10 +144,10 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
144
144
|
# @param [String] size
|
145
145
|
# @param [Hash] options
|
146
146
|
# @return [String]
|
147
|
-
def image(size, options={})
|
147
|
+
def image(size, options = {})
|
148
148
|
domain = options[:domain] || 'http://placehold.it'
|
149
149
|
src = "#{domain}/#{size}"
|
150
|
-
hex = %w
|
150
|
+
hex = %w[a b c d e f 0 1 2 3 4 5 6 7 8 9]
|
151
151
|
background_color = options[:background_color]
|
152
152
|
color = options[:color]
|
153
153
|
|
@@ -10,8 +10,8 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
10
10
|
require 'sass'
|
11
11
|
SassCompressor
|
12
12
|
}, 'Set the CSS compressor to use.'
|
13
|
-
option :content_types, %w
|
14
|
-
option :inline_content_types, %w
|
13
|
+
option :content_types, %w[text/css], 'Content types of resources that contain CSS'
|
14
|
+
option :inline_content_types, %w[text/html text/php], 'Content types of resources that contain inline CSS'
|
15
15
|
|
16
16
|
def ready
|
17
17
|
# Setup Rack middleware to minify CSS
|
@@ -23,7 +23,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class SassCompressor
|
26
|
-
def self.compress(style, options={})
|
26
|
+
def self.compress(style, options = {})
|
27
27
|
root_node = ::Sass::SCSS::CssParser.new(style, 'middleman-css-input', 1).parse
|
28
28
|
root_node.options = {}.merge!(options).merge!(style: :compressed)
|
29
29
|
root_node.render.strip
|
@@ -44,7 +44,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
44
44
|
inline: Bool,
|
45
45
|
compressor: Or[Proc, RespondTo[:to_proc], RespondTo[:compress]]
|
46
46
|
} => Any
|
47
|
-
def initialize(app, options={})
|
47
|
+
def initialize(app, options = {})
|
48
48
|
@app = app
|
49
49
|
@ignore = options.fetch(:ignore)
|
50
50
|
@inline = options.fetch(:inline)
|
@@ -66,10 +66,10 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
66
66
|
path = env['PATH_INFO']
|
67
67
|
|
68
68
|
minified = if @inline && minifiable_inline?(content_type)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
minify_inline(::Middleman::Util.extract_response_text(response))
|
70
|
+
elsif minifiable?(content_type) && !ignore?(path)
|
71
|
+
minify(::Middleman::Util.extract_response_text(response))
|
72
|
+
end
|
73
73
|
|
74
74
|
if minified
|
75
75
|
headers['Content-Length'] = minified.bytesize.to_s
|
@@ -118,7 +118,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
118
118
|
# @return [String]
|
119
119
|
def minify_inline(content)
|
120
120
|
content.gsub(INLINE_CSS_REGEX) do
|
121
|
-
|
121
|
+
Regexp.last_match(1) + minify(Regexp.last_match(2)) + Regexp.last_match(3)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
memoize :minify_inline
|
@@ -10,8 +10,8 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|
10
10
|
require 'uglifier'
|
11
11
|
::Uglifier.new
|
12
12
|
}, 'Set the JS compressor to use.'
|
13
|
-
option :content_types, %w
|
14
|
-
option :inline_content_types, %w
|
13
|
+
option :content_types, %w[application/javascript application/ld+json], 'Content types of resources that contain JS'
|
14
|
+
option :inline_content_types, %w[text/html text/php], 'Content types of resources that contain inline JS'
|
15
15
|
|
16
16
|
def ready
|
17
17
|
# Setup Rack middleware to minify JS
|
@@ -36,7 +36,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|
36
36
|
inline: Bool,
|
37
37
|
compressor: Or[Proc, RespondTo[:to_proc], RespondTo[:compress]]
|
38
38
|
} => Any
|
39
|
-
def initialize(app, options={})
|
39
|
+
def initialize(app, options = {})
|
40
40
|
@app = app
|
41
41
|
@ignore = options.fetch(:ignore)
|
42
42
|
@inline = options.fetch(:inline)
|
@@ -58,10 +58,10 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|
58
58
|
@path = env['PATH_INFO']
|
59
59
|
|
60
60
|
minified = if @inline && minifiable_inline?(type)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
minify_inline(::Middleman::Util.extract_response_text(response))
|
62
|
+
elsif minifiable?(type) && !ignore?(@path)
|
63
|
+
minify(::Middleman::Util.extract_response_text(response))
|
64
|
+
end
|
65
65
|
|
66
66
|
if minified
|
67
67
|
headers['Content-Length'] = minified.bytesize.to_s
|
@@ -113,9 +113,9 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|
113
113
|
# @return [String]
|
114
114
|
def minify_inline(content)
|
115
115
|
content.gsub(INLINE_JS_REGEX) do |match|
|
116
|
-
first =
|
117
|
-
inline_content =
|
118
|
-
last =
|
116
|
+
first = Regexp.last_match(1)
|
117
|
+
inline_content = Regexp.last_match(2)
|
118
|
+
last = Regexp.last_match(3)
|
119
119
|
|
120
120
|
# Only compress script tags that contain JavaScript (as opposed to
|
121
121
|
# something like jQuery templates, identified with a "text/html" type).
|
@@ -3,12 +3,12 @@ require 'addressable/uri'
|
|
3
3
|
# Relative Assets extension
|
4
4
|
class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
5
5
|
option :exts, nil, 'List of extensions that get converted to relative paths.'
|
6
|
-
option :sources, %w
|
6
|
+
option :sources, %w[.css .htm .html .xhtml], 'List of extensions that are searched for relative assets.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip converting to relative paths.'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites.'
|
9
9
|
option :helpers_only, false, 'Allow only Ruby helpers to change paths.'
|
10
10
|
|
11
|
-
def initialize(app, options_hash={}, &block)
|
11
|
+
def initialize(app, options_hash = {}, &block)
|
12
12
|
super
|
13
13
|
|
14
14
|
return if options[:helpers_only]
|
@@ -46,11 +46,11 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|
46
46
|
end
|
47
47
|
|
48
48
|
helpers do
|
49
|
-
def asset_url(path, prefix='', options={})
|
49
|
+
def asset_url(path, prefix = '', options = {})
|
50
50
|
super(path, prefix, app.extensions[:relative_assets].mark_as_relative(super, options, current_resource))
|
51
51
|
end
|
52
52
|
|
53
|
-
def asset_path(kind, source, options={})
|
53
|
+
def asset_path(kind, source, options = {})
|
54
54
|
super(kind, source, app.extensions[:relative_assets].mark_as_relative(super, options, current_resource))
|
55
55
|
end
|
56
56
|
end
|
@@ -64,10 +64,10 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|
64
64
|
relative_path = uri.host.nil?
|
65
65
|
|
66
66
|
full_asset_path = if relative_path
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
dirpath.join(asset_path).to_s
|
68
|
+
else
|
69
|
+
asset_path
|
70
|
+
end
|
71
71
|
|
72
72
|
current_dir = Pathname(request_path).dirname
|
73
73
|
result = Pathname(full_asset_path).relative_path_from(current_dir).to_s
|
@@ -37,17 +37,18 @@ module Middleman
|
|
37
37
|
engine = extension[1..-1].to_sym
|
38
38
|
|
39
39
|
# Store last engine for later (could be inside nested renders)
|
40
|
-
|
40
|
+
engine_was = context.current_engine
|
41
|
+
context.current_engine = engine
|
41
42
|
|
42
43
|
# Save current buffer for later
|
43
44
|
buf_was = context.save_buffer
|
44
45
|
|
45
46
|
# Read from disk or cache the contents of the file
|
46
47
|
body = if opts[:template_body]
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
opts.delete(:template_body)
|
49
|
+
else
|
50
|
+
template_data_for_file
|
51
|
+
end
|
51
52
|
|
52
53
|
# Merge per-extension options from config
|
53
54
|
extension = File.extname(path)
|
@@ -5,7 +5,6 @@ module Middleman
|
|
5
5
|
class << self
|
6
6
|
def setup_load_paths
|
7
7
|
@_is_setup ||= begin
|
8
|
-
|
9
8
|
# Only look for config.rb if MM_ROOT isn't set
|
10
9
|
if !ENV['MM_ROOT'] && (found_path = findup('config.rb'))
|
11
10
|
ENV['MM_ROOT'] = found_path
|
@@ -22,27 +21,28 @@ module Middleman
|
|
22
21
|
|
23
22
|
# Set BUNDLE_GEMFILE and run Bundler setup. Raises an exception if there is no Gemfile
|
24
23
|
def setup_bundler
|
25
|
-
|
24
|
+
found_gemfile_root = findup('Gemfile', ENV['MM_ROOT'])
|
25
|
+
|
26
|
+
if found_gemfile_root
|
26
27
|
ENV['BUNDLE_GEMFILE'] ||= File.join(found_gemfile_root, 'Gemfile')
|
27
28
|
end
|
28
29
|
|
29
30
|
unless File.exist?(ENV['BUNDLE_GEMFILE'])
|
30
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('
|
31
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../Gemfile', __dir__)
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
raise "Couldn't find your Gemfile. Middleman projects require a Gemfile for specifying dependencies."
|
38
|
-
end
|
34
|
+
raise "Couldn't find your Gemfile. Middleman projects require a Gemfile for specifying dependencies." unless File.exist?(ENV['BUNDLE_GEMFILE'])
|
35
|
+
|
36
|
+
require 'bundler/setup'
|
37
|
+
Bundler.require
|
39
38
|
end
|
40
39
|
|
41
40
|
# Recursive method to find a file in parent directories
|
42
|
-
def findup(filename, cwd=Dir.pwd)
|
41
|
+
def findup(filename, cwd = Dir.pwd)
|
43
42
|
cwd = Pathname(cwd)
|
44
43
|
return cwd.to_s if (cwd + filename).exist?
|
45
44
|
return false if cwd.root?
|
45
|
+
|
46
46
|
findup(filename, cwd.parent)
|
47
47
|
end
|
48
48
|
end
|