Directory indexes now work during build, with the exception of .htaccess files.
This commit is contained in:
parent
4ce6913baf
commit
ca1f3ddf83
|
@ -101,10 +101,10 @@ module Middleman::Cli
|
|||
# @return [void]
|
||||
def tilt_template(page)
|
||||
build_dir = self.class.shared_instance.build_dir
|
||||
output_file = File.join(self.class.shared_instance.build_dir, page.output_file_path)
|
||||
|
||||
begin
|
||||
response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20"))
|
||||
output_file = File.join(self.class.shared_instance.build_dir, page.destination_path)
|
||||
create_file(output_file, response.body, { :force => true })
|
||||
rescue
|
||||
say_status :error, destination, :red
|
||||
|
@ -228,6 +228,8 @@ module Middleman::Cli
|
|||
|
||||
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)
|
||||
|
|
|
@ -64,7 +64,7 @@ module Middleman::CoreExtensions::Routing
|
|||
|
||||
# Setup proxy
|
||||
if opts.has_key?(:proxy)
|
||||
reroute(url, opts[:proxy])
|
||||
proxy(url, opts[:proxy])
|
||||
|
||||
if opts.has_key?(:ignore) && opts[:ignore]
|
||||
ignore(opts[:proxy])
|
||||
|
|
|
@ -74,7 +74,7 @@ module Middleman::CoreExtensions::Sitemap
|
|||
# @param [String] url
|
||||
# @param [String] target
|
||||
# @return [void]
|
||||
def reroute(*args)
|
||||
def proxy(*args)
|
||||
sitemap.proxy(*args)
|
||||
end
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ module Middleman::Extensions
|
|||
# Include methods
|
||||
app.send :include, InstanceMethods
|
||||
|
||||
# TODO: unify these
|
||||
|
||||
# Before requests
|
||||
app.before do
|
||||
prefix = @original_path.sub(/\/$/, "")
|
||||
|
@ -51,30 +53,30 @@ module Middleman::Extensions
|
|||
end
|
||||
end
|
||||
|
||||
# Basically does the same as above, but in build mode
|
||||
app.build_reroute do |destination, request_path|
|
||||
index_ext = File.extname(index_file)
|
||||
new_index_path = "/#{index_file}"
|
||||
frontmatter_ignore = false
|
||||
app.after_configuration do
|
||||
# Basically does the same as above, but in build mode
|
||||
sitemap.reroute do |destination, page|
|
||||
new_index_path = "/#{index_file}"
|
||||
frontmatter_ignore = false
|
||||
|
||||
# Check for file and frontmatter
|
||||
if sitemap.exists?(request_path)
|
||||
p = sitemap.page(request_path)
|
||||
d = p.data
|
||||
if !d.nil?
|
||||
# Check for file and frontmatter
|
||||
d = page.data
|
||||
if !page.data.nil?
|
||||
frontmatter_ignore = d.has_key?("directory_index") && d["directory_index"] == false
|
||||
end
|
||||
end
|
||||
|
||||
# Only reroute if not ignored
|
||||
if ignored_directory_indexes.include?(request_path)
|
||||
false
|
||||
elsif request_path =~ /#{new_index_path}$/
|
||||
false
|
||||
elsif frontmatter_ignore
|
||||
false
|
||||
else
|
||||
destination.sub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path),
|
||||
# Only reroute if not ignored
|
||||
request_path = page.request_path
|
||||
if ignored_directory_indexes.include? page
|
||||
destination
|
||||
elsif request_path.end_with? new_index_path
|
||||
destination
|
||||
elsif frontmatter_ignore
|
||||
destination
|
||||
else
|
||||
index_ext = File.extname(index_file)
|
||||
destination.chomp(File.extname(index_file)) + new_index_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -82,10 +84,9 @@ module Middleman::Extensions
|
|||
alias :included :registered
|
||||
end
|
||||
|
||||
# Directory indexes instance methods
|
||||
module InstanceMethods
|
||||
# A list of pages which will not use directory indexes
|
||||
# @return [Array<String>]
|
||||
# @return [Array<Middleman::Sitemap::Page>]
|
||||
def ignored_directory_indexes
|
||||
@_ignored_directory_indexes ||= []
|
||||
end
|
||||
|
@ -97,7 +98,7 @@ module Middleman::Extensions
|
|||
# @return [void]
|
||||
def page(url, options={}, &block)
|
||||
if options.has_key?(:directory_index) && !options["directory_index"]
|
||||
ignored_directory_indexes << url
|
||||
ignored_directory_indexes << sitemap.page(url)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
|
@ -193,7 +193,7 @@ module Middleman::Sitemap
|
|||
# @return [String]
|
||||
def destination_path
|
||||
store.reroute_callbacks.inject(self.path) do |destination, callback|
|
||||
callback.call(destination)
|
||||
callback.call(destination, self)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue