Directory indexes work completely now, in preview and with dotfiles.
This commit is contained in:
parent
ca1f3ddf83
commit
e27e0cdd44
|
@ -101,13 +101,14 @@ module Middleman::Cli
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def tilt_template(page)
|
def tilt_template(page)
|
||||||
build_dir = self.class.shared_instance.build_dir
|
build_dir = self.class.shared_instance.build_dir
|
||||||
output_file = File.join(self.class.shared_instance.build_dir, page.output_file_path)
|
output_file = File.join(self.class.shared_instance.build_dir, page.destination_path)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20"))
|
response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20"))
|
||||||
create_file(output_file, response.body, { :force => true })
|
create_file(output_file, response.body, { :force => true })
|
||||||
rescue
|
rescue
|
||||||
say_status :error, destination, :red
|
say_status :error, output_file, :red
|
||||||
|
puts $!
|
||||||
abort
|
abort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -201,6 +202,8 @@ module Middleman::Cli
|
||||||
# Sort paths to be built by the above order. This is primarily so Compass can
|
# Sort paths to be built by the above order. This is primarily so Compass can
|
||||||
# find files in the build folder when it needs to generate sprites for the
|
# find files in the build folder when it needs to generate sprites for the
|
||||||
# css files
|
# css files
|
||||||
|
|
||||||
|
# TODO: deal with pages, not paths
|
||||||
paths = @app.sitemap.all_paths.sort do |a, b|
|
paths = @app.sitemap.all_paths.sort do |a, b|
|
||||||
a_ext = File.extname(a)
|
a_ext = File.extname(a)
|
||||||
b_ext = File.extname(b)
|
b_ext = File.extname(b)
|
||||||
|
@ -213,28 +216,15 @@ module Middleman::Cli
|
||||||
|
|
||||||
# Loop over all the paths and build them.
|
# Loop over all the paths and build them.
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
puts "SOURCE: #{path}"
|
page = @app.sitemap.page(path)
|
||||||
|
|
||||||
file_source = path
|
next if page.ignored?
|
||||||
# TODO: OMG use pathnames?
|
next if @config[:glob] && !File.fnmatch(@config[:glob], path)
|
||||||
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
|
||||||
file_destination.gsub!('/./', '/')
|
|
||||||
|
|
||||||
if @app.sitemap.proxied?(file_source)
|
|
||||||
file_source = @app.sitemap.page(file_source).proxied_to
|
|
||||||
elsif @app.sitemap.page(file_source).ignored?
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
page = @app.sitemap.page(file_source)
|
|
||||||
|
|
||||||
puts "DEST: #{page.destination_path}"
|
|
||||||
|
|
||||||
next if @config[:glob] && !File.fnmatch(@config[:glob], file_source)
|
|
||||||
|
|
||||||
base.tilt_template(page)
|
base.tilt_template(page)
|
||||||
|
|
||||||
@cleaning_queue.delete(Pathname.new(page.destination_path).realpath) if cleaning?
|
output_path = File.join(@destination, page.destination_path)
|
||||||
|
@cleaning_queue.delete(Pathname.new(output_path).realpath) if cleaning?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,8 @@ module Middleman::Extensions
|
||||||
# Include methods
|
# Include methods
|
||||||
app.send :include, InstanceMethods
|
app.send :include, InstanceMethods
|
||||||
|
|
||||||
# TODO: unify these
|
# TODO: unify these by replacing the "before" thing with a
|
||||||
|
# lookup by destination_path
|
||||||
|
|
||||||
# Before requests
|
# Before requests
|
||||||
app.before do
|
app.before do
|
||||||
|
@ -36,13 +37,15 @@ module Middleman::Extensions
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Otherwise check this extension for list of ignored indexes
|
# Otherwise check this extension for list of ignored indexes
|
||||||
is_ignored = ignored_directory_indexes.include?(extensioned_path)
|
if sitemap.exists?(extensioned_path)
|
||||||
|
is_ignored = ignored_directory_indexes.include?(sitemap.page(extensioned_path))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# If we're going to remap to a directory index
|
# If we're going to remap to a directory index
|
||||||
if !sitemap.exists?(indexed_path) && !is_ignored && !fm_ignored
|
if !sitemap.exists?(indexed_path) && !is_ignored && !fm_ignored
|
||||||
parts = @original_path.split("/")
|
parts = @original_path.split("/")
|
||||||
last_part = parts.last
|
last_part = parts.last || ''
|
||||||
last_part_ext = File.extname(last_part)
|
last_part_ext = File.extname(last_part)
|
||||||
|
|
||||||
# Change the request
|
# Change the request
|
||||||
|
@ -65,16 +68,19 @@ module Middleman::Extensions
|
||||||
frontmatter_ignore = d.has_key?("directory_index") && d["directory_index"] == false
|
frontmatter_ignore = d.has_key?("directory_index") && d["directory_index"] == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
index_ext = File.extname(index_file)
|
||||||
|
|
||||||
# Only reroute if not ignored
|
# Only reroute if not ignored
|
||||||
request_path = page.request_path
|
request_path = page.request_path
|
||||||
if ignored_directory_indexes.include? page
|
if ignored_directory_indexes.include? page
|
||||||
destination
|
destination
|
||||||
elsif request_path.end_with? new_index_path
|
elsif request_path == index_file || request_path.end_with?(new_index_path)
|
||||||
destination
|
destination
|
||||||
elsif frontmatter_ignore
|
elsif frontmatter_ignore
|
||||||
destination
|
destination
|
||||||
|
elsif index_ext != File.extname(request_path)
|
||||||
|
destination
|
||||||
else
|
else
|
||||||
index_ext = File.extname(index_file)
|
|
||||||
destination.chomp(File.extname(index_file)) + new_index_path
|
destination.chomp(File.extname(index_file)) + new_index_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,6 +104,8 @@ module Middleman::Sitemap
|
||||||
return true if @ignored_regexes.any? { |r| r.match(path_clean) }
|
return true if @ignored_regexes.any? { |r| r.match(path_clean) }
|
||||||
return true if @ignored_callbacks.any? { |b| b.call(path_clean) }
|
return true if @ignored_callbacks.any? { |b| b.call(path_clean) }
|
||||||
|
|
||||||
|
# TODO: We should also check ignored_sitemap_matchers here
|
||||||
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue