final copping
This commit is contained in:
parent
5a936d315d
commit
6bb9673630
|
@ -32,10 +32,11 @@ module Middleman
|
|||
def include_environment(name)
|
||||
path = File.dirname(__FILE__)
|
||||
other_config = File.join(path, name.to_s)
|
||||
if File.exist? other_config
|
||||
|
||||
return unless File.exist? other_config
|
||||
|
||||
instance_eval File.read(other_config), other_config, 1
|
||||
end
|
||||
end
|
||||
|
||||
def ready(&block)
|
||||
@ready_callbacks << block
|
||||
|
|
|
@ -17,7 +17,8 @@ module Middleman
|
|||
def after_configuration
|
||||
helpers_path = File.join(app.root, app.config[:helpers_dir])
|
||||
|
||||
if File.exist?(helpers_path)
|
||||
return unless File.exist?(helpers_path)
|
||||
|
||||
Dir[File.join(helpers_path, app.config[:helpers_filename_glob])].each do |filename|
|
||||
module_name = app.config[:helpers_filename_to_module_name_proc].call(filename)
|
||||
next unless module_name
|
||||
|
@ -30,5 +31,4 @@ module Middleman
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,10 +81,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|||
|
||||
# This is for backwards compatibility with the old provides_metadata-based code
|
||||
# that used to be in this extension, but I don't know how much sense it makes.
|
||||
unless resource.options[:lang]
|
||||
next if resource.options[:lang]
|
||||
|
||||
resource.add_metadata options: { lang: @mount_at_root }, locals: { lang: @mount_at_root }
|
||||
end
|
||||
end
|
||||
|
||||
resources + new_resources
|
||||
end
|
||||
|
|
|
@ -61,9 +61,7 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
if path.is_a?(String)
|
||||
path = '/' + Util.strip_leading_slash(path)
|
||||
end
|
||||
path = '/' + Util.strip_leading_slash(path) if path.is_a?(String)
|
||||
|
||||
@page_configs << [path, metadata]
|
||||
end
|
||||
|
|
|
@ -233,12 +233,13 @@ module Middleman
|
|||
@app = app
|
||||
|
||||
ext = self
|
||||
if ext.respond_to?(:instance_available)
|
||||
|
||||
return unless ext.respond_to?(:instance_available)
|
||||
|
||||
@klass.instance_available do
|
||||
ext.instance_available
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -67,11 +67,11 @@ module Middleman
|
|||
raise 'You must provide a Middleman::Extension or a block that returns a Middleman::Extension'
|
||||
end
|
||||
|
||||
if options[:auto_activate]
|
||||
return unless options[:auto_activate]
|
||||
|
||||
descriptor = AutoActivation.new(name, options[:modes] || :all)
|
||||
@auto_activate[options[:auto_activate]] << descriptor
|
||||
end
|
||||
end
|
||||
|
||||
# @api private
|
||||
# Load an extension by name, lazily evaluating the block provided to {#register} if necessary.
|
||||
|
@ -114,11 +114,11 @@ module Middleman
|
|||
# @param [Middleman::Application] app An instance of the app.
|
||||
def auto_activate(group, app)
|
||||
@auto_activate[group].each do |descriptor|
|
||||
if descriptor[:modes] == :all || descriptor[:modes].include?(app.config[:mode])
|
||||
next unless descriptor[:modes] == :all || descriptor[:modes].include?(app.config[:mode])
|
||||
|
||||
app.activate descriptor[:name]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,13 +35,12 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
asset_path
|
||||
end
|
||||
|
||||
if asset_page = app.sitemap.find_resource_by_path(full_asset_path)
|
||||
return unless asset_page = app.sitemap.find_resource_by_path(full_asset_path)
|
||||
|
||||
replacement_path = "/#{asset_page.destination_path}"
|
||||
replacement_path = Pathname.new(replacement_path).relative_path_from(dirpath).to_s if relative_path
|
||||
|
||||
replacement_path
|
||||
end
|
||||
end
|
||||
|
||||
# Update the main sitemap resource list
|
||||
# @return [void]
|
||||
|
|
|
@ -29,9 +29,9 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|||
asset_path
|
||||
end
|
||||
|
||||
if !full_asset_path.include?('//') && !asset_path.start_with?('data:')
|
||||
return unless !full_asset_path.include?('//') && !asset_path.start_with?('data:')
|
||||
|
||||
current_dir = Pathname('/' + request_path).dirname
|
||||
Pathname(full_asset_path).relative_path_from(current_dir).to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'webrick'
|
|||
require 'middleman-core/meta_pages'
|
||||
require 'middleman-core/logger'
|
||||
|
||||
# rubocop:disable GlobalVars
|
||||
module Middleman
|
||||
module PreviewServer
|
||||
DEFAULT_PORT = 4567
|
||||
|
@ -110,12 +111,12 @@ module Middleman
|
|||
end
|
||||
|
||||
def start_file_watcher
|
||||
return if @listener or @options[:disable_watcher]
|
||||
return if @listener || @options[:disable_watcher]
|
||||
|
||||
# Watcher Library
|
||||
require 'listen'
|
||||
|
||||
options = {force_polling: @options[:force_polling]}
|
||||
options = { force_polling: @options[:force_polling] }
|
||||
options[:latency] = @options[:latency] if @options[:latency]
|
||||
|
||||
@listener = Listen.to(Dir.pwd, options) do |modified, added, removed|
|
||||
|
@ -153,6 +154,7 @@ module Middleman
|
|||
Signal.trap(sig) do
|
||||
# Do as little work as possible in the signal context
|
||||
$mm_shutdown = true
|
||||
|
||||
@webrick.stop
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,12 +12,12 @@ module Middleman
|
|||
|
||||
def manipulate_resource_list(resources)
|
||||
resources.each do |resource|
|
||||
next unless resource.source_file =~ %r{\.liquid$}
|
||||
|
||||
# Convert data object into a hash for liquid
|
||||
if resource.source_file =~ %r{\.liquid$}
|
||||
resource.add_metadata locals: { data: app.data.to_h }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -100,7 +100,7 @@ module Middleman
|
|||
# @param [String] path A path as a string
|
||||
# @return [Boolean] Whether the path matches the matcher
|
||||
def path_match(matcher, path)
|
||||
!!case
|
||||
case
|
||||
when matcher.is_a?(String)
|
||||
if matcher.include? '*'
|
||||
File.fnmatch(matcher, path)
|
||||
|
@ -108,7 +108,7 @@ module Middleman
|
|||
path == matcher
|
||||
end
|
||||
when matcher.respond_to?(:match)
|
||||
matcher.match(path)
|
||||
!matcher.match(path).nil?
|
||||
when matcher.respond_to?(:call)
|
||||
matcher.call(path)
|
||||
else
|
||||
|
@ -149,11 +149,16 @@ module Middleman
|
|||
return source if source.to_s.include?('//') || source.to_s.start_with?('data:')
|
||||
|
||||
asset_folder = case kind
|
||||
when :css then app.config[:css_dir]
|
||||
when :js then app.config[:js_dir]
|
||||
when :images then app.config[:images_dir]
|
||||
when :fonts then app.config[:fonts_dir]
|
||||
else kind.to_s
|
||||
when :css
|
||||
app.config[:css_dir]
|
||||
when :js
|
||||
app.config[:js_dir]
|
||||
when :images
|
||||
app.config[:images_dir]
|
||||
when :fonts
|
||||
app.config[:fonts_dir]
|
||||
else
|
||||
kind.to_s
|
||||
end
|
||||
|
||||
source = source.to_s.tr(' ', '')
|
||||
|
@ -172,7 +177,7 @@ module Middleman
|
|||
# @return [String] The fully qualified asset url
|
||||
def asset_url(app, path, prefix='', _options={})
|
||||
# Don't touch assets which already have a full path
|
||||
if path.include?('//') or path.start_with?('data:')
|
||||
if path.include?('//') || path.start_with?('data:')
|
||||
path
|
||||
else # rewrite paths to use their destination path
|
||||
if resource = app.sitemap.find_resource_by_destination_path(url_for(app, path))
|
||||
|
|
Loading…
Reference in a new issue