middleman-core 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,9 +50,10 @@ Feature: Middleman CLI
50
50
  Then a directory named "source" should exist
51
51
  When I cd to "source"
52
52
  Then the following files should exist:
53
- | index.html |
53
+ | index.html.erb |
54
+ | layouts/layout.erb |
54
55
  | humans.txt |
55
- | js/main.js |
56
+ | js/main.js |
56
57
 
57
58
  Scenario: Create a new HTML5 project with Rack
58
59
  When I run `middleman init MY_PROJECT --rack --template=html5`
@@ -69,4 +69,15 @@ Feature: YAML Front Matter
69
69
  <%= data.page.title %>
70
70
  """
71
71
  When I go to "/front-matter-change.html"
72
- Then I should see "Hola Mundo"
72
+ Then I should see "Hola Mundo"
73
+
74
+ Scenario: A template should handle an empty YAML feed
75
+ Given the Server is running at "frontmatter-app"
76
+ And the file "source/front-matter-change.html.erb" has the contents
77
+ """
78
+ ---
79
+ ---
80
+ Hello World
81
+ """
82
+ When I go to "/front-matter-change.html"
83
+ Then I should see "Hello World"
@@ -31,7 +31,7 @@ module Middleman::CoreExtensions
31
31
  )
32
32
 
33
33
  sitemap.provides_metadata do |path|
34
- fmdata = frontmatter_manager.data(path).first
34
+ fmdata = frontmatter_manager.data(path).first || {}
35
35
 
36
36
  data = {}
37
37
  %w(layout layout_engine).each do |opt|
@@ -158,7 +158,7 @@ module Middleman::CoreExtensions
158
158
  # @return [void]
159
159
  def manipulate_resource_list(resources)
160
160
  resources.each do |r|
161
- if !r.proxy? && r.data["ignored"] == true
161
+ if !r.proxy? && !r.data.nil? && r.data["ignored"] == true
162
162
  r.frontmatter_ignored = true
163
163
  end
164
164
  end
@@ -68,6 +68,13 @@ module Middleman
68
68
  app.register Middleman::Renderers::Less
69
69
  rescue LoadError
70
70
  end
71
+
72
+ # Stylus Support
73
+ begin
74
+ require "middleman-core/renderers/stylus"
75
+ app.register Middleman::Renderers::Stylus
76
+ rescue LoadError
77
+ end
71
78
  end
72
79
 
73
80
  alias :included :registered
@@ -6,17 +6,18 @@ module Middleman
6
6
  DEFAULT_PORT = 4567
7
7
 
8
8
  class << self
9
- attr_reader :app, :port
9
+ attr_reader :app, :host, :port
10
10
  delegate :logger, :to => :app
11
11
 
12
12
  # Start an instance of Middleman::Application
13
13
  # @return [void]
14
14
  def start(opts={})
15
15
  @options = opts
16
+ @host = @options[:host] || Socket.gethostname
16
17
  @port = @options[:port] || DEFAULT_PORT
17
18
 
18
19
  mount_instance
19
- logger.info "== The Middleman is standing watch on port #{port}"
20
+ logger.info "== The Middleman is standing watch at http://#{host}:#{port}"
20
21
 
21
22
  @initialized ||= false
22
23
  unless @initialized
@@ -52,11 +53,11 @@ module Middleman
52
53
  # @return [void]
53
54
  def reload
54
55
  logger.info "== The Middleman is reloading"
55
-
56
+
56
57
  unmount_instance
57
58
  mount_instance
58
-
59
- logger.info "== The Middleman is standing watch on port #{port}"
59
+
60
+ logger.info "== The Middleman is standing watch at http://#{host}:#{port}"
60
61
  end
61
62
 
62
63
  # Stop the current instance, exit Webrick
@@ -73,22 +74,22 @@ module Middleman
73
74
  if opts[:environment]
74
75
  set :environment, opts[:environment].to_sym
75
76
  end
76
-
77
+
77
78
  logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
78
79
  end
79
80
  end
80
81
 
81
82
  def start_file_watcher
82
83
  return if @options[:"disable-watcher"]
83
-
84
+
84
85
  first_run = !@listener
85
-
86
+
86
87
  if first_run
87
88
  # Watcher Library
88
89
  require "listen"
89
90
  @listener = Listen.to(Dir.pwd, :relative_paths => true)
90
91
  end
91
-
92
+
92
93
  @listener.change do |modified, added, removed|
93
94
  added_and_modified = (modified + added)
94
95
 
@@ -125,11 +126,9 @@ module Middleman
125
126
 
126
127
  # Initialize webrick
127
128
  # @return [void]
128
- def setup_webrick(host, is_logging)
129
- @host = host
130
-
129
+ def setup_webrick(is_logging)
131
130
  http_opts = {
132
- :BindAddress => @host,
131
+ :BindAddress => host,
133
132
  :Port => port,
134
133
  :AccessLog => []
135
134
  }
@@ -154,13 +153,10 @@ module Middleman
154
153
  def mount_instance
155
154
  @app = new_app
156
155
 
157
- @webrick ||= setup_webrick(
158
- @options[:host] || "0.0.0.0",
159
- @options[:debug] || false
160
- )
161
-
156
+ @webrick ||= setup_webrick(@options[:debug] || false)
157
+
162
158
  start_file_watcher
163
-
159
+
164
160
  @webrick.mount "/", ::Rack::Handler::WEBrick, app.class.to_rack_app
165
161
  end
166
162
 
@@ -180,13 +176,13 @@ module Middleman
180
176
  %r{^lib/^[^\.](.*)\.rb$},
181
177
  %r{^helpers/^[^\.](.*)_helper\.rb$}
182
178
  ]
183
-
179
+
184
180
  if @options[:reload_paths]
185
181
  @options[:reload_paths].split(',').each do |part|
186
182
  match_against << %r{^#{part}}
187
183
  end
188
184
  end
189
-
185
+
190
186
  paths.any? do |path|
191
187
  match_against.any? do |matcher|
192
188
  path.match(matcher)
@@ -5,6 +5,14 @@ module Middleman
5
5
 
6
6
  class RedcarpetTemplate < ::Tilt::RedcarpetTemplate::Redcarpet2
7
7
 
8
+ def initialize(*args, &block)
9
+ super
10
+
11
+ if @options.has_key?(:context)
12
+ @context = @options[:context]
13
+ end
14
+ end
15
+
8
16
  # Overwrite built-in Tilt version.
9
17
  # Don't overload :renderer option with smartypants
10
18
  # Support renderer-level options
@@ -32,9 +40,11 @@ module Middleman
32
40
  renderer.new(render_options)
33
41
  end
34
42
 
35
- def evaluate(scope, locals, &block)
43
+ def evaluate(context, locals, &block)
44
+ @context ||= context
45
+
36
46
  if @engine.renderer.respond_to? :middleman_app=
37
- @engine.renderer.middleman_app = scope
47
+ @engine.renderer.middleman_app = @context
38
48
  end
39
49
  super
40
50
  end
@@ -23,11 +23,12 @@ module Middleman
23
23
  )
24
24
 
25
25
  app.after_configuration do
26
- sass_context_hack = {
26
+ context_hack = {
27
27
  :context => self
28
28
  }
29
- ::Slim::EmbeddedEngine.default_options[:sass] = sass_context_hack
30
- ::Slim::EmbeddedEngine.default_options[:scss] = sass_context_hack
29
+ %w(sass scss markdown).each do |engine|
30
+ ::Slim::EmbeddedEngine.default_options[engine.to_sym] = context_hack
31
+ end
31
32
  end
32
33
  end
33
34
 
@@ -0,0 +1,28 @@
1
+ require "stylus"
2
+ require "stylus/tilt"
3
+
4
+ module Middleman
5
+ module Renderers
6
+
7
+ # Sass renderer
8
+ module Stylus
9
+
10
+ # Setup extension
11
+ class << self
12
+
13
+ # Once registered
14
+ def registered(app)
15
+ # Default less options
16
+ app.set :styl, {}
17
+
18
+ app.before_configuration do
19
+ template_extensions :styl => :css
20
+ end
21
+ end
22
+
23
+ alias :included :registered
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: HTML5 Boilerplate Middleman
3
+ ---
4
+
5
+ <!-- Add your site or application content here -->
6
+ <p>Hello world! This is HTML5 Boilerplate.</p>
@@ -6,7 +6,8 @@
6
6
  <head>
7
7
  <meta charset="utf-8">
8
8
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9
- <title></title>
9
+ <!-- Use title if it's in the page YAML frontmatter -->
10
+ <title><%= data.page.title || "HTML5 Boilerplate" %></title>
10
11
  <meta name="description" content="">
11
12
  <meta name="viewport" content="width=device-width">
12
13
 
@@ -21,8 +22,7 @@
21
22
  <p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
22
23
  <![endif]-->
23
24
 
24
- <!-- Add your site or application content here -->
25
- <p>Hello world! This is HTML5 Boilerplate.</p>
25
+ <%= yield %>
26
26
 
27
27
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
28
28
  <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.0.6' unless const_defined?(:VERSION)
4
+ VERSION = '3.0.7' unless const_defined?(:VERSION)
5
5
  end
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: 3.0.6
4
+ version: 3.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-23 00:00:00.000000000 Z
13
+ date: 2012-12-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -439,6 +439,7 @@ files:
439
439
  - lib/middleman-core/renderers/redcarpet.rb
440
440
  - lib/middleman-core/renderers/sass.rb
441
441
  - lib/middleman-core/renderers/slim.rb
442
+ - lib/middleman-core/renderers/stylus.rb
442
443
  - lib/middleman-core/sitemap.rb
443
444
  - lib/middleman-core/sitemap/extensions/ignores.rb
444
445
  - lib/middleman-core/sitemap/extensions/on_disk.rb
@@ -483,11 +484,12 @@ files:
483
484
  - lib/middleman-core/templates/html5/source/favicon.ico
484
485
  - lib/middleman-core/templates/html5/source/humans.txt
485
486
  - lib/middleman-core/templates/html5/source/img/.gitignore
486
- - lib/middleman-core/templates/html5/source/index.html
487
+ - lib/middleman-core/templates/html5/source/index.html.erb
487
488
  - lib/middleman-core/templates/html5/source/js/main.js
488
489
  - lib/middleman-core/templates/html5/source/js/plugins.js
489
490
  - lib/middleman-core/templates/html5/source/js/vendor/jquery-1.8.0.min.js
490
491
  - lib/middleman-core/templates/html5/source/js/vendor/modernizr-2.6.1.min.js
492
+ - lib/middleman-core/templates/html5/source/layouts/layout.erb
491
493
  - lib/middleman-core/templates/html5/source/robots.txt
492
494
  - lib/middleman-core/templates/local.rb
493
495
  - lib/middleman-core/templates/mobile.rb
@@ -595,7 +597,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
595
597
  version: '0'
596
598
  segments:
597
599
  - 0
598
- hash: -3834291849307720462
600
+ hash: 1408914751343926382
599
601
  required_rubygems_version: !ruby/object:Gem::Requirement
600
602
  none: false
601
603
  requirements:
@@ -604,10 +606,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
604
606
  version: '0'
605
607
  segments:
606
608
  - 0
607
- hash: -3834291849307720462
609
+ hash: 1408914751343926382
608
610
  requirements: []
609
611
  rubyforge_project:
610
- rubygems_version: 1.8.23
612
+ rubygems_version: 1.8.24
611
613
  signing_key:
612
614
  specification_version: 3
613
615
  summary: Hand-crafted frontend development