middleman-core 4.5.1 → 4.6.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/.simplecov +0 -2
- data/.yardopts +1 -2
- data/Rakefile +1 -1
- data/features/builder.feature +4 -4
- data/features/content_type.feature +1 -1
- data/features/data.feature +5 -0
- data/features/front-matter.feature +21 -0
- data/features/minify_javascript.feature +38 -39
- data/features/preview_changes.feature +11 -0
- data/features/sass_in_slim.feature +2 -2
- data/features/support/env.rb +8 -0
- data/fixtures/data-with-aliases-app/config.rb +3 -0
- data/fixtures/data-with-aliases-app/data/pages.yml +9 -0
- data/fixtures/data-with-aliases-app/source/index.html.erb +1 -0
- data/fixtures/data-with-aliases-app/source/layout.erb +5 -0
- data/fixtures/generator-test/config.rb +1 -14
- data/fixtures/sinatra-app/config.rb +2 -0
- data/lib/middleman-core/application.rb +0 -13
- data/lib/middleman-core/builder.rb +3 -3
- data/lib/middleman-core/contracts.rb +0 -1
- data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +1 -1
- data/lib/middleman-core/extensions/minify_javascript.rb +1 -1
- data/lib/middleman-core/file_renderer.rb +1 -7
- data/lib/middleman-core/preview_server/server_hostname.rb +0 -2
- data/lib/middleman-core/preview_server.rb +3 -2
- data/lib/middleman-core/rack.rb +6 -6
- data/lib/middleman-core/renderers/coffee_script.rb +2 -6
- data/lib/middleman-core/renderers/erb.rb +15 -3
- data/lib/middleman-core/renderers/haml.rb +1 -3
- data/lib/middleman-core/renderers/kramdown.rb +7 -11
- data/lib/middleman-core/renderers/less.rb +10 -26
- data/lib/middleman-core/renderers/liquid.rb +1 -1
- data/lib/middleman-core/renderers/redcarpet.rb +4 -14
- data/lib/middleman-core/renderers/sass.rb +3 -10
- data/lib/middleman-core/renderers/sass_functions.rb +2 -2
- data/lib/middleman-core/renderers/slim.rb +9 -1
- data/lib/middleman-core/sources/source_watcher.rb +1 -1
- data/lib/middleman-core/step_definitions/commandline_steps.rb +14 -14
- data/lib/middleman-core/step_definitions.rb +3 -0
- data/lib/middleman-core/template_renderer.rb +2 -2
- data/lib/middleman-core/util/data.rb +4 -5
- data/lib/middleman-core/util/paths.rb +2 -1
- data/lib/middleman-core/util.rb +6 -0
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +0 -2
- data/middleman-core.gemspec +16 -15
- data/spec/spec_helper.rb +2 -2
- metadata +1176 -62
- data/.gemtest +0 -0
- data/.rspec +0 -1
- data/cucumber.yml +0 -2
@@ -1,36 +1,20 @@
|
|
1
|
-
require 'less'
|
2
|
-
|
3
1
|
module Middleman
|
4
2
|
module Renderers
|
5
3
|
# Sass renderer
|
6
4
|
class Less < ::Middleman::Extension
|
7
|
-
define_setting :less, {}, 'LESS compiler options'
|
8
|
-
|
9
|
-
def initialize(app, options={}, &block)
|
10
|
-
super
|
11
|
-
|
12
|
-
# Tell Tilt to use it as well (for inline sass blocks)
|
13
|
-
::Tilt.register 'less', LocalLoadingLessTemplate
|
14
|
-
::Tilt.prefer(LocalLoadingLessTemplate)
|
15
|
-
end
|
16
|
-
|
17
|
-
def after_configuration
|
18
|
-
app.files.by_type(:source).watchers.each do |source|
|
19
|
-
::Less.paths << (source.directory + app.config[:css_dir]).to_s
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
5
|
# A SassTemplate for Tilt which outputs debug messages
|
24
|
-
class
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
6
|
+
class DummyLessTemplate < ::Tilt::Template
|
7
|
+
def evaluate(scope, locals, &block)
|
8
|
+
raise <<~ERROR
|
9
|
+
The builtin less renderer has been removed from middleman.
|
10
|
+
To continue using less, make sure to setup an external pipeline.
|
11
|
+
See external pipeline documentation at https://middlemanapp.com/advanced/external-pipeline
|
12
|
+
for more information.
|
13
|
+
ERROR
|
32
14
|
end
|
33
15
|
end
|
16
|
+
|
17
|
+
::Tilt.register 'less', DummyLessTemplate
|
34
18
|
end
|
35
19
|
end
|
36
20
|
end
|
@@ -11,7 +11,7 @@ module Middleman
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Called by Liquid to retrieve a template file
|
14
|
-
def read_template_file(template_path, _)
|
14
|
+
def read_template_file(template_path, _ = nil)
|
15
15
|
file = app.files.find(:source, "_#{template_path}.liquid")
|
16
16
|
raise ::Liquid::FileSystemError, "No such template '#{template_path}'" unless file
|
17
17
|
file.read
|
@@ -10,13 +10,12 @@ module Middleman
|
|
10
10
|
escape_html: :filter_html
|
11
11
|
}.freeze
|
12
12
|
|
13
|
-
|
14
|
-
super
|
13
|
+
private
|
15
14
|
|
16
|
-
|
15
|
+
def _prepare_output
|
16
|
+
Redcarpet::Markdown.new(generate_renderer, options).render(data)
|
17
17
|
end
|
18
18
|
|
19
|
-
# Overwrite built-in Tilt version.
|
20
19
|
# Don't overload :renderer option with smartypants
|
21
20
|
# Support renderer-level options
|
22
21
|
def generate_renderer
|
@@ -26,6 +25,7 @@ module Middleman
|
|
26
25
|
|
27
26
|
# Pick a renderer
|
28
27
|
renderer = MiddlemanRedcarpetHTML
|
28
|
+
renderer.scope = options[:context]
|
29
29
|
|
30
30
|
if options.delete(:smartypants)
|
31
31
|
# Support SmartyPants
|
@@ -44,16 +44,6 @@ module Middleman
|
|
44
44
|
renderer.new(render_options)
|
45
45
|
end
|
46
46
|
|
47
|
-
def evaluate(scope, _)
|
48
|
-
@output ||= begin
|
49
|
-
MiddlemanRedcarpetHTML.scope = @context || scope
|
50
|
-
|
51
|
-
@engine.render(data)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
47
|
def covert_options_to_aliases!
|
58
48
|
ALIASES.each do |aka, actual|
|
59
49
|
options[actual] = options.delete(aka) if options.key? aka
|
@@ -29,26 +29,19 @@ module Middleman
|
|
29
29
|
|
30
30
|
# A SassTemplate for Tilt which outputs debug messages
|
31
31
|
class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate
|
32
|
-
def initialize(*args, &block)
|
33
|
-
super
|
34
|
-
|
35
|
-
@context = @options[:context] if @options.key?(:context)
|
36
|
-
end
|
37
|
-
|
38
32
|
# Define the expected syntax for the template
|
39
33
|
# @return [Symbol]
|
40
34
|
def syntax
|
41
35
|
:sass
|
42
36
|
end
|
43
37
|
|
44
|
-
|
38
|
+
private
|
45
39
|
|
46
40
|
# Add exception messaging
|
47
41
|
# @param [Class] context
|
48
42
|
# @return [String]
|
49
|
-
def
|
50
|
-
@context
|
51
|
-
|
43
|
+
def _prepare_output
|
44
|
+
@context = @options[:context]
|
52
45
|
@engine = ::SassC::Engine.new(data, sass_options)
|
53
46
|
|
54
47
|
begin
|
@@ -29,7 +29,7 @@ module Middleman
|
|
29
29
|
# background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
|
30
30
|
#
|
31
31
|
def image_url(source, options={}, _cache_buster=nil)
|
32
|
-
# Work with the
|
32
|
+
# Work with the Sass #image_url API
|
33
33
|
if options.respond_to? :value
|
34
34
|
case options.value
|
35
35
|
when true
|
@@ -66,7 +66,7 @@ module Middleman
|
|
66
66
|
# src: font-url("image.jpg", $digest: true); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
|
67
67
|
#
|
68
68
|
def font_url(source, options={})
|
69
|
-
# Work with the
|
69
|
+
# Work with the Sass #font_url API
|
70
70
|
if options.respond_to? :value
|
71
71
|
case options.value
|
72
72
|
when true
|
@@ -39,9 +39,17 @@ module Middleman
|
|
39
39
|
::Slim::Engine.set_options(
|
40
40
|
buffer: '@_out_buf',
|
41
41
|
use_html_safe: true,
|
42
|
-
generator: ::Temple::Generators::RailsOutputBuffer,
|
43
42
|
disable_escape: true
|
44
43
|
)
|
44
|
+
begin
|
45
|
+
require "action_view"
|
46
|
+
rescue LoadError
|
47
|
+
# Don't add generator option if action_view is not available, since it depends on it
|
48
|
+
else
|
49
|
+
::Slim::Engine.set_options(
|
50
|
+
generator: ::Temple::Generators::RailsOutputBuffer,
|
51
|
+
)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
@@ -335,7 +335,7 @@ module Middleman
|
|
335
335
|
|
336
336
|
Contract Pathname => Pathname
|
337
337
|
def strip_extensions(p)
|
338
|
-
p = p.sub_ext('') while ::
|
338
|
+
p = p.sub_ext('') while Middleman::Util.tilt_class(p.to_s) || p.extname == '.html'
|
339
339
|
Pathname(p.to_s + '.*')
|
340
340
|
end
|
341
341
|
|
@@ -1,28 +1,28 @@
|
|
1
1
|
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
|
2
2
|
begin
|
3
|
-
Timeout.timeout(exit_timeout) do
|
3
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
4
4
|
loop do
|
5
|
-
fail "You need to start middleman interactively first." unless
|
5
|
+
fail "You need to start middleman interactively first." unless last_command_started
|
6
6
|
|
7
|
-
if
|
8
|
-
|
7
|
+
if unescape_text(last_command_started.output) =~ Regexp.new(unescape_text(expected))
|
8
|
+
all_commands.each { |p| p.terminate }
|
9
9
|
break
|
10
10
|
end
|
11
11
|
|
12
12
|
sleep 0.1
|
13
13
|
end
|
14
14
|
end
|
15
|
-
rescue ChildProcess::TimeoutError,
|
16
|
-
|
15
|
+
rescue ChildProcess::TimeoutError, Timeout::Error
|
16
|
+
last_command_started.terminate
|
17
17
|
ensure
|
18
|
-
announcer.stdout
|
19
|
-
announcer.stderr
|
18
|
+
aruba.announcer.announce :stdout, last_command_started.stdout
|
19
|
+
aruba.announcer.announce :stderr, last_command_started.stderr
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
# Make it just a long running process
|
24
24
|
Given /`(.*?)` is running in background/ do |cmd|
|
25
|
-
|
25
|
+
run_command(cmd, exit_timeout: 120)
|
26
26
|
end
|
27
27
|
|
28
28
|
Given /I have a local hosts file with:/ do |string|
|
@@ -49,10 +49,10 @@ Given /I start a dns server with:/ do |string|
|
|
49
49
|
)
|
50
50
|
)
|
51
51
|
|
52
|
-
|
52
|
+
set_environment_variable 'PATH', File.expand_path(File.join(aruba.current_directory, 'bin')) + ':' + ENV['PATH']
|
53
53
|
write_file db_file, string
|
54
54
|
|
55
|
-
@dns_server =
|
55
|
+
@dns_server = run_command("dns_server.rb #{db_file} #{port}", exit_timeout: 120)
|
56
56
|
end
|
57
57
|
|
58
58
|
Given /I start a mdns server with:/ do |string|
|
@@ -68,10 +68,10 @@ Given /I start a mdns server with:/ do |string|
|
|
68
68
|
)
|
69
69
|
)
|
70
70
|
|
71
|
-
|
71
|
+
set_environment_variable 'PATH', File.expand_path(File.join(aruba.current_directory, 'bin')) + ':' + ENV['PATH']
|
72
72
|
write_file db_file, string
|
73
73
|
|
74
|
-
@mdns_server =
|
74
|
+
@mdns_server = run_command("dns_server.rb #{db_file} #{port}", exit_timeout: 120)
|
75
75
|
end
|
76
76
|
|
77
77
|
Given /I start a mdns server for the local hostname/ do
|
@@ -80,5 +80,5 @@ end
|
|
80
80
|
|
81
81
|
# Make sure each and every process is really dead
|
82
82
|
After do
|
83
|
-
|
83
|
+
all_commands.each { |p| p.terminate }
|
84
84
|
end
|
@@ -16,6 +16,9 @@ module ArubaMonkeypatch
|
|
16
16
|
end
|
17
17
|
World(ArubaMonkeypatch)
|
18
18
|
|
19
|
+
# The Capybara monkey-patch that switches between RSpec::Matchers#all and Capybara::DSL#all
|
20
|
+
World(Capybara::RSpecMatcherProxies)
|
21
|
+
|
19
22
|
Before do
|
20
23
|
@aruba_timeout_seconds = RUBY_PLATFORM == 'java' ? 120 : 60
|
21
24
|
end
|
@@ -119,10 +119,10 @@ module Middleman
|
|
119
119
|
|
120
120
|
if defined?(::I18n)
|
121
121
|
old_locale = ::I18n.locale
|
122
|
-
::I18n.locale = options
|
122
|
+
::I18n.locale = options.delete(:locale) if options[:locale]
|
123
123
|
|
124
124
|
# Backwards compat
|
125
|
-
::I18n.locale = options
|
125
|
+
::I18n.locale = options.delete(:lang) if options[:lang]
|
126
126
|
end
|
127
127
|
|
128
128
|
# Sandboxed class for template eval
|
@@ -2,7 +2,6 @@ require 'yaml'
|
|
2
2
|
require 'json'
|
3
3
|
require 'toml'
|
4
4
|
require 'pathname'
|
5
|
-
require 'backports/2.1.0/array/to_h'
|
6
5
|
require 'hashie'
|
7
6
|
require 'memoist'
|
8
7
|
|
@@ -118,16 +117,16 @@ module Middleman
|
|
118
117
|
# @return [Hash]
|
119
118
|
Contract String, Pathname => Hash
|
120
119
|
def parse_yaml(content, full_path)
|
121
|
-
permitted_classes = [Date, Symbol]
|
120
|
+
permitted_classes = [Date, Time, DateTime, Symbol, Regexp]
|
122
121
|
c = begin
|
123
122
|
::Middleman::Util.instrument 'parse.yaml' do
|
124
123
|
allowed_parameters = ::YAML.method(:safe_load).parameters
|
125
124
|
if allowed_parameters.include? [:key, :permitted_classes]
|
126
|
-
::YAML.safe_load(content, permitted_classes: permitted_classes)
|
125
|
+
::YAML.safe_load(content, permitted_classes: permitted_classes, aliases: true)
|
127
126
|
elsif allowed_parameters.include? [:key, :whitelist_classes]
|
128
|
-
::YAML.safe_load(content, whitelist_classes: permitted_classes)
|
127
|
+
::YAML.safe_load(content, whitelist_classes: permitted_classes, aliases: true)
|
129
128
|
else
|
130
|
-
::YAML.safe_load(content, permitted_classes)
|
129
|
+
::YAML.safe_load(content, permitted_classes, [], true)
|
131
130
|
end
|
132
131
|
end
|
133
132
|
rescue StandardError, ::Psych::SyntaxError => error
|
@@ -7,7 +7,6 @@ require 'tilt'
|
|
7
7
|
|
8
8
|
require 'middleman-core/contracts'
|
9
9
|
|
10
|
-
# rubocop:disable ModuleLength
|
11
10
|
module Middleman
|
12
11
|
module Util
|
13
12
|
extend Memoist
|
@@ -24,6 +23,8 @@ module Middleman
|
|
24
23
|
Contract String => Any
|
25
24
|
def tilt_class(path)
|
26
25
|
::Tilt[path]
|
26
|
+
rescue LoadError
|
27
|
+
nil
|
27
28
|
end
|
28
29
|
memoize :tilt_class
|
29
30
|
|
data/lib/middleman-core/util.rb
CHANGED
data/lib/middleman-core.rb
CHANGED
data/middleman-core.gemspec
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
-
require File.expand_path('../lib/middleman-core/version', __FILE__)
|
1
|
+
require_relative './lib/middleman-core/version'
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = 'middleman-core'
|
@@ -11,18 +9,22 @@ Gem::Specification.new do |s|
|
|
11
9
|
s.email = ['me@tdreyno.com', 'ben@benhollis.net', 'karlfreeman@gmail.com']
|
12
10
|
s.homepage = 'https://middlemanapp.com'
|
13
11
|
s.summary = 'Hand-crafted frontend development'
|
14
|
-
s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass,
|
12
|
+
s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.'
|
15
13
|
|
16
14
|
s.files = `git ls-files -z`.split("\0")
|
17
15
|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
18
|
-
|
19
|
-
s.required_ruby_version = '>= 2.
|
16
|
+
|
17
|
+
s.required_ruby_version = '>= 2.7.0'
|
20
18
|
|
21
19
|
# Core
|
22
20
|
s.add_dependency('bundler', '~> 2.0')
|
23
|
-
s.add_dependency('rack',
|
24
|
-
s.add_dependency('
|
25
|
-
s.add_dependency('
|
21
|
+
s.add_dependency('rack', '>= 3')
|
22
|
+
s.add_dependency('rackup')
|
23
|
+
s.add_dependency('tilt', ['~> 2.2'])
|
24
|
+
s.add_dependency('erubi')
|
25
|
+
s.add_dependency('haml', ['>= 4.0.5'])
|
26
|
+
s.add_dependency('coffee-script', ['~> 2.2'])
|
27
|
+
s.add_dependency('kramdown', ['~> 2.4'])
|
26
28
|
s.add_dependency('fast_blank')
|
27
29
|
s.add_dependency('parallel')
|
28
30
|
s.add_dependency('servolux')
|
@@ -31,7 +33,7 @@ Gem::Specification.new do |s|
|
|
31
33
|
s.add_dependency('webrick')
|
32
34
|
|
33
35
|
# Helpers
|
34
|
-
s.add_dependency('activesupport', ['>= 6.1'
|
36
|
+
s.add_dependency('activesupport', ['>= 6.1'])
|
35
37
|
s.add_dependency('padrino-helpers', ['~> 0.15.0'])
|
36
38
|
s.add_dependency("addressable", ["~> 2.4"])
|
37
39
|
s.add_dependency('memoist', ['~> 0.14'])
|
@@ -40,7 +42,7 @@ Gem::Specification.new do |s|
|
|
40
42
|
s.add_dependency('listen', ['~> 3.0'])
|
41
43
|
|
42
44
|
# i18n
|
43
|
-
s.add_dependency('i18n',
|
45
|
+
s.add_dependency('i18n', '>= 1.6', '< 1.15')
|
44
46
|
|
45
47
|
# Automatic Image Sizes
|
46
48
|
s.add_dependency('fastimage', ['~> 2.0'])
|
@@ -49,14 +51,13 @@ Gem::Specification.new do |s|
|
|
49
51
|
s.add_dependency('sassc', ['~> 2.0'])
|
50
52
|
|
51
53
|
# Minify JS
|
52
|
-
s.add_dependency('uglifier', ['
|
54
|
+
s.add_dependency('uglifier', ['>= 3', '< 5'])
|
53
55
|
s.add_dependency('execjs', ['~> 2.0'])
|
54
56
|
|
55
57
|
# Testing
|
56
|
-
s.add_dependency('contracts'
|
58
|
+
s.add_dependency('contracts')
|
57
59
|
|
58
60
|
# Hash stuff
|
59
|
-
s.add_dependency('hashie',
|
61
|
+
s.add_dependency('hashie', '>= 3.4', '< 6.0')
|
60
62
|
s.add_dependency('hamster', ['~> 3.0'])
|
61
|
-
s.add_dependency('backports', ['~> 3.6'])
|
62
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,17 +9,17 @@ end
|
|
9
9
|
|
10
10
|
require_relative 'support/given'
|
11
11
|
|
12
|
-
# encoding: utf-8
|
13
12
|
RSpec.configure do |config|
|
14
13
|
config.filter_run :focus
|
15
14
|
config.run_all_when_everything_filtered = true
|
16
15
|
|
17
16
|
config.default_formatter = 'doc' if config.files_to_run.one?
|
18
17
|
|
19
|
-
# config.profile_examples = 10
|
20
18
|
config.order = :random
|
21
19
|
Kernel.srand config.seed
|
22
20
|
|
21
|
+
config.color = true
|
22
|
+
|
23
23
|
config.expect_with :rspec do |expectations|
|
24
24
|
expectations.syntax = :expect
|
25
25
|
end
|