middleman-core 4.4.2 → 4.5.0

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
  SHA256:
3
- metadata.gz: 13aa21c1035525447cfbccc018a28fc08b230dc5014e8403a4f6bf3a1fb20c79
4
- data.tar.gz: 28e8922409bddf4309a5b0b98afd5d778420d95c390344fc149448771e495b73
3
+ metadata.gz: 955d0ea89728b170a8a5e7b94dadbf9c7e848ac05c41ee69e8d6932e531c6d45
4
+ data.tar.gz: 1c59256a26b181e745b0a263514411c61aa6887fff9c293b5a9dba0ebb10f665
5
5
  SHA512:
6
- metadata.gz: be9c030e750a5db77379753eeb71a432d27ee3b03c7f8530dad5e01de61cf3b67f395b28212773ea651417a51bd04535055525c532ee53160f292cab19a18e85
7
- data.tar.gz: 8e4d535a621ce5e874935d5ba65c608a7f2f5b9016d586496643be679a08f74fb93b7ea749dcfe0ac02216247379c69d8e1c60cfd6a1dd63fb8380183cd0d5c3
6
+ metadata.gz: 6a7956f26e7c55806f06ab7dc18e5fb544f3f91a43b814011edb5aecec5fa0d9124cd873b402a04d65edabba4f0d3f32750d963be889d3379a0f17bb1356428a
7
+ data.tar.gz: a6f6e1038e04ea990628b2a6a62b59fdfb4da77acfa46f49a07ac3774c2f706c1ff7366a1f745e0a70ccd1dbe4f18ad276664a616bb05da4f0033186b3fe292e
data/.simplecov CHANGED
@@ -1,7 +1,7 @@
1
- SimpleCov.start do
1
+ SimpleCov.configure do
2
2
  add_filter '/fixtures/'
3
3
  add_filter '/features/'
4
4
  add_filter '/spec/'
5
5
  add_filter '/step_definitions/'
6
6
  add_filter '/lib/vendored-middleman-deps/'
7
- end
7
+ end
@@ -123,8 +123,10 @@ Feature: i18n Builder
123
123
  | hello.html |
124
124
  And the file "en/index.html" should contain "Howdy"
125
125
  And the file "en/hello.html" should contain "Hello World"
126
+ And the file "en/fallback.html" should contain "Fallback"
126
127
  And the file "es/index.html" should contain "Como Esta?"
127
128
  And the file "es/hola.html" should contain "Hola World"
129
+ And the file "es/fallback.html" should contain "Fallback"
128
130
 
129
131
  Scenario: Running localize with the subset config
130
132
  Given a fixture app "i18n-test-app"
@@ -211,3 +211,97 @@ Feature: i18n Paths
211
211
  Then I should see 'Current: /es/article.html'
212
212
  Then I should see 'Other: /article.html'
213
213
  Then I should see 'Current with anchor: /es/article.html#test-anchor'
214
+
215
+ Scenario: Using url_for with the no mount config
216
+ Given a fixture app "empty-app"
217
+ And a file named "data/pages.yml" with:
218
+ """
219
+ - hello.html
220
+ """
221
+ And a file named "locales/en.yml" with:
222
+ """
223
+ ---
224
+ en:
225
+ msg: Hello
226
+ """
227
+ And a file named "locales/es.yml" with:
228
+ """
229
+ ---
230
+ es:
231
+ paths:
232
+ hello: "hola"
233
+ msg: Hola
234
+ """
235
+ And a file named "source/localizable/hello.html.erb" with:
236
+ """
237
+ Page: <%= t(:msg) %>
238
+ <% data.pages.each_with_index do |p, i| %>
239
+ Current: <%= url_for "/#{p}" %>
240
+ Other: <%= url_for "/#{p}", locale: ::I18n.locale == :en ? :es : :en %>
241
+ <% end %>
242
+ """
243
+ And a file named "source/localizable/article.html.erb" with:
244
+ """
245
+ Page Lang: Default
246
+
247
+ Current: <%= url_for "/article.html" %>
248
+ Other: <%= url_for "/article.html", locale: ::I18n.locale == :en ? :es : :en %>
249
+ Current with anchor: <%= url_for "/article.html", :anchor => "test-anchor" %>
250
+ """
251
+ And a file named "source/localizable/article.es.html.erb" with:
252
+ """
253
+ Page Lang: Spanish
254
+
255
+ Current: <%= url_for "/article.html" %>
256
+ Other: <%= url_for "/article.html", locale: :en %>
257
+ Current with anchor: <%= url_for "/article.html", :anchor => "test-anchor" %>
258
+ """
259
+ And a file named "source/localizable/post.en.html.erb" with:
260
+ """
261
+ Page Lang: English
262
+
263
+ Current: <%= url_for "/post.html" %>
264
+ Other: <%= url_for "/post.html", locale: :es %>
265
+ Current with anchor: <%= url_for "/post.html", :anchor => "test-anchor" %>
266
+ """
267
+ And a file named "source/localizable/post.es.html.erb" with:
268
+ """
269
+ Page Lang: Spanish
270
+
271
+ Current: <%= url_for "/post.html" %>
272
+ Other: <%= url_for "/post.html", locale: :en %>
273
+ Current with anchor: <%= url_for "/post.html", :anchor => "test-anchor" %>
274
+ """
275
+ And a file named "config.rb" with:
276
+ """
277
+ activate :i18n, mount_at_root: false
278
+ """
279
+ Given the Server is running
280
+ When I go to "/en/hello.html"
281
+ Then I should see "Page: Hello"
282
+ Then I should see 'Current: /en/hello.html'
283
+ Then I should see 'Other: /es/hola.html'
284
+ When I go to "/es/hola.html"
285
+ Then I should see "Page: Hola"
286
+ Then I should see 'Current: /es/hola.html'
287
+ Then I should see 'Other: /en/hello.html'
288
+ When I go to "/en/article.html"
289
+ Then I should see "Page Lang: Default"
290
+ Then I should see 'Current: /en/article.html'
291
+ Then I should see 'Other: /es/article.html'
292
+ Then I should see 'Current with anchor: /en/article.html#test-anchor'
293
+ When I go to "/es/article.html"
294
+ Then I should see "Page Lang: Spanish"
295
+ Then I should see 'Current: /es/article.html'
296
+ Then I should see 'Other: /en/article.html'
297
+ Then I should see 'Current with anchor: /es/article.html#test-anchor'
298
+ When I go to "/en/post.html"
299
+ Then I should see "Page Lang: English"
300
+ Then I should see 'Current: /en/post.html'
301
+ Then I should see 'Other: /es/post.html'
302
+ Then I should see 'Current with anchor: /en/post.html#test-anchor'
303
+ When I go to "/es/post.html"
304
+ Then I should see "Page Lang: Spanish"
305
+ Then I should see 'Current: /es/post.html'
306
+ Then I should see 'Other: /en/post.html'
307
+ Then I should see 'Current with anchor: /es/post.html#test-anchor'
@@ -1,241 +1,241 @@
1
- # Feature: i18n Preview
2
- # In order to preview localized html
1
+ Feature: i18n Preview
2
+ In order to preview localized html
3
3
 
4
- # Scenario: Running localize with the default config
5
- # Given a fixture app "i18n-test-app"
6
- # And a file named "config.rb" with:
7
- # """
8
- # activate :i18n
9
- # """
10
- # Given the Server is running at "i18n-test-app"
11
- # When I go to "/"
12
- # Then I should see "Howdy"
13
- # When I go to "/hello.html"
14
- # Then I should see "Hello World"
15
- # When I go to "/morning.html"
16
- # Then I should see "Good morning"
17
- # When I go to "/one.html"
18
- # Then I should see "Only one"
19
- # When I go to "/defaults_en/index.html"
20
- # Then I should see "File Not Found"
21
- # When I go to "/en/index.html"
22
- # Then I should see "File Not Found"
23
- # When I go to "/en/morning.html"
24
- # Then I should see "File Not Found"
25
- # When I go to "/defaults_es/index.html"
26
- # Then I should see "File Not Found"
27
- # When I go to "/es/index.html"
28
- # Then I should see "Como Esta?"
29
- # When I go to "/es/hola.html"
30
- # Then I should see "Hola World"
31
- # When I go to "/es/manana.html"
32
- # Then I should see "Buenos días"
33
- # When I go to "/es/una.html"
34
- # Then I should see "Solamente una"
4
+ Scenario: Running localize with the default config
5
+ Given a fixture app "i18n-test-app"
6
+ And a file named "config.rb" with:
7
+ """
8
+ activate :i18n
9
+ """
10
+ Given the Server is running at "i18n-test-app"
11
+ When I go to "/"
12
+ Then I should see "Howdy"
13
+ When I go to "/hello.html"
14
+ Then I should see "Hello World"
15
+ When I go to "/morning.html"
16
+ Then I should see "Good morning"
17
+ When I go to "/one.html"
18
+ Then I should see "Only one"
19
+ When I go to "/defaults_en/index.html"
20
+ Then I should see "File Not Found"
21
+ When I go to "/en/index.html"
22
+ Then I should see "File Not Found"
23
+ When I go to "/en/morning.html"
24
+ Then I should see "File Not Found"
25
+ When I go to "/defaults_es/index.html"
26
+ Then I should see "File Not Found"
27
+ When I go to "/es/index.html"
28
+ Then I should see "Como Esta?"
29
+ When I go to "/es/hola.html"
30
+ Then I should see "Hola World"
31
+ When I go to "/es/manana.html"
32
+ Then I should see "Buenos días"
33
+ When I go to "/es/una.html"
34
+ Then I should see "Solamente una"
35
35
 
36
- # Scenario: A template changes i18n during preview
37
- # Given a fixture app "i18n-test-app"
38
- # And a file named "config.rb" with:
39
- # """
40
- # activate :i18n
41
- # """
42
- # Given the Server is running at "i18n-test-app"
43
- # And the file "locales/en.yml" has the contents
44
- # """
45
- # ---
46
- # en:
47
- # greetings: "Howdy"
48
- # hi: "Hello"
49
- # """
50
- # When I go to "/"
51
- # Then I should see "Howdy"
52
- # When I go to "/hello.html"
53
- # Then I should see "Hello World"
54
- # When the file "locales/en.yml" has the contents
55
- # """
56
- # ---
57
- # en:
58
- # greetings: "How You Doin"
59
- # hi: "Sup"
60
- # """
61
- # When I go to "/"
62
- # Then I should see "How You Doin"
63
- # When I go to "/hello.html"
64
- # Then I should see "Sup World"
36
+ Scenario: A template changes i18n during preview
37
+ Given a fixture app "i18n-test-app"
38
+ And a file named "config.rb" with:
39
+ """
40
+ activate :i18n
41
+ """
42
+ Given the Server is running at "i18n-test-app"
43
+ And the file "locales/en.yml" has the contents
44
+ """
45
+ ---
46
+ en:
47
+ greetings: "Howdy"
48
+ hi: "Hello"
49
+ """
50
+ When I go to "/"
51
+ Then I should see "Howdy"
52
+ When I go to "/hello.html"
53
+ Then I should see "Hello World"
54
+ When the file "locales/en.yml" has the contents
55
+ """
56
+ ---
57
+ en:
58
+ greetings: "How You Doin"
59
+ hi: "Sup"
60
+ """
61
+ When I go to "/"
62
+ Then I should see "How You Doin"
63
+ When I go to "/hello.html"
64
+ Then I should see "Sup World"
65
65
 
66
- # Scenario: Running localize with the alt path config
67
- # Given a fixture app "i18n-test-app"
68
- # And a file named "config.rb" with:
69
- # """
70
- # activate :i18n, path: "/lang_:locale/"
71
- # """
72
- # Given the Server is running at "i18n-test-app"
73
- # When I go to "/"
74
- # Then I should see "Howdy"
75
- # When I go to "/hello.html"
76
- # Then I should see "Hello World"
77
- # When I go to "/lang_en/index.html"
78
- # Then I should see "File Not Found"
79
- # When I go to "/lang_es/index.html"
80
- # Then I should see "Como Esta?"
81
- # When I go to "/lang_es/hola.html"
82
- # Then I should see "Hola World"
66
+ Scenario: Running localize with the alt path config
67
+ Given a fixture app "i18n-test-app"
68
+ And a file named "config.rb" with:
69
+ """
70
+ activate :i18n, path: "/lang_:locale/"
71
+ """
72
+ Given the Server is running at "i18n-test-app"
73
+ When I go to "/"
74
+ Then I should see "Howdy"
75
+ When I go to "/hello.html"
76
+ Then I should see "Hello World"
77
+ When I go to "/lang_en/index.html"
78
+ Then I should see "File Not Found"
79
+ When I go to "/lang_es/index.html"
80
+ Then I should see "Como Esta?"
81
+ When I go to "/lang_es/hola.html"
82
+ Then I should see "Hola World"
83
83
 
84
84
 
85
- # Scenario: Running localize with the alt root config
86
- # Given a fixture app "i18n-alt-root-app"
87
- # And a file named "config.rb" with:
88
- # """
89
- # activate :i18n, templates_dir: "lang_data"
90
- # """
91
- # Given the Server is running at "i18n-alt-root-app"
92
- # When I go to "/"
93
- # Then I should see "Howdy"
94
- # When I go to "/hello.html"
95
- # Then I should see "Hello World"
96
- # When I go to "/en/index.html"
97
- # Then I should see "File Not Found"
98
- # When I go to "/es/index.html"
99
- # Then I should see "Como Esta?"
100
- # When I go to "/es/hola.html"
101
- # Then I should see "Hola World"
85
+ Scenario: Running localize with the alt root config
86
+ Given a fixture app "i18n-alt-root-app"
87
+ And a file named "config.rb" with:
88
+ """
89
+ activate :i18n, templates_dir: "lang_data"
90
+ """
91
+ Given the Server is running at "i18n-alt-root-app"
92
+ When I go to "/"
93
+ Then I should see "Howdy"
94
+ When I go to "/hello.html"
95
+ Then I should see "Hello World"
96
+ When I go to "/en/index.html"
97
+ Then I should see "File Not Found"
98
+ When I go to "/es/index.html"
99
+ Then I should see "Como Esta?"
100
+ When I go to "/es/hola.html"
101
+ Then I should see "Hola World"
102
102
 
103
- # Scenario: Running localize with the lang map config
104
- # Given a fixture app "i18n-test-app"
105
- # And a file named "config.rb" with:
106
- # """
107
- # activate :i18n, lang_map: { en: :english, es: :spanish }
108
- # """
109
- # Given the Server is running at "i18n-test-app"
110
- # When I go to "/"
111
- # Then I should see "Howdy"
112
- # When I go to "/hello.html"
113
- # Then I should see "Hello World"
114
- # When I go to "/english/index.html"
115
- # Then I should see "File Not Found"
116
- # When I go to "/spanish/index.html"
117
- # Then I should see "Como Esta?"
118
- # When I go to "/spanish/hola.html"
119
- # Then I should see "Hola World"
103
+ Scenario: Running localize with the lang map config
104
+ Given a fixture app "i18n-test-app"
105
+ And a file named "config.rb" with:
106
+ """
107
+ activate :i18n, lang_map: { en: :english, es: :spanish }
108
+ """
109
+ Given the Server is running at "i18n-test-app"
110
+ When I go to "/"
111
+ Then I should see "Howdy"
112
+ When I go to "/hello.html"
113
+ Then I should see "Hello World"
114
+ When I go to "/english/index.html"
115
+ Then I should see "File Not Found"
116
+ When I go to "/spanish/index.html"
117
+ Then I should see "Como Esta?"
118
+ When I go to "/spanish/hola.html"
119
+ Then I should see "Hola World"
120
120
 
