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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/features/asset_hash.feature +24 -24
  2. data/features/ignore_already_minified.feature +39 -4
  3. data/features/markdown.feature +3 -12
  4. data/features/markdown_redcarpet.feature +37 -0
  5. data/features/minify_css.feature +72 -10
  6. data/features/minify_javascript.feature +108 -10
  7. data/features/slim.feature +15 -1
  8. data/fixtures/markdown-app/config.rb +0 -9
  9. data/lib/middleman-more.rb +1 -74
  10. data/lib/middleman-more/core_extensions/compass.rb +49 -48
  11. data/lib/middleman-more/core_extensions/sprockets.rb +10 -2
  12. data/lib/middleman-more/extensions/asset_hash.rb +9 -23
  13. data/lib/middleman-more/extensions/cache_buster.rb +51 -53
  14. data/lib/middleman-more/extensions/gzip.rb +14 -0
  15. data/lib/middleman-more/extensions/minify_css.rb +60 -70
  16. data/lib/middleman-more/extensions/minify_javascript.rb +70 -77
  17. data/lib/middleman-more/extensions/relative_assets.rb +47 -47
  18. data/lib/middleman-more/register_extensions.rb +82 -0
  19. data/lib/middleman-more/renderers/coffee_script.rb +22 -0
  20. data/lib/middleman-more/renderers/haml.rb +24 -19
  21. data/lib/middleman-more/renderers/liquid.rb +28 -23
  22. data/lib/middleman-more/renderers/markdown.rb +50 -42
  23. data/lib/middleman-more/renderers/sass.rb +70 -63
  24. data/lib/middleman-more/renderers/slim.rb +27 -19
  25. data/middleman-more.gemspec +6 -7
  26. metadata +34 -43
  27. data/fixtures/already-minified-app/config.rb +0 -2
  28. data/fixtures/already-minified-app/source/javascripts/test.min.js +0 -10
  29. data/fixtures/already-minified-app/source/stylesheets/test.min.css +0 -10
  30. data/fixtures/minify-css-app/config.rb +0 -0
  31. data/fixtures/passthrough-app/config.rb +0 -17
  32. data/fixtures/slim-app/config.rb +0 -1
  33. data/fixtures/slim-app/source/slim.html.slim +0 -7
@@ -7,8 +7,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
7
7
  | images/100px-1242c368.png |
8
8
  | images/100px-5fd6fb90.jpg |
9
9
  | images/100px-5fd6fb90.gif |
10
- | javascripts/application-570e5d45.js |
11
- | stylesheets/site-d9d84711.css |
10
+ | javascripts/application-df677242.js |
11
+ | stylesheets/site-ed8c2d12.css |
12
12
  | index.html |
13
13
  | subdir/index.html |
14
14
  | other/index.html |
@@ -19,50 +19,50 @@ Feature: Assets get a file hash appended to their and references to them are upd
19
19
  | javascripts/application.js |
20
20
  | stylesheets/site.css |
21
21
 
22
- And the file "javascripts/application-570e5d45.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
23
- And the file "stylesheets/site-d9d84711.css" should contain "background-image: url('../images/100px-5fd6fb90.jpg')"
24
- And the file "index.html" should contain 'href="stylesheets/site-d9d84711.css"'
25
- And the file "index.html" should contain 'src="javascripts/application-570e5d45.js"'
22
+ And the file "javascripts/application-df677242.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
23
+ And the file "stylesheets/site-ed8c2d12.css" should contain "background-image: url('../images/100px-5fd6fb90.jpg')"
24
+ And the file "index.html" should contain 'href="stylesheets/site-ed8c2d12.css"'
25
+ And the file "index.html" should contain 'src="javascripts/application-df677242.js"'
26
26
  And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
27
- And the file "subdir/index.html" should contain 'href="../stylesheets/site-d9d84711.css"'
28
- And the file "subdir/index.html" should contain 'src="../javascripts/application-570e5d45.js"'
27
+ And the file "subdir/index.html" should contain 'href="../stylesheets/site-ed8c2d12.css"'
28
+ And the file "subdir/index.html" should contain 'src="../javascripts/application-df677242.js"'
29
29
  And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
30
- And the file "other/index.html" should contain 'href="../stylesheets/site-d9d84711.css"'
31
- And the file "other/index.html" should contain 'src="../javascripts/application-570e5d45.js"'
30
+ And the file "other/index.html" should contain 'href="../stylesheets/site-ed8c2d12.css"'
31
+ And the file "other/index.html" should contain 'src="../javascripts/application-df677242.js"'
32
32
  And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
33
33
 
34
34
  Scenario: Hashed assets work in preview server
35
35
  Given the Server is running at "asset-hash-app"
36
36
  When I go to "/"
37
- Then I should see 'href="stylesheets/site-d9d84711.css"'
38
- And I should see 'src="javascripts/application-570e5d45.js"'
37
+ Then I should see 'href="stylesheets/site-ed8c2d12.css"'
38
+ And I should see 'src="javascripts/application-df677242.js"'
39
39
  And I should see 'src="images/100px-5fd6fb90.jpg"'
40
40
  When I go to "/subdir/"
41
- Then I should see 'href="../stylesheets/site-d9d84711.css"'
42
- And I should see 'src="../javascripts/application-570e5d45.js"'
41
+ Then I should see 'href="../stylesheets/site-ed8c2d12.css"'
42
+ And I should see 'src="../javascripts/application-df677242.js"'
43
43
  And I should see 'src="../images/100px-5fd6fb90.jpg"'
44
44
  When I go to "/other/"
45
- Then I should see 'href="../stylesheets/site-d9d84711.css"'
46
- And I should see 'src="../javascripts/application-570e5d45.js"'
45
+ Then I should see 'href="../stylesheets/site-ed8c2d12.css"'
46
+ And I should see 'src="../javascripts/application-df677242.js"'
47
47
  And I should see 'src="../images/100px-5fd6fb90.jpg"'
48
- When I go to "/javascripts/application-570e5d45.js"
48
+ When I go to "/javascripts/application-df677242.js"
49
49
  Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
50
- When I go to "/stylesheets/site-d9d84711.css"
50
+ When I go to "/stylesheets/site-ed8c2d12.css"
51
51
  Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
52
52
 
53
53
  Scenario: Enabling an asset host still produces hashed files and references
54
54
  Given the Server is running at "asset-hash-host-app"
55
55
  When I go to "/"
56
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-0ac82771.css"'
56
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-e5a31a3e.css"'
57
57
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
58
58
  When I go to "/subdir/"
59
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-0ac82771.css"'
59
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-e5a31a3e.css"'
60
60
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
61
61
  When I go to "/other/"
62
- Then I should see 'href="http://middlemanapp.com/stylesheets/site-0ac82771.css"'
62
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-e5a31a3e.css"'
63
63
  And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
64
64
  # Asset helpers don't appear to work from Compass right now
65
- # When I go to "/stylesheets/site-0ac82771.css"
65
+ # When I go to "/stylesheets/site-e5a31a3e.css"
66
66
  # Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"
67
67
 
68
68
  Scenario: The asset hash should change when a SASS or Sprockets partial changes
@@ -73,12 +73,12 @@ Feature: Assets get a file hash appended to their and references to them are upd
73
73
  font-size: 14px
74
74
  """
75
75
  When I go to "/partials/"
76
- Then I should see 'href="../stylesheets/uses_partials-e81dd9b4.css'
76
+ Then I should see 'href="../stylesheets/uses_partials-8b948098.css'
77
77
  And the file "source/stylesheets/_partial.sass" has the contents
78
78
  """
79
79
  body
80
80
  font-size: 18px !important
81
81
  """
82
82
  When I go to "/partials/"
83
- Then I should see 'href="../stylesheets/uses_partials-ba3ef309.css'
83
+ Then I should see 'href="../stylesheets/uses_partials-1f9f0ed2.css'
84
84
 
@@ -1,12 +1,47 @@
1
1
  Feature: CSS and Javascripts which are minify shouldn't be re-minified
2
- Scenario: CSS file
3
-
2
+
4
3
  Scenario: JS files containing ".min" should not be re-compressed
5
- And the Server is running at "already-minified-app"
4
+ Given an empty app
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :minify_javascript
8
+ """
9
+ And a file named "source/javascripts/test.min.js" with:
10
+ """
11
+ var numbers = [ 1,
12
+ 2,
13
+ 3,
14
+ 4,
15
+ 5,
16
+ 6,
17
+ 7,
18
+ 8,
19
+ 9,
20
+ 10 ];
21
+ """
22
+ And the Server is running at "empty_app"
6
23
  When I go to "/javascripts/test.min.js"
7
24
  Then I should see "10" lines
8
25
 
9
26
  Scenario: CSS files containing ".min" should not be re-compressed
10
- And the Server is running at "already-minified-app"
27
+ Given an empty app
28
+ And a file named "config.rb" with:
29
+ """
30
+ activate :minify_css
31
+ """
32
+ And a file named "source/stylesheets/test.min.css" with:
33
+ """
34
+ body { one: 1;
35
+ two: 2;
36
+ three: 3;
37
+ four: 4;
38
+ five: 5;
39
+ six: 6;
40
+ seven: 7;
41
+ eight: 8;
42
+ nine: 9;
43
+ ten: 10; }
44
+ """
45
+ And the Server is running at "empty_app"
11
46
  When I go to "/stylesheets/test.min.css"
12
47
  Then I should see "10" lines
@@ -6,22 +6,13 @@ Feature: Markdown support
6
6
  When I go to "/index.html"
7
7
  Then I should see "<p>Hello World</p>"
8
8
 
9
- Scenario: Redcarpet 2 extensions
9
+ Scenario: Markdown extensions (Maruku)
10
10
  Given the Server is running at "markdown-app"
11
11
  When I go to "/smarty_pants.html"
12
- Then I should see "&ldquo;"
12
+ Then I should see "&#8220;"
13
13
  When I go to "/no_intra_emphasis.html"
14
14
  Then I should not see "<em>"
15
15
  When I go to "/tables.html"
16
16
  Then I should see "<table>"
17
- When I go to "/fenced_code_blocks.html"
18
- Then I should see "<code>"
19
- When I go to "/autolink.html"
20
- Then I should see "<a href"
21
- When I go to "/strikethrough.html"
22
- Then I should see "<del>"
23
17
  When I go to "/space_after_headers.html"
24
- Then I should not see "<h1>"
25
- When I go to "/superscript.html"
26
- Then I should see "<sup>"
27
-
18
+ Then I should not see "<h1>"
@@ -0,0 +1,37 @@
1
+ @nojava
2
+ Feature: Markdown support
3
+ In order to test included Maruku support
4
+
5
+ Scenario: Redcarpet 2 extensions
6
+ Given a fixture app "markdown-app"
7
+ And a file named "config.rb" with:
8
+ """
9
+ set :markdown_engine, :redcarpet
10
+ set :markdown, :no_intra_emphasis => true,
11
+ :tables => true,
12
+ :fenced_code_blocks => true,
13
+ :autolink => true,
14
+ :strikethrough => true,
15
+ :lax_html_blocks => true,
16
+ :space_after_headers => true,
17
+ :superscript => true#, :smartypants => true
18
+
19
+ """
20
+ Given the Server is running at "markdown-app"
21
+ # When I go to "/smarty_pants.html"
22
+ # Then I should see "&#8220;"
23
+ When I go to "/no_intra_emphasis.html"
24
+ Then I should not see "<em>"
25
+ When I go to "/tables.html"
26
+ Then I should see "<table>"
27
+ When I go to "/fenced_code_blocks.html"
28
+ Then I should see "<code>"
29
+ When I go to "/autolink.html"
30
+ Then I should see "<a href"
31
+ When I go to "/strikethrough.html"
32
+ Then I should see "<del>"
33
+ When I go to "/space_after_headers.html"
34
+ Then I should not see "<h1>"
35
+ When I go to "/superscript.html"
36
+ Then I should see "<sup>"
37
+
@@ -1,32 +1,52 @@
1
1
  Feature: Minify CSS
2
2
  In order reduce bytes sent to client and appease YSlow
3
-
4
- Background:
5
- Given current environment is "build"
6
3
 
7
4
  Scenario: Rendering external css with the feature disabled
8
- Given "minify_css" feature is "disabled"
5
+ Given a fixture app "minify-css-app"
6
+ And a file named "config.rb" with:
7
+ """
8
+ """
9
9
  And the Server is running at "minify-css-app"
10
10
  When I go to "/stylesheets/site.css"
11
11
  Then I should see "60" lines
12
12
  And I should see "only screen and (device-width"
13
13
 
14
14
  Scenario: Rendering external css with the feature enabled
15
- Given "minify_css" feature is "enabled"
15
+ Given a fixture app "minify-css-app"
16
+ And a file named "config.rb" with:
17
+ """
18
+ activate :minify_css
19
+ """
16
20
  And the Server is running at "minify-css-app"
17
21
  When I go to "/stylesheets/site.css"
18
22
  Then I should see "1" lines
19
23
  And I should see "only screen and (device-width"
20
24
  When I go to "/more-css/site.css"
21
- Then I should see "1" lines
25
+ Then I should see "1" lines
22
26
 
23
27
  Scenario: Rendering external css with passthrough compressor
24
- Given the Server is running at "passthrough-app"
28
+ Given a fixture app "passthrough-app"
29
+ And a file named "config.rb" with:
30
+ """
31
+ module ::PassThrough
32
+ def self.compress(data)
33
+ data
34
+ end
35
+ end
36
+
37
+ activate :minify_css
38
+
39
+ set :css_compressor, ::PassThrough
40
+ """
41
+ And the Server is running at "passthrough-app"
25
42
  When I go to "/stylesheets/site.css"
26
43
  Then I should see "55" lines
27
44
 
28
45
  Scenario: Rendering inline css with the feature disabled
29
- Given "minify_css" feature is "disabled"
46
+ Given a fixture app "minify-css-app"
47
+ And a file named "config.rb" with:
48
+ """
49
+ """
30
50
  And the Server is running at "minify-css-app"
31
51
  When I go to "/inline-css.html"
32
52
  Then I should see:
@@ -42,7 +62,22 @@ Feature: Minify CSS
42
62
  """
43
63
 
44
64
  Scenario: Rendering inline css with a passthrough minifier
45
- Given the Server is running at "passthrough-app"
65
+ Given a fixture app "passthrough-app"
66
+ And a file named "config.rb" with:
67
+ """
68
+ module ::PassThrough
69
+ def self.compress(data)
70
+ data
71
+ end
72
+ end
73
+
74
+ activate :minify_css, :inline => true
75
+
76
+ set :css_compressor, ::PassThrough
77
+
78
+ page "/inline-css.html", :layout => false
79
+ """
80
+ And the Server is running at "passthrough-app"
46
81
  When I go to "/inline-css.html"
47
82
  Then I should see:
48
83
  """
@@ -53,8 +88,35 @@ Feature: Minify CSS
53
88
  </style>
54
89
  """
55
90
 
91
+ Scenario: Rendering inline css with a passthrough minifier using activate-style compressor
92
+ Given a fixture app "passthrough-app"
93
+ And a file named "config.rb" with:
94
+ """
95
+ module ::HelloCompressor
96
+ def self.compress(data)
97
+ "Hello"
98
+ end
99
+ end
100
+
101
+ activate :minify_css, :inline => true, :compressor => ::HelloCompressor
102
+
103
+ page "/inline-css.html", :layout => false
104
+ """
105
+ And the Server is running at "passthrough-app"
106
+ When I go to "/inline-css.html"
107
+ Then I should see:
108
+ """
109
+ <style type='text/css'>
110
+ Hello
111
+ </style>
112
+ """
113
+
56
114
  Scenario: Rendering inline css with the feature enabled
57
- Given "minify_css" feature is "enabled"
115
+ Given a fixture app "minify-css-app"
116
+ And a file named "config.rb" with:
117
+ """
118
+ activate :minify_css, :inline => true
119
+ """
58
120
  And the Server is running at "minify-css-app"
59
121
  When I go to "/inline-css.html"
60
122
  Then I should see:
@@ -1,11 +1,11 @@
1
1
  Feature: Minify Javascript
2
2
  In order reduce bytes sent to client and appease YSlow
3
3
 
4
- Background:
5
- Given current environment is "build"
6
-
7
4
  Scenario: Rendering inline js with the feature disabled
8
- Given "minify_javascript" feature is "disabled"
5
+ Given a fixture app "minify-js-app"
6
+ And a file named "config.rb" with:
7
+ """
8
+ """
9
9
  And the Server is running at "minify-js-app"
10
10
  When I go to "/inline-js.html"
11
11
  Then I should see:
@@ -42,7 +42,22 @@ Feature: Minify Javascript
42
42
  """
43
43
 
44
44
  Scenario: Rendering inline js with a passthrough minifier
45
- Given the Server is running at "passthrough-app"
45
+ Given a fixture app "passthrough-app"
46
+ And a file named "config.rb" with:
47
+ """
48
+ module ::PassThrough
49
+ def self.compress(data)
50
+ data
51
+ end
52
+ end
53
+
54
+ activate :minify_javascript, :inline => true
55
+
56
+ set :js_compressor, ::PassThrough
57
+
58
+ page "/inline-js.html", :layout => false
59
+ """
60
+ And the Server is running at "passthrough-app"
46
61
  When I go to "/inline-js.html"
47
62
  Then I should see:
48
63
  """
@@ -77,8 +92,48 @@ Feature: Minify Javascript
77
92
  </script>
78
93
  """
