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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/Rakefile +1 -0
  2. data/features/asset_hash.feature +84 -0
  3. data/features/cache_buster.feature +5 -4
  4. data/features/coffee-script.feature +2 -2
  5. data/features/compass-sprites.feature +6 -0
  6. data/features/gzip.feature +21 -0
  7. data/features/{ignore_already_minified.features → ignore_already_minified.feature} +0 -0
  8. data/features/minify_css.feature +50 -2
  9. data/features/minify_javascript.feature +89 -6
  10. data/features/relative_assets.feature +47 -6
  11. data/features/sass_partials.feature +5 -1
  12. data/features/sprockets_gems.feature +7 -2
  13. data/fixtures/asset-hash-app/config.rb +8 -0
  14. data/fixtures/asset-hash-app/source/images/100px.gif +0 -0
  15. data/fixtures/asset-hash-app/source/images/100px.jpg +0 -0
  16. data/fixtures/asset-hash-app/source/images/100px.png +0 -0
  17. data/fixtures/asset-hash-app/source/index.html.erb +308 -0
  18. data/fixtures/asset-hash-app/source/javascripts/application.js +8 -0
  19. data/fixtures/asset-hash-app/source/layout.erb +18 -0
  20. data/fixtures/asset-hash-app/source/other.html.erb +2 -0
  21. data/fixtures/asset-hash-app/source/partials.html.erb +1 -0
  22. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +2 -0
  23. data/fixtures/asset-hash-app/source/stylesheets/site.css.scss +4 -0
  24. data/fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass +4 -0
  25. data/fixtures/asset-hash-app/source/subdir/index.html.erb +308 -0
  26. data/fixtures/asset-hash-host-app/config.rb +6 -0
  27. data/fixtures/asset-hash-host-app/source/images/100px.gif +0 -0
  28. data/fixtures/asset-hash-host-app/source/images/100px.jpg +0 -0
  29. data/fixtures/asset-hash-host-app/source/images/100px.png +0 -0
  30. data/fixtures/asset-hash-host-app/source/index.html.erb +6 -0
  31. data/fixtures/asset-hash-host-app/source/layout.erb +17 -0
  32. data/fixtures/asset-hash-host-app/source/other.html.erb +2 -0
  33. data/fixtures/asset-hash-host-app/source/stylesheets/site.css.scss +4 -0
  34. data/fixtures/asset-hash-host-app/source/subdir/index.html.erb +6 -0
  35. data/fixtures/cache-buster-app/source/cache-buster.html.erb +2 -1
  36. data/fixtures/compass-sprites-app/config.rb +0 -0
  37. data/fixtures/compass-sprites-app/source/images/icon/arrow_down.png +0 -0
  38. data/fixtures/compass-sprites-app/source/images/icon/arrow_left.png +0 -0
  39. data/fixtures/compass-sprites-app/source/images/icon/arrow_right.png +0 -0
  40. data/fixtures/compass-sprites-app/source/images/icon/arrow_up.png +0 -0
  41. data/fixtures/compass-sprites-app/source/stylesheets/site.css.scss +3 -0
  42. data/fixtures/gzip-app/config.rb +1 -0
  43. data/fixtures/gzip-app/source/index.html +0 -0
  44. data/fixtures/gzip-app/source/javascripts/test.js +1 -0
  45. data/fixtures/gzip-app/source/stylesheets/test.css +1 -0
  46. data/fixtures/minify-css-app/source/inline-css.html.haml +5 -0
  47. data/fixtures/minify-css-app/source/more-css/site.css +3 -0
  48. data/fixtures/minify-css-app/source/stylesheets/site.css.sass +5 -1
  49. data/fixtures/minify-js-app/config.rb +1 -1
  50. data/fixtures/minify-js-app/source/inline-js.html.haml +22 -1
  51. data/fixtures/minify-js-app/source/more-js/other.js +8 -0
  52. data/fixtures/passthrough-app/config.rb +4 -4
  53. data/fixtures/passthrough-app/source/inline-css.html.haml +5 -4
  54. data/fixtures/passthrough-app/source/inline-js.html.haml +22 -1
  55. data/fixtures/relative-assets-app/config.rb +1 -0
  56. data/fixtures/relative-assets-app/source/relative_image.html.erb +8 -1
  57. data/fixtures/sprockets-app/source/library/js/vendored_include.js +1 -0
  58. data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +1 -0
  59. data/lib/middleman-more.rb +23 -9
  60. data/lib/middleman-more/core_extensions/compass.rb +22 -38
  61. data/lib/middleman-more/core_extensions/sprockets.rb +41 -123
  62. data/lib/middleman-more/extensions/asset_hash.rb +132 -0
  63. data/lib/middleman-more/extensions/cache_buster.rb +5 -6
  64. data/lib/middleman-more/extensions/gzip.rb +57 -0
  65. data/lib/middleman-more/extensions/minify_css.rb +73 -7
  66. data/lib/middleman-more/extensions/minify_css/rainpress.rb +168 -0
  67. data/lib/middleman-more/extensions/minify_javascript.rb +45 -21
  68. data/lib/middleman-more/extensions/relative_assets.rb +2 -1
  69. data/lib/middleman-more/renderers/haml.rb +4 -0
  70. data/lib/middleman-more/renderers/liquid.rb +6 -1
  71. data/lib/middleman-more/renderers/markdown.rb +10 -1
  72. data/lib/middleman-more/renderers/sass.rb +12 -6
  73. data/lib/middleman-more/renderers/slim.rb +5 -0
  74. data/middleman-more.gemspec +9 -9
  75. metadata +192 -178
  76. data/lib/middleman-more/extensions/minify_css/cssmin.rb +0 -55
@@ -1,55 +0,0 @@
1
- #--
2
- # Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- #
8
- # * Redistributions of source code must retain the above copyright notice,
9
- # this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above copyright notice,
11
- # this list of conditions and the following disclaimer in the documentation
12
- # and/or other materials provided with the distribution.
13
- # * Neither the name of this project nor the names of its contributors may be
14
- # used to endorse or promote products derived from this software without
15
- # specific prior written permission.
16
- #
17
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- #++
28
-
29
- module CSSMin
30
- def self.compress(input)
31
- css = input.is_a?(IO) ? input.read : input.dup.to_s
32
- css.gsub!(/\/\*[\s\S]*?\*\//, '')
33
- css.gsub!(/\s+/, ' ')
34
- css.gsub!(/"\\"\}\\""/, '___BMH___')
35
- css.gsub!(/(?:^|\})[^\{:]+\s+:+[^\{]*\{/) do |match|
36
- match.gsub(':', '___PSEUDOCLASSCOLON___')
37
- end
38
- css.gsub!(/\s+([!\{\};:>+\(\)\],])/, '\1')
39
- css.gsub!('___PSEUDOCLASSCOLON___', ':')
40
- css.gsub!(/([!\{\}:;>+\(\[,])\s+/, '\1')
41
- css.gsub!(/([^;\}])\}/, '\1;}')
42
- css.gsub!(/([\s:])([+-]?0)(?:%|em|ex|px|in|cm|mm|pt|pc)/i, '\1\2')
43
- css.gsub!(/:(?:0 )+0;/, ':0;')
44
- css.gsub!('background-position:0;', 'background-position:0 0;')
45
- css.gsub!(/(:|\s)0+\.(\d+)/, '\1.\2')
46
- css.gsub!(/rgb\s*\(\s*([0-9,\s]+)\s*\)/) do |match|
47
- '#' << $1.scan(/\d+/).map{|n| n.to_i.to_s(16).rjust(2, '0') }.join
48
- end
49
- css.gsub!(/([^"'=\s])\s*#([0-9a-f])\2([0-9a-f])\3([0-9a-f])\4/i, '\1 #\2\3\4')
50
- css.gsub!(/[^\}]+\{;\}\n/, '')
51
- css.gsub!('___BMH___', '"\"}\""')
52
- css.gsub!(/;;+/, ';')
53
- css.strip
54
- end
55
- end