Forward port some stable changes
This commit is contained in:
parent
a251c82562
commit
409a892da7
13
.editorconfig
Normal file
13
.editorconfig
Normal file
|
@ -0,0 +1,13 @@
|
|||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
|
@ -25,8 +25,6 @@ ClassLength:
|
|||
Enabled: false
|
||||
Documentation:
|
||||
Enabled: false
|
||||
Encoding:
|
||||
Enabled: false
|
||||
HashSyntax:
|
||||
EnforcedStyle: ruby19
|
||||
SpaceAroundEqualsInParameterDefault:
|
||||
|
|
|
@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
|
|||
require 'cucumber/rake/task'
|
||||
|
||||
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
||||
t.cucumber_opts = "--color --tags ~@wip --strict"
|
||||
t.cucumber_opts = '--color --tags ~@wip --strict'
|
||||
end
|
||||
|
||||
require 'rake/clean'
|
||||
|
|
1
middleman-core/.rspec
Normal file
1
middleman-core/.rspec
Normal file
|
@ -0,0 +1 @@
|
|||
--color
|
2
middleman-core/cucumber.yml
Normal file
2
middleman-core/cucumber.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
default: --require features --tags ~@wip
|
||||
wip: --require features --tags @wip
|
|
@ -7,19 +7,19 @@ Feature: Templates should be chainable
|
|||
Then I should see "Title</h1>"
|
||||
And I should see "Subtitle</h2>"
|
||||
And I should see "Sup</h3>"
|
||||
|
||||
|
||||
Scenario: Build chained template
|
||||
Given a successfully built app at "chained-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| test.html.combobreaker |
|
||||
| test.erb.combobreaker |
|
||||
And the file "index.html" should contain "Title</h1>"
|
||||
And the file "index.html" should contain "Subtitle</h2>"
|
||||
And the file "index.html" should contain "Sup</h3>"
|
||||
And the file "test.html.combobreaker.html" should contain "Title</h1>"
|
||||
And the file "test.html.combobreaker.html" should contain "Subtitle</h2>"
|
||||
And the file "test.html.combobreaker.html" should contain "Sup</h3>"
|
||||
And the file "test.erb.combobreaker" should contain "Title</h1>"
|
||||
And the file "test.erb.combobreaker" should contain "Subtitle</h2>"
|
||||
And the file "test.erb.combobreaker" should contain "Sup</h3>"
|
||||
|
||||
Scenario: Partials are parsed by multiple template engines: Outer template has .erb and inner .md.erb
|
||||
Given a fixture app "partial-chained_templates-app"
|
||||
|
@ -32,7 +32,7 @@ Feature: Templates should be chainable
|
|||
And a template named "my_partial.html.md.erb" with:
|
||||
"""
|
||||
## My Partial
|
||||
|
||||
|
||||
<%= 'hello world' %>
|
||||
"""
|
||||
And the Server is running
|
||||
|
@ -61,7 +61,7 @@ Feature: Templates should be chainable
|
|||
And a template named "my_partial.html.md.erb" with:
|
||||
"""
|
||||
## My Partial
|
||||
|
||||
|
||||
<%= 'hello world' %>
|
||||
"""
|
||||
And the Server is running
|
||||
|
@ -90,7 +90,7 @@ Feature: Templates should be chainable
|
|||
And a template named "my_partial.html.erb" with:
|
||||
"""
|
||||
<h2>My Partial</h2>
|
||||
|
||||
|
||||
<%= 'hello world' %>
|
||||
"""
|
||||
And the Server is running
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# Use ActiveSupport JSON
|
||||
require 'active_support/json'
|
||||
require 'active_support/core_ext/integer/inflections'
|
||||
|
||||
require 'middleman-core/contracts'
|
||||
|
|
|
@ -7,7 +7,8 @@ require 'padrino-helpers'
|
|||
class Padrino::Helpers::OutputHelpers::ErbHandler
|
||||
# Force Erb capture not to use safebuffer
|
||||
def capture_from_template(*args, &block)
|
||||
self.output_buffer, buf_was = '', output_buffer
|
||||
self.output_buffer = ''
|
||||
buf_was = output_buffer
|
||||
raw = block.call(*args)
|
||||
captured = template.instance_variable_get(:@_out_buf)
|
||||
self.output_buffer = buf_was
|
||||
|
|
|
@ -17,7 +17,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
def after_configuration
|
||||
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
||||
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
|
||||
|
||||
|
||||
app.use ::Middleman::Middleware::InlineURLRewriter,
|
||||
id: :asset_hash,
|
||||
url_extensions: options.exts,
|
||||
|
|
|
@ -125,8 +125,8 @@ module Middleman
|
|||
|
||||
# config.rb
|
||||
watcher = files.watch :reload,
|
||||
path: root,
|
||||
only: match_against
|
||||
path: root,
|
||||
only: match_against
|
||||
|
||||
# Hack around node_modules in root.
|
||||
watcher.listener.ignore(/^node_modules/)
|
||||
|
|
|
@ -102,7 +102,7 @@ module Middleman
|
|||
|
||||
begin
|
||||
# Write out the contents of the page
|
||||
res.write resource.render({}, { rack: { request: req } })
|
||||
res.write resource.render({}, rack: { request: req })
|
||||
|
||||
# Valid content is a 200 status
|
||||
res.status = 200
|
||||
|
|
|
@ -40,7 +40,6 @@ module Middleman
|
|||
|
||||
# Haml Renderer
|
||||
class Haml < ::Middleman::Extension
|
||||
|
||||
def initialize(app, options={}, &block)
|
||||
super
|
||||
|
||||
|
@ -53,7 +52,7 @@ module Middleman
|
|||
modified_options = options.dup
|
||||
modified_options[:context] = compiler_options[:context]
|
||||
|
||||
text = template_class.new(nil, 1, modified_options) {text}.render
|
||||
text = template_class.new(nil, 1, modified_options) { text }.render
|
||||
super(text, compiler_options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -86,8 +86,8 @@ module Middleman
|
|||
end
|
||||
|
||||
class Resource
|
||||
def proxy_to(path)
|
||||
throw "Resource#proxy_to has been removed. Use ProxyResource class instead."
|
||||
def proxy_to(_path)
|
||||
throw 'Resource#proxy_to has been removed. Use ProxyResource class instead.'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,9 +48,7 @@ module Middleman
|
|||
@app = @store.app
|
||||
@path = path
|
||||
|
||||
if source && source.is_a?(String)
|
||||
source = Pathname(source)
|
||||
end
|
||||
source = Pathname(source) if source && source.is_a?(String)
|
||||
|
||||
if source && source.is_a?(Pathname)
|
||||
@file_descriptor = ::Middleman::SourceFile.new(source.relative_path_from(@app.source_dir), source, @app.source_dir, Set.new([:source]))
|
||||
|
|
|
@ -187,23 +187,24 @@ module Middleman
|
|||
|
||||
@app.logger.debug '== Rebuilding resource list'
|
||||
|
||||
@resources = @resource_list_manipulators.reduce([]) do |result, m|
|
||||
@resources = []
|
||||
|
||||
@resource_list_manipulators.each do |m|
|
||||
@app.logger.debug "== Running manipulator: #{m[:name]}"
|
||||
newres = m[:manipulator].send(m[:custom_name] || :manipulate_resource_list, result)
|
||||
@resources = m[:manipulator].send(m[:custom_name] || :manipulate_resource_list, @resources)
|
||||
|
||||
# Reset lookup cache
|
||||
reset_lookup_cache!
|
||||
|
||||
# Rebuild cache
|
||||
newres.each do |resource|
|
||||
@resources.each do |resource|
|
||||
@_lookup_by_path[resource.path] = resource
|
||||
@_lookup_by_destination_path[resource.destination_path] = resource
|
||||
end
|
||||
|
||||
newres
|
||||
invalidate_resources_not_ignored_cache!
|
||||
end
|
||||
|
||||
invalidate_resources_not_ignored_cache!
|
||||
@update_count += 1
|
||||
end
|
||||
end
|
||||
|
@ -223,7 +224,7 @@ module Middleman
|
|||
Contract String => String
|
||||
def remove_templating_extensions(path)
|
||||
# Strip templating extensions as long as Tilt knows them
|
||||
path = path.sub(File.extname(path), '') while ::Tilt[path]
|
||||
path = path.sub(/#{::Regexp.escape(File.extname(path))}$/, '') while ::Tilt[path]
|
||||
path
|
||||
end
|
||||
|
||||
|
|
|
@ -8,16 +8,14 @@ require 'backports/2.0.0/enumerable/lazy'
|
|||
module Listen
|
||||
class Silencer
|
||||
# TODO: switch type and path places - and verify
|
||||
def silenced?(relative_path, type)
|
||||
def silenced?(relative_path, _type)
|
||||
path = relative_path.to_s
|
||||
|
||||
# if only_patterns && type == :file
|
||||
# return true unless only_patterns.any? { |pattern| path =~ pattern }
|
||||
# end
|
||||
|
||||
if only_patterns
|
||||
return !only_patterns.any? { |pattern| path =~ pattern }
|
||||
end
|
||||
return !only_patterns.any? { |pattern| path =~ pattern } if only_patterns
|
||||
|
||||
ignore_patterns.any? { |pattern| path =~ pattern }
|
||||
end
|
||||
|
|
|
@ -71,7 +71,8 @@ module Middleman
|
|||
engine = extension[1..-1].to_sym
|
||||
|
||||
# Store last engine for later (could be inside nested renders)
|
||||
self.current_engine, engine_was = engine, current_engine
|
||||
self.current_engine = engine
|
||||
engine_was = current_engine
|
||||
|
||||
# By default, no content is captured
|
||||
content = ''
|
||||
|
|
|
@ -11,11 +11,11 @@ require 'middleman-core/util'
|
|||
require 'yaml'
|
||||
|
||||
# Parsing JSON data
|
||||
require 'active_support/json'
|
||||
require 'json'
|
||||
|
||||
module Middleman
|
||||
module Util
|
||||
module Data
|
||||
module Data
|
||||
include Contracts
|
||||
|
||||
module_function
|
||||
|
@ -121,7 +121,7 @@ module Middleman
|
|||
Contract String, Pathname => Maybe[[Hash, String]]
|
||||
def parse_json(content, full_path)
|
||||
begin
|
||||
data = map_value(::ActiveSupport::JSON.decode(content))
|
||||
data = map_value(::JSON.parse(content))
|
||||
rescue => e
|
||||
$stderr.puts "JSON Exception parsing #{full_path}: #{e.message}"
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue