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
@@ -0,0 +1,22 @@
1
+ module Middleman
2
+ module Renderers
3
+
4
+ # CoffeeScript Renderer
5
+ module CoffeeScript
6
+
7
+ # Setup extension
8
+ class << self
9
+ # Once registered
10
+ def registered(app)
11
+ # Require gem
12
+ require "coffee_script"
13
+
14
+ app.before_configuration do
15
+ template_extensions :coffee => :js
16
+ end
17
+ end
18
+ alias :included :registered
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,25 +1,30 @@
1
- # Require gem
2
- require "haml"
3
-
4
- # Haml Renderer
5
- module Middleman::Renderers::Haml
6
-
7
- # Setup extension
8
- class << self
9
- # Once registered
10
- def registered(app)
11
- # Add haml helpers to context
12
- app.send :include, ::Haml::Helpers
1
+ module Middleman
2
+ module Renderers
3
+
4
+ # Haml Renderer
5
+ module Haml
13
6
 
14
- app.before_configuration do
15
- template_extensions :haml => :html
16
- end
7
+ # Setup extension
8
+ class << self
9
+ # Once registered
10
+ def registered(app)
11
+ # Require gem
12
+ require "haml"
13
+
14
+ app.before_configuration do
15
+ template_extensions :haml => :html
16
+ end
17
+
18
+ # Add haml helpers to context
19
+ app.send :include, ::Haml::Helpers
17
20
 
18
- # Setup haml helper paths
19
- app.ready do
20
- init_haml_helpers
21
+ # Setup haml helper paths
22
+ app.ready do
23
+ init_haml_helpers
24
+ end
25
+ end
26
+ alias :included :registered
21
27
  end
22
28
  end
23
- alias :included :registered
24
29
  end
25
30
  end
@@ -1,35 +1,40 @@
1
- # Liquid Renderer
2
- module Middleman::Renderers::Liquid
1
+ module Middleman
2
+ module Renderers
3
+
4
+ # Liquid Renderer
5
+ module Liquid
3
6
 
4
- # Setup extension
5
- class << self
7
+ # Setup extension
8
+ class << self
6
9
 
7
- # Once registerd
8
- def registered(app)
9
- # Liquid is not included in the default gems,
10
- # but we'll support it if available.
11
- begin
10
+ # Once registerd
11
+ def registered(app)
12
+ # Liquid is not included in the default gems,
13
+ # but we'll support it if available.
14
+ begin
15
+ # Require Gem
16
+ require "liquid"
12
17
 
13
- # Require Gem
14
- require "liquid"
18
+ app.before_configuration do
19
+ template_extensions :liquid => :html
20
+ end
15
21
 
16
- app.before_configuration do
17
- template_extensions :liquid => :html
18
- end
19
-
20
- # After config, setup liquid partial paths
21
- app.after_configuration do
22
- Liquid::Template.file_system = Liquid::LocalFileSystem.new(source_dir)
22
+ # After config, setup liquid partial paths
23
+ app.after_configuration do
24
+ ::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(source_dir)
23
25
 
24
- # Convert data object into a hash for liquid
25
- sitemap.provides_metadata %r{\.liquid$} do |path|
26
- { :locals => { :data => data.to_h } }
26
+ # Convert data object into a hash for liquid
27
+ sitemap.provides_metadata %r{\.liquid$} do |path|
28
+ { :locals => { :data => data.to_h } }
29
+ end
30
+ end
31
+ rescue LoadError
27
32
  end
28
33
  end
29
- rescue LoadError
34
+
35
+ alias :included :registered
30
36
  end
31
37
  end
32
38
 
33
- alias :included :registered
34
39
  end
35
40
  end
@@ -1,50 +1,58 @@
1
- # Markdown renderer
2
- module Middleman::Renderers::Markdown
3
-
4
- # Setup extension
5
- class << self
1
+ module Middleman
2
+ module Renderers
6
3
 
7
- # Once registered
8
- def registered(app)
9
- # Require redcarpet gem
10
- require "redcarpet"
11
-
12
- # Forcably disable Redcarpet1 support.
13
- # Tilt defaults to this if available, but the compat
14
- # layer disables extensions.
15
- Object.send(:remove_const, :RedcarpetCompat) if defined? ::RedcarpetCompat
16
-
17
- # Set our preference for a markdown engine
18
- app.set :markdown_engine, :redcarpet
19
- app.set :markdown_engine_prefix, ::Tilt
4
+ # Markdown renderer
5
+ module Markdown
6
+
7
+ # Setup extension
8
+ class << self
9
+
10
+ # Once registered
11
+ def registered(app)
12
+ # Set our preference for a markdown engine
13
+ # TODO: Find a JRuby-compatible version
14
+ app.set :markdown_engine, :maruku
15
+ app.set :markdown_engine_prefix, ::Tilt
20
16
 
21
- app.before_configuration do
22
- template_extensions :markdown => :html,
23
- :mdown => :html,
24
- :md => :html,
25
- :mkd => :html,
26
- :mkdn => :html
27
- end
17
+ app.before_configuration do
18
+ template_extensions :markdown => :html,
19
+ :mdown => :html,
20
+ :md => :html,
21
+ :mkd => :html,
22
+ :mkdn => :html
23
+ end
28
24
 
29
- # Once configuration is parsed
30
- app.after_configuration do
31
-
32
- # Look for the user's preferred engine
33
- unless markdown_engine.nil?
34
-
35
- # Map symbols to classes
36
- if markdown_engine.is_a? Symbol
37
- engine = markdown_engine.to_s
38
- engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
39
- markdown_engine = markdown_engine_prefix.const_get("#{engine}Template")
25
+ # Once configuration is parsed
26
+ app.after_configuration do
27
+
28
+ # Look for the user's preferred engine
29
+ unless markdown_engine.nil?
30
+
31
+ # Map symbols to classes
32
+ markdown_engine_klass = if markdown_engine.is_a? Symbol
33
+ engine = markdown_engine.to_s
34
+ engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
35
+ markdown_engine_prefix.const_get("#{engine}Template")
36
+ else
37
+ markdown_engine_prefix
38
+ end
39
+
40
+ if markdown_engine == :redcarpet
41
+ # Forcably disable Redcarpet1 support.
42
+ # Tilt defaults to this if available, but the compat
43
+ # layer disables extensions.
44
+ require "redcarpet"
45
+ Object.send(:remove_const, :RedcarpetCompat) if defined? ::RedcarpetCompat
46
+ end
47
+
48
+ # Tell tilt to use that engine
49
+ ::Tilt.prefer(markdown_engine_klass)
50
+ end
40
51
  end
41
-
42
- # Tell tilt to use that engine
43
- ::Tilt.prefer(markdown_engine)
44
52
  end
53
+
54
+ alias :included :registered
45
55
  end
46
56
  end
47
-
48
- alias :included :registered
49
57
  end
50
- end
58
+ end
@@ -1,81 +1,88 @@
1
1
  # Pull in gems
2
2
  require "sprockets"
3
3
  require "sprockets-sass"
4
- require "sass"
5
4
 
6
- # Stick with Compass' asset functions
7
- Sprockets::Sass.add_sass_functions = false
8
-
9
- # Sass renderer
10
- module Middleman::Renderers::Sass
5
+ module Middleman
6
+ module Renderers
7
+
8
+ # Sass renderer
9
+ module Sass
11
10
 
12
- # Setup extension
13
- class << self
11
+ # Setup extension
12
+ class << self
14
13
 
15
- # Once registered
16
- def registered(app)
17
- # Default sass options
18
- app.set :sass, {}
14
+ # Once registered
15
+ def registered(app)
16
+ require "sass"
17
+
18
+ # Stick with Compass' asset functions
19
+ ::Sprockets::Sass.add_sass_functions = false
20
+
21
+ # Default sass options
22
+ app.set :sass, {}
19
23
 
20
- app.before_configuration do
21
- template_extensions :scss => :css,
22
- :sass => :css
23
- end
24
- end
24
+ app.before_configuration do
25
+ template_extensions :scss => :css,
26
+ :sass => :css
27
+ end
28
+
29
+ # Tell Sprockets to use our custom Sass template
30
+ ::Sprockets.register_engine ".sass", SassPlusCSSFilenameTemplate
31
+
32
+ # Tell Tilt to use it as well (for inline sass blocks)
33
+ ::Tilt.register 'sass', SassPlusCSSFilenameTemplate
34
+ ::Tilt.prefer(SassPlusCSSFilenameTemplate)
35
+
36
+ # Tell Sprockets to use our custom Scss template
37
+ ::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
38
+
39
+ # Tell Tilt to use it as well (for inline scss blocks)
40
+ ::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
41
+ ::Tilt.prefer(ScssPlusCSSFilenameTemplate)
42
+ end
25
43
 
26
- alias :included :registered
27
- end
44
+ alias :included :registered
45
+ end
28
46
 
29
- # A SassTemplate for Sprockets/Tilt which outputs debug messages
30
- class SassPlusCSSFilenameTemplate < ::Sprockets::Sass::SassTemplate
47
+ # A SassTemplate for Sprockets/Tilt which outputs debug messages
48
+ class SassPlusCSSFilenameTemplate < ::Sprockets::Sass::SassTemplate
31
49
 
32
- # Add exception messaging
33
- # @param [Class] context
34
- # @param [Hash] locals
35
- # @return [String]
36
- def evaluate(context, locals, &block)
37
- begin
38
- super
39
- rescue Sass::SyntaxError => e
40
- Sass::SyntaxError.exception_to_css(e, :full_exception => true)
41
- end
42
- end
50
+ # Add exception messaging
51
+ # @param [Class] context
52
+ # @param [Hash] locals
53
+ # @return [String]
54
+ def evaluate(context, locals, &block)
55
+ begin
56
+ super
57
+ rescue Sass::SyntaxError => e
58
+ Sass::SyntaxError.exception_to_css(e, :full_exception => true)
59
+ end
60
+ end
43
61
 
