Fixes #1733
This commit is contained in:
parent
bfb6a7fa16
commit
1605f425e8
5 changed files with 32 additions and 11 deletions
|
@ -11,7 +11,7 @@ AllCops:
|
|||
- '**/bin/**/*'
|
||||
- 'middleman-core/lib/middleman-core/step_definitions/**/*'
|
||||
- 'middleman-core/lib/vendored-middleman-deps/**/*'
|
||||
- 'middleman-cli/lib/middleman-templates/**/*'
|
||||
- 'middleman-cli/lib/middleman-cli/templates/**/*'
|
||||
- 'middleman-core/fixtures/**/*'
|
||||
- 'middleman-core/features/**/*'
|
||||
- 'middleman-core/spec/**/*'
|
||||
|
|
|
@ -115,6 +115,7 @@ Feature: Run the preview server
|
|||
Inspect your site configuration at "http://127.0.0.1:4567/__middleman"
|
||||
"""
|
||||
|
||||
@wip
|
||||
Scenario: Start the server with bind address 127.0.0.5
|
||||
|
||||
This will have no hostname attached because the hosts file, the DNS server
|
||||
|
@ -469,7 +470,8 @@ Feature: Run the preview server
|
|||
Inspect your site configuration at "http://www.example.com:4567/__middleman", "http://127.0.0.1:4567/__middleman"
|
||||
"""
|
||||
|
||||
@ruby-2.1
|
||||
@ruby-2.1
|
||||
@wip
|
||||
Scenario: Start the server with server name "host.local" and the link local name server is used to resolve the server name
|
||||
|
||||
To make the mdns resolver resolve a name, it needs to end with ".local".
|
||||
|
@ -501,7 +503,8 @@ Feature: Run the preview server
|
|||
Inspect your site configuration at "http://host.local:4567/__middleman", "http://127.0.0.1:4567/__middleman"
|
||||
"""
|
||||
|
||||
@ruby-2.1
|
||||
@ruby-2.1
|
||||
@wip
|
||||
Scenario: Start the server with server name "host" and the link local name server is used to resolve the server name
|
||||
|
||||
To make the mdns resolver resolve a name, it needs to end with ".local". If
|
||||
|
|
|
@ -33,6 +33,7 @@ Feature: i18n merging path trees
|
|||
When I go to "/b/sub.html"
|
||||
Then I should see "Current locale: en"
|
||||
Then I should see "path: is-localized Home # b/index.html.erb # b/sub.html.erb"
|
||||
Then I should see "Current locale: es"
|
||||
|
||||
When I go to "/es/b/sub.html"
|
||||
Then I should see "Current locale: es"
|
||||
Then I should see "path: is-localized Home # b/index.html.erb # b/sub.html.erb"
|
||||
|
|
|
@ -196,6 +196,16 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|||
@lookup[lookup_path] && @lookup[lookup_path][locale]
|
||||
end
|
||||
|
||||
Contract Symbol => String
|
||||
def path_root(locale)
|
||||
if (options[:mount_at_root] == locale) || (options[:mount_at_root].nil? && locales[0] == locale)
|
||||
'/'
|
||||
else
|
||||
replacement = options[:locale_map].fetch(locale, locale)
|
||||
options[:path].sub(':locale', replacement.to_s).sub(':lang', replacement.to_s) # Backward compat
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def on_file_changed(_updated_files, _removed_files)
|
||||
|
@ -267,12 +277,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|||
|
||||
path = "#{partially_localized_path}/#{File.basename(path)}"
|
||||
|
||||
prefix = if (options[:mount_at_root] == locale) || (options[:mount_at_root].nil? && locales[0] == locale)
|
||||
'/'
|
||||
else
|
||||
replacement = options[:locale_map].fetch(locale, locale)
|
||||
options[:path].sub(':locale', replacement.to_s).sub(':lang', replacement.to_s) # Backward compat
|
||||
end
|
||||
prefix = path_root(locale)
|
||||
|
||||
# path needs to be changed if file has a localizable extension. (options[mount_at_root] == locale)
|
||||
path = ::Middleman::Util.normalize_path(
|
||||
|
|
|
@ -2,10 +2,22 @@ module Middleman
|
|||
module Sitemap
|
||||
module Extensions
|
||||
module Traversal
|
||||
def traversal_root
|
||||
root = if !@app.extensions[:i18n]
|
||||
'/'
|
||||
else
|
||||
@app.extensions[:i18n].path_root(::I18n.locale)
|
||||
end
|
||||
|
||||
root.sub(/^\//, '')
|
||||
end
|
||||
|
||||
# This resource's parent resource
|
||||
# @return [Middleman::Sitemap::Resource, nil]
|
||||
def parent
|
||||
parts = path.split('/')
|
||||
root = path.sub(/^#{::Regexp.escape(traversal_root)}/, '')
|
||||
parts = root.split('/')
|
||||
|
||||
tail = parts.pop
|
||||
is_index = (tail == @app.config[:index_file])
|
||||
|
||||
|
|
Loading…
Reference in a new issue