This commit is contained in:
Thomas Reynolds 2016-03-02 12:00:39 -08:00
parent c44f7482b1
commit 7b59f240d5
2 changed files with 12 additions and 2 deletions

View file

@ -1,6 +1,10 @@
master master
=== ===
* Fix directory indexes with `.htm` files. #1821
# 4.1.2
* Add `page_id` concept. Using the `id` key in frontmatter, proxy or page will set an ID on a resource which can be referenced by `url_for` and `link_to`. * Add `page_id` concept. Using the `id` key in frontmatter, proxy or page will set an ID on a resource which can be referenced by `url_for` and `link_to`.
* Allow looking for `Gemfile` when setting up a project to fail gracefully. * Allow looking for `Gemfile` when setting up a project to fail gracefully.
* Send correct exit code when external_pipeline fails during build. * Send correct exit code when external_pipeline fails during build.

View file

@ -11,16 +11,22 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
index_file = app.config[:index_file] index_file = app.config[:index_file]
new_index_path = "/#{index_file}" new_index_path = "/#{index_file}"
extensions = %w(.htm .html .php)
resources.each do |resource| resources.each do |resource|
# Check if it would be pointless to reroute # Check if it would be pointless to reroute
next if resource.destination_path == index_file || next if resource.destination_path == index_file ||
resource.destination_path.end_with?(new_index_path) || resource.destination_path.end_with?(new_index_path) ||
File.extname(index_file) != resource.ext !extensions.include?(resource.ext)
# Check if file metadata (options set by "page" in config.rb or frontmatter) turns directory_index off # Check if file metadata (options set by "page" in config.rb or frontmatter) turns directory_index off
next if resource.options[:directory_index] == false next if resource.options[:directory_index] == false
resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path extensions.each do |ext|
resource.destination_path = resource.destination_path.chomp(ext)
end
resource.destination_path += new_index_path
end end
end end
end end