44
- protected
45
- # Change Sass path, for url functions, to the build folder if we're building
46
- # @return [Hash]
47
- def sass_options
48
- location_of_sass_file = File.expand_path(@context.source, @context.root)
62
+ protected
63
+ # Change Sass path, for url functions, to the build folder if we're building
64
+ # @return [Hash]
65
+ def sass_options
66
+ location_of_sass_file = File.expand_path(@context.source, @context.root)
49
67
 
50
- parts = basename.split('.')
51
- parts.pop
52
- css_filename = File.join(location_of_sass_file, @context.css_dir, parts.join("."))
68
+ parts = basename.split('.')
69
+ parts.pop
70
+ css_filename = File.join(location_of_sass_file, @context.css_dir, parts.join("."))
53
71
 
54
- super.merge(:css_filename => css_filename)
55
- end
56
- end
57
-
58
- # Tell Sprockets to use our custom Sass template
59
- ::Sprockets.register_engine ".sass", SassPlusCSSFilenameTemplate
60
-
61
- # Tell Tilt to use it as well (for inline sass blocks)
62
- ::Tilt.register 'sass', SassPlusCSSFilenameTemplate
63
- ::Tilt.prefer(SassPlusCSSFilenameTemplate)
72
+ super.merge(:css_filename => css_filename)
73
+ end
74
+ end
64
75
 
65
- # SCSS version of the above template
66
- class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate
76
+ # SCSS version of the above template
77
+ class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate
67
78
 
68
- # Define the expected syntax for the template
69
- # @return [Symbol]
70
- def syntax
71
- :scss
79
+ # Define the expected syntax for the template
80
+ # @return [Symbol]
81
+ def syntax
82
+ :scss
83
+ end
84
+ end
85
+
72
86
  end
73
87
  end
74
-
75
- # Tell Sprockets to use our custom Scss template
76
- ::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
77
-
78
- # Tell Tilt to use it as well (for inline scss blocks)
79
- ::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
80
- ::Tilt.prefer(ScssPlusCSSFilenameTemplate)
81
88
  end
@@ -1,27 +1,35 @@
1
- # Slim renderer
2
- module Middleman::Renderers::Slim
1
+ module Middleman
2
+ module Renderers
3
+
4
+ # Slim renderer
5
+ module Slim
3
6
 
4
- # Setup extension
5
- class << self
7
+ # Setup extension
8
+ class << self
6
9
 
7
- # Once registered
8
- def registered(app)
9
- # Slim is not included in the default gems,
10
- # but we'll support it if available.
11
- begin
12
- # Load gem
13
- require "slim"
10
+ # Once registered
11
+ def registered(app)
12
+ # Slim is not included in the default gems,
13
+ # but we'll support it if available.
14
+ begin
15
+ # Load gem
16
+ require "slim"
14
17
 
15
- app.before_configuration do
16
- template_extensions :slim => :html
17
- end
18
+ app.before_configuration do
19
+ template_extensions :slim => :html
20
+ end
18
21
 
19
- # Setup Slim options to work with partials
20
- Slim::Engine.set_default_options(:buffer => '@_out_buf', :generator => Temple::Generators::StringBuffer) if defined?(Slim)
21
- rescue LoadError
22
+ # Setup Slim options to work with partials
23
+ ::Slim::Engine.set_default_options(
24
+ :buffer => '@_out_buf',
25
+ :generator => ::Temple::Generators::StringBuffer
26
+ )
27
+ rescue LoadError
28
+ end
29
+ end
30
+
31
+ alias :included :registered
22
32
  end
23
33
  end
24
-
25
- alias :included :registered
26
34
  end
27
35
  end
@@ -13,20 +13,19 @@ Gem::Specification.new do |s|
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
 
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {fixtures,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.files = `git ls-files -z`.split("\0")
17
+ s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
19
18
  s.require_paths = ["lib"]
20
19
 
21
20
  s.add_dependency("middleman-core", Middleman::VERSION)
22
21
  s.add_dependency("uglifier", ["~> 1.2.0"])
23
- s.add_dependency("haml", ["~> 3.1.0"])
22
+ s.add_dependency("haml", [">= 3.1.0"])
24
23
  s.add_dependency("sass", [">= 3.1.7"])
25
- s.add_dependency("compass", ["~> 0.12.1"])
24
+ s.add_dependency("compass", [">= 0.12.1"])
26
25
  s.add_dependency("coffee-script", ["~> 2.2.0"])
27
- s.add_dependency("execjs", ["~> 1.2"])
26
+ s.add_dependency("execjs", ["~> 1.3.2"])
28
27
  s.add_dependency("sprockets", ["~> 2.1"])
29
28
  s.add_dependency("sprockets-sass", ["~> 0.8.0"])
30
- s.add_dependency("redcarpet", ["~> 2.1.0"])
29
+ s.add_dependency("maruku", ["~> 0.6.0"])
31
30
  end
32
31