middleman-more 3.1.0.beta.2 → 3.1.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1df77f4d11379ce20fec027e19c1bdbe25ebe5f
4
- data.tar.gz: 23137fa1344a5ce4a2fd3b2b2b487d9fef92664d
3
+ metadata.gz: e8d70a64e249ff6df7795667ef05024a708f3a60
4
+ data.tar.gz: 96958acceab755073342eda0410ba132ce751ded
5
5
  SHA512:
6
- metadata.gz: 549c6712e66858016fddceedf9aadce140159a6258098535a69f15beddcc7cf79d579413549ed329a1ac270a3d089cef0d10002b2927b435a2706b4e429076cf
7
- data.tar.gz: 156fbf13a8828514215da7688a96d72edd4bc7b7ad53c747563aa3ded4fa64460bccfe917c3b50158a4b9aa8ac5981b9e0a9f9b0bc19222d41f9910a3baca014
6
+ metadata.gz: ddb8512c1b091fffd6a30cd975c5464129febb07b776596a7770f4cf4024d642b2d37d6b143b02a91975bfc50436c97fff189b5b9019c9538d7d218970a87fbe
7
+ data.tar.gz: 390cacdf49c818ffc2ae284b7298b85d9cd4aefc5b6d2b670d9f2bdaf632babfafc2e3a13c4cc6d50c35ff8325d707f45f78eb2c3aeeff77f2453f74035e3141
@@ -12,14 +12,22 @@ Feature: i18n Builder
12
12
  Then the following files should exist:
13
13
  | index.html |
14
14
  | hello.html |
15
+ | morning.html |
15
16
  | es/index.html |
16
17
  | es/hola.html |
18
+ | es/manana.html |
19
+ | CNAME |
20
+ | password.txt |
17
21
  Then the following files should not exist:
18
22
  | en/index.html |
19
23
  And the file "index.html" should contain "Howdy"
20
24
  And the file "hello.html" should contain "Hello World"
25
+ And the file "morning.html" should contain "Good morning"
21
26
  And the file "es/index.html" should contain "Como Esta?"
22
27
  And the file "es/hola.html" should contain "Hola World"
28
+ And the file "es/manana.html" should contain "Buenos días"
29
+ And the file "CNAME" should contain "test.github.com"
30
+ And the file "password.txt" should contain "hunter2"
23
31
 
24
32
  Scenario: Running localize with the alt path config
25
33
  Given a fixture app "i18n-test-app"
@@ -12,12 +12,18 @@ Feature: i18n Preview
12
12
  Then I should see "Howdy"
13
13
  When I go to "/hello.html"
14
14
  Then I should see "Hello World"
15
+ When I go to "/morning.html"
16
+ Then I should see "Good morning"
15
17
  When I go to "/en/index.html"
16
18
  Then I should see "File Not Found"
19
+ When I go to "/en/morning.html"
20
+ Then I should see "File Not Found"
17
21
  When I go to "/es/index.html"
18
22
  Then I should see "Como Esta?"
19
23
  When I go to "/es/hola.html"
20
24
  Then I should see "Hola World"
25
+ When I go to "/es/manana.html"
26
+ Then I should see "Buenos días"
21
27
 
22
28
  Scenario: A template changes i18n during preview
23
29
  Given a fixture app "i18n-test-app"
@@ -119,8 +125,14 @@ Feature: i18n Preview
119
125
  Then I should see "Como Esta?"
120
126
  When I go to "/hola.html"
121
127
  Then I should see "Hola World"
128
+ When I go to "/manana.html"
129
+ Then I should see "Buenos días"
122
130
  When I go to "/hello.html"
123
131
  Then I should see "File Not Found"
132
+ When I go to "/en/morning.html"
133
+ Then I should see "Good morning"
134
+ When I go to "/es/manana.html"
135
+ Then I should see "File Not Found"
124
136
  When I go to "/es/index.html"
125
137
  Then I should see "File Not Found"
126
138
  When I go to "/es/hola.html"
@@ -2,6 +2,7 @@
2
2
  es:
3
3
  paths:
4
4
  hello: "hola"
5
+ morning: "manana"
5
6
 
6
7
  greetings: "Como Esta?"
