:automatic_directory_matcher optionally converts a character sequence in file names into a subdirectory. Closes #491
This commit is contained in:
parent
ddc0712c1b
commit
c3796a9161
|
@ -1,3 +1,7 @@
|
|||
Master
|
||||
===
|
||||
* automatic_directory_matcher (#491)
|
||||
|
||||
3.0.0.rc.2
|
||||
====
|
||||
* Doing a build now shows identical files (#475)
|
||||
|
|
32
middleman-core/features/automatic_directory_matcher.feature
Normal file
32
middleman-core/features/automatic_directory_matcher.feature
Normal file
|
@ -0,0 +1,32 @@
|
|||
Feature: Map special characters to automatically put files in a directory
|
||||
|
||||
Scenario: Building files with special character escape
|
||||
Given a successfully built app at "automatic-directory-matcher-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| root.html |
|
||||
| root-plain.html |
|
||||
| sub/sub.html |
|
||||
| sub/sub-plain.html |
|
||||
| sub/sub/sub.html |
|
||||
| sub/sub/sub-plain.html |
|
||||
Then the following files should not exist:
|
||||
| sub--sub.html |
|
||||
| sub--sub-plain.html |
|
||||
| sub--sub--sub.html |
|
||||
| sub--sub--sub-plain.html |
|
||||
|
||||
Scenario: Previewing files with special character escape
|
||||
Given the Server is running at "automatic-directory-matcher-app"
|
||||
When I go to "/root.html"
|
||||
Then I should see "Root Erb"
|
||||
When I go to "/root-plain.html"
|
||||
Then I should see "Root Plain"
|
||||
When I go to "/sub/sub.html"
|
||||
Then I should see "Sub1 Erb"
|
||||
When I go to "/sub/sub-plain.html"
|
||||
Then I should see "Sub1 Plain"
|
||||
When I go to "/sub/sub/sub.html"
|
||||
Then I should see "Sub2 Erb"
|
||||
When I go to "/sub/sub/sub-plain.html"
|
||||
Then I should see "Sub2 Plain"
|
|
@ -0,0 +1 @@
|
|||
set :automatic_directory_matcher, "--"
|
|
@ -0,0 +1 @@
|
|||
Root Plain
|
|
@ -0,0 +1 @@
|
|||
Root Erb
|
|
@ -0,0 +1 @@
|
|||
Sub2 Plain
|
|
@ -0,0 +1 @@
|
|||
Sub2 Erb
|
|
@ -0,0 +1 @@
|
|||
Sub1 Plain
|
|
@ -0,0 +1 @@
|
|||
Sub1 Erb
|
|
@ -19,6 +19,9 @@ module Middleman
|
|||
app.register Middleman::Sitemap::Extensions::Proxies
|
||||
app.register Middleman::Sitemap::Extensions::Ignores
|
||||
|
||||
# Set to automatically convert some characters into a directory
|
||||
app.set :automatic_directory_matcher, nil
|
||||
|
||||
# Setup callbacks which can exclude paths from the sitemap
|
||||
app.set :ignored_sitemap_matchers, {
|
||||
# dotfiles and folders in the root
|
||||
|
|
|
@ -174,6 +174,12 @@ module Middleman
|
|||
return false unless file.include?(prefix)
|
||||
|
||||
path = file.sub(prefix, "")
|
||||
|
||||
# Replace a file name containing automatic_directory_matcher with a folder
|
||||
unless @app.automatic_directory_matcher.nil?
|
||||
path = path.gsub(@app.automatic_directory_matcher, "/")
|
||||
end
|
||||
|
||||
extensionless_path(path)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue