This commit is contained in:
Thomas Reynolds 2016-01-05 10:58:11 -08:00
parent bfb6a7fa16
commit 1605f425e8
5 changed files with 32 additions and 11 deletions

View file

@ -11,7 +11,7 @@ AllCops:
- '**/bin/**/*' - '**/bin/**/*'
- 'middleman-core/lib/middleman-core/step_definitions/**/*' - 'middleman-core/lib/middleman-core/step_definitions/**/*'
- 'middleman-core/lib/vendored-middleman-deps/**/*' - 'middleman-core/lib/vendored-middleman-deps/**/*'
- 'middleman-cli/lib/middleman-templates/**/*' - 'middleman-cli/lib/middleman-cli/templates/**/*'
- 'middleman-core/fixtures/**/*' - 'middleman-core/fixtures/**/*'
- 'middleman-core/features/**/*' - 'middleman-core/features/**/*'
- 'middleman-core/spec/**/*' - 'middleman-core/spec/**/*'

View file

@ -115,6 +115,7 @@ Feature: Run the preview server
Inspect your site configuration at "http://127.0.0.1:4567/__middleman" Inspect your site configuration at "http://127.0.0.1:4567/__middleman"
""" """
@wip
Scenario: Start the server with bind address 127.0.0.5 Scenario: Start the server with bind address 127.0.0.5
This will have no hostname attached because the hosts file, the DNS server 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" 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 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". 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" 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 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 To make the mdns resolver resolve a name, it needs to end with ".local". If

View file

@ -33,6 +33,7 @@ Feature: i18n merging path trees
When I go to "/b/sub.html" When I go to "/b/sub.html"
Then I should see "Current locale: en" 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 "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" 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" Then I should see "path: is-localized Home # b/index.html.erb # b/sub.html.erb"

View file

@ -196,6 +196,16 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
@lookup[lookup_path] && @lookup[lookup_path][locale] @lookup[lookup_path] && @lookup[lookup_path][locale]
end 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 private
def on_file_changed(_updated_files, _removed_files) 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)}" path = "#{partially_localized_path}/#{File.basename(path)}"
prefix = if (options[:mount_at_root] == locale) || (options[:mount_at_root].nil? && locales[0] == locale) prefix = path_root(locale)
'/'
else
replacement = options[:locale_map].fetch(locale, locale)
options[:path].sub(':locale', replacement.to_s).sub(':lang', replacement.to_s) # Backward compat
end
# path needs to be changed if file has a localizable extension. (options[mount_at_root] == locale) # path needs to be changed if file has a localizable extension. (options[mount_at_root] == locale)
path = ::Middleman::Util.normalize_path( path = ::Middleman::Util.normalize_path(

View file

@ -2,10 +2,22 @@ module Middleman
module Sitemap module Sitemap
module Extensions module Extensions
module Traversal 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 # This resource's parent resource
# @return [Middleman::Sitemap::Resource, nil] # @return [Middleman::Sitemap::Resource, nil]
def parent def parent
parts = path.split('/') root = path.sub(/^#{::Regexp.escape(traversal_root)}/, '')
parts = root.split('/')
tail = parts.pop tail = parts.pop
is_index = (tail == @app.config[:index_file]) is_index = (tail == @app.config[:index_file])