middleman 2.0.0.rc3 → 2.0.0.rc4

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 +3 -4
  2. data/Rakefile +2 -14
  3. data/bin/mm-build +1 -1
  4. data/bin/mm-server +5 -3
  5. data/features/{w_asset_host.feature → asset_host.feature} +0 -0
  6. data/features/{x_automatic_image_sizes.feature → automatic_image_sizes.feature} +0 -0
  7. data/features/{y_cache_buster.feature → cache_buster.feature} +0 -0
  8. data/features/minify_css.feature +8 -8
  9. data/features/{z_relative_assets.feature → relative_assets.feature} +0 -0
  10. data/features/step_definitions/asset_host_steps.rb +6 -4
  11. data/features/step_definitions/middleman_steps.rb +8 -5
  12. data/features/step_definitions/page_layout_steps.rb +11 -7
  13. data/features/support/env.rb +3 -52
  14. data/fixtures/test-app/source/{front-matter.html.slim → front-matter.html.erb} +1 -1
  15. data/fixtures/test-app/source/stylesheets/auto-css.css +3 -0
  16. data/fixtures/test-app/source/stylesheets/auto-css/auto-css.css +3 -0
  17. data/fixtures/test-app/source/stylesheets/auto-css/sub/auto-css.css +3 -0
  18. data/lib/middleman.rb +12 -5
  19. data/lib/middleman/base.rb +156 -0
  20. data/lib/middleman/builder.rb +13 -12
  21. data/lib/middleman/config.ru +1 -1
  22. data/lib/middleman/core_extensions/compass.rb +11 -9
  23. data/lib/middleman/core_extensions/features.rb +17 -11
  24. data/lib/middleman/core_extensions/front_matter.rb +26 -20
  25. data/lib/middleman/core_extensions/rack_map.rb +2 -1
  26. data/lib/middleman/core_extensions/sprockets.rb +5 -3
  27. data/lib/middleman/features/blog.rb +2 -2
  28. data/lib/middleman/renderers/sass.rb +22 -20
  29. data/lib/middleman/templates/default/config.ru +1 -1
  30. data/lib/middleman/templates/html5/config.ru +1 -1
  31. data/lib/middleman/templates/xhtml/config.ru +1 -1
  32. data/lib/middleman/version.rb +1 -1
  33. data/middleman.gemspec +2 -1
  34. metadata +42 -32
  35. data/lib/middleman/features/live_reload.rb +0 -26
  36. data/lib/middleman/server.rb +0 -142
@@ -1,26 +0,0 @@
1
- module Middleman::Features::LiveReload
2
- class << self
3
- def registered(app)
4
- return unless Middleman::Server.development?
5
-
6
- begin
7
- require 'livereload'
8
- rescue LoadError
9
- puts "Livereload not available. Install it with: gem install livereload"
10
- end
11
-
12
- new_config = ::LiveReload::Config.new do |config|
13
- ::Tilt.mappings.each do |key, v|
14
- config.exts << key
15
- end
16
- end
17
-
18
- pid = fork {
19
- require 'livereload'
20
- ::LiveReload.run [Middleman::Server.views], new_config
21
- }
22
-
23
- end
24
- alias :included :registered
25
- end
26
- end
@@ -1,142 +0,0 @@
1
- # We're riding on Sinatra, so let's include it.
2
- require "sinatra/base"
3
-
4
- module Middleman
5
- class Server < Sinatra::Base
6
- class << self
7
- # Override Sinatra's set to accept a block
8
- # Specifically for the asset_host feature
9
- def set(option, value=self, &block)
10
- if block_given?
11
- value = Proc.new { block }
12
- end
13
-
14
- super(option, value, &nil)
15
- end
16
-
17
- # Convenience method to check if we're in build mode
18
- def build?; environment == :build; end
19
- end
20
-
21
- # Basic Sinatra config
22
- set :app_file, __FILE__
23
- set :root, ENV["MM_DIR"] || Dir.pwd
24
- set :sessions, false
25
- set :logging, false
26
- set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
27
-
28
- # Middleman-specific options
29
- set :index_file, "index.html" # What file responds to folder requests
30
- # Such as the homepage (/) or subfolders (/about/)
31
-
32
- # These directories are passed directly to Compass
33
- set :js_dir, "javascripts" # Where to look for javascript files
34
- set :css_dir, "stylesheets" # Where to look for CSS files
35
- set :images_dir, "images" # Where to look for images
36
- set :fonts_dir, "fonts" # Where to look for fonts
37
-
38
- set :build_dir, "build" # Which folder are builds output to
39
- set :http_prefix, nil # During build, add a prefix for absolute paths
40
-
41
- # Pass all request to Middleman, even "static" files
42
- set :static, false
43
-
44
- set :views, "source"
45
-
46
- # Add Rack::Builder.map to Sinatra
47
- register Middleman::CoreExtensions::RackMap
48
-
49
- # Activate custom features
50
- register Middleman::CoreExtensions::Features
51
-
52
- # Setup custom rendering
53
- register Middleman::CoreExtensions::Rendering
54
-
55
- # Compass framework
56
- register Middleman::CoreExtensions::Compass
57
-
58
- # Sprockets asset handling
59
- register Middleman::CoreExtensions::Sprockets
60
-
61
- # Setup asset path pipeline
62
- register Middleman::CoreExtensions::Assets
63
-
64
- # Activate built-in helpers
65
- register Middleman::CoreExtensions::DefaultHelpers
66
-
67
- # Activate Yaml Data package
68
- register Middleman::CoreExtensions::Data
69
-
70
- # with_layout and page routing
71
- register Middleman::CoreExtensions::Routing
72
-
73
- # Parse YAML from templates
74
- register Middleman::CoreExtensions::FrontMatter
75
-
76
- set :default_features, [
77
- :lorem
78
- ]
79
-
80
- # Default layout name
81
- set :layout, :layout
82
-
83
- # This will match all requests not overridden in the project's config.rb
84
- not_found do
85
- process_request
86
- end
87
-
88
- # See if Tilt cannot handle this file
89
- before do
90
- result = resolve_template(request.path_info, :raise_exceptions => false)
91
- if result
92
- extensionless_path, template_engine = result
93
-
94
- # Return static files
95
- if !::Tilt.mappings.has_key?(template_engine.to_s)
96
- content_type mime_type(File.extname(request.path_info)), :charset => 'utf-8'
97
- status 200
98
- send_file File.join(Middleman::Server.views, request.path_info)
99
- request["already_sent"] = true
100
- end
101
- else
102
- $stderr.puts "File not found: #{request.path_info}"
103
- status 404
104
- request["already_sent"] = true
105
- end
106
- end
107
-
108
- private
109
- # Internal method to look for templates and evaluate them if found
110
- def process_request(options={})
111
- return if request["already_sent"]
112
-
113
- options.merge!(request['custom_options'] || {})
114
-
115
- old_layout = settings.layout
116
- settings.set :layout, options[:layout] if !options[:layout].nil?
117
-
118
- layout = if settings.layout
119
- if options[:layout] == false || request.path_info =~ /\.(css|js)$/
120
- false
121
- else
122
- settings.fetch_layout_path(settings.layout).to_sym
123
- end
124
- else
125
- false
126
- end
127
-
128
- render_options = { :layout => layout }
129
- render_options[:layout_engine] = options[:layout_engine] if options.has_key? :layout_engine
130
- result = render(request.path_info, render_options)
131
- settings.set :layout, old_layout
132
-
133
- if result
134
- content_type mime_type(File.extname(request.path_info)), :charset => 'utf-8'
135
- status 200
136
- body result
137
- else
138
- status 404
139
- end
140
- end
141
- end
142
- end