middleman-more 3.0.0 → 3.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.cane +2 -0
  2. data/.cane-exclusions.yml +3 -0
  3. data/features/coffee-script.feature +6 -1
  4. data/features/markdown_redcarpet.feature +23 -1
  5. data/features/minify_css.feature +2 -0
  6. data/features/sass-assets-paths.feature +11 -0
  7. data/features/sass_cache_path.feature +22 -0
  8. data/features/slim.feature +49 -1
  9. data/features/support/env.rb +2 -2
  10. data/fixtures/asset-host-app/config.rb +1 -1
  11. data/fixtures/auto-css-app/config.rb +1 -1
  12. data/fixtures/auto-js-app/config.rb +1 -1
  13. data/fixtures/coffeescript-app/config.rb +1 -1
  14. data/fixtures/content-for-app/config.rb +1 -1
  15. data/fixtures/extensionless-text-files-app/config.rb +1 -1
  16. data/fixtures/lorem-app/config.rb +1 -1
  17. data/fixtures/markdown-app/source/images/blank.gif +0 -0
  18. data/fixtures/minify-css-app/source/stylesheets/report.css +1 -0
  19. data/fixtures/nested-layout-app/config.rb +1 -1
  20. data/fixtures/page-classes-app/config.rb +1 -1
  21. data/fixtures/relative-assets-app/config.rb +1 -1
  22. data/fixtures/sass-assets-path-app/assets/stylesheets/_shared-asset.sass +1 -0
  23. data/fixtures/sass-assets-path-app/assets/stylesheets/_shared-asset.scss +1 -0
  24. data/fixtures/sass-assets-path-app/config.rb +4 -0
  25. data/fixtures/sass-assets-path-app/my-vendor/stylesheets/_partial.sass +2 -0
  26. data/fixtures/sass-assets-path-app/source/stylesheets/plain.css.sass +16 -0
  27. data/fixtures/sass-cache-path-custom-app/config.rb +3 -0
  28. data/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass +4 -0
  29. data/fixtures/sass-cache-path-default-app/config.rb +3 -0
  30. data/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass +4 -0
  31. data/fixtures/traversal-app/config.rb +1 -1
  32. data/fixtures/wildcard-directory-index-app/config.rb +1 -1
  33. data/lib/middleman-more.rb +19 -16
  34. data/lib/middleman-more/core_extensions/assets.rb +5 -5
  35. data/lib/middleman-more/core_extensions/compass.rb +9 -4
  36. data/lib/middleman-more/core_extensions/default_helpers.rb +3 -3
  37. data/lib/middleman-more/core_extensions/i18n.rb +31 -27
  38. data/lib/middleman-more/extensions/asset_hash.rb +8 -7
  39. data/lib/middleman-more/extensions/asset_host.rb +9 -9
  40. data/lib/middleman-more/extensions/automatic_image_sizes.rb +6 -6
  41. data/lib/middleman-more/extensions/automatic_image_sizes/fastimage.rb +6 -6
  42. data/lib/middleman-more/extensions/cache_buster.rb +11 -11
  43. data/lib/middleman-more/extensions/directory_indexes.rb +14 -13
  44. data/lib/middleman-more/extensions/gzip.rb +7 -7
  45. data/lib/middleman-more/extensions/lorem.rb +10 -10
  46. data/lib/middleman-more/extensions/minify_css.rb +5 -5
  47. data/lib/middleman-more/extensions/minify_css/rainpress.rb +2 -2
  48. data/lib/middleman-more/extensions/minify_javascript.rb +7 -7
  49. data/lib/middleman-more/extensions/relative_assets.rb +9 -9
  50. data/lib/middleman-more/templates/smacss.rb +30 -0
  51. data/lib/middleman-more/templates/smacss/source/_footer.haml +1 -0
  52. data/lib/middleman-more/templates/smacss/source/index.html.haml +1 -0
  53. data/lib/middleman-more/templates/smacss/source/layouts/layout.haml +13 -0
  54. data/lib/middleman-more/templates/smacss/source/stylesheets/_0.site-settings.scss +0 -0
  55. data/lib/middleman-more/templates/smacss/source/stylesheets/_1.base.scss +2 -0
  56. data/lib/middleman-more/templates/smacss/source/stylesheets/_2.layout.scss +2 -0
  57. data/lib/middleman-more/templates/smacss/source/stylesheets/_3.states.scss +2 -0
  58. data/lib/middleman-more/templates/smacss/source/stylesheets/_4.themes.scss +2 -0
  59. data/lib/middleman-more/templates/smacss/source/stylesheets/modules/_btn.scss +2 -0
  60. data/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss +7 -0
  61. data/lib/middleman_extension.rb +1 -1
  62. metadata +47 -11
data/.cane ADDED
@@ -0,0 +1,2 @@
1
+ --exclusions-file .cane-exclusions.yml
2
+ --no-doc
@@ -0,0 +1,3 @@
1
+ style:
2
+ - lib/middleman-more/extensions/minify_css/rainpress.rb
3
+ - lib/middleman-more/extensions/automatic_image_sizes/fastimage.rb
@@ -14,4 +14,9 @@ Feature: Support coffee-script
14
14
  Scenario: Rendering broken coffee
15
15
  Given the Server is running at "coffeescript-app"
16
16
  When I go to "/javascripts/broken-coffee.js"
17
- Then I should see "reserved word"
17
+ Then I should see "reserved word"
18
+
19
+ Scenario: Building broken coffee
20
+ Given a built app at "coffeescript-app"
21
+ Then the output should contain "error build/javascripts/broken-coffee.js"
22
+ And the exit status should be 1
@@ -40,4 +40,26 @@ Feature: Markdown support
40
40
  When I go to "/with_toc_data.html"
41
41
  Then I should see "toc_0"
42
42
  When I go to "/hard_wrap.html"
43
- Then I should see "br"
43
+ Then I should see "br"
44
+
45
+ Scenario: Redcarpet uses our link_to and image_tag helpers
46
+ Given a fixture app "markdown-app"
47
+ And a file named "config.rb" with:
48
+ """
49
+ set :markdown_engine, :redcarpet
50
+ activate :automatic_image_sizes
51
+ activate :directory_indexes
52
+ """
53
+ And a file named "source/link_and_image.html.markdown" with:
54
+ """
55
+ [A link](/smarty_pants.html)
56
+
57
+ ![image](blank.gif)
58
+ """
59
+ Given the Server is running at "markdown-app"
60
+ When I go to "/link_and_image/"
61
+ Then I should see "/smarty_pants/"
62
+ Then I should see 'width="1"'
63
+ And I should see 'height="1"'
64
+ And I should see 'src="/images/blank.gif"'
65
+
@@ -23,6 +23,8 @@ Feature: Minify CSS
23
23
  And I should see "only screen and (device-width"
24
24
  When I go to "/more-css/site.css"
25
25
  Then I should see "1" lines
26
+ When I go to "/stylesheets/report.css"
27
+ Then I should see "p{border:1px solid #ff6600}"
26
28
 
27
29
  Scenario: Rendering external css with passthrough compressor
28
30
  Given a fixture app "passthrough-app"
@@ -0,0 +1,11 @@
1
+ Feature: Support SASS assets paths
2
+ In order to import common shared assets when writing Sass
3
+
4
+ Scenario: Importing assets from 'assets/stylesheets/' directory in app root
5
+ Given the Server is running at "sass-assets-path-app"
6
+ When I go to "/stylesheets/plain.css"
7
+ Then I should see "color: green;"
8
+ Then I should see "/* Works with shared SCSS assets from APPROOT/assets/stylesheets/_shared-asset.scss */"
9
+ Then I should see "/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */"
10
+ Then I should see "font-size: 18px"
11
+ Then I should see "/* Works with shared SASS assets from external source directory */"
@@ -0,0 +1,22 @@
1
+ Feature: SASS .sass_cache custom location
2
+
3
+ Scenario: Using the default location for .sass_cache folder
4
+ Given the Server is running at "sass-cache-path-default-app"
5
+
6
+ When I go to "/stylesheets/plain.css"
7
+ Then I should see "color: blue;"
8
+
9
+ # TODO::
10
+ # Not sure how to test this location, as the directory is stored outside of the app root
11
+ # during testing, but inside app root in "production"
12
+
13
+ # Then a directory named ".sass_cache" should exist
14
+
15
+
16
+ Scenario: Using a custom location for .sass_cache folder
17
+ Given the Server is running at "sass-cache-path-custom-app"
18
+
19
+ When I go to "/stylesheets/plain.css"
20
+ Then I should see "html, body, div, span, applet, object, iframe,"
21
+
22
+ Then a directory named "/tmp/middleman-more-custom-sass_cache_path" should exist
@@ -18,4 +18,52 @@ Feature: Support slim templating language
18
18
  """
19
19
  And the Server is running at "empty_app"
20
20
  When I go to "/slim.html"
21
- Then I should see "<h1>Welcome to Slim</h1>"
21
+ Then I should see "<h1>Welcome to Slim</h1>"
22
+
23
+ Scenario: Rendering Scss in a Slim filter
24
+ Given an empty app
25
+ And a file named "config.rb" with:
26
+ """
27
+ """
28
+ And a file named "source/scss.html.slim" with:
29
+ """
30
+ doctype 5
31
+ html lang='en'
32
+ head
33
+ meta charset="utf-8"
34
+ scss:
35
+ @import "compass";
36
+ @include global-reset;
37
+ body
38
+ h1 Welcome to Slim
39
+ """
40
+ And a file named "source/sass.html.slim" with:
41
+ """
42
+ doctype 5
43
+ html lang='en'
44
+ head
45
+ meta charset="utf-8"
46
+ sass:
47
+ @import "compass"
48
+ +global-reset
49
+ body
50
+ h1 Welcome to Slim
51
+ """
52
+ And a file named "source/error.html.slim" with:
53
+ """
54
+ doctype 5
55
+ html lang='en'
56
+ head
57
+ meta charset="utf-8"
58
+ scss:
59
+ +global-reset
60
+ body
61
+ h1 Welcome to Slim
62
+ """
63
+ And the Server is running at "empty_app"
64
+ When I go to "/scss.html"
65
+ Then I should see "html, body, div"
66
+ When I go to "/sass.html"
67
+ Then I should see "html, body, div"
68
+ When I go to "/error.html"
69
+ Then I should see "Syntax error"
@@ -6,5 +6,5 @@ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
6
6
  core_root = File.expand_path("../../../../middleman-core/lib/middleman-core", __FILE__)
7
7
 
8
8
  require core_root
9
- require File.join(core_root, "step_definitions")
10
- require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-more')
9
+ require File.join(core_root, "step_definitions")
10
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-more')
@@ -3,4 +3,4 @@ set :layout, false
3
3
  activate :asset_host
4
4
  set :asset_host do |asset|
5
5
  "http://assets%d.example.com" % (asset.hash % 4)
6
- end
6
+ end
@@ -8,4 +8,4 @@ with_layout false do
8
8
  }.each do |path|
9
9
  page path
10
10
  end
11
- end
11
+ end
@@ -8,4 +8,4 @@ with_layout false do
8
8
  }.each do |path|
9
9
  page path
10
10
  end
11
- end
11
+ end
@@ -1 +1 @@
1
- require "coffee-filter"
1
+ require "coffee-filter"
@@ -4,4 +4,4 @@ with_layout :content_for do
4
4
  page "/content_for_erb.html"
5
5
  page "/content_for_haml.html"
6
6
  page "/content_for_slim.html"
7
- end
7
+ end
@@ -1 +1 @@
1
- activate :directory_indexes
1
+ activate :directory_indexes
@@ -1 +1 @@
1
- # activate :minify_css
1
+ # activate :minify_css
@@ -0,0 +1 @@
1
+ p{border: 1px solid #ff6600;}
@@ -1 +1 @@
1
- set :layout, :inner
1
+ set :layout, :inner
@@ -1,4 +1,4 @@
1
1
  with_layout false do
2
2
  page "/sub1/page-classes.html"
3
3
  page "/sub1/sub2/page-classes.html"
4
- end
4
+ end
@@ -1 +1 @@
1
- # activate :relative_assets
1
+ # activate :relative_assets
@@ -0,0 +1 @@
1
+ /* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */
@@ -0,0 +1 @@
1
+ /* Works with shared SCSS assets from APPROOT/assets/stylesheets/_shared-asset.scss */
@@ -0,0 +1,4 @@
1
+ set :sass_assets_paths, [
2
+ File.join(root, "assets", "stylesheets"),
3
+ File.join(root, "my-vendor", "stylesheets")
4
+ ]
@@ -0,0 +1,2 @@
1
+ body
2
+ font-size: 18px
@@ -0,0 +1,16 @@
1
+
2
+ red
3
+ color: green
4
+
5
+ /* imports below
6
+
7
+ // SCSS with extension
8
+ @import "_shared-asset.scss"
9
+
10
+ // without extension
11
+ @import "shared-asset"
12
+
13
+ // imported from outside of local 'assets/' directory
14
+ @import "_partial.sass"
15
+
16
+ /* Works with shared SASS assets from external source directory */
@@ -0,0 +1,3 @@
1
+
2
+
3
+ set :sass_cache_path, File.join('/tmp', "#{File.basename(Dir.pwd)}-custom-sass_cache_path")
@@ -0,0 +1,4 @@
1
+ @import "compass/reset"
2
+
3
+ red
4
+ color: blue
@@ -0,0 +1,3 @@
1
+
2
+ # Using default setting
3
+ # set :sass_cache_path, File.join(Dir.pwd, '.sass_cache')
@@ -0,0 +1,4 @@
1
+ @import "compass/reset"
2
+
3
+ red
4
+ color: blue
@@ -4,4 +4,4 @@ page "/sub/fake.html", :proxy => "/proxied.html", :ignore => true
4
4
  page "/sub/fake2.html", :proxy => "/proxied.html", :ignore => true
5
5
 
6
6
  page "/directory-indexed/fake.html", :proxy => "/proxied.html", :ignore => true
7
- page "/directory-indexed/fake2.html", :proxy => "/proxied.html", :ignore => true
7
+ page "/directory-indexed/fake2.html", :proxy => "/proxied.html", :ignore => true
@@ -1,2 +1,2 @@
1
1
  activate :directory_indexes
2
- page "/admin/*", :layout => :admin
2
+ page "/admin/*", :layout => :admin
@@ -6,15 +6,18 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
6
6
 
7
7
  module Middleman
8
8
  module More
9
-
9
+
10
10
  # Setup extension
11
11
  class << self
12
12
 
13
13
  # Once registered
14
14
  def registered(app, options={})
15
- ###
15
+ ###
16
16
  # Setup Core Extensions
17
17
  ###
18
+
19
+ require "middleman-core/templates"
20
+ require "middleman-more/templates/smacss"
18
21
 
19
22
  # Setup default helpers
20
23
  require "middleman-more/core_extensions/default_helpers"
@@ -29,62 +32,62 @@ module Middleman
29
32
  app.after_configuration do
30
33
  # This is for making the tests work - since the tests
31
34
  # don't completely reload middleman, I18n.load_path can get
32
- # polluted with paths from other test app directories that don't
35
+ # polluted with paths from other test app directories that don't
33
36
  # exist anymore.
34
37
  ::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}}
35
38
  ::I18n.reload!
36
39
  end
37
-
40
+
38
41
  Middleman::Extensions.register(:i18n) do
39
42
  require "middleman-more/core_extensions/i18n"
40
43
  Middleman::CoreExtensions::Internationalization
41
44
  end
42
-
45
+
43
46
  # Compass framework
44
47
  require "middleman-more/core_extensions/compass"
45
48
  Middleman::Application.register Middleman::CoreExtensions::Compass
46
49
 
47
- ###
50
+ ###
48
51
  # Setup Optional Extensions
49
52
  ###
50
53
 
51
- # CacheBuster adds a query string to assets in dynamic templates to avoid
52
- # browser caches failing to update to your new content.
54
+ # CacheBuster adds a query string to assets in dynamic templates to
55
+ # avoid browser caches failing to update to your new content.
53
56
  Middleman::Extensions.register(:cache_buster) do
54
57
  require "middleman-more/extensions/cache_buster"
55
- Middleman::Extensions::CacheBuster
58
+ Middleman::Extensions::CacheBuster
56
59
  end
57
60
 
58
61
  # MinifyCss compresses CSS
59
62
  Middleman::Extensions.register(:minify_css) do
60
63
  require "middleman-more/extensions/minify_css"
61
- Middleman::Extensions::MinifyCss
64
+ Middleman::Extensions::MinifyCss
62
65
  end
63
66
 
64
67
  # MinifyJavascript compresses JS
65
68
  Middleman::Extensions.register(:minify_javascript) do
66
69
  require "middleman-more/extensions/minify_javascript"
67
- Middleman::Extensions::MinifyJavascript
70
+ Middleman::Extensions::MinifyJavascript
68
71
  end
69
72
 
70
73
  # RelativeAssets allow any asset path in dynamic templates to be either
71
74
  # relative to the root of the project or use an absolute URL.
72
75
  Middleman::Extensions.register(:relative_assets) do
73
76
  require "middleman-more/extensions/relative_assets"
74
- Middleman::Extensions::RelativeAssets
77
+ Middleman::Extensions::RelativeAssets
75
78
  end
76
79
 
77
80
  # GZIP assets and pages during build
78
81
  Middleman::Extensions.register(:gzip) do
79
82
  require "middleman-more/extensions/gzip"
80
- Middleman::Extensions::Gzip
83
+ Middleman::Extensions::Gzip
81
84
  end
82
85
 
83
86
  # AssetHash appends a hash of the file contents to the assets filename
84
87
  # to avoid browser caches failing to update to your new content.
85
88
  Middleman::Extensions.register(:asset_hash) do
86
89
  require "middleman-more/extensions/asset_hash"
87
- Middleman::Extensions::AssetHash
90
+ Middleman::Extensions::AssetHash
88
91
  end
89
92
 
90
93
  # AssetHost allows you to setup multiple domains to host your static
@@ -92,13 +95,13 @@ module Middleman
92
95
  # through each of the asset servers to better spread the load.
93
96
  Middleman::Extensions.register(:asset_host) do
94
97
  require "middleman-more/extensions/asset_host"
95
- Middleman::Extensions::AssetHost
98
+ Middleman::Extensions::AssetHost
96
99
  end
97
100
 
98
101
  # Provide Apache-style index.html files for directories
99
102
  Middleman::Extensions.register(:directory_indexes) do
100
103
  require "middleman-more/extensions/directory_indexes"
101
- Middleman::Extensions::DirectoryIndexes
104
+ Middleman::Extensions::DirectoryIndexes
102
105
  end
103
106
 
104
107
  # Lorem provides a handful of helpful prototyping methods to generate
@@ -1,24 +1,24 @@
1
1
  module Middleman
2
2
  module CoreExtensions
3
-
3
+
4
4
  # Base helper to manipulate asset paths
5
5
  module Assets
6
-
6
+
7
7
  # Extension registered
8
8
  class << self
9
9
  def registered(app)
10
10
  # Disable Padrino cache buster
11
11
  app.set :asset_stamp, false
12
-
12
+
13
13
  # Include helpers
14
14
  app.send :include, InstanceMethod
15
15
  end
16
16
  alias :included :registered
17
17
  end
18
-
18
+
19
19
  # Methods to be mixed-in to Middleman::Application
20
20
  module InstanceMethod
21
-
21
+
22
22
  # Get the URL of an asset given a type/prefix
23
23
  #
24
24
  # @param [String] path The path (such as "photo.jpg")
@@ -17,12 +17,18 @@ module Middleman
17
17
  # done with it
18
18
  app.define_hook :compass_config
19
19
 
20
+ # Location of SASS/SCSS files external to source directory.
21
+ # @return [Array]
22
+ # set :sass_assets_paths, ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
23
+ app.set :sass_assets_paths, []
24
+
20
25
  app.after_configuration do
21
26
  ::Compass.configuration do |config|
22
27
  config.project_path = source_dir
23
28
  config.environment = :development
24
- config.cache_path = File.join(root, ".sass-cache")
29
+ config.cache_path = sass_cache_path
25
30
  config.sass_dir = css_dir
31
+ config.additional_import_paths = sass_assets_paths
26
32
  config.css_dir = css_dir
27
33
  config.javascripts_dir = js_dir
28
34
  config.fonts_dir = fonts_dir
@@ -65,16 +71,15 @@ module Middleman
65
71
 
66
72
  end
67
73
 
68
- # A Compass template for Tilt
74
+ # A Compass Sass template for Tilt, adding our options in
69
75
  class CompassSassTemplate < ::Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
70
- private
71
76
  def sass_options
72
77
  super.merge(::Compass.configuration.to_sass_engine_options)
73
78
  end
74
79
  end
75
80
 
81
+ # A Compass Scss template for Tilt, adding our options in
76
82
  class CompassScssTemplate < ::Middleman::Renderers::Sass::ScssPlusCSSFilenameTemplate
77
- private
78
83
  def sass_options
79
84
  super.merge(::Compass.configuration.to_sass_engine_options)
80
85
  end