middleman 2.0.0.beta6 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/CHANGELOG +2 -0
  2. data/features/data.feature +7 -0
  3. data/features/front-matter.feature +7 -0
  4. data/features/helpers_page_classes.feature +6 -6
  5. data/fixtures/test-app/config.rb +23 -36
  6. data/fixtures/test-app/data/test.yml +4 -0
  7. data/fixtures/test-app/source/auto-css/auto-css.html.haml +1 -0
  8. data/fixtures/test-app/source/auto-css/index.html.haml +1 -0
  9. data/fixtures/test-app/source/auto-css/sub/auto-css.html.haml +1 -0
  10. data/fixtures/test-app/source/auto-js/auto-js.html.haml +1 -0
  11. data/fixtures/test-app/source/auto-js/index.html.haml +1 -0
  12. data/fixtures/test-app/source/auto-js/sub/auto-js.html.haml +1 -0
  13. data/fixtures/test-app/source/data.html.erb +1 -0
  14. data/fixtures/test-app/source/front-matter.html.slim +6 -0
  15. data/fixtures/test-app/source/sub1/page-classes.html.haml +1 -0
  16. data/fixtures/test-app/source/sub1/sub2/page-classes.html.haml +1 -0
  17. data/lib/middleman.rb +72 -2
  18. data/lib/middleman/core_extensions/assets.rb +57 -0
  19. data/lib/middleman/{features → core_extensions}/data.rb +7 -6
  20. data/lib/middleman/{features → core_extensions}/default_helpers.rb +8 -6
  21. data/lib/middleman/core_extensions/features.rb +96 -0
  22. data/lib/middleman/core_extensions/front_matter.rb +83 -0
  23. data/lib/middleman/core_extensions/rendering.rb +18 -0
  24. data/lib/middleman/core_extensions/routing.rb +62 -0
  25. data/lib/middleman/features/asset_host.rb +5 -5
  26. data/lib/middleman/features/blog.rb +43 -56
  27. data/lib/middleman/features/cache_buster.rb +7 -7
  28. data/lib/middleman/features/relative_assets.rb +4 -4
  29. data/lib/middleman/features/tiny_src.rb +2 -2
  30. data/lib/middleman/server.rb +44 -142
  31. data/lib/middleman/version.rb +1 -1
  32. metadata +35 -9
  33. data/fixtures/test-app/source/front-matter.html.erb +0 -7
  34. data/lib/middleman/assets.rb +0 -33
  35. data/lib/middleman/features.rb +0 -126
  36. data/lib/middleman/features/front_matter.rb +0 -60
@@ -1,3 +1,3 @@
1
1
  module Middleman
2
- VERSION = "2.0.0.beta6"
2
+ VERSION = "2.0.0.rc1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: middleman
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.beta6
5
+ version: 2.0.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Reynolds
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 -07:00
13
+ date: 2011-07-07 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -281,6 +281,8 @@ files:
281
281
  - bin/mm-server
282
282
  - features/builder.feature
283
283
  - features/coffee-script.feature
284
+ - features/data.feature
285
+ - features/front-matter.feature
284
286
  - features/generator.feature
285
287
  - features/helpers_auto_javascript_include_tag.feature
286
288
  - features/helpers_auto_stylesheet_link_tag.feature
@@ -303,15 +305,23 @@ files:
303
305
  - features/y_cache_buster.feature
304
306
  - features/z_relative_assets.feature
305
307
  - fixtures/test-app/config.rb
308
+ - fixtures/test-app/data/test.yml
306
309
  - fixtures/test-app/source/_partial.haml
307
310
  - fixtures/test-app/source/asset_host.html.haml
308
311
  - fixtures/test-app/source/auto-css.html.haml
312
+ - fixtures/test-app/source/auto-css/auto-css.html.haml
313
+ - fixtures/test-app/source/auto-css/index.html.haml
314
+ - fixtures/test-app/source/auto-css/sub/auto-css.html.haml
309
315
  - fixtures/test-app/source/auto-image-sizes.html.haml
310
316
  - fixtures/test-app/source/auto-js.html.haml
317
+ - fixtures/test-app/source/auto-js/auto-js.html.haml
318
+ - fixtures/test-app/source/auto-js/index.html.haml
319
+ - fixtures/test-app/source/auto-js/sub/auto-js.html.haml
311
320
  - fixtures/test-app/source/cache-buster.html.haml
312
321
  - fixtures/test-app/source/custom-layout-dir/index.html.haml
313
322
  - fixtures/test-app/source/custom-layout.html.haml
314
- - fixtures/test-app/source/front-matter.html.erb
323
+ - fixtures/test-app/source/data.html.erb
324
+ - fixtures/test-app/source/front-matter.html.slim
315
325
  - fixtures/test-app/source/images/blank.gif
316
326
  - fixtures/test-app/source/index.html.haml
317
327
  - fixtures/test-app/source/inline-coffeescript.html.haml
@@ -340,21 +350,25 @@ files:
340
350
  - fixtures/test-app/source/stylesheets/site.css.sass
341
351
  - fixtures/test-app/source/stylesheets/site_scss.css.scss
342
352
  - fixtures/test-app/source/stylesheets/static.css
353
+ - fixtures/test-app/source/sub1/page-classes.html.haml
354
+ - fixtures/test-app/source/sub1/sub2/page-classes.html.haml
343
355
  - fixtures/test-app/source/tiny_src.html.haml
344
356
  - lib/middleman.rb
345
- - lib/middleman/assets.rb
346
357
  - lib/middleman/builder.rb
347
358
  - lib/middleman/config.ru
348
- - lib/middleman/features.rb
359
+ - lib/middleman/core_extensions/assets.rb
360
+ - lib/middleman/core_extensions/data.rb
361
+ - lib/middleman/core_extensions/default_helpers.rb
362
+ - lib/middleman/core_extensions/features.rb
363
+ - lib/middleman/core_extensions/front_matter.rb
364
+ - lib/middleman/core_extensions/rendering.rb
365
+ - lib/middleman/core_extensions/routing.rb
349
366
  - lib/middleman/features/asset_host.rb
350
367
  - lib/middleman/features/automatic_image_sizes.rb
351
368
  - lib/middleman/features/automatic_image_sizes/fastimage.rb
352
369
  - lib/middleman/features/blog.rb
353
370
  - lib/middleman/features/cache_buster.rb
354
371
  - lib/middleman/features/code_ray.rb
355
- - lib/middleman/features/data.rb
356
- - lib/middleman/features/default_helpers.rb
357
- - lib/middleman/features/front_matter.rb
358
372
  - lib/middleman/features/live_reload.rb
359
373
  - lib/middleman/features/lorem.rb
360
374
  - lib/middleman/features/minify_css.rb
@@ -438,6 +452,8 @@ summary: A static site generator based on Sinatra. Providing Haml, Sass, Compass
438
452
  test_files:
439
453
  - features/builder.feature
440
454
  - features/coffee-script.feature
455
+ - features/data.feature
456
+ - features/front-matter.feature
441
457
  - features/generator.feature
442
458
  - features/helpers_auto_javascript_include_tag.feature
443
459
  - features/helpers_auto_stylesheet_link_tag.feature
@@ -460,15 +476,23 @@ test_files:
460
476
  - features/y_cache_buster.feature
461
477
  - features/z_relative_assets.feature
462
478
  - fixtures/test-app/config.rb
479
+ - fixtures/test-app/data/test.yml
463
480
  - fixtures/test-app/source/_partial.haml
464
481
  - fixtures/test-app/source/asset_host.html.haml
465
482
  - fixtures/test-app/source/auto-css.html.haml
483
+ - fixtures/test-app/source/auto-css/auto-css.html.haml
484
+ - fixtures/test-app/source/auto-css/index.html.haml
485
+ - fixtures/test-app/source/auto-css/sub/auto-css.html.haml
466
486
  - fixtures/test-app/source/auto-image-sizes.html.haml
467
487
  - fixtures/test-app/source/auto-js.html.haml
488
+ - fixtures/test-app/source/auto-js/auto-js.html.haml
489
+ - fixtures/test-app/source/auto-js/index.html.haml
490
+ - fixtures/test-app/source/auto-js/sub/auto-js.html.haml
468
491
  - fixtures/test-app/source/cache-buster.html.haml
469
492
  - fixtures/test-app/source/custom-layout-dir/index.html.haml
470
493
  - fixtures/test-app/source/custom-layout.html.haml
471
- - fixtures/test-app/source/front-matter.html.erb
494
+ - fixtures/test-app/source/data.html.erb
495
+ - fixtures/test-app/source/front-matter.html.slim
472
496
  - fixtures/test-app/source/images/blank.gif
473
497
  - fixtures/test-app/source/index.html.haml
474
498
  - fixtures/test-app/source/inline-coffeescript.html.haml
@@ -497,4 +521,6 @@ test_files:
497
521
  - fixtures/test-app/source/stylesheets/site.css.sass
498
522
  - fixtures/test-app/source/stylesheets/site_scss.css.scss
499
523
  - fixtures/test-app/source/stylesheets/static.css
524
+ - fixtures/test-app/source/sub1/page-classes.html.haml
525
+ - fixtures/test-app/source/sub1/sub2/page-classes.html.haml
500
526
  - fixtures/test-app/source/tiny_src.html.haml
@@ -1,7 +0,0 @@
1
- ---
2
- layout: false
3
- title: No title
4
- ---
5
-
6
- <%= data.page.title %>
7
- <%= data.page.inspect %>
@@ -1,33 +0,0 @@
1
- module Middleman
2
- module Assets
3
- @@asset_handler_map = []
4
- @@asset_handler_stack = []
5
-
6
- def self.register(handler_name, &block)
7
- if block_given?
8
- @@asset_handler_stack << block
9
- @@asset_handler_map << handler_name
10
- end
11
- end
12
-
13
- def self.get_url(path, prefix="", request=nil)
14
- @@asset_handler_stack.last.call(path, prefix, request)
15
- end
16
-
17
- def self.before(position, *args)
18
- current_index = @@asset_handler_map.index(position)
19
- return nil unless current_index
20
-
21
- previous = current_index - 1
22
- if (previous >= 0) && (previous < @@asset_handler_map.length)
23
- @@asset_handler_stack[previous].call(*args)
24
- else
25
- nil
26
- end
27
- end
28
- end
29
- end
30
-
31
- Middleman::Assets.register :base do |path, prefix, request|
32
- path.include?("://") ? path : File.join(Middleman::Server.http_prefix || "/", prefix, path)
33
- end
@@ -1,126 +0,0 @@
1
- # Middleman provides an extension API which allows you to hook into the
2
- # lifecycle of a page request, or static build, and manipulate the output.
3
- # Internal to Middleman, these extensions are called "features," but we use
4
- # the exact same API as is made available to the public.
5
- #
6
- # A Middleman extension looks like this:
7
- #
8
- # module MyExtension
9
- # class << self
10
- # def registered(app)
11
- # # My Code
12
- # end
13
- # end
14
- # end
15
- #
16
- # In your `config.rb`, you must load your extension (if it is not defined in
17
- # that file) and call `activate`.
18
- #
19
- # require "my_extension"
20
- # activate MyExtension
21
- #
22
- # This will call the `registered` method in your extension and provide you
23
- # with the `app` parameter which is a Middleman::Server context. From here
24
- # you can choose to respond to requests for certain paths or simply attach
25
- # Rack middleware to the stack.
26
- #
27
- # The built-in features cover a wide range of functions. Some provide helper
28
- # methods to use in your views. Some modify the output on-the-fly. And some
29
- # apply computationally-intensive changes to your final build files.
30
-
31
- module Middleman::Features
32
-
33
- # RelativeAssets allow any asset path in dynamic templates to be either
34
- # relative to the root of the project or use an absolute URL.
35
- autoload :RelativeAssets, "middleman/features/relative_assets"
36
-
37
- # AssetHost allows you to setup multiple domains to host your static assets.
38
- # Calls to asset paths in dynamic templates will then rotate through each of
39
- # the asset servers to better spread the load.
40
- autoload :AssetHost, "middleman/features/asset_host"
41
-
42
- # CacheBuster adds a query string to assets in dynamic templates to avoid
43
- # browser caches failing to update to your new content.
44
- autoload :CacheBuster, "middleman/features/cache_buster"
45
-
46
- # DefaultHelpers are the built-in dynamic template helpers.
47
- autoload :DefaultHelpers, "middleman/features/default_helpers"
48
-
49
- # AutomaticImageSizes inspects the images used in your dynamic templates and
50
- # automatically adds width and height attributes to their HTML elements.
51
- autoload :AutomaticImageSizes, "middleman/features/automatic_image_sizes"
52
-
53
- # UglyHaml enables the non-indented output format from Haml templates. Useful
54
- # for somewhat obfuscating the output and hiding the fact that you're using Haml.
55
- autoload :UglyHaml, "middleman/features/ugly_haml"
56
-
57
- # MinifyCss uses the YUI compressor to shrink CSS files
58
- autoload :MinifyCss, "middleman/features/minify_css"
59
-
60
- # MinifyJavascript uses the YUI compressor to shrink JS files
61
- autoload :MinifyJavascript, "middleman/features/minify_javascript"
62
-
63
- # CodeRay is a syntax highlighter.
64
- autoload :CodeRay, "middleman/features/code_ray"
65
-
66
- # Lorem provides a handful of helpful prototyping methods to generate words,
67
- # paragraphs, fake images, names and email addresses.
68
- autoload :Lorem, "middleman/features/lorem"
69
-
70
- # Data looks at the data/ folder for YAML files and makes them available
71
- # to dynamic requests.
72
- autoload :Data, "middleman/features/data"
73
-
74
- # Parse YAML metadata from templates
75
- autoload :FrontMatter, "middleman/features/front_matter"
76
-
77
- # Treat project as a blog
78
- autoload :Blog, "middleman/features/blog"
79
-
80
- # Proxy web services requests in dev mode only
81
- autoload :Proxy, "middleman/features/proxy"
82
-
83
- # Automatically resize images for mobile devises
84
- # autoload :TinySrc, "middleman/features/tiny_src"
85
-
86
- # LiveReload will auto-reload browsers with the live reload extension installed after changes
87
- # Currently disabled and untested.
88
- # autoload :LiveReload, "middleman/features/live_reload"
89
-
90
- # The Feature API is itself a Feature. Mind blowing!
91
- class << self
92
- def registered(app)
93
- app.extend ClassMethods
94
- end
95
- alias :included :registered
96
- end
97
-
98
- module ClassMethods
99
- # This method is available in the project's `config.rb`.
100
- # It takes a underscore-separated symbol, finds the appropriate
101
- # feature module and includes it.
102
- #
103
- # activate :lorem
104
- #
105
- # Alternatively, you can pass in a Middleman feature module directly.
106
- #
107
- # activate MyFeatureModule
108
- def activate(feature)
109
- feature = feature.to_s if feature.is_a? Symbol
110
-
111
- if feature.is_a? String
112
- feature = feature.camelize
113
- feature = Middleman::Features.const_get(feature)
114
- end
115
-
116
- register feature
117
- end
118
-
119
- # Deprecated API. Please use `activate` instead.
120
- def enable(feature_name)
121
- $stderr.puts "Warning: Feature activation has been renamed from enable to activate"
122
- activate(feature_name)
123
- super(feature_name)
124
- end
125
- end
126
- end
@@ -1,60 +0,0 @@
1
- require "yaml"
2
- require "tilt"
3
-
4
- module Middleman::Features::FrontMatter
5
- class << self
6
- def registered(app)
7
- app.extend ClassMethods
8
-
9
- ::Tilt::register RDiscountTemplate, 'markdown', 'mkd', 'md'
10
- ::Tilt::register RedClothTemplate, 'textile'
11
- ::Tilt::register ERBTemplate, 'erb', 'rhtml'
12
- ::Tilt::register ErubisTemplate, 'erb', 'rhtml', 'erubis'
13
- end
14
- alias :included :registered
15
- end
16
-
17
- module ClassMethods
18
- def parse_front_matter(content)
19
- yaml_regex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
20
- if content =~ yaml_regex
21
- begin
22
- data = YAML.load($1)
23
- rescue => e
24
- puts "YAML Exception: #{e.message}"
25
- end
26
-
27
- content = content.split(yaml_regex).last
28
- end
29
-
30
- data ||= {}
31
- [data, content]
32
- end
33
- end
34
-
35
- module YamlAware
36
- def prepare
37
- options, @data = Middleman::Server.parse_front_matter(@data)
38
- super
39
- end
40
- end
41
-
42
- # MARKDOWN
43
- class RDiscountTemplate < ::Tilt::RDiscountTemplate
44
- include Middleman::Features::FrontMatter::YamlAware
45
- end
46
-
47
- # TEXTILE
48
- class RedClothTemplate < ::Tilt::RedClothTemplate
49
- include Middleman::Features::FrontMatter::YamlAware
50
- end
51
-
52
- # ERb
53
- class ERBTemplate < ::Tilt::ERBTemplate
54
- include Middleman::Features::FrontMatter::YamlAware
55
- end
56
-
57
- class ErubisTemplate < ::Tilt::ErubisTemplate
58
- include Middleman::Features::FrontMatter::YamlAware
59
- end
60
- end