79
94
 
95
+ Scenario: Rendering inline css with a passthrough minifier using activate-style compressor
96
+ Given a fixture app "passthrough-app"
97
+ And a file named "config.rb" with:
98
+ """
99
+ module ::HelloCompressor
100
+ def self.compress(data)
101
+ "Hello"
102
+ end
103
+ end
104
+
105
+ activate :minify_javascript, :inline => true, :compressor => ::HelloCompressor
106
+
107
+ page "/inline-js.html", :layout => false
108
+ """
109
+ And the Server is running at "passthrough-app"
110
+ When I go to "/inline-js.html"
111
+ Then I should see:
112
+ """
113
+ <script type='text/javascript'>
114
+ //<![CDATA[
115
+ Hello
116
+ //]]>
117
+ </script>
118
+ <script>
119
+ Hello
120
+ </script>
121
+ <script type='text/javascript'>
122
+ //<!--
123
+ Hello
124
+ //-->
125
+ </script>
126
+ <script type='text/html'>
127
+ I'm a jQuery {{template}}.
128
+ </script>
129
+ """
130
+
80
131
  Scenario: Rendering inline js with the feature enabled
81
- Given "minify_javascript" feature is "enabled"
132
+ Given a fixture app "minify-js-app"
133
+ And a file named "config.rb" with:
134
+ """
135
+ activate :minify_javascript, :inline => true
136
+ """
82
137
  And the Server is running at "minify-js-app"
83
138
  When I go to "/inline-js.html"
84
139
  Then I should see:
@@ -102,7 +157,11 @@ Feature: Minify Javascript
102
157
  """
103
158
 
104
159
  Scenario: Rendering external js with the feature enabled
105
- Given "minify_javascript" feature is "enabled"
160
+ Given a fixture app "minify-js-app"
161
+ And a file named "config.rb" with:
162
+ """
163
+ activate :minify_javascript
164
+ """
106
165
  And the Server is running at "minify-js-app"
107
166
  When I go to "/javascripts/js_test.js"
108
167
  Then I should see "1" lines
@@ -115,23 +174,62 @@ Feature: Minify Javascript
115
174
  Then I should see "8" lines
116
175
 
117
176
  Scenario: Rendering inline js (coffeescript) with the feature enabled
118
- Given "minify_javascript" feature is "enabled"
177
+ Given a fixture app "minify-js-app"
178
+ And a file named "config.rb" with:
179
+ """
180
+ require "coffee-filter"
181
+ activate :minify_javascript, :inline => true
182
+ """
119
183
  And the Server is running at "minify-js-app"
120
184
  When I go to "/inline-coffeescript.html"
121
185
  Then I should see "6" lines
122
186
 
123
187
  Scenario: Rendering external js (coffeescript) with the feature enabled
124
- Given "minify_javascript" feature is "enabled"
188
+ Given a fixture app "minify-js-app"
189
+ And a file named "config.rb" with:
190
+ """
191
+ activate :minify_javascript
192
+ """
125
193
  And the Server is running at "minify-js-app"
126
194
  When I go to "/javascripts/coffee_test.js"
127
195
  Then I should see "1" lines
128
196
 
129
197
  Scenario: Rendering inline js (coffeescript) with a passthrough minifier
130
- Given the Server is running at "passthrough-app"
198
+ Given a fixture app "passthrough-app"
199
+ And a file named "config.rb" with:
200
+ """
201
+ require "coffee-filter"
202
+
203
+ module ::PassThrough
204
+ def self.compress(data)
205
+ data
206
+ end
207
+ end
208
+
209
+ activate :minify_javascript, :inline => true
210
+
211
+ set :js_compressor, ::PassThrough
212
+
213
+ page "/inline-coffeescript.html", :layout => false
214
+ """
215
+ And the Server is running at "passthrough-app"
131
216
  When I go to "/inline-coffeescript.html"
132
217
  Then I should see "16" lines
133
218
 
134
219
  Scenario: Rendering external js (coffeescript) with a passthrough minifier
220
+ Given a fixture app "passthrough-app"
221
+ And a file named "config.rb" with:
222
+ """
223
+ module ::PassThrough
224
+ def self.compress(data)
225
+ data
226
+ end
227
+ end
228
+
229
+ activate :minify_javascript
230
+
231
+ set :js_compressor, ::PassThrough
232
+ """
135
233
  And the Server is running at "passthrough-app"
136
234
  When I go to "/javascripts/coffee_test.js"
137
235
  Then I should see "11" lines