121
- # Scenario: Running localize with a non-English mount config
122
- # Given a fixture app "i18n-test-app"
123
- # And a file named "config.rb" with:
124
- # """
125
- # activate :i18n, mount_at_root: :es
126
- # """
127
- # Given the Server is running at "i18n-test-app"
128
- # When I go to "/en/index.html"
129
- # Then I should see "Howdy"
130
- # When I go to "/en/hello.html"
131
- # Then I should see "Hello World"
132
- # When I go to "/"
133
- # Then I should see "Como Esta?"
134
- # When I go to "/hola.html"
135
- # Then I should see "Hola World"
136
- # When I go to "/manana.html"
137
- # Then I should see "Buenos días"
138
- # When I go to "/hello.html"
139
- # Then I should see "File Not Found"
140
- # When I go to "/en/morning.html"
141
- # Then I should see "Good morning"
142
- # When I go to "/es/manana.html"
143
- # Then I should see "File Not Found"
144
- # When I go to "/es/index.html"
145
- # Then I should see "File Not Found"
146
- # When I go to "/es/hola.html"
147
- # Then I should see "File Not Found"
121
+ Scenario: Running localize with a non-English mount config
122
+ Given a fixture app "i18n-test-app"
123
+ And a file named "config.rb" with:
124
+ """
125
+ activate :i18n, mount_at_root: :es
126
+ """
127
+ Given the Server is running at "i18n-test-app"
128
+ When I go to "/en/index.html"
129
+ Then I should see "Howdy"
130
+ When I go to "/en/hello.html"
131
+ Then I should see "Hello World"
132
+ When I go to "/"
133
+ Then I should see "Como Esta?"
134
+ When I go to "/hola.html"
135
+ Then I should see "Hola World"
136
+ When I go to "/manana.html"
137
+ Then I should see "Buenos días"
138
+ When I go to "/hello.html"
139
+ Then I should see "File Not Found"
140
+ When I go to "/en/morning.html"
141
+ Then I should see "Good morning"
142
+ When I go to "/es/manana.html"
143
+ Then I should see "File Not Found"
144
+ When I go to "/es/index.html"
145
+ Then I should see "File Not Found"
146
+ When I go to "/es/hola.html"
147
+ Then I should see "File Not Found"
148
148
 
149
- # Scenario: Running localize with a non-English lang subset
150
- # Given a fixture app "i18n-test-app"
151
- # And a file named "config.rb" with:
152
- # """
153
- # activate :i18n, langs: :es
154
- # """
155
- # Given the Server is running at "i18n-test-app"
156
- # When I go to "/en/index.html"
157
- # Then I should see "File Not Found"
158
- # When I go to "/en/hello.html"
159
- # Then I should see "File Not Found"
160
- # When I go to "/"
161
- # Then I should see "Como Esta?"
162
- # When I go to "/hola.html"
163
- # Then I should see "Hola World"
164
- # When I go to "/hello.html"
165
- # Then I should see "File Not Found"
166
- # When I go to "/es/index.html"
167
- # Then I should see "File Not Found"
168
- # When I go to "/es/hola.html"
169
- # Then I should see "File Not Found"
149
+ Scenario: Running localize with a non-English lang subset
150
+ Given a fixture app "i18n-test-app"
151
+ And a file named "config.rb" with:
152
+ """
153
+ activate :i18n, langs: :es
154
+ """
155
+ Given the Server is running at "i18n-test-app"
156
+ When I go to "/en/index.html"
157
+ Then I should see "File Not Found"
158
+ When I go to "/en/hello.html"
159
+ Then I should see "File Not Found"
160
+ When I go to "/"
161
+ Then I should see "Como Esta?"
162
+ When I go to "/hola.html"
163
+ Then I should see "Hola World"
164
+ When I go to "/hello.html"
165
+ Then I should see "File Not Found"
166
+ When I go to "/es/index.html"
167
+ Then I should see "File Not Found"
168
+ When I go to "/es/hola.html"
169
+ Then I should see "File Not Found"
170
170
 
171
171
 
172
- # Scenario: Running localize with the no mount config
173
- # Given a fixture app "i18n-test-app"
174
- # And a file named "config.rb" with:
175
- # """
176
- # activate :i18n, mount_at_root: false
177
- # """
178
- # Given the Server is running at "i18n-test-app"
179
- # When I go to "/en/index.html"
180
- # Then I should see "Howdy"
181
- # When I go to "/en/hello.html"
182
- # Then I should see "Hello World"
183
- # When I go to "/"
184
- # Then I should see "File Not Found"
185
- # When I go to "/hello.html"
186
- # Then I should see "File Not Found"
187
- # When I go to "/es/index.html"
188
- # Then I should see "Como Esta?"
189
- # When I go to "/es/hola.html"
190
- # Then I should see "Hola World"
172
+ Scenario: Running localize with the no mount config
173
+ Given a fixture app "i18n-test-app"
174
+ And a file named "config.rb" with:
175
+ """
176
+ activate :i18n, mount_at_root: false
177
+ """
178
+ Given the Server is running at "i18n-test-app"
179
+ When I go to "/en/index.html"
180
+ Then I should see "Howdy"
181
+ When I go to "/en/hello.html"
182
+ Then I should see "Hello World"
183
+ When I go to "/"
184
+ Then I should see "File Not Found"
185
+ When I go to "/hello.html"
186
+ Then I should see "File Not Found"
187
+ When I go to "/es/index.html"
188
+ Then I should see "Como Esta?"
189
+ When I go to "/es/hola.html"
190
+ Then I should see "Hola World"
191
191
 
192
- # Scenario: Running localize with the subset config
193
- # Given a fixture app "i18n-test-app"
194
- # And a file named "config.rb" with:
195
- # """
196
- # activate :i18n, langs: [:en]
197
- # """
198
- # Given the Server is running at "i18n-test-app"
199
- # When I go to "/"
200
- # Then I should see "Howdy"
201
- # When I go to "/hello.html"
202
- # Then I should see "Hello World"
203
- # When I go to "/en/index.html"
204
- # Then I should see "File Not Found"
205
- # When I go to "/es/index.html"
206
- # Then I should see "File Not Found"
207
- # When I go to "/es/hola.html"
208
- # Then I should see "File Not Found"
192
+ Scenario: Running localize with the subset config
193
+ Given a fixture app "i18n-test-app"
194
+ And a file named "config.rb" with:
195
+ """
196
+ activate :i18n, langs: [:en]
197
+ """
198
+ Given the Server is running at "i18n-test-app"
199
+ When I go to "/"
200
+ Then I should see "Howdy"
201
+ When I go to "/hello.html"
202
+ Then I should see "Hello World"
203
+ When I go to "/en/index.html"
204
+ Then I should see "File Not Found"
205
+ When I go to "/es/index.html"
206
+ Then I should see "File Not Found"
207
+ When I go to "/es/hola.html"
208
+ Then I should see "File Not Found"
209
209
 
210
- # Scenario: Running localize with relative_assets
211
- # Given a fixture app "i18n-test-app"
212
- # And a file named "config.rb" with:
213
- # """
214
- # activate :i18n
215
- # activate :relative_assets
216
- # """
217
- # Given the Server is running at "i18n-test-app"
218
- # When I go to "/"
219
- # Then I should see '"stylesheets/site.css"'
220
- # When I go to "/hello.html"
221
- # Then I should see '"stylesheets/site.css"'
222
- # When I go to "/es/index.html"
223
- # Then I should see '"../stylesheets/site.css"'
224
- # When I go to "/es/hola.html"
225
- # Then I should see '"../stylesheets/site.css"'
210
+ Scenario: Running localize with relative_assets
211
+ Given a fixture app "i18n-test-app"
212
+ And a file named "config.rb" with:
213
+ """
214
+ activate :i18n
215
+ activate :relative_assets
216
+ """
217
+ Given the Server is running at "i18n-test-app"
218
+ When I go to "/"
219
+ Then I should see '"stylesheets/site.css"'
220
+ When I go to "/hello.html"
221
+ Then I should see '"stylesheets/site.css"'
222
+ When I go to "/es/index.html"
223
+ Then I should see '"../stylesheets/site.css"'
224
+ When I go to "/es/hola.html"
225
+ Then I should see '"../stylesheets/site.css"'
226
226
 
227
- # Scenario: Missing translations fall back to the default locale
228
- # Given a fixture app "i18n-default-app"
229
- # And a file named "config.rb" with:
230
- # """
231
- # activate :i18n, mount_at_root: :es
232
- # """
233
- # Given the Server is running at "i18n-default-app"
234
- # When I go to "/en/"
235
- # Then I should see "Default locale: es"
236
- # Then I should see "Current locale: en"
237
- # Then I should see "Buenos días"
238
- # Then I should see "Howdy"
227
+ Scenario: Missing translations fall back to the default locale
228
+ Given a fixture app "i18n-default-app"
229
+ And a file named "config.rb" with:
230
+ """
231
+ activate :i18n, mount_at_root: :es
232
+ """
233
+ Given the Server is running at "i18n-default-app"
234
+ When I go to "/en/"
235
+ Then I should see "Default locale: es"
236
+ Then I should see "Current locale: en"
237
+ Then I should see "Buenos días"
238
+ Then I should see "Howdy"
239
239
 
240
240
  # Scenario: Nested i18n yaml
241
241
  # Given a fixture app "i18n-nested-app"
@@ -249,4 +249,4 @@
249
249
  # Then I should see "More"
250
250
  # When I go to "/es/"
251
251
  # Then I should see "Como Esta?"
252
- # Then I should see "Mucho"
252
+ # Then I should see "Mucho"
@@ -5,8 +5,7 @@ require 'sassc'
5
5
  require 'simplecov'
6
6
  SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/../..'))
7
7
 
8
- require 'coveralls'
9
- Coveralls.wear!
8
+ SimpleCov.start
10
9
 
11
10
  PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
12
11
  require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-core')
@@ -1,4 +1,4 @@
1
- = content_for :from_template do
2
- = "I am the yielded content haml <s>with html tags</s>"
1
+ - content_for :from_template do
2
+ != "I am the yielded content haml <s>with html tags</s>"
3
3
 
4
4
  %p I am in the template
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  en:
3
3
  greetings: "Howdy"
4
- hi: "Hello"
4
+ hi: "Hello"
5
+ fallback: "Fallback"
@@ -0,0 +1 @@
1
+ <%= I18n.t(:fallback) %>
@@ -1,3 +1,4 @@
1
+ require 'addressable/uri'
1
2
  require 'pathname'
2
3
  require 'fileutils'
3
4
  require 'tempfile'
@@ -229,7 +230,7 @@ module Middleman
229
230
  if resource.binary?
230
231
  export_file!(output_file, resource.file_descriptor[:full_path])
231
232
  else
232
- response = @rack.get(::WEBrick::HTTPUtils.escape(resource.request_path))
233
+ response = @rack.get(Addressable::URI.encode(resource.request_path))
233
234
 
234
235
  # If we get a response, save it to a tempfile.
235
236
  if response.status == 200
@@ -218,8 +218,11 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
218
218
  # Given a source path (referenced either absolutely or relatively)
219
219
  # or a Resource, this will produce the nice URL configured for that
220
220
  # path, respecting :relative_links, directory indexes, etc.
221
+ #
222
+ # Relative routes will be relative the the current_resource. Pass the
223
+ # `:current_resource` option to customize.
221
224
  def url_for(path_or_resource, options={})
222
- options_with_resource = {}.merge!(options).merge!(current_resource: current_resource)
225
+ options_with_resource = {}.merge!(current_resource: current_resource).merge!(options)
223
226
  ::Middleman::Util.url_for(app, path_or_resource, options_with_resource)
224
227
  end
225
228
 
@@ -151,7 +151,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
151
151
  new_resources = []
152
152
 
153
153
  file_extension_resources = resources.select do |resource|
154
- parse_locale_extension(resource.path)
154
+ # Ignore resources which are outside of the localizable directory
155
+ File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path) &&
156
+ parse_locale_extension(resource.path)
155
157
  end
156
158
 
157
159
  localizable_folder_resources = resources.select do |resource|