7
- hi: "Hola"
8
+ hi: "Hola"
@@ -0,0 +1 @@
1
+ test.github.com
@@ -0,0 +1 @@
1
+ Good morning
@@ -0,0 +1 @@
1
+ Buenos días
@@ -0,0 +1 @@
1
+ hunter2
@@ -14,7 +14,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
14
14
  app.helpers ::Padrino::Helpers::RenderHelpers
15
15
  app.helpers ::Padrino::Helpers::NumberHelpers
16
16
  # app.helpers ::Padrino::Helpers::TranslationHelpers
17
- app.helpers ::Padrino::Helpers::Breadcrumbs
17
+ # app.helpers ::Padrino::Helpers::Breadcrumbs
18
18
 
19
19
  app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
20
20
  end
@@ -17,6 +17,8 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
17
17
  end
18
18
 
19
19
  app.config.define_setting :locales_dir, "locales", 'The directory holding your locale configurations'
20
+
21
+ app.send :include, LocaleHelpers
20
22
  end
21
23
 
22
24
  def after_configuration
@@ -71,7 +73,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
71
73
  app.files.deleted(&method(:on_file_changed))
72
74
  end
73
75
 
74
- helpers do
76
+ helpers do
75
77
  def t(*args)
76
78
  ::I18n.t(*args)
77
79
  end
@@ -108,43 +110,73 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
108
110
  new_resources = []
109
111
 
110
112
  resources.each do |resource|
111
- next unless File.fnmatch(File.join(options[:templates_dir], "**"), resource.path)
113
+ # If it's a "localizable template"
114
+ if File.fnmatch?(File.join(options[:templates_dir], "**"), resource.path)
115
+ page_id = File.basename(resource.path, File.extname(resource.path))
116
+ langs.each do |lang|
117
+ # Remove folder name
118
+ path = resource.path.sub(options[:templates_dir], "")
119
+ new_resources << build_resource(path, resource.path, page_id, lang)
120
+ end
121
+ elsif result = parse_locale_extension(resource.path)
122
+ lang, path, page_id = result
123
+ new_resources << build_resource(path, resource.path, page_id, lang)
124
+ end
125
+ end
112
126
 
113
- page_id = File.basename(resource.path, File.extname(resource.path))
127
+ resources + new_resources
128
+ end
114
129
 
115
- old_locale = ::I18n.locale
116
- langs.map do |lang|
117
- ::I18n.locale = lang
130
+ private
118
131
 
119
- localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id, :fallback => [])
120
- path = resource.path.sub(options[:templates_dir], "")
132
+ # Parse locale extension filename
133
+ # @return [lang, path, basename]
134
+ # will return +nil+ if no locale extension
135
+ def parse_locale_extension(path)
136
+ path_bits = path.split('.')
137
+ return nil if path_bits.size < 3
121
138
 
122
- # Build lang path
123
- if @mount_at_root == lang
124
- prefix = "/"
125
- else
126
- replacement = options[:lang_map].has_key?(lang) ? options[:lang_map][lang] : lang
127
- prefix = options[:path].sub(":locale", replacement.to_s)
128
- end
139
+ lang = path_bits.delete_at(-2).to_sym
140
+ return nil unless langs.include?(lang)
129
141
 
130
- path = ::Middleman::Util.normalize_path(
131
- File.join(prefix, path.sub(page_id, localized_page_id))
132
- )
142
+ path = path_bits.join('.')
143
+ basename = File.basename(path_bits[0..-2].join('.'))
133
144
 
134
- @_localization_data[path] = [lang, path, localized_page_id]
145
+ [lang, path, basename]
146
+ end
135
147
 
136
- p = ::Middleman::Sitemap::Resource.new(
137
- app.sitemap,
138
- path
139
- )
140
- p.proxy_to(resource.path)
148
+ def build_resource(path, source_path, page_id, lang)
149
+ old_locale = ::I18n.locale
150
+ ::I18n.locale = lang
141
151
 
142
- new_resources << p
143
- end
144
- ::I18n.locale = old_locale
152
+ localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id, :fallback => [])
145
153
 
154
+ if @mount_at_root == lang
155
+ prefix = "/"
156
+ else
157
+ replacement = options[:lang_map].fetch(lang, lang)
158
+ prefix = options[:path].sub(":locale", replacement.to_s)
146
159
  end
