middleman-core 3.1.0.beta.1 → 3.1.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 162338185650a24dbf63fc3f9e937c325696e8a4
4
+ data.tar.gz: 4127281186efb590b13ffcbcab498ece1db4b418
5
+ SHA512:
6
+ metadata.gz: a3e4a7d833d68f8e60a518db42e581a765197fa2904fbaaade630abdd69cdb2143e4dc058a7724fce4e022251ebd108d98e5ab94186e9ab0bffb61e7b8c31cf7
7
+ data.tar.gz: 26736224cbb3f390c8be6877e357f6cc83daa09bdbcca78c8e9276b1bdfd25acf0a5cf5c215d793cb43be00320627119230b0a70dddbe6f4de40fb7cd5b997e5
@@ -177,6 +177,11 @@ module Middleman
177
177
  super
178
178
  end
179
179
 
180
+ # Needed so that method_missing makes sense
181
+ def respond_to?(method, include_private = false)
182
+ super || @local_data.has_key?(method.to_s) || !!(data_for_path(method))
183
+ end
184
+
180
185
  # Convert all the data into a static hash
181
186
  #
182
187
  # @return [Hash]
@@ -37,6 +37,7 @@ module Middleman
37
37
  class << self
38
38
  # @private
39
39
  def registered(app)
40
+ app.define_hook :initialized
40
41
  app.define_hook :after_configuration
41
42
  app.define_hook :before_configuration
42
43
  app.define_hook :build_config
@@ -68,19 +69,15 @@ module Middleman
68
69
  # @param [Hash] options Per-extension options hash
69
70
  # @return [void]
70
71
  def register(extension, options={}, &block)
71
- if extension.instance_of? Module
72
- extend extension
73
- if extension.respond_to?(:registered)
74
- if extension.method(:registered).arity === 1
75
- extension.registered(self, &block)
76
- else
77
- extension.registered(self, options, &block)
78
- end
72
+ extend extension
73
+ if extension.respond_to?(:registered)
74
+ if extension.method(:registered).arity === 1
75
+ extension.registered(self, &block)
76
+ else
77
+ extension.registered(self, options, &block)
79
78
  end
80
- extension
81
- elsif extension.instance_of?(Class) && extension.ancestors.include?(::Middleman::Extension)
82
- extension.new(self, options, &block)
83
79
  end
80
+ extension
84
81
  end
85
82
  end
86
83
 
@@ -105,7 +102,22 @@ module Middleman
105
102
  logger.error "== Unknown Extension: #{ext}"
106
103
  else
107
104
  logger.debug "== Activating: #{ext}"
108
- extensions[ext] = self.class.register(ext_module, options, &block)
105
+
106
+ if ext_module.instance_of? Module
107
+ extensions[ext] = self.class.register(ext_module, options, &block)
108
+ elsif ext_module.instance_of?(Class) && ext_module.ancestors.include?(::Middleman::Extension)
109
+ if ext_module.supports_multiple_instances?
110
+ extensions[ext] ||= {}
111
+ key = "instance_#{extensions[ext].keys.length}"
112
+ extensions[ext][key] = ext_module.new(self.class, options, &block)
113
+ else
114
+ if extensions[ext]
115
+ logger.error "== #{ext} already activated."
116
+ else
117
+ extensions[ext] = ext_module.new(self.class, options, &block)
118
+ end
119
+ end
120
+ end
109
121
  end
110
122
  end
111
123
 
@@ -144,11 +156,19 @@ module Middleman
144
156
  run_hook :build_config if build?
145
157
  run_hook :development_config if development?
146
158
 
159
+ run_hook :initialized
160
+
147
161
  run_hook :after_configuration
148
162
 
149
163
  logger.debug "Loaded extensions:"
150
164
  self.extensions.each do |ext,_|
151
- logger.debug "== Extension: #{ext}"
165
+ if ext.is_a?(Hash)
166
+ ext.each do |k,_|
167
+ logger.debug "== Extension: #{k}"
168
+ end
169
+ else
170
+ logger.debug "== Extension: #{ext}"
171
+ end
152
172
  end
153
173
  end
154
174
  end
@@ -25,6 +25,8 @@ module Middleman
25
25
  ::Tilt.mappings.delete('html') # WTF, Tilt?
26
26
  ::Tilt.mappings.delete('csv')
27
27
 
28
+ require 'active_support/core_ext/string/output_safety'
29
+
28
30
  # Activate custom renderers
29
31
  require "middleman-core/renderers/erb"
30
32
  app.register Middleman::Renderers::ERb
@@ -127,9 +129,10 @@ module Middleman
127
129
 
128
130
  # Store last engine for later (could be inside nested renders)
129
131
  @current_engine, engine_was = engine, @current_engine
130
- old_locale = ::I18n.locale
131
-
132
- I18n.locale = opts[:lang] if opts[:lang]
132
+ if defined?(::I18n)
133
+ old_locale = ::I18n.locale
134
+ ::I18n.locale = opts[:lang] if opts[:lang]
135
+ end
133
136
 
134
137
  # Use a dup of self as a context so that instance variables set within
135
138
  # the template don't persist for other templates.
@@ -167,7 +170,7 @@ module Middleman
167
170
  ensure
168
171
  # Pop all the saved variables from earlier as we may be returning to a
169
172
  # previous render (layouts, partials, nested layouts).
170
- ::I18n.locale = old_locale
173
+ ::I18n.locale = old_locale if defined?(::I18n)
171
174
  @current_engine = engine_was
172
175
  @content_blocks = nil
173
176
  @current_locs = nil
@@ -274,7 +277,9 @@ module Middleman
274
277
  content = callback.call(content, path, locs, template_class)
275
278
  end
276
279
 
277
- return content
280
+ output = ::ActiveSupport::SafeBuffer.new
281
+ output.safe_concat content
282
+ output
278
283
  ensure
279
284
  # Reset stored buffer
280
285
  @_out_buf = _buf_was
@@ -408,7 +413,7 @@ module Middleman
408
413
  @_out_buf = _buf_was
409
414
  end
410
415
 
411
- concat_content render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content }
416
+ concat_safe_content render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content }
412
417
  ensure
413
418
  @current_engine = engine_was
414
419
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/class/attribute"
2
+
1
3
  module Middleman
2
4
 
3
5
  module Extensions
@@ -82,7 +84,7 @@ module Middleman
82
84
  def rubygems_latest_specs
83
85
  # If newer Rubygems
84
86
  if ::Gem::Specification.respond_to? :latest_specs
85
- ::Gem::Specification.latest_specs
87
+ ::Gem::Specification.latest_specs(true)
86
88
  else
87
89
  ::Gem.source_index.latest_specs
88
90
  end
@@ -102,6 +104,10 @@ module Middleman
102
104
  end
103
105
 
104
106
  class Extension
107
+ class_attribute :supports_multiple_instances, :instance_reader => false, :instance_writer => false
108
+ class_attribute :defined_helpers, :instance_reader => false, :instance_writer => false
109
+ class_attribute :ext_name, :instance_reader => false, :instance_writer => false
110
+
105
111
  class << self
106
112
  def config
107
113
  @_config ||= ::Middleman::Configuration::ConfigurationManager.new
@@ -110,11 +116,29 @@ module Middleman
110
116
  def option(key, default=nil, description=nil)
111
117
  config.define_setting(key, default, description)
112
118
  end
119
+
120
+ def helpers(&block)
121
+ self.defined_helpers ||= []
122
+
123
+ m = Module.new
124
+ m.module_eval(&block)
125
+ self.defined_helpers << m
126
+ end
127
+
128
+ def extension_name
129
+ self.ext_name || self.name.underscore.split("/").last.to_sym
130
+ end
131
+
132
+ def register(n=self.extension_name)
133
+ ::Middleman::Extensions.register(n, self)
134
+ end
113
135
  end
114
136
 
115
137
  attr_accessor :app, :options
116
138
 
117
139
  def initialize(klass, options_hash={})
140
+ @_helpers = []
141
+
118
142
  @options = self.class.config.dup
119
143
  @options.finalize!
120
144
 
@@ -125,14 +149,23 @@ module Middleman
125
149
  yield @options if block_given?
126
150
 
127
151
  ext = self
128
- klass.after_configuration do
152
+ klass.initialized do
129
153
  ext.app = self
130
- ext.after_configuration
154
+
155
+ (ext.class.defined_helpers || []).each do |m|
156
+ ext.app.class.send(:include, m)
157
+ end
131
158
  end
132
- end
133
159
 
134
- def after_configuration
135
- nil
160
+ klass.after_configuration do
161
+ if ext.respond_to?(:after_configuration)
162
+ ext.after_configuration
163
+ end
164
+
165
+ if ext.respond_to?(:manipulate_resource_list)
166
+ ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext)
167
+ end
168
+ end
136
169
  end
137
170
  end
138
171
  end
@@ -32,7 +32,7 @@ module Middleman
32
32
  'Path' => @resource.path,
33
33
  'Build Path' => @resource.destination_path,
34
34
  'URL' => content_tag(:a, @resource.url, :href => @resource.url),
35
- 'Template' => @resource.source_file,
35
+ 'Source File' => @resource.source_file,
36
36
  }
37
37
 
38
38
  data = @resource.data
@@ -19,7 +19,9 @@ module Middleman
19
19
  # Setup Slim options to work with partials
20
20
  ::Slim::Engine.set_default_options(
21
21
  :buffer => '@_out_buf',
22
- :generator => ::Temple::Generators::StringBuffer
22
+ :use_html_safe => true,
23
+ :generator => ::Temple::Generators::RailsOutputBuffer,
24
+ :disable_escape => true
23
25
  )
24
26
 
25
27
  app.after_configuration do
@@ -68,6 +68,9 @@ module Middleman
68
68
  # (e.g., if the resource is named 'gallery.html' and a path exists named 'gallery/', this would return true)
69
69
  # @return [Boolean]
70
70
  def eponymous_directory?
71
+ if !path.end_with?("/#{app.index_file}") && destination_path.end_with?("/#{app.index_file}")
72
+ return true
73
+ end
71
74
  full_path = File.join(app.source_dir, eponymous_directory_path)
72
75
  !!(File.exists?(full_path) && File.directory?(full_path))
73
76
  end
@@ -6,14 +6,14 @@ source 'http://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  group :development do
9
- gem "rake", "~> 0.9.2"
10
- gem "rdoc", "~> 3.9"
11
- gem "yard", "~> 0.8.0"
9
+ gem "rake"
10
+ gem "rdoc"
11
+ gem "yard"
12
12
  end
13
13
 
14
14
  group :test do
15
- gem "cucumber", "~> 1.2.0"
15
+ gem "cucumber"
16
16
  gem "fivemat"
17
- gem "aruba", "~> 0.4.11"
18
- gem "rspec", "~> 2.7"
17
+ gem "aruba"
18
+ gem "rspec"
19
19
  end
@@ -1,2 +1,5 @@
1
1
  # Ignore bundler lock file
2
- Gemfile.lock
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
@@ -2,19 +2,16 @@
2
2
  require "middleman-core"
3
3
 
4
4
  # Extension namespace
5
- module MyExtension < Middleman::Extension
5
+ class MyExtension < ::Middleman::Extension
6
6
  option :my_option, "default", "An example option"
7
7
 
8
- def initialize(app, options_hash={})
8
+ def initialize(app, options_hash={}, &block)
9
9
  # Call super to build options from the options_hash
10
10
  super
11
11
 
12
12
  # Require libraries only when activated
13
13
  # require 'necessary/library'
14
14
 
15
- # Include helpers or instance methods for the Middleman app
16
- # app.send :include, Helpers
17
-
18
15
  # set up your extension
19
16
  # puts options.my_option
20
17
  end
@@ -23,7 +20,11 @@ module MyExtension < Middleman::Extension
23
20
  # Do something
24
21
  end
25
22
 
26
- # module Helpers
23
+ # A Sitemap Manipulator
24
+ # def manipulate_resource_list(resources)
25
+ # end
26
+
27
+ # module do
27
28
  # def a_helper
28
29
  # end
29
30
  # end
@@ -32,9 +33,7 @@ end
32
33
 
33
34
  # Register extensions which can be activated
34
35
  # Make sure we have the version of Middleman we expect
35
- # ::Middleman::Extensions.register(:extension_name) do
36
- #
37
- # # Return the extension class
38
- # ::MyExtension
39
- #
40
- # end
36
+ # Name param may be omited, it will default to underscored
37
+ # version of class name
38
+
39
+ # MyExtension.register(:my_extension)
@@ -4,6 +4,9 @@ source 'http://rubygems.org'
4
4
 
5
5
  gem "middleman", "~><%= Middleman::VERSION %>"
6
6
 
7
+ # Live-reloading plugin
8
+ gem "middleman-livereload"
9
+
7
10
  # For faster file watcher updates:
8
11
  # gem "rb-fsevent", "~> 0.9.3") # OS X
9
12
  # gem "rb-inotify", "~> 0.9.0") # Linux
@@ -2,10 +2,6 @@
2
2
  # Compass
3
3
  ###
4
4
 
5
- # Susy grids in Compass
6
- # First: gem install susy
7
- # require 'susy'
8
-
9
5
  # Change Compass configuration
10
6
  # compass_config do |config|
11
7
  # config.output_style = :compact
@@ -82,11 +78,6 @@ configure :build do
82
78
  # Use relative URLs
83
79
  # activate :relative_assets
84
80
 
85
- # Compress PNGs after build
86
- # First: gem install middleman-smusher
87
- # require "middleman-smusher"
88
- # activate :smusher
89
-
90
81
  # Or use a different image path
91
82
  # set :http_path, "/Content/images/"
92
83
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.1.0.beta.1' unless const_defined?(:VERSION)
4
+ VERSION = '3.1.0.beta.2' unless const_defined?(:VERSION)
5
5
  end
@@ -19,20 +19,18 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # Core
21
21
  s.add_dependency("bundler", ["~> 1.1"])
22
- s.add_dependency("rack", ["~> 1.4.1"])
22
+ s.add_dependency("rack", [">= 1.4.5"])
23
23
  s.add_dependency("tilt", ["~> 1.3.6"])
24
24
 
25
25
  # Builder
26
26
  s.add_dependency("rack-test", ["~> 0.6.1"])
27
27
 
28
28
  # CLI
29
- s.add_dependency("thor", ["~> 0.15.4"])
29
+ s.add_dependency("thor", ["~> 0.17.0"])
30
30
 
31
31
  # Helpers
32
32
  s.add_dependency("activesupport", ["~> 3.2.6"])
33
33
 
34
34
  # Watcher
35
- s.add_dependency("listen", ["~> 0.7.3"])
36
- # s.add_dependency("rb-fsevent", ["~> 0.9.3"]) # OS X
37
- # s.add_dependency("rb-inotify", ["~> 0.9.0"]) # Linux
35
+ s.add_dependency("listen", ["~> 1.0.2"])
38
36
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.beta.1
5
- prerelease: 6
4
+ version: 3.1.0.beta.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thomas Reynolds
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-04-14 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,23 +28,20 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rack
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ~>
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
- version: 1.4.1
34
+ version: 1.4.5
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ~>
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
- version: 1.4.1
41
+ version: 1.4.5
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: tilt
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ~>
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
@@ -63,7 +56,6 @@ dependencies:
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rack-test
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
60
  - - ~>
69
61
  - !ruby/object:Gem::Version
@@ -71,7 +63,6 @@ dependencies:
71
63
  type: :runtime
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
67
  - - ~>
77
68
  - !ruby/object:Gem::Version
@@ -79,23 +70,20 @@ dependencies:
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: thor
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
74
  - - ~>
85
75
  - !ruby/object:Gem::Version
86
- version: 0.15.4
76
+ version: 0.17.0
87
77
  type: :runtime
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
81
  - - ~>
93
82
  - !ruby/object:Gem::Version
94
- version: 0.15.4
83
+ version: 0.17.0
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: activesupport
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
88
  - - ~>
101
89
  - !ruby/object:Gem::Version
@@ -103,7 +91,6 @@ dependencies:
103
91
  type: :runtime
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
95
  - - ~>
109
96
  - !ruby/object:Gem::Version
@@ -111,19 +98,17 @@ dependencies:
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: listen
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
102
  - - ~>
117
103
  - !ruby/object:Gem::Version
118
- version: 0.7.3
104
+ version: 1.0.2
119
105
  type: :runtime
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
109
  - - ~>
125
110
  - !ruby/object:Gem::Version
126
- version: 0.7.3
111
+ version: 1.0.2
127
112
  description: A static site generator. Provides dozens of templating languages (Haml,
128
113
  Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache
129
114
  busting, Yaml data (and more) an easy part of your development cycle.
@@ -638,30 +623,26 @@ files:
638
623
  homepage: http://middlemanapp.com
639
624
  licenses:
640
625
  - MIT
626
+ metadata: {}
641
627
  post_install_message:
642
628
  rdoc_options: []
643
629
  require_paths:
644
630
  - lib
645
631
  required_ruby_version: !ruby/object:Gem::Requirement
646
- none: false
647
632
  requirements:
648
- - - ! '>='
633
+ - - '>='
649
634
  - !ruby/object:Gem::Version
650
635
  version: '0'
651
- segments:
652
- - 0
653
- hash: 4098219803529430260
654
636
  required_rubygems_version: !ruby/object:Gem::Requirement
655
- none: false
656
637
  requirements:
657
- - - ! '>'
638
+ - - '>'
658
639
  - !ruby/object:Gem::Version
659
640
  version: 1.3.1
660
641
  requirements: []
661
642
  rubyforge_project:
662
- rubygems_version: 1.8.24
643
+ rubygems_version: 2.0.0
663
644
  signing_key:
664
- specification_version: 3
645
+ specification_version: 4
665
646
  summary: Hand-crafted frontend development
666
647
  test_files:
667
648
  - features/3rd_party_cli.feature