Fix a lot of breakage caused by removing/hiding accessors
This commit is contained in:
parent
78b7bbb92a
commit
213c672969
|
@ -254,7 +254,7 @@ module Middleman::Cli
|
|||
FileUtils.cp(resource.source_file, output_file)
|
||||
else
|
||||
begin
|
||||
response = @rack.get(URI.escape(resource.request_path))
|
||||
response = @rack.get(URI.escape(resource.destination_path))
|
||||
|
||||
if response.status == 200
|
||||
base.create_file(output_file, binary_encode(response.body))
|
||||
|
|
|
@ -7,7 +7,7 @@ module Middleman
|
|||
class Liquid < Middleman::Extension
|
||||
# After config, setup liquid partial paths
|
||||
def after_configuration
|
||||
::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(source_dir)
|
||||
::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(app.source_dir)
|
||||
end
|
||||
|
||||
def manipulate_resource_list(resources)
|
||||
|
|
|
@ -3,15 +3,15 @@ module Middleman
|
|||
module Extensions
|
||||
# Class to handle managing ignores
|
||||
class Ignores
|
||||
def initialize(sitemap)
|
||||
@app = sitemap.app
|
||||
def initialize(app, sitemap)
|
||||
@app = app
|
||||
@app.add_to_config_context :ignore, &method(:create_ignore)
|
||||
@app.define_singleton_method(:ignore, &method(:create_ignore))
|
||||
@app.define_singleton_method :ignore, &method(:create_ignore)
|
||||
|
||||
# Array of callbacks which can ass ignored
|
||||
@ignored_callbacks = []
|
||||
|
||||
sitemap.define_singleton_method(:ignored?, &method(:ignored?))
|
||||
sitemap.define_singleton_method :ignored?, &method(:ignored?)
|
||||
::Middleman::Sitemap::Resource.send :include, IgnoreResourceInstanceMethods
|
||||
end
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ module Middleman
|
|||
attr_accessor :sitemap
|
||||
attr_accessor :waiting_for_ready
|
||||
|
||||
def initialize(sitemap)
|
||||
def initialize(app, sitemap)
|
||||
@sitemap = sitemap
|
||||
@app = @sitemap.app
|
||||
@app = app
|
||||
@file_paths_on_disk = Set.new
|
||||
|
||||
scoped_self = self
|
||||
|
|
|
@ -4,8 +4,8 @@ module Middleman
|
|||
# Manages the list of proxy configurations and manipulates the sitemap
|
||||
# to include new resources based on those configurations
|
||||
class Proxies
|
||||
def initialize(sitemap)
|
||||
@app = sitemap.app
|
||||
def initialize(app)
|
||||
@app = app
|
||||
@app.add_to_config_context :proxy, &method(:create_proxy)
|
||||
@app.define_singleton_method(:proxy, &method(:create_proxy))
|
||||
|
||||
|
@ -109,10 +109,10 @@ module Middleman
|
|||
# if there is no resource.
|
||||
# @return [Sitemap::Resource]
|
||||
def proxied_to_resource
|
||||
proxy_resource = store.find_resource_by_path(proxied_to)
|
||||
proxy_resource = @store.find_resource_by_path(proxied_to)
|
||||
|
||||
unless proxy_resource
|
||||
raise "Path #{path} proxies to unknown file #{proxied_to}:#{store.resources.map(&:path)}"
|
||||
raise "Path #{path} proxies to unknown file #{proxied_to}:#{@store.resources.map(&:path)}"
|
||||
end
|
||||
|
||||
if proxy_resource.proxy?
|
||||
|
|
|
@ -6,8 +6,8 @@ module Middleman
|
|||
# Manages the list of proxy configurations and manipulates the sitemap
|
||||
# to include new resources based on those configurations
|
||||
class Redirects
|
||||
def initialize(sitemap)
|
||||
@app = sitemap.app
|
||||
def initialize(app)
|
||||
@app = app
|
||||
@app.add_to_config_context :redirect, &method(:create_redirect)
|
||||
|
||||
@redirects = {}
|
||||
|
@ -86,6 +86,10 @@ module Middleman
|
|||
def metadata
|
||||
@local_metadata.dup
|
||||
end
|
||||
|
||||
def get_source_file
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,8 +4,8 @@ module Middleman
|
|||
class RequestEndpoints
|
||||
# Manages the list of proxy configurations and manipulates the sitemap
|
||||
# to include new resources based on those configurations
|
||||
def initialize(sitemap)
|
||||
@app = sitemap.app
|
||||
def initialize(app)
|
||||
@app = app
|
||||
@app.add_to_config_context :endpoint, &method(:create_endpoint)
|
||||
|
||||
@endpoints = {}
|
||||
|
|
|
@ -7,7 +7,7 @@ module Middleman
|
|||
def parent
|
||||
parts = path.split('/')
|
||||
tail = parts.pop
|
||||
is_index = (tail == app.config[:index_file])
|
||||
is_index = (tail == @app.config[:index_file])
|
||||
|
||||
return nil if is_index && parts.length < 1
|
||||
|
||||
|
@ -21,7 +21,7 @@ module Middleman
|
|||
found
|
||||
else
|
||||
parts.pop if is_index
|
||||
store.find_resource_by_destination_path("#{parts.join('/')}/#{app.config[:index_file]}")
|
||||
store.find_resource_by_destination_path("#{parts.join('/')}/#{@app.config[:index_file]}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,11 +34,11 @@ module Middleman
|
|||
base_path = eponymous_directory_path
|
||||
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
||||
else
|
||||
base_path = path.sub("#{app.config[:index_file]}", '')
|
||||
base_path = path.sub("#{@app.config[:index_file]}", '')
|
||||
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
||||
end
|
||||
|
||||
store.resources.select do |sub_resource|
|
||||
@store.resources.select do |sub_resource|
|
||||
if sub_resource.path == path || sub_resource.path !~ prefix
|
||||
false
|
||||
else
|
||||
|
@ -47,7 +47,7 @@ module Middleman
|
|||
if parts.length == 1
|
||||
true
|
||||
elsif parts.length == 2
|
||||
parts.last == app.config[:index_file]
|
||||
parts.last == @app.config[:index_file]
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -65,17 +65,17 @@ module Middleman
|
|||
# Whether this resource is either a directory index, or has the same name as an existing directory in the source
|
||||
# @return [Boolean]
|
||||
def directory_index?
|
||||
path.include?(app.config[:index_file]) || path =~ /\/$/ || eponymous_directory?
|
||||
path.include?(@app.config[:index_file]) || path =~ /\/$/ || eponymous_directory?
|
||||
end
|
||||
|
||||
# Whether the resource has the same name as a directory in the source
|
||||
# (e.g., if the resource is named 'gallery.html' and a path exists named 'gallery/', this would return true)
|
||||
# @return [Boolean]
|
||||
def eponymous_directory?
|
||||
if !path.end_with?("/#{app.config[:index_file]}") && destination_path.end_with?("/#{app.config[:index_file]}")
|
||||
if !path.end_with?("/#{@app.config[:index_file]}") && destination_path.end_with?("/#{@app.config[:index_file]}")
|
||||
return true
|
||||
end
|
||||
full_path = File.join(app.source_dir, eponymous_directory_path)
|
||||
full_path = File.join(@app.source_dir, eponymous_directory_path)
|
||||
File.exist?(full_path) && File.directory?(full_path)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ module Middleman
|
|||
# which is the path relative to the source directory, minus any template
|
||||
# extensions. All "path" parameters used in this class are source paths.
|
||||
class Store
|
||||
# @return [Middleman::Application]
|
||||
attr_reader :app
|
||||
|
||||
# Initialize with parent app
|
||||
# @param [Middleman::Application] app
|
||||
def initialize(app)
|
||||
|
@ -34,23 +37,23 @@ module Middleman
|
|||
reset_lookup_cache!
|
||||
|
||||
# Handle ignore commands
|
||||
Middleman::Sitemap::Extensions::Ignores.new(self)
|
||||
Middleman::Sitemap::Extensions::Ignores.new(@app, self)
|
||||
|
||||
# Extensions
|
||||
{
|
||||
# Register classes which can manipulate the main site map list
|
||||
on_disk: Middleman::Sitemap::Extensions::OnDisk,
|
||||
on_disk: Middleman::Sitemap::Extensions::OnDisk.new(@app, self),
|
||||
|
||||
# Request Endpoints
|
||||
request_endpoints: Middleman::Sitemap::Extensions::RequestEndpoints,
|
||||
request_endpoints: Middleman::Sitemap::Extensions::RequestEndpoints.new(@app),
|
||||
|
||||
# Proxies
|
||||
proxies: Middleman::Sitemap::Extensions::Proxies,
|
||||
proxies: Middleman::Sitemap::Extensions::Proxies.new(@app),
|
||||
|
||||
# Redirects
|
||||
redirects: Middleman::Sitemap::Extensions::Redirects
|
||||
redirects: Middleman::Sitemap::Extensions::Redirects.new(@app)
|
||||
}.each do |k, m|
|
||||
register_resource_list_manipulator(k, m.new(self))
|
||||
register_resource_list_manipulator(k, m)
|
||||
end
|
||||
|
||||
@app.config_context.class.send :delegate, :sitemap, to: :app
|
||||
|
|
Loading…
Reference in a new issue