From 6f8715360cca828898d10ce5c3234d2aaa5995e6 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 27 Jul 2011 20:04:35 -0700 Subject: [PATCH] actually use the handy dandy :index_file param we have --- lib/middleman/features/directory_indexes.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/middleman/features/directory_indexes.rb b/lib/middleman/features/directory_indexes.rb index 8be607c5..0999efea 100644 --- a/lib/middleman/features/directory_indexes.rb +++ b/lib/middleman/features/directory_indexes.rb @@ -5,20 +5,23 @@ module Middleman::Features::DirectoryIndexes app.extend ClassMethods app.build_reroute do |destination, request_path| - indexed_path = request_path.gsub(/\/$/, "") + ".html" + index_ext = File.extname(app.settings.index_file) + new_index_path = "/#{app.settings.index_file}" + + indexed_path = request_path.gsub(/\/$/, "") + index_ext if app.settings.ignored_directory_indexes.include?(request_path) false else [ - destination.gsub(/\.html$/, "/index.html"), - request_path.gsub(/\.html$/, "/index.html") + destination.gsub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path), + request_path.gsub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path) ] end end app.before do - indexed_path = request.path_info.gsub(/\/$/, "") + ".html" + indexed_path = request.path_info.gsub(/\/$/, "") + File.extname(app.settings.index_file) if !settings.ignored_directory_indexes.include?(indexed_path) parts = request.path_info.split("/")