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