middleman-core 4.1.0.rc.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/asset_hash.feature +30 -32
- data/features/asset_host.feature +2 -0
- data/features/gzip.feature +1 -1
- data/features/import_files.feature +0 -2
- data/features/nested_layouts.feature +20 -17
- data/fixtures/asset-host-app/source/javascripts/asset_host.js +2 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +1 -1
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +1 -1
- data/fixtures/nested-layout-app/source/layouts/inner.erb +5 -2
- data/fixtures/nested-layout-app/source/layouts/inner_haml.haml +6 -2
- data/fixtures/nested-layout-app/source/layouts/inner_slim.slim +6 -2
- data/fixtures/nested-layout-app/source/layouts/master.erb +7 -1
- data/fixtures/nested-layout-app/source/layouts/master_haml.haml +5 -1
- data/fixtures/nested-layout-app/source/layouts/master_slim.slim +5 -1
- data/fixtures/nested-layout-app/source/layouts/outer.erb +6 -2
- data/fixtures/nested-layout-app/source/layouts/outer_haml.haml +5 -1
- data/fixtures/nested-layout-app/source/layouts/outer_slim.slim +5 -1
- data/lib/middleman-core.rb +0 -3
- data/lib/middleman-core/application.rb +7 -9
- data/lib/middleman-core/builder.rb +88 -44
- data/lib/middleman-core/contracts.rb +102 -13
- data/lib/middleman-core/core_extensions/data.rb +15 -10
- data/lib/middleman-core/core_extensions/default_helpers.rb +15 -6
- data/lib/middleman-core/core_extensions/file_watcher.rb +2 -2
- data/lib/middleman-core/core_extensions/front_matter.rb +11 -3
- data/lib/middleman-core/core_extensions/i18n.rb +1 -1
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +2 -2
- data/lib/middleman-core/extension.rb +1 -1
- data/lib/middleman-core/extensions.rb +1 -1
- data/lib/middleman-core/extensions/asset_hash.rb +1 -1
- data/lib/middleman-core/extensions/asset_host.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +1 -1
- data/lib/middleman-core/extensions/cache_buster.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +2 -1
- data/lib/middleman-core/extensions/gzip.rb +2 -2
- data/lib/middleman-core/extensions/minify_css.rb +1 -1
- data/lib/middleman-core/extensions/minify_javascript.rb +1 -1
- data/lib/middleman-core/extensions/relative_assets.rb +1 -1
- data/lib/middleman-core/file_renderer.rb +12 -9
- data/lib/middleman-core/logger.rb +1 -0
- data/lib/middleman-core/preview_server.rb +14 -14
- data/lib/middleman-core/renderers/haml.rb +3 -1
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +7 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/import.rb +3 -1
- data/lib/middleman-core/sitemap/resource.rb +7 -6
- data/lib/middleman-core/sources.rb +30 -13
- data/lib/middleman-core/sources/source_watcher.rb +50 -12
- data/lib/middleman-core/step_definitions/middleman_steps.rb +2 -2
- data/lib/middleman-core/template_context.rb +1 -1
- data/lib/middleman-core/template_renderer.rb +13 -4
- data/lib/middleman-core/util.rb +6 -606
- data/lib/middleman-core/util/binary.rb +79 -0
- data/lib/middleman-core/util/data.rb +37 -8
- data/lib/middleman-core/util/files.rb +134 -0
- data/lib/middleman-core/util/paths.rb +251 -0
- data/lib/middleman-core/util/rack.rb +52 -0
- data/lib/middleman-core/util/uri_templates.rb +97 -0
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -0
- metadata +25 -4
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'middleman-core/contracts'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Util
|
5
|
+
include Contracts
|
6
|
+
|
7
|
+
module_function
|
8
|
+
|
9
|
+
# Extract the text of a Rack response as a string.
|
10
|
+
# Useful for extensions implemented as Rack middleware.
|
11
|
+
# @param response The response from #call
|
12
|
+
# @return [String] The whole response as a string.
|
13
|
+
Contract RespondTo[:each] => String
|
14
|
+
def extract_response_text(response)
|
15
|
+
# The rack spec states all response bodies must respond to each
|
16
|
+
result = ''
|
17
|
+
response.each do |part, _|
|
18
|
+
result << part
|
19
|
+
end
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
Contract String, String, ArrayOf[String], Proc => String
|
24
|
+
def rewrite_paths(body, _path, exts, &_block)
|
25
|
+
matcher = /([\'\"\(,]\s*)([^\s\'\"\)>]+(#{::Regexp.union(exts)}))/
|
26
|
+
|
27
|
+
url_fn_prefix = 'url('
|
28
|
+
|
29
|
+
body.dup.gsub(matcher) do |match|
|
30
|
+
opening_character = $1
|
31
|
+
asset_path = $2
|
32
|
+
|
33
|
+
if asset_path.start_with?(url_fn_prefix)
|
34
|
+
opening_character << url_fn_prefix
|
35
|
+
asset_path = asset_path[url_fn_prefix.length..-1]
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
uri = ::Addressable::URI.parse(asset_path)
|
40
|
+
|
41
|
+
if uri.relative? && uri.host.nil? && !(asset_path =~ /^[^\/].*[a-z]+\.[a-z]+\/.*/) && (result = yield(asset_path))
|
42
|
+
"#{opening_character}#{result}"
|
43
|
+
else
|
44
|
+
match
|
45
|
+
end
|
46
|
+
rescue ::Addressable::URI::InvalidURIError
|
47
|
+
match
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# For URI templating
|
2
|
+
require 'addressable/uri'
|
3
|
+
require 'addressable/template'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
require 'active_support/inflector/transliterate'
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
module Util
|
9
|
+
# Handy methods for dealing with URI templates. Mix into whatever class.
|
10
|
+
module UriTemplates
|
11
|
+
module_function
|
12
|
+
|
13
|
+
# Given a URI template string, make an Addressable::Template
|
14
|
+
# This supports the legacy middleman-blog/Sinatra style :colon
|
15
|
+
# URI templates as well as RFC6570 templates.
|
16
|
+
#
|
17
|
+
# @param [String] tmpl_src URI template source
|
18
|
+
# @return [Addressable::Template] a URI template
|
19
|
+
def uri_template(tmpl_src)
|
20
|
+
# Support the RFC6470 templates directly if people use them
|
21
|
+
if tmpl_src.include?(':')
|
22
|
+
tmpl_src = tmpl_src.gsub(/:([A-Za-z0-9]+)/, '{\1}')
|
23
|
+
end
|
24
|
+
|
25
|
+
::Addressable::Template.new(::Middleman::Util.normalize_path(tmpl_src))
|
26
|
+
end
|
27
|
+
|
28
|
+
# Apply a URI template with the given data, producing a normalized
|
29
|
+
# Middleman path.
|
30
|
+
#
|
31
|
+
# @param [Addressable::Template] template
|
32
|
+
# @param [Hash] data
|
33
|
+
# @return [String] normalized path
|
34
|
+
def apply_uri_template(template, data)
|
35
|
+
::Middleman::Util.normalize_path(::Addressable::URI.unencode(template.expand(data)).to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Use a template to extract parameters from a path, and validate some special (date)
|
39
|
+
# keys. Returns nil if the special keys don't match.
|
40
|
+
#
|
41
|
+
# @param [Addressable::Template] template
|
42
|
+
# @param [String] path
|
43
|
+
def extract_params(template, path)
|
44
|
+
template.extract(path, BlogTemplateProcessor)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Parameterize a string preserving any multibyte characters
|
48
|
+
def safe_parameterize(str)
|
49
|
+
sep = '-'
|
50
|
+
|
51
|
+
# Reimplementation of http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-parameterize that preserves un-transliterate-able multibyte chars.
|
52
|
+
parameterized_string = ::ActiveSupport::Inflector.transliterate(str.to_s).downcase
|
53
|
+
parameterized_string.gsub!(/[^a-z0-9\-_\?]+/, sep)
|
54
|
+
|
55
|
+
parameterized_string.chars.to_a.each_with_index do |char, i|
|
56
|
+
next unless char == '?' && str[i].bytes.count != 1
|
57
|
+
parameterized_string[i] = str[i]
|
58
|
+
end
|
59
|
+
|
60
|
+
re_sep = ::Regexp.escape(sep)
|
61
|
+
# No more than one of the separator in a row.
|
62
|
+
parameterized_string.gsub!(/#{re_sep}{2,}/, sep)
|
63
|
+
# Remove leading/trailing separator.
|
64
|
+
parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
|
65
|
+
|
66
|
+
parameterized_string
|
67
|
+
end
|
68
|
+
|
69
|
+
# Convert a date into a hash of components to strings
|
70
|
+
# suitable for using in a URL template.
|
71
|
+
# @param [DateTime] date
|
72
|
+
# @return [Hash] parameters
|
73
|
+
def date_to_params(date)
|
74
|
+
{
|
75
|
+
year: date.year.to_s,
|
76
|
+
month: date.month.to_s.rjust(2, '0'),
|
77
|
+
day: date.day.to_s.rjust(2, '0')
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# A special template processor that validates date fields
|
83
|
+
# and has an extra-permissive default regex.
|
84
|
+
#
|
85
|
+
# See https://github.com/sporkmonger/addressable/blob/master/lib/addressable/template.rb#L279
|
86
|
+
class BlogTemplateProcessor
|
87
|
+
def self.match(name)
|
88
|
+
case name
|
89
|
+
when 'year' then '\d{4}'
|
90
|
+
when 'month' then '\d{2}'
|
91
|
+
when 'day' then '\d{2}'
|
92
|
+
else '.*?'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/middleman-core.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -88,6 +88,20 @@ dependencies:
|
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: parallel
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
type: :runtime
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
91
105
|
- !ruby/object:Gem::Dependency
|
92
106
|
name: activesupport
|
93
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -436,6 +450,7 @@ files:
|
|
436
450
|
- fixtures/asset-host-app/source/.htaccess
|
437
451
|
- fixtures/asset-host-app/source/asset_host.html.erb
|
438
452
|
- fixtures/asset-host-app/source/images/blank.gif
|
453
|
+
- fixtures/asset-host-app/source/javascripts/asset_host.js
|
439
454
|
- fixtures/asset-host-app/source/stylesheets/asset_host.css.sass
|
440
455
|
- fixtures/auto-css-app/config.rb
|
441
456
|
- fixtures/auto-css-app/source/auto-css.html.erb
|
@@ -1390,7 +1405,12 @@ files:
|
|
1390
1405
|
- lib/middleman-core/template_context.rb
|
1391
1406
|
- lib/middleman-core/template_renderer.rb
|
1392
1407
|
- lib/middleman-core/util.rb
|
1408
|
+
- lib/middleman-core/util/binary.rb
|
1393
1409
|
- lib/middleman-core/util/data.rb
|
1410
|
+
- lib/middleman-core/util/files.rb
|
1411
|
+
- lib/middleman-core/util/paths.rb
|
1412
|
+
- lib/middleman-core/util/rack.rb
|
1413
|
+
- lib/middleman-core/util/uri_templates.rb
|
1394
1414
|
- lib/middleman-core/version.rb
|
1395
1415
|
- lib/middleman/rack.rb
|
1396
1416
|
- middleman-core.gemspec
|
@@ -1423,9 +1443,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1423
1443
|
version: 2.0.0
|
1424
1444
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1425
1445
|
requirements:
|
1426
|
-
- - "
|
1446
|
+
- - ">="
|
1427
1447
|
- !ruby/object:Gem::Version
|
1428
|
-
version:
|
1448
|
+
version: '0'
|
1429
1449
|
requirements: []
|
1430
1450
|
rubyforge_project:
|
1431
1451
|
rubygems_version: 2.4.8
|
@@ -1568,6 +1588,7 @@ test_files:
|
|
1568
1588
|
- fixtures/asset-host-app/source/.htaccess
|
1569
1589
|
- fixtures/asset-host-app/source/asset_host.html.erb
|
1570
1590
|
- fixtures/asset-host-app/source/images/blank.gif
|
1591
|
+
- fixtures/asset-host-app/source/javascripts/asset_host.js
|
1571
1592
|
- fixtures/asset-host-app/source/stylesheets/asset_host.css.sass
|
1572
1593
|
- fixtures/auto-css-app/config.rb
|
1573
1594
|
- fixtures/auto-css-app/source/auto-css.html.erb
|