@@ -190,10 +192,61 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
190
192
  resource.ignore!
191
193
  end
192
194
 
193
- @lookup = new_resources.each_with_object({}) do |desc, sum|
194
- abs_path = desc.source_path.sub(options[:templates_dir], '')
195
- sum[abs_path] ||= {}
196
- sum[abs_path][desc.locale] = '/' + desc.path
195
+ # This generates a lookup hash that maps the real path (as seen by the web
196
+ # page user) to the paths of the localized versions. The lookup is later
197
+ # used by `url_for '/some/page.html', :locale => :en` and other url
198
+ # helpers.
199
+ #
200
+ # For example (given :mount_at_root => :es) and localized paths:
201
+ #
202
+ # @lookup['/en/magic/stuff.html'] = {:en => '/en/magic/stuff.html', :de => '/de/magisches/zeug.html', :es => '/magico/cosas.html'}
203
+ # @lookup['/de/index.html'] = {:en => '/en/index.html', :de => '/de/index.html', :es => '/index.html'}
204
+ # @lookup['/en/index.html'] = {:en => '/en/index.html', :de => '/de/index.html', :es => '/index.html'}
205
+ # @lookup['/index.html'] = {:en => '/en/index.html', :de => '/de/index.html', :es => '/index.html'}
206
+ #
207
+ # We do this by grouping by the source paths with the locales removed. All
208
+ # the localized pages with the same content in different languages get the
209
+ # same key.
210
+ #
211
+ @source_path_group = new_resources.group_by do |resource|
212
+ # Try to get source path without extension
213
+ _locale, path, _page_id = parse_locale_extension(resource.source_path)
214
+
215
+ # If that fails, there is no extension, so we use the original path. We
216
+ # can not use resource.path here, because .path may be translated, so the
217
+ # file names do not match up.
218
+ path ||= resource.source_path
219
+
220
+ # This will contain the localizable/ directory, but that does not matter,
221
+ # because it will be contained in both alternatives above, so the
222
+ # grouping key will be correct.
223
+ path
224
+ end
225
+
226
+ # Then we walk this grouped hash and generate the lookup table as given
227
+ # above.
228
+ @lookup = {}
229
+ @source_path_group.each do |src_path, resources|
230
+ # For each group we generate a list of the paths the user really sees
231
+ # (e.g. ['/en/index.html', '/de/index.html', '/index.html'])
232
+ exposed_paths = resources.map(&:path)
233
+
234
+ # We also generate a map with the same infos, but with the locales as keys.
235
+ # e.g. {:en => '/en/index.html', :de => '/de/index.html', :es => '/index.html'}
236
+ locale_map = resources.each_with_object({}) do |resource, map|
237
+ map[resource.locale] = '/' + resource.path
238
+ end
239
+
240
+ # Then we add those to the lookup table, so every path has a
241
+ # cross-reference to any other path in other locales.
242
+ exposed_paths.each do |path|
243
+ @lookup['/' + path] = locale_map
244
+ end
245
+
246
+ if @mount_at_root == false
247
+ src_path = src_path.sub(options[:templates_dir] + '/', '')
248
+ @lookup["/#{src_path}"] = locale_map
249
+ end
197
250
  end
198
251
 
199
252
  new_resources.reduce(resources) do |sum, r|
@@ -235,7 +288,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
235
288
  ::I18n.default_locale = @mount_at_root
236
289
 
237
290
  # Reset fallbacks to fall back to our new default
238
- ::I18n.fallbacks = ::I18n::Locale::Fallbacks.new if ::I18n.respond_to?(:fallbacks)
291
+ if ::I18n.respond_to?(:fallbacks)
292
+ ::I18n.fallbacks = ::I18n::Locale::Fallbacks.new(::I18n.default_locale)
293
+ end
239
294
  end
240
295
 
241
296
  Contract ArrayOf[Symbol]
@@ -1,3 +1,4 @@
1
+ require 'addressable/uri'
1
2
  require 'middleman-core/util'
2
3
  require 'middleman-core/rack'
3
4
 
@@ -87,7 +88,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
87
88
  else
88
89
  # Render through the Rack interface so middleware and mounted apps get a shot
89
90
  response = @rack_client.get(
90
- ::WEBrick::HTTPUtils.escape(resource.destination_path),
91
+ Addressable::URI.encode(resource.destination_path),
91
92
  'bypass_inline_url_rewriter_asset_hash' => 'true'
92
93
  )
93
94
 
@@ -6,6 +6,7 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
6
6
  option :source, nil, 'Path to merge into sitemap', required: true
7
7
  option :latency, 0.25, 'Latency between refreshes of source'
8
8
  option :disable_background_execution, false, "Don't run the command in a separate background thread"
9
+ option :ignore_exit_code, false, 'Ignore exit code for restart or stop of a command'
9
10
 
10
11
  def initialize(app, config={}, &block)
11
12
  super
@@ -65,7 +66,7 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
65
66
 
66
67
  @current_thread.wait
67
68
 
68
- if !@current_thread.exitstatus.nil? && @current_thread.exitstatus != 0
69
+ if !options[:ignore_exit_code] && !@current_thread.exitstatus.nil? && @current_thread.exitstatus != 0
69
70
  logger.error '== External: Command failed with non-zero exit status'
70
71
  exit(1)
71
72
  end
@@ -3,7 +3,7 @@ require 'rack/file'
3
3
  require 'rack/lint'
4
4
  require 'rack/head'
5
5
  require 'rack/utils'
6
- require 'webrick'
6
+ require 'addressable/uri'
7
7
 
8
8
  require 'middleman-core/util'
9
9
  require 'middleman-core/logger'
@@ -87,7 +87,7 @@ module Middleman
87
87
  def process_request(env, req, res)
88
88
  start_time = Time.now
89
89
 
90
- request_path = WEBrick::HTTPUtils.unescape(env['PATH_INFO'].dup)
90
+ request_path = Addressable::URI.unencode(env['PATH_INFO'].dup)
91
91
  if request_path.respond_to? :force_encoding
92
92
  request_path.force_encoding('UTF-8')
93
93
  end
@@ -29,12 +29,18 @@ module Middleman
29
29
  def prepare; end
30
30
 
31
31
  def evaluate(scope, locals, &block)
32
- options = {}.merge!(@options).merge!(filename: eval_file, line: line, context: @context || scope)
32
+ options = {}.merge!(@options).merge!(context: @context || scope)
33
33
  if options.include?(:outvar)
34
34
  options[:buffer] = options.delete(:outvar)
35
35
  options[:save_buffer] = true
36
36
  end
37
- @engine = ::Haml::Engine.new(data, options)
37
+ if Object.const_defined?('::Haml::Template') # haml 6+
38
+ @engine = ::Haml::Template.new(eval_file, line, options) { data }
39
+ else
40
+ options[:filename] = eval_file
41
+ options[:line] = line
42
+ @engine = ::Haml::Engine.new(data, options)
43
+ end
38
44
  output = @engine.render(scope, locals, &block)
39
45
 
40
46
  output
@@ -46,8 +52,12 @@ module Middleman
46
52
  def initialize(app, options={}, &block)
47
53
  super
48
54
 
49
- ::Haml::Options.defaults[:context] = nil
50
- ::Haml::Options.send :attr_accessor, :context
55
+ if Object.const_defined?('::Haml::Options') # Haml 5 and older
56
+ ::Haml::Options.defaults[:context] = nil
57
+ ::Haml::Options.send :attr_accessor, :context
58
+ else # Haml 6+
59
+ ::Haml::Engine.define_options context: nil
60
+ end
51
61
  if defined?(::Haml::TempleEngine)
52
62
  ::Haml::TempleEngine.define_options context: nil
53
63
  end
@@ -55,12 +65,31 @@ module Middleman
55
65
  # rubocop:disable NestedMethodDefinition
56
66
  [::Haml::Filters::Sass, ::Haml::Filters::Scss, ::Haml::Filters::Markdown].each do |f|
57
67
  f.class_exec do
58
- def self.render_with_options(text, compiler_options)
59
- modified_options = options.dup
60
- modified_options[:context] = compiler_options[:context]
61
-
62
- text = template_class.new(nil, 1, modified_options) { text }.render
63
- super(text, compiler_options)
68
+ if respond_to?(:template_class) # Haml 5 and older
69
+ def self.render_with_options(text, compiler_options)
70
+ modified_options = options.dup
71
+ modified_options[:context] = compiler_options[:context]
72
+
73
+ text = template_class.new(nil, 1, modified_options) { text }.render
74
+ super(text, compiler_options)
75
+ end
76
+ else # Haml 6+
77
+ def initialize(options = {})
78
+ super
79
+ @context = options[:context]
80
+ end
81
+
82
+ def compile_with_tilt(node, name, indent_width: 0)
83
+ options = { context: @context }
84
+ source = node.value[:text]
85
+ result = ::Tilt["t.#{name}"].new(nil, 1, options) { source }.render
86
+
87
+ temple = [:multi, [:static, result.gsub(/^/, ' ' * indent_width)]]
88
+ source.lines.size.times do
89
+ temple << [:newline]
90
+ end
91
+ temple
92
+ end
64
93
  end
65
94
  end
66
95
  end
@@ -1,7 +1,7 @@
1
1
  require 'middleman-core/rack'
2
2
  require 'rspec/expectations'
3
3
  require 'capybara/cucumber'
4
- require 'webrick'
4
+ require 'addressable/uri'
5
5
 
6
6
  Given /^a clean server$/ do
7
7
  @initialize_commands = []
@@ -73,11 +73,11 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
73
73
  end
74
74
 
75
75
  When /^I go to "([^\"]*)"$/ do |url|
76
- visit(WEBrick::HTTPUtils.escape(url))
76
+ visit(Addressable::URI.encode(url))
77
77
  end
78
78
 
79
79
  Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
80
- expect{ visit(WEBrick::HTTPUtils.escape(url)) }.to_not raise_exception
80
+ expect { visit(Addressable::URI.encode(url)) }.to_not raise_exception
81
81
  end
82
82
 
83
83
  Then /^the content type should be "([^\"]*)"$/ do |expected|
@@ -118,9 +118,17 @@ module Middleman
118
118
  # @return [Hash]
119
119
  Contract String, Pathname => Hash
120
120
  def parse_yaml(content, full_path)
121
+ permitted_classes = [Date, Symbol]
121
122
  c = begin
122
123
  ::Middleman::Util.instrument 'parse.yaml' do
123
- ::YAML.load(content)
124
+ allowed_parameters = ::YAML.method(:safe_load).parameters
125
+ if allowed_parameters.include? [:key, :permitted_classes]
126
+ ::YAML.safe_load(content, permitted_classes: permitted_classes)
127
+ elsif allowed_parameters.include? [:key, :whitelist_classes]
128
+ ::YAML.safe_load(content, whitelist_classes: permitted_classes)
129
+ else
130
+ ::YAML.safe_load(content, permitted_classes)
131
+ end
124
132
  end
125
133
  rescue StandardError, ::Psych::SyntaxError => error
126
134
  warn "YAML Exception parsing #{full_path}: #{error.message}"
@@ -4,7 +4,6 @@ require 'uri'
4
4
  require 'addressable/uri'
