mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Merge pull request #172 from bhollis/master
Build .htaccess files (and other things in the sitemap) directly even when directory-indexes are on
This commit is contained in:
commit
0898ff6d42
3 changed files with 5 additions and 3 deletions
|
@ -11,6 +11,7 @@ Feature: Directory Index
|
||||||
Then "needs_index.html" should not exist at "indexable-app"
|
Then "needs_index.html" should not exist at "indexable-app"
|
||||||
Then "a_folder/needs_index.html" should not exist at "indexable-app"
|
Then "a_folder/needs_index.html" should not exist at "indexable-app"
|
||||||
Then "leave_me_alone/index.html" should not exist at "indexable-app"
|
Then "leave_me_alone/index.html" should not exist at "indexable-app"
|
||||||
|
Then ".htaccess" should exist at "indexable-app"
|
||||||
|
|
||||||
Scenario: Preview normal file
|
Scenario: Preview normal file
|
||||||
Given the Server is running at "indexable-app"
|
Given the Server is running at "indexable-app"
|
||||||
|
|
1
fixtures/indexable-app/source/.htaccess
Normal file
1
fixtures/indexable-app/source/.htaccess
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# I'm an htaccess file!
|
|
@ -4,6 +4,8 @@ module Middleman::Extensions
|
||||||
def registered(app)
|
def registered(app)
|
||||||
app.send :include, InstanceMethods
|
app.send :include, InstanceMethods
|
||||||
app.before do
|
app.before do
|
||||||
|
next if sitemap.exists?(@original_path)
|
||||||
|
|
||||||
prefix = @original_path.sub(/\/$/, "")
|
prefix = @original_path.sub(/\/$/, "")
|
||||||
indexed_path = prefix + "/" + index_file
|
indexed_path = prefix + "/" + index_file
|
||||||
|
|
||||||
|
@ -26,8 +28,6 @@ module Middleman::Extensions
|
||||||
index_ext = File.extname(index_file)
|
index_ext = File.extname(index_file)
|
||||||
new_index_path = "/#{index_file}"
|
new_index_path = "/#{index_file}"
|
||||||
|
|
||||||
indexed_path = request_path.sub(/\/$/, "") + index_ext
|
|
||||||
|
|
||||||
if ignored_directory_indexes.include?(request_path)
|
if ignored_directory_indexes.include?(request_path)
|
||||||
false
|
false
|
||||||
elsif request_path =~ /#{new_index_path}$/
|
elsif request_path =~ /#{new_index_path}$/
|
||||||
|
|
Loading…
Reference in a new issue