147
160
 
148
- resources + new_resources
161
+ path = ::Middleman::Util.normalize_path(
162
+ File.join(prefix, path.sub(page_id, localized_page_id))
163
+ )
164
+
165
+ @_localization_data[path] = [lang, path, localized_page_id]
166
+
167
+ p = ::Middleman::Sitemap::Resource.new(app.sitemap, path)
168
+ p.proxy_to(source_path)
169
+
170
+ ::I18n.locale = old_locale
171
+
172
+ p
173
+ end
174
+
175
+ module LocaleHelpers
176
+ # Access the list of languages supported by this Middleman application
177
+ # @return [Array<Symbol>]
178
+ def langs
179
+ extensions[:i18n].langs
180
+ end
149
181
  end
150
182
  end
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency("coffee-script", ["~> 2.2.0"])
25
25
  s.add_dependency("execjs", ["~> 1.4.0"])
26
26
  s.add_dependency("kramdown", ["~> 1.0.0"])
27
- s.add_dependency("i18n", ["~> 0.6.4"])
28
- s.add_dependency("padrino-helpers", ["0.11.1"])
27
+ s.add_dependency("i18n", ["~> 0.6.1"])
28
+ s.add_dependency("padrino-helpers", ["0.10.7"])
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-more
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.beta.2
4
+ version: 3.1.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-01 00:00:00.000000000 Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 3.1.0.beta.2
20
+ version: 3.1.0.beta.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 3.1.0.beta.2
27
+ version: 3.1.0.beta.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: uglifier
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -129,28 +129,28 @@ dependencies:
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
- version: 0.6.4
132
+ version: 0.6.1
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ~>
138
138
  - !ruby/object:Gem::Version
139
- version: 0.6.4
139
+ version: 0.6.1
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: padrino-helpers
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - '='
145
145
  - !ruby/object:Gem::Version
146
- version: 0.11.1
146
+ version: 0.10.7
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - '='
152
152
  - !ruby/object:Gem::Version
153
- version: 0.11.1
153
+ version: 0.10.7
154
154
  description: A static site generator. Provides dozens of templating languages (Haml,
155
155
  Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache
156
156
  busting, Yaml data (and more) an easy part of your development cycle.
@@ -325,9 +325,13 @@ files:
325
325
  - fixtures/i18n-force-locale/source/index.haml
326
326
  - fixtures/i18n-test-app/locales/en.yml
327
327
  - fixtures/i18n-test-app/locales/es.yml
328
+ - fixtures/i18n-test-app/source/CNAME
328
329
  - fixtures/i18n-test-app/source/layout.erb
329
330
  - fixtures/i18n-test-app/source/localizable/hello.html.erb
330
331
  - fixtures/i18n-test-app/source/localizable/index.html.erb
332
+ - fixtures/i18n-test-app/source/morning.en.html.erb
333
+ - fixtures/i18n-test-app/source/morning.es.html.erb
334
+ - fixtures/i18n-test-app/source/password.txt
331
335
  - fixtures/i18n-test-app/source/stylesheets/site.css
332
336
  - fixtures/ignore-app/source/about.html.erb
333
337
  - fixtures/ignore-app/source/images/icon/messages.png
@@ -802,9 +806,13 @@ test_files:
802
806
  - fixtures/i18n-force-locale/source/index.haml
803
807
  - fixtures/i18n-test-app/locales/en.yml
804
808
  - fixtures/i18n-test-app/locales/es.yml
809
+ - fixtures/i18n-test-app/source/CNAME
805
810
  - fixtures/i18n-test-app/source/layout.erb
806
811
  - fixtures/i18n-test-app/source/localizable/hello.html.erb
807
812
  - fixtures/i18n-test-app/source/localizable/index.html.erb
813
+ - fixtures/i18n-test-app/source/morning.en.html.erb
814
+ - fixtures/i18n-test-app/source/morning.es.html.erb
815
+ - fixtures/i18n-test-app/source/password.txt
808
816
  - fixtures/i18n-test-app/source/stylesheets/site.css
809
817
  - fixtures/ignore-app/source/about.html.erb
810
818
  - fixtures/ignore-app/source/images/icon/messages.png