5
5
  require 'memoist'
6
6
  require 'tilt'
7
- require 'webrick'
8
7
 
9
8
  require 'middleman-core/contracts'
10
9
 
@@ -34,7 +33,7 @@ module Middleman
34
33
  Contract String => String
35
34
  def normalize_path(path)
36
35
  # The tr call works around a bug in Ruby's Unicode handling
37
- WEBrick::HTTPUtils.unescape(path).sub(%r{^/}, '').tr('', '')
36
+ Addressable::URI.unencode(path).sub(%r{^/}, '').tr('', '')
38
37
  end
39
38
  memoize :normalize_path
40
39
 
@@ -1,5 +1,4 @@
1
- # For instrumenting
2
- require 'active_support/notifications'
1
+ require 'active_support/all'
3
2
 
4
3
  require 'middleman-core/application'
5
4
  require 'middleman-core/sources'
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '4.4.2'.freeze unless const_defined?(:VERSION)
4
+ VERSION = '4.5.0'.freeze unless const_defined?(:VERSION)
5
5
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.license = 'MIT'
10
10
  s.authors = ['Thomas Reynolds', 'Ben Hollis', 'Karl Freeman']
11
11
  s.email = ['me@tdreyno.com', 'ben@benhollis.net', 'karlfreeman@gmail.com']
12
- s.homepage = 'http://middlemanapp.com'
12
+ s.homepage = 'https://middlemanapp.com'
13
13
  s.summary = 'Hand-crafted frontend development'
14
14
  s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.'
15
15
 
@@ -31,13 +31,13 @@ Gem::Specification.new do |s|
31
31
  s.add_dependency('webrick')
32
32
 
33
33
  # Helpers
34
- s.add_dependency('activesupport', ['>= 6.1', '< 7.0'])
34
+ s.add_dependency('activesupport', ['>= 6.1', '< 7.1'])
35
35
  s.add_dependency('padrino-helpers', ['~> 0.15.0'])
36
36
  s.add_dependency("addressable", ["~> 2.4"])
37
37
  s.add_dependency('memoist', ['~> 0.14'])
38
38
 
39
39
  # Watcher
40
- s.add_dependency('listen', ['~> 3.0.0'])
40
+ s.add_dependency('listen', ['~> 3.0'])
41
41
 
42
42
  # i18n
43
43
  s.add_dependency('i18n', ['~> 1.6.0'])
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
53
53
  s.add_dependency('execjs', ['~> 2.0'])
54
54
 
55
55
  # Testing
56
- s.add_dependency('contracts', ['~> 0.13.0'])
56
+ s.add_dependency('contracts', ['~> 0.13'])
57
57
 
58
58
  # Hash stuff
59
59
  s.add_dependency('hashie', ['~> 3.4'])
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))
3
-
4
- require 'coveralls'
5
- Coveralls.wear!
3
+ SimpleCov.start
6
4
 
7
5
  require 'aruba/api'
8
6
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-11-03 00:00:00.000000000 Z
13
+ date: 2023-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -167,7 +167,7 @@ dependencies:
167
167
  version: '6.1'
168
168
  - - "<"
169
169
  - !ruby/object:Gem::Version
170
- version: '7.0'
170
+ version: '7.1'
171
171
  type: :runtime
172
172
  prerelease: false
173
173
  version_requirements: !ruby/object:Gem::Requirement
@@ -177,7 +177,7 @@ dependencies:
177
177
  version: '6.1'
178
178
  - - "<"
179
179
  - !ruby/object:Gem::Version
180
- version: '7.0'
180
+ version: '7.1'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: padrino-helpers
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: 3.0.0
229
+ version: '3.0'
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: 3.0.0
236
+ version: '3.0'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: i18n
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -310,14 +310,14 @@ dependencies:
310
310
  requirements:
311
311
  - - "~>"
312
312
  - !ruby/object:Gem::Version
313
- version: 0.13.0
313
+ version: '0.13'
314
314
  type: :runtime
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
318
  - - "~>"
319
319
  - !ruby/object:Gem::Version
320
- version: 0.13.0
320
+ version: '0.13'
321
321
  - !ruby/object:Gem::Dependency
322
322
  name: hashie
323
323
  requirement: !ruby/object:Gem::Requirement
@@ -873,6 +873,7 @@ files:
873
873
  - fixtures/i18n-test-app/source/layouts/layout.erb
874
874
  - fixtures/i18n-test-app/source/localizable/_state.en.erb
875
875
  - fixtures/i18n-test-app/source/localizable/_state.es.erb
876
+ - fixtures/i18n-test-app/source/localizable/fallback.html.erb
876
877
  - fixtures/i18n-test-app/source/localizable/hello.html.erb
877
878
  - fixtures/i18n-test-app/source/localizable/images/flag.en.svg
878
879
  - fixtures/i18n-test-app/source/localizable/images/flag.es.svg
@@ -1570,7 +1571,7 @@ files:
1570
1571
  - spec/middleman-core/util_spec.rb
1571
1572
  - spec/spec_helper.rb
1572
1573
  - spec/support/given.rb
1573
- homepage: http://middlemanapp.com
1574
+ homepage: https://middlemanapp.com
1574
1575
  licenses:
1575
1576
  - MIT
1576
1577
  metadata: {}
@@ -1589,7 +1590,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1589
1590
  - !ruby/object:Gem::Version
1590
1591
  version: '0'
1591
1592
  requirements: []
1592
- rubygems_version: 3.2.22
1593
+ rubygems_version: 3.4.10
1593
1594
  signing_key:
1594
1595
  specification_version: 4
1595
1596
  summary: Hand-crafted frontend development