middleman 0.99.1.pre → 0.99.2.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +9 -17
- data/VERSION +1 -1
- data/features/builder.feature +16 -0
- data/features/coffee-script.feature +7 -0
- data/features/helpers_auto_stylesheet_link_tag.feature +17 -0
- data/features/helpers_page_classes.feature +17 -0
- data/features/less-css.feature +7 -0
- data/features/padrino_helpers.feature +10 -0
- data/features/scss-support.feature +7 -0
- data/features/step_definitions/asset_host_steps.rb +1 -1
- data/features/step_definitions/builder_steps.rb +45 -0
- data/features/step_definitions/env.rb +1 -1
- data/features/step_definitions/generator_steps.rb +9 -3
- data/features/step_definitions/middleman_steps.rb +8 -6
- data/features/step_definitions/page_layout_steps.rb +2 -2
- data/features/{asset_host.feature → w_asset_host.feature} +0 -0
- data/features/{automatic_image_sizes.feature → x_automatic_image_sizes.feature} +0 -0
- data/features/{cache_buster.feature → y_cache_buster.feature} +0 -0
- data/features/{relative_assets.feature → z_relative_assets.feature} +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/config.rb +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/images/blank.gif +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/static.html +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/auto-css.css +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/static.css +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/sub1/auto-css.css +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/sub1/sub2/auto-css.css +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/_partial.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/asset_host.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/auto-css.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/auto-image-sizes.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/cache-buster.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/custom-layout.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/index.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/inline-css.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/inline-js.html.haml +0 -0
- data/fixtures/test-app/views/javascripts/coffee_test.js.coffee +3 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/layout.haml +0 -0
- data/{spec/fixtures/sample/views → fixtures/test-app/views/layouts}/custom.haml +0 -0
- data/fixtures/test-app/views/padrino_test.html.haml +5 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/page-classes.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/services/index.html.haml +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/asset_host.css.sass +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/relative_assets.css.sass +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/site.css.sass +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/site_scss.css.scss +0 -0
- data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/test_less.css.less +0 -0
- data/lib/middleman.rb +9 -1
- data/lib/middleman/features.rb +29 -36
- data/lib/middleman/features/asset_host.rb +16 -15
- data/lib/middleman/features/automatic_image_sizes.rb +26 -24
- data/lib/middleman/features/cache_buster.rb +34 -33
- data/lib/middleman/features/default_helpers.rb +26 -33
- data/lib/middleman/features/livereload.rb +1 -1
- data/lib/middleman/features/minify_css.rb +8 -7
- data/lib/middleman/features/minify_javascript.rb +11 -10
- data/lib/middleman/features/relative_assets.rb +30 -29
- data/lib/middleman/features/slickmap.rb +43 -42
- data/lib/middleman/features/smush_pngs.rb +29 -29
- data/lib/middleman/features/ugly_haml.rb +7 -6
- data/lib/middleman/renderers/{coffee.rb → coffee_script.rb} +11 -8
- data/lib/middleman/renderers/haml.rb +28 -33
- data/lib/middleman/renderers/sass.rb +30 -28
- data/lib/middleman/server.rb +44 -49
- data/lib/middleman/template/config.rbt +6 -6
- data/middleman.gemspec +49 -50
- metadata +79 -75
- data/lib/middleman/renderers.rb +0 -26
- data/spec/builder_spec.rb +0 -62
- data/spec/fixtures/sample/views/maruku.html.maruku +0 -1
- data/spec/helpers_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -8
@@ -1,38 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Middleman::Features::SmushPNGs
|
2
|
+
class << self
|
3
|
+
def registered(app)
|
4
|
+
require "middleman/builder"
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
app.alias_method :pre_smush_after_run, :after_run
|
7
|
+
app.define_method :after_run do
|
8
|
+
pre_smush_after_run
|
9
|
+
smush_dir = File.join(Middleman::Server.build_dir, Middleman::Server.images_dir)
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
# Read cache
|
12
|
+
cache_file = File.join(Middleman::Server.root, ".smush-cache")
|
13
|
+
cache_data = if File.exists?(cache_file)
|
14
|
+
Marshal.restore(File.read(cache_file))
|
15
|
+
else
|
16
|
+
{}
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
require "smusher"
|
20
|
+
require "json/pure"
|
21
|
+
::Smusher.class_eval do
|
22
|
+
images_in_folder(smush_dir).each do |file|
|
23
|
+
original_file_size = size(file)
|
24
|
+
return if original_file_size.zero?
|
25
|
+
return if cache_data[file] && cache_data[file] == original_file_size
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
with_logging(file, true) do
|
28
|
+
write_optimized_data(file)
|
29
|
+
cache_data[file] = size(file) # Add or update cache
|
30
|
+
File.open(cache_file, "w") { |f| f.write Marshal.dump(cache_data) } # Write cache
|
31
|
+
say "<%= color('#{"[SMUSHED]".rjust(12)}', :yellow) %> " + file.gsub(Middleman::Server.build_dir+"/", '')
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
36
|
-
end
|
37
|
-
|
38
|
-
Middleman::Features.register :smush_pngs, Middleman::Features::SmushPngs
|
38
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Middleman::Features::UglyHaml
|
2
|
+
class << self
|
3
|
+
def registered(app)
|
4
|
+
app.set :haml, app.settings.haml.merge({ :ugly_haml => true })
|
5
|
+
end
|
6
|
+
alias :included :registered
|
4
7
|
end
|
5
|
-
end
|
6
|
-
|
7
|
-
Middleman::Features.register :ugly_haml, Middleman::Features::UglyHaml
|
8
|
+
end
|
@@ -1,7 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Middleman
|
2
|
+
module Renderers
|
3
|
+
module CoffeeScript
|
4
|
+
class << self
|
5
|
+
def registered(app)
|
6
|
+
Tilt.register 'coffee', Tilt::CoffeeTemplate
|
7
|
+
end
|
8
|
+
alias :included :registered
|
9
|
+
end
|
10
|
+
end
|
5
11
|
end
|
6
12
|
end
|
7
13
|
|
@@ -22,7 +28,4 @@ unless defined? Tilt::CoffeeTemplate
|
|
22
28
|
@output ||= ::CoffeeScript::compile(data, options)
|
23
29
|
end
|
24
30
|
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
Middleman::Renderers.register(:coffee, Tilt::CoffeeTemplate)
|
31
|
+
end
|
@@ -1,47 +1,42 @@
|
|
1
1
|
require "haml"
|
2
2
|
|
3
3
|
module Middleman
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
haml "_#{name}".to_sym, options.merge(:layout => false)
|
4
|
+
module Renderers
|
5
|
+
module Haml
|
6
|
+
class << self
|
7
|
+
def registered(app)
|
8
|
+
app.helpers Middleman::Renderers::Haml::Helpers
|
9
|
+
end
|
10
|
+
alias :included :registered
|
11
|
+
end
|
12
|
+
|
13
|
+
module Helpers
|
14
|
+
def haml_partial(name, options = {})
|
15
|
+
partial(name, options)
|
17
16
|
end
|
18
17
|
end
|
19
|
-
end
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
module Table
|
20
|
+
include ::Haml::Filters::Base
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
def render(text)
|
23
|
+
output = '<div class="table"><table cellspacing="0" cellpadding="0">'
|
24
|
+
line_num = 0
|
25
|
+
text.each_line do |line|
|
26
|
+
line_num += 1
|
27
|
+
next if line.strip.empty?
|
28
|
+
output << %Q{<tr class="#{(line_num % 2 == 0) ? "even" : "odd" }#{(line_num == 1) ? " first" : "" }">}
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
columns = line.split("|").map { |p| p.strip }
|
31
|
+
columns.each_with_index do |col, i|
|
32
|
+
output << %Q{<td class="col#{i+1}">#{col}</td>}
|
33
|
+
end
|
36
34
|
|
37
|
-
|
35
|
+
output << "</tr>"
|
36
|
+
end
|
37
|
+
output + "</table></div>"
|
38
38
|
end
|
39
|
-
output + "</table></div>"
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class Middleman::Server
|
46
|
-
helpers Middleman::Haml::Helpers
|
47
42
|
end
|
@@ -1,32 +1,36 @@
|
|
1
1
|
require "sass"
|
2
2
|
require "compass"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Middleman
|
5
|
+
module Renderers
|
6
|
+
module Sass
|
7
|
+
class << self
|
8
|
+
def registered(app)
|
9
|
+
app.after_feature_init do
|
10
|
+
::Compass.configuration do |config|
|
11
|
+
config.cache_path = File.join(self.root, ".sass-cache") # For sassc files
|
12
|
+
config.project_path = self.root
|
13
|
+
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
14
|
+
config.output_style = :nested
|
15
|
+
config.fonts_dir = File.join(File.basename(self.public), self.fonts_dir)
|
16
|
+
config.css_dir = File.join(File.basename(self.public), self.css_dir)
|
17
|
+
config.images_dir = File.join(File.basename(self.public), self.images_dir)
|
18
|
+
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix || "/", self.images_dir)
|
19
|
+
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix || "/", self.css_dir)
|
20
|
+
config.asset_cache_buster { false }
|
9
21
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
config.add_import_path(config.sass_dir)
|
24
|
-
end
|
25
|
-
|
26
|
-
configure :build do
|
27
|
-
::Compass.configuration do |config|
|
28
|
-
config.css_dir = File.join(File.basename(self.build_dir), self.css_dir)
|
29
|
-
config.images_dir = File.join(File.basename(self.build_dir), self.images_dir)
|
22
|
+
config.add_import_path(config.sass_dir)
|
23
|
+
end
|
24
|
+
|
25
|
+
configure :build do
|
26
|
+
::Compass.configuration do |config|
|
27
|
+
config.css_dir = File.join(File.basename(self.build_dir), self.css_dir)
|
28
|
+
config.images_dir = File.join(File.basename(self.build_dir), self.images_dir)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
alias :included :registered
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -45,7 +49,6 @@ class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
Tilt.register 'sass', Tilt::SassPlusCSSFilenameTemplate
|
48
|
-
Middleman::Renderers.register(:sass, Tilt::SassPlusCSSFilenameTemplate)
|
49
52
|
|
50
53
|
class Tilt::ScssPlusCSSFilenameTemplate < Tilt::SassPlusCSSFilenameTemplate
|
51
54
|
def sass_options
|
@@ -53,10 +56,9 @@ class Tilt::ScssPlusCSSFilenameTemplate < Tilt::SassPlusCSSFilenameTemplate
|
|
53
56
|
end
|
54
57
|
end
|
55
58
|
Tilt.register 'scss', Tilt::ScssPlusCSSFilenameTemplate
|
56
|
-
Middleman::Renderers.register(:scss, Tilt::ScssPlusCSSFilenameTemplate)
|
57
59
|
|
58
60
|
|
59
|
-
module Middleman::Haml
|
61
|
+
module Middleman::Renderers::Haml
|
60
62
|
module Sass
|
61
63
|
include ::Haml::Filters::Base
|
62
64
|
|
data/lib/middleman/server.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# We're riding on Sinatra, so let's include it.
|
2
2
|
require "sinatra/base"
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
require "
|
7
|
-
|
8
|
-
# Monkey-patch Sinatra to expose the layout parameter
|
9
|
-
class Sinatra::Request
|
10
|
-
attr_accessor :layout
|
11
|
-
end
|
4
|
+
# Use the padrino project's helpers
|
5
|
+
require "padrino-core/application/rendering"
|
6
|
+
require "padrino-helpers"
|
12
7
|
|
13
8
|
module Middleman
|
14
9
|
class Server < Sinatra::Base
|
@@ -20,8 +15,7 @@ module Middleman
|
|
20
15
|
set :logging, false
|
21
16
|
set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
|
22
17
|
|
23
|
-
# Import
|
24
|
-
helpers Sinatra::ContentFor
|
18
|
+
# Import padrino helper methods
|
25
19
|
|
26
20
|
# Middleman-specific options
|
27
21
|
set :index_file, "index.html" # What file responds to folder requests
|
@@ -36,20 +30,18 @@ module Middleman
|
|
36
30
|
set :build_dir, "build" # Which folder are builds output to
|
37
31
|
set :http_prefix, nil # During build, add a prefix for absolute paths
|
38
32
|
|
39
|
-
#
|
40
|
-
|
33
|
+
# Use Padrino Helpers
|
34
|
+
register Padrino::Helpers
|
35
|
+
set :asset_stamp, false # Disable Padrino cache buster until explicitly enabled
|
41
36
|
|
42
|
-
#
|
43
|
-
|
44
|
-
@@enabled_features[feature_name] = config
|
45
|
-
super(feature_name)
|
46
|
-
end
|
37
|
+
# Activate custom features
|
38
|
+
register Middleman::Features
|
47
39
|
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
# Activate built-in helpers
|
41
|
+
register Middleman::Features::DefaultHelpers
|
42
|
+
|
43
|
+
# Tilt-aware renderer
|
44
|
+
register Padrino::Rendering
|
53
45
|
|
54
46
|
# Override Sinatra's set to accept a block
|
55
47
|
def self.set(option, value=self, &block)
|
@@ -68,37 +60,48 @@ module Middleman
|
|
68
60
|
@@run_after_features << block
|
69
61
|
end
|
70
62
|
|
63
|
+
# Activate custom renderers
|
64
|
+
register Middleman::Renderers::CoffeeScript
|
65
|
+
register Middleman::Renderers::Haml
|
66
|
+
register Middleman::Renderers::Sass
|
67
|
+
|
71
68
|
# Rack helper for adding mime-types during local preview
|
72
69
|
def self.mime(ext, type)
|
73
70
|
ext = ".#{ext}" unless ext.to_s[0] == ?.
|
74
71
|
::Rack::Mime::MIME_TYPES[ext.to_s] = type
|
75
72
|
end
|
76
73
|
|
77
|
-
#
|
78
|
-
|
74
|
+
# Default layout name
|
75
|
+
layout :layout
|
76
|
+
|
77
|
+
def self.current_layout
|
78
|
+
@layout
|
79
|
+
end
|
79
80
|
|
80
81
|
# Takes a block which allows many pages to have the same layout
|
81
82
|
# with_layout :admin do
|
82
83
|
# page "/admin/"
|
83
84
|
# page "/admin/login.html"
|
84
85
|
# end
|
85
|
-
def self.with_layout(
|
86
|
-
|
86
|
+
def self.with_layout(layout_name, &block)
|
87
|
+
old_layout = current_layout
|
88
|
+
|
89
|
+
layout(layout_name)
|
87
90
|
class_eval(&block) if block_given?
|
88
91
|
ensure
|
89
|
-
|
92
|
+
layout(old_layout)
|
90
93
|
end
|
91
94
|
|
92
95
|
# The page method allows the layout to be set on a specific path
|
93
96
|
# page "/about.html", :layout => false
|
94
97
|
# page "/", :layout => :homepage_layout
|
95
98
|
def self.page(url, options={}, &block)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
url << settings.index_file if url.match(%r{/$})
|
100
|
+
|
101
|
+
options[:layout] ||= current_layout
|
99
102
|
get(url) do
|
100
103
|
return yield if block_given?
|
101
|
-
process_request(
|
104
|
+
process_request(options)
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
@@ -109,20 +112,21 @@ module Middleman
|
|
109
112
|
|
110
113
|
private
|
111
114
|
# Internal method to look for templates and evaluate them if found
|
112
|
-
def process_request(
|
115
|
+
def process_request(options={})
|
113
116
|
# Normalize the path and add index if we're looking at a directory
|
114
117
|
path = request.path
|
115
118
|
path << settings.index_file if path.match(%r{/$})
|
116
119
|
path.gsub!(%r{^/}, '')
|
117
|
-
|
118
|
-
|
120
|
+
|
121
|
+
old_layout = settings.current_layout
|
122
|
+
settings.layout(options[:layout]) if !options[:layout].nil?
|
123
|
+
result = render(path, :layout => settings.fetch_layout_path.to_sym)
|
124
|
+
settings.layout(old_layout)
|
125
|
+
|
126
|
+
if result
|
119
127
|
content_type mime_type(File.extname(path)), :charset => 'utf-8'
|
120
|
-
|
121
|
-
|
122
|
-
if respond_to? renderer
|
123
|
-
status 200
|
124
|
-
return send(renderer, path.to_sym, { :layout => layout })
|
125
|
-
end
|
128
|
+
status 200
|
129
|
+
return result
|
126
130
|
end
|
127
131
|
|
128
132
|
status 404
|
@@ -131,8 +135,6 @@ module Middleman
|
|
131
135
|
end
|
132
136
|
|
133
137
|
require "middleman/assets"
|
134
|
-
require "middleman/renderers"
|
135
|
-
require "middleman/features"
|
136
138
|
|
137
139
|
# The Rack App
|
138
140
|
class Middleman::Server
|
@@ -152,13 +154,6 @@ class Middleman::Server
|
|
152
154
|
set :app_file, File.expand_path(local_config)
|
153
155
|
end
|
154
156
|
|
155
|
-
# loop over enabled feature
|
156
|
-
@@enabled_features.each do |feature_name, feature_config|
|
157
|
-
next unless send(:"#{feature_name}?")
|
158
|
-
$stderr.puts "== Enabling: #{feature_name.to_s.capitalize}" if logging?
|
159
|
-
Middleman::Features.run(feature_name, feature_config, self)
|
160
|
-
end
|
161
|
-
|
162
157
|
use ::Rack::ConditionalGet if environment == :development
|
163
158
|
|
164
159
|
@@run_after_features.each { |block| class_eval(&block) }
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Automatic sitemaps
|
2
|
-
#
|
2
|
+
# activate :slickmap
|
3
3
|
|
4
4
|
# Automatic image dimension calculations
|
5
|
-
#
|
5
|
+
# activate :automatic_image_sizes
|
6
6
|
|
7
7
|
# Per-page layout changes
|
8
8
|
# With no layout
|
@@ -41,16 +41,16 @@ set :images_dir, "<%= images_dir -%>"
|
|
41
41
|
# Build-specific configuration
|
42
42
|
configure :build do
|
43
43
|
# For example, change the Compass output style for deployment
|
44
|
-
#
|
44
|
+
# activate :minify_css
|
45
45
|
|
46
46
|
# Minify Javascript on build
|
47
|
-
#
|
47
|
+
# activate :minify_javascript
|
48
48
|
|
49
49
|
# Shrink/smush PNG/JPEGs on build
|
50
|
-
#
|
50
|
+
# activate :smush_pngs
|
51
51
|
|
52
52
|
# Enable cache buster
|
53
|
-
#
|
53
|
+
# activate :cache_buster
|
54
54
|
|
55
55
|
# Or use a different image path
|
56
56
|
# set :http_path, "/Content/images/"
|