middleman 2.0.8 → 2.0.9.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gemspec
3
+ gemspec :name => "middleman"
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks
2
+ Bundler::GemHelper.install_tasks :name => ENV["NAME"] || "middleman"
3
3
 
4
4
  require 'cucumber/rake/task'
5
5
 
@@ -0,0 +1,6 @@
1
+ Feature: Support liquid partials
2
+
3
+ Scenario: Rendering liquid
4
+ Given the Server is running at "test-app"
5
+ When I go to "/liquid_master.html"
6
+ Then I should see "Greetings"
@@ -1,5 +1,6 @@
1
1
  Given /^I am using an asset host$/ do
2
2
  @server ||= Middleman.server
3
+ @server.set :show_exceptions, false
3
4
  @server.activate :asset_host
4
5
  @server.set :asset_host do |asset|
5
6
  "http://assets%d.example.com" % (asset.hash % 4)
@@ -1,5 +1,6 @@
1
1
  Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
2
2
  @server ||= Middleman.server
3
+ @server.set :show_exceptions, false
3
4
  if state == "enabled"
4
5
  @server.activate(feature.to_sym)
5
6
  end
@@ -8,6 +9,7 @@ end
8
9
 
9
10
  Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
10
11
  @server ||= Middleman.server
12
+ @server.set :show_exceptions, false
11
13
  @server.set variable.to_sym, value
12
14
  end
13
15
 
@@ -17,6 +19,7 @@ end
17
19
 
18
20
  Given /^the Server is running at "([^\"]*)"$/ do |app_path|
19
21
  @server ||= Middleman.server
22
+ @server.set :show_exceptions, false
20
23
  root = File.dirname(File.dirname(File.dirname(__FILE__)))
21
24
  @server.set :root, File.join(root, "fixtures", app_path)
22
25
  @browser = Rack::Test::Session.new(Rack::MockSession.new(@server.new))
@@ -1,10 +1,12 @@
1
1
  Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
2
2
  @server ||= Middleman.server
3
+ @server.set :show_exceptions, false
3
4
  @server.page(url, :layout => layout.to_sym)
4
5
  end
5
6
 
6
7
  Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
7
8
  @server ||= Middleman.server
9
+ @server.set :show_exceptions, false
8
10
  @server.with_layout(layout.to_sym) do
9
11
  page(url)
10
12
  end
@@ -20,6 +20,7 @@ with_layout false do
20
20
  page "/slim.html"
21
21
  page "/data.html"
22
22
  page "/data2.html"
23
+ page "/liquid_master.html"
23
24
  page "/page-classes.html"
24
25
  page "/sub1/page-classes.html"
25
26
  page "/sub1/sub2/page-classes.html"
@@ -1 +1,2 @@
1
+ {{data}}
1
2
  {% for item in data.test %}{{item.title}}{% endfor %}
@@ -0,0 +1 @@
1
+ {% include "liquid_partial" %}
@@ -69,11 +69,12 @@ module Middleman
69
69
 
70
70
  # Custom Renderers
71
71
  module Renderers
72
- autoload :Haml, "middleman/renderers/haml"
73
- autoload :Sass, "middleman/renderers/sass"
74
- autoload :Slim, "middleman/renderers/slim"
75
- autoload :Markdown, "middleman/renderers/markdown"
72
+ autoload :Haml, "middleman/renderers/haml"
73
+ autoload :Sass, "middleman/renderers/sass"
74
+ autoload :Slim, "middleman/renderers/slim"
75
+ autoload :Markdown, "middleman/renderers/markdown"
76
76
  autoload :CoffeeScript, "middleman/renderers/coffee_script"
77
+ autoload :Liquid, "middleman/renderers/liquid"
77
78
  end
78
79
 
79
80
  module CoreExtensions
@@ -1,11 +1,12 @@
1
+ require "i18n"
2
+
3
+ require "active_support"
4
+ require "active_support/json"
5
+ require "active_support/core_ext/class/attribute_accessors"
6
+
1
7
  module Middleman::Base
2
8
  class << self
3
- def registered(app)
4
- # Explicitly require json support
5
- require "i18n"
6
- require "active_support"
7
- require "active_support/json"
8
-
9
+ def registered(app)
9
10
  app.extend ClassMethods
10
11
  app.send :include, InstanceMethods
11
12
 
@@ -43,6 +44,9 @@ module Middleman::Base
43
44
  # Activate custom features
44
45
  app.register Middleman::CoreExtensions::Features
45
46
 
47
+ # Activate Yaml Data package
48
+ app.register Middleman::CoreExtensions::Data
49
+
46
50
  # Setup custom rendering
47
51
  app.register Middleman::CoreExtensions::Rendering
48
52
 
@@ -58,9 +62,6 @@ module Middleman::Base
58
62
  # Activate built-in helpers
59
63
  app.register Middleman::CoreExtensions::DefaultHelpers
60
64
 
61
- # Activate Yaml Data package
62
- app.register Middleman::CoreExtensions::Data
63
-
64
65
  # with_layout and page routing
65
66
  app.register Middleman::CoreExtensions::Routing
66
67
 
@@ -86,14 +87,8 @@ module Middleman::Base
86
87
  end
87
88
 
88
89
  # See if Tilt cannot handle this file
89
- app.before_processing do
90
- if !settings.views.include?(settings.root)
91
- settings.set :views, File.join(settings.root, settings.views)
92
- end
93
-
90
+ app.before_processing(:base) do |result|
94
91
  request_path = request.path_info.gsub("%20", " ")
95
- result = resolve_template(request_path, :raise_exceptions => false)
96
-
97
92
  should_be_ignored = !(request["is_proxy"]) && settings.excluded_paths.include?("/#{request_path}")
98
93
 
99
94
  if result && !should_be_ignored
@@ -132,16 +127,16 @@ module Middleman::Base
132
127
  super(option, value, &nil)
133
128
  end
134
129
 
135
- def before_processing(&block)
130
+ def before_processing(name=:unnamed, idx=-1, &block)
136
131
  @before_processes ||= []
137
- @before_processes << block
132
+ @before_processes.insert(idx, [name, block])
138
133
  end
139
134
 
140
- def execute_before_processing!(inst)
135
+ def execute_before_processing!(inst, resolved_template)
141
136
  @before_processes ||= []
142
137
 
143
- @before_processes.all? do |block|
144
- inst.instance_eval(&block)
138
+ @before_processes.all? do |name, block|
139
+ inst.instance_exec(resolved_template, &block)
145
140
  end
146
141
  end
147
142
 
@@ -152,14 +147,24 @@ module Middleman::Base
152
147
  module InstanceMethods
153
148
  # Internal method to look for templates and evaluate them if found
154
149
  def process_request(options={})
155
- return unless settings.execute_before_processing!(self)
156
-
150
+ if !settings.views.include?(settings.root)
151
+ settings.set :views, File.join(settings.root, settings.views)
152
+ end
153
+
154
+ # Normalize the path and add index if we're looking at a directory
155
+ request.path_info = self.class.path_to_index(request.path)
156
+
157
+ request_path = request.path_info.gsub("%20", " ")
158
+ found_template = resolve_template(request_path, :raise_exceptions => false)
159
+ return status(404) unless found_template
160
+ return unless settings.execute_before_processing!(self, found_template)
161
+
157
162
  options.merge!(request['custom_options'] || {})
158
163
 
159
164
  old_layout = settings.layout
160
165
  settings.set :layout, options[:layout] if !options[:layout].nil?
161
166
 
162
- layout = if settings.layout
167
+ local_layout = if settings.layout
163
168
  if options[:layout] == false || request.path_info =~ /\.(css|js)$/
164
169
  false
165
170
  else
@@ -169,23 +174,24 @@ module Middleman::Base
169
174
  false
170
175
  end
171
176
 
172
- render_options = { :layout => layout }
177
+ render_options = { :layout => local_layout }
173
178
  render_options[:layout_engine] = options[:layout_engine] if options.has_key? :layout_engine
174
- request_path = request.path_info.gsub("%20", " ")
175
- path, engine = resolve_template(request_path)
176
179
 
177
- locals = {}
178
- locals[:data] = data.to_h if engine == :liquid
180
+ path, engine = found_template
181
+ locals = request['custom_locals'] || {}
179
182
 
180
- result = render(engine, path, render_options, locals)
181
- settings.set :layout, old_layout
182
-
183
- if result
184
- content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
185
- status 200
186
- body result
187
- else
188
- status 404
183
+ begin
184
+ result = render(engine, path, render_options, locals)
185
+
186
+ if result
187
+ content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
188
+ status 200
189
+ body result
190
+ end
191
+ # rescue
192
+ # status(404)
193
+ ensure
194
+ settings.set :layout, old_layout
189
195
  end
190
196
  end
191
197
  end
@@ -17,7 +17,7 @@ module Middleman
17
17
  request_path = destination.sub(/^#{SHARED_SERVER.build_dir}/, "")
18
18
 
19
19
  begin
20
- destination, request_page = SHARED_SERVER.reroute_builder(destination, request_path)
20
+ destination, request_path = SHARED_SERVER.reroute_builder(destination, request_path)
21
21
 
22
22
  request_path.gsub!(/\s/, "%20")
23
23
  response = Middleman::Builder.shared_rack.get(request_path)
@@ -53,6 +53,9 @@ module Middleman::CoreExtensions::Data
53
53
  def to_h
54
54
  data = {}
55
55
 
56
+ @@local_sources ||= {}
57
+ @@callback_sources ||= {}
58
+
56
59
  (@@local_sources || {}).each do |k, v|
57
60
  data[k] = data_for_path(k)
58
61
  end
@@ -28,10 +28,7 @@ module Middleman::CoreExtensions::FrontMatter
28
28
  ::Tilt.prefer(HamlTemplate)
29
29
 
30
30
  app.after_configuration do
31
- app.before_processing do
32
- request_path = request.path_info.gsub("%20", " ")
33
- result = resolve_template(request_path, :raise_exceptions => false)
34
-
31
+ app.before_processing(:front_matter) do |result|
35
32
  if result && Tilt.mappings.has_key?(result[1].to_s)
36
33
  extensionless_path, template_engine = result
37
34
  full_file_path = "#{extensionless_path}.#{template_engine}"
@@ -12,6 +12,7 @@ module Middleman::CoreExtensions::Rendering
12
12
  app.register Middleman::Renderers::Sass
13
13
  app.register Middleman::Renderers::Markdown
14
14
  app.register Middleman::Renderers::CoffeeScript
15
+ app.register Middleman::Renderers::Liquid
15
16
  end
16
17
  alias :included :registered
17
18
  end
@@ -9,12 +9,6 @@ module Middleman::CoreExtensions::Routing
9
9
  app.build_reroute do |destination, request_path|
10
10
  throw if app.settings.excluded_paths.include?(request_path)
11
11
  end
12
-
13
- # Normalize the path and add index if we're looking at a directory
14
- app.before_processing do
15
- request.path_info = self.class.path_to_index(request.path)
16
- true
17
- end
18
12
  end
19
13
  alias :included :registered
20
14
  end
@@ -76,7 +70,7 @@ module Middleman::CoreExtensions::Routing
76
70
  settings.ignore(url)
77
71
  end
78
72
  end
79
-
73
+
80
74
  paths_for_url(url).each do |p|
81
75
  get(p) do
82
76
  if settings.proxied_paths.has_key?(url)
@@ -17,13 +17,13 @@ module Middleman::Features::DirectoryIndexes
17
17
  else
18
18
  [
19
19
  destination.gsub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path),
20
- request_path.gsub(/#{index_ext.gsub(".", "\\.")}$/, new_index_path)
20
+ request_path
21
21
  ]
22
22
  end
23
23
  end
24
24
 
25
25
  app.before do
26
- indexed_path = request.path_info.gsub(/\/$/, "") + "/" + app.settings.index_file
26
+ indexed_path = request.path_info.gsub(/\/$/, "") + "/" + app.settings.index_file
27
27
  indexed_exists = resolve_template(indexed_path, :raise_exceptions => false)
28
28
 
29
29
  extensioned_path = request.path_info.gsub(/\/$/, "") + File.extname(app.settings.index_file)
@@ -0,0 +1,29 @@
1
+ module Middleman::Renderers::Liquid
2
+ class << self
3
+ def registered(app)
4
+ # Liquid is not included in the default gems,
5
+ # but we'll support it if necessary.
6
+ begin
7
+ require "liquid"
8
+
9
+ app.after_configuration do
10
+ full_path = app.views
11
+ full_path = File.join(app.root, app.views) unless app.views.include?(app.root)
12
+
13
+ Liquid::Template.file_system = Liquid::LocalFileSystem.new(full_path)
14
+
15
+ app.before_processing(:liquid) do |result|
16
+ if result && result[1] == :liquid
17
+ request['custom_locals'] ||= {}
18
+ request['custom_locals'][:data] = data.to_h
19
+ end
20
+
21
+ true
22
+ end
23
+ end
24
+ rescue LoadError
25
+ end
26
+ end
27
+ alias :included :registered
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Middleman
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.9.pre"
3
3
  end
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
38
38
  eos
39
39
 
40
40
  s.add_dependency("rack", ["~> 1.3.0"])
41
- # s.add_dependency("eventmachine", ["1.0.0.beta.3"])
42
41
  s.add_dependency("thin", ["~> 1.2.11"])
43
42
  s.add_dependency("thor", ["~> 0.14.0"])
44
43
  s.add_dependency("tilt", ["~> 1.3.1"])
@@ -55,18 +54,16 @@ eos
55
54
  s.add_dependency("padrino-core", ["~> 0.10.2"])
56
55
  s.add_dependency("padrino-helpers", ["~> 0.10.2"])
57
56
 
58
- case Config::CONFIG['host_os'].downcase
59
- when %r{mswin|mingw}
60
- # s.add_runtime_dependency "windows-api", "= 0.4.0"
61
- # s.add_runtime_dependency "windows-pr", "= 1.1.2"
62
- s.add_dependency("win32-process", ["~> 0.6.5"])
63
- s.add_dependency("win32console", ["~> 1.3.0"])
64
- s.add_dependency("rb-fchange")
65
- when %r{darwin}
57
+ # case s.platform.to_s
58
+ # when %r{mswin|mingw}
59
+ # s.add_dependency("eventmachine", ["1.0.0.beta.3"])
60
+ # s.add_dependency("win32-process", ["~> 0.6.5"])
61
+ # s.add_dependency("win32console", ["~> 1.3.0"])
62
+ # s.add_dependency("rb-fchange")
63
+ # else
66
64
  s.add_dependency("rb-fsevent", ["~> 0.4.2"])
67
- when %r{linux}
68
65
  s.add_dependency("therubyracer", ["~> 0.9.4"])
69
- end
66
+ # end
70
67
 
71
68
  s.add_dependency("guard", ["~> 0.6.2"])
72
69
  s.add_dependency("middleman-livereload", ["~> 0.2.0"])
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
4
+ hash: 961915968
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 8
10
- version: 2.0.8
9
+ - 9
10
+ - pre
11
+ version: 2.0.9.pre
11
12
  platform: ruby
12
13
  authors:
13
14
  - Thomas Reynolds
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-09-06 00:00:00 -07:00
19
+ date: 2011-09-09 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -292,6 +293,22 @@ dependencies:
292
293
  type: :runtime
293
294
  - !ruby/object:Gem::Dependency
294
295
  requirement: &id018 !ruby/object:Gem::Requirement
296
+ none: false
297
+ requirements:
298
+ - - ~>
299
+ - !ruby/object:Gem::Version
300
+ hash: 51
301
+ segments:
302
+ - 0
303
+ - 9
304
+ - 4
305
+ version: 0.9.4
306
+ version_requirements: *id018
307
+ name: therubyracer
308
+ prerelease: false
309
+ type: :runtime
310
+ - !ruby/object:Gem::Dependency
311
+ requirement: &id019 !ruby/object:Gem::Requirement
295
312
  none: false
296
313
  requirements:
297
314
  - - ~>
@@ -302,12 +319,12 @@ dependencies:
302
319
  - 6
303
320
  - 2
304
321
  version: 0.6.2
305
- version_requirements: *id018
322
+ version_requirements: *id019
306
323
  name: guard
307
324
  prerelease: false
308
325
  type: :runtime
309
326
  - !ruby/object:Gem::Dependency
310
- requirement: &id019 !ruby/object:Gem::Requirement
327
+ requirement: &id020 !ruby/object:Gem::Requirement
311
328
  none: false
312
329
  requirements:
313
330
  - - ~>
@@ -318,12 +335,12 @@ dependencies:
318
335
  - 2
319
336
  - 0
320
337
  version: 0.2.0
321
- version_requirements: *id019
338
+ version_requirements: *id020
322
339
  name: middleman-livereload
323
340
  prerelease: false
324
341
  type: :runtime
325
342
  - !ruby/object:Gem::Dependency
326
- requirement: &id020 !ruby/object:Gem::Requirement
343
+ requirement: &id021 !ruby/object:Gem::Requirement
327
344
  none: false
328
345
  requirements:
329
346
  - - ~>
@@ -334,12 +351,12 @@ dependencies:
334
351
  - 1
335
352
  - 1
336
353
  version: 0.1.1
337
- version_requirements: *id020
354
+ version_requirements: *id021
338
355
  name: coffee-filter
339
356
  prerelease: false
340
357
  type: :development
341
358
  - !ruby/object:Gem::Dependency
342
- requirement: &id021 !ruby/object:Gem::Requirement
359
+ requirement: &id022 !ruby/object:Gem::Requirement
343
360
  none: false
344
361
  requirements:
345
362
  - - ~>
@@ -350,12 +367,12 @@ dependencies:
350
367
  - 2
351
368
  - 0
352
369
  version: 2.2.0
353
- version_requirements: *id021
370
+ version_requirements: *id022
354
371
  name: liquid
355
372
  prerelease: false
356
373
  type: :development
357
374
  - !ruby/object:Gem::Dependency
358
- requirement: &id022 !ruby/object:Gem::Requirement
375
+ requirement: &id023 !ruby/object:Gem::Requirement
359
376
  none: false
360
377
  requirements:
361
378
  - - ~>
@@ -366,12 +383,12 @@ dependencies:
366
383
  - 0
367
384
  - 2
368
385
  version: 1.0.2
369
- version_requirements: *id022
386
+ version_requirements: *id023
370
387
  name: cucumber
371
388
  prerelease: false
372
389
  type: :development
373
390
  - !ruby/object:Gem::Dependency
374
- requirement: &id023 !ruby/object:Gem::Requirement
391
+ requirement: &id024 !ruby/object:Gem::Requirement
375
392
  none: false
376
393
  requirements:
377
394
  - - "="
@@ -382,12 +399,12 @@ dependencies:
382
399
  - 8
383
400
  - 7
384
401
  version: 0.8.7
385
- version_requirements: *id023
402
+ version_requirements: *id024
386
403
  name: rake
387
404
  prerelease: false
388
405
  type: :development
389
406
  - !ruby/object:Gem::Dependency
390
- requirement: &id024 !ruby/object:Gem::Requirement
407
+ requirement: &id025 !ruby/object:Gem::Requirement
391
408
  none: false
392
409
  requirements:
393
410
  - - ~>
@@ -398,7 +415,7 @@ dependencies:
398
415
  - 6
399
416
  - 0
400
417
  version: 2.6.0
401
- version_requirements: *id024
418
+ version_requirements: *id025
402
419
  name: rspec
403
420
  prerelease: false
404
421
  type: :development
@@ -440,6 +457,7 @@ files:
440
457
  - features/helpers_auto_javascript_include_tag.feature
441
458
  - features/helpers_auto_stylesheet_link_tag.feature
442
459
  - features/helpers_page_classes.feature
460
+ - features/liquid.feature
443
461
  - features/markdown.feature
444
462
  - features/minify_css.feature
445
463
  - features/minify_javascript.feature
@@ -472,6 +490,7 @@ files:
472
490
  - fixtures/sprockets-app/source/library/javascripts/sprockets_sub.js
473
491
  - fixtures/test-app/config.rb
474
492
  - fixtures/test-app/data/test.yml
493
+ - fixtures/test-app/source/_liquid_partial.liquid
475
494
  - fixtures/test-app/source/_partial.haml
476
495
  - fixtures/test-app/source/a_folder/needs_index.html
477
496
  - fixtures/test-app/source/asset_host.html.haml
@@ -511,6 +530,7 @@ files:
511
530
  - fixtures/test-app/source/javascripts/sprockets_sub.js
512
531
  - fixtures/test-app/source/layout.haml
513
532
  - fixtures/test-app/source/layouts/custom.haml
533
+ - fixtures/test-app/source/liquid_master.html.liquid
514
534
  - fixtures/test-app/source/markdown.html.markdown
515
535
  - fixtures/test-app/source/needs_index.html
516
536
  - fixtures/test-app/source/padrino_test.html.haml
@@ -567,6 +587,7 @@ files:
567
587
  - lib/middleman/guard.rb
568
588
  - lib/middleman/renderers/coffee_script.rb
569
589
  - lib/middleman/renderers/haml.rb
590
+ - lib/middleman/renderers/liquid.rb
570
591
  - lib/middleman/renderers/markdown.rb
571
592
  - lib/middleman/renderers/sass.rb
572
593
  - lib/middleman/renderers/slim.rb
@@ -641,12 +662,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
641
662
  required_rubygems_version: !ruby/object:Gem::Requirement
642
663
  none: false
643
664
  requirements:
644
- - - ">="
665
+ - - ">"
645
666
  - !ruby/object:Gem::Version
646
- hash: 3
667
+ hash: 25
647
668
  segments:
648
- - 0
649
- version: "0"
669
+ - 1
670
+ - 3
671
+ - 1
672
+ version: 1.3.1
650
673
  requirements: []
651
674
 
652
675
  rubyforge_project:
@@ -668,6 +691,7 @@ test_files:
668
691
  - features/helpers_auto_javascript_include_tag.feature
669
692
  - features/helpers_auto_stylesheet_link_tag.feature
670
693
  - features/helpers_page_classes.feature
694
+ - features/liquid.feature
671
695
  - features/markdown.feature
672
696
  - features/minify_css.feature
673
697
  - features/minify_javascript.feature
@@ -700,6 +724,7 @@ test_files:
700
724
  - fixtures/sprockets-app/source/library/javascripts/sprockets_sub.js
701
725
  - fixtures/test-app/config.rb
702
726
  - fixtures/test-app/data/test.yml
727
+ - fixtures/test-app/source/_liquid_partial.liquid
703
728
  - fixtures/test-app/source/_partial.haml
704
729
  - fixtures/test-app/source/a_folder/needs_index.html
705
730
  - fixtures/test-app/source/asset_host.html.haml
@@ -739,6 +764,7 @@ test_files:
739
764
  - fixtures/test-app/source/javascripts/sprockets_sub.js
740
765
  - fixtures/test-app/source/layout.haml
741
766
  - fixtures/test-app/source/layouts/custom.haml
767
+ - fixtures/test-app/source/liquid_master.html.liquid
742
768
  - fixtures/test-app/source/markdown.html.markdown
743
769
  - fixtures/test-app/source/needs_index.html
744
770
  - fixtures/test-app/source/padrino_test.html.haml