middleman 0.9.0.pre → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -0
- data/.gitignore +2 -3
- data/LICENSE +0 -0
- data/README.rdoc +0 -4
- data/Rakefile +36 -26
- data/VERSION +1 -1
- data/bin/mm-build +54 -3
- data/bin/mm-init +8 -11
- data/bin/mm-server +4 -56
- data/deps.rip +7 -0
- data/lib/middleman.rb +1 -5
- data/lib/middleman/base.rb +98 -120
- data/lib/middleman/builder.rb +8 -55
- data/lib/middleman/features/cache_buster.rb +7 -41
- data/lib/middleman/features/compass.rb +28 -0
- data/lib/middleman/features/content_for.rb +9 -0
- data/lib/middleman/features/growl.rb +2 -0
- data/lib/middleman/features/haml.rb +128 -0
- data/lib/middleman/features/markaby.rb +43 -0
- data/lib/middleman/features/maruku.rb +42 -0
- data/lib/middleman/features/minify_css.rb +2 -9
- data/lib/middleman/features/minify_javascript.rb +24 -13
- data/lib/middleman/features/relative_assets.rb +14 -21
- data/lib/middleman/features/slickmap.rb +4 -117
- data/lib/middleman/features/sprockets+ruby19.rb +29 -0
- data/lib/middleman/features/sprockets.rb +29 -0
- data/lib/middleman/helpers.rb +47 -0
- data/lib/middleman/template/init.rb +22 -0
- data/lib/middleman/template/views/index.haml +1 -0
- data/lib/middleman/template/views/layout.haml +4 -11
- data/lib/middleman/template/views/stylesheets/site.sass +1 -0
- data/middleman.gemspec +53 -109
- data/spec/builder_spec.rb +19 -16
- data/spec/fixtures/sample/init.rb +2 -28
- data/spec/fixtures/sample/public/javascripts/empty-with-include.js +1 -0
- data/spec/fixtures/sample/public/javascripts/to-be-included.js +1 -0
- data/spec/fixtures/sample/public/static.html +0 -0
- data/spec/fixtures/sample/public/stylesheets/static.css +0 -0
- data/spec/fixtures/sample/views/_partial.haml +0 -0
- data/spec/fixtures/sample/views/index.html.haml +0 -0
- data/spec/fixtures/sample/views/inline-js.html.haml +0 -0
- data/spec/fixtures/sample/views/layout.haml +1 -1
- data/spec/fixtures/sample/views/markaby.html.mab +5 -0
- data/spec/fixtures/sample/views/maruku.html.maruku +0 -0
- data/spec/fixtures/sample/views/services/index.html.haml +0 -0
- data/spec/fixtures/sample/views/stylesheets/site.css.sass +1 -1
- data/spec/generator_spec.rb +34 -0
- data/spec/spec_helper.rb +5 -3
- metadata +72 -288
- data/features/asset_host.feature +0 -12
- data/features/automatic_image_sizes.feature +0 -14
- data/features/cache_buster.feature +0 -22
- data/features/generator.feature +0 -8
- data/features/minify_css.feature +0 -22
- data/features/minify_javascript.feature +0 -12
- data/features/page_alias_and_layouts.feature +0 -12
- data/features/relative_assets.feature +0 -12
- data/features/step_definitions/asset_host_steps.rb +0 -7
- data/features/step_definitions/env.rb +0 -3
- data/features/step_definitions/generator_steps.rb +0 -24
- data/features/step_definitions/middleman_steps.rb +0 -28
- data/features/step_definitions/page_layout_steps.rb +0 -13
- data/lib/middleman/assets.rb +0 -33
- data/lib/middleman/config.ru +0 -2
- data/lib/middleman/features.rb +0 -39
- data/lib/middleman/features/asset_host.rb +0 -21
- data/lib/middleman/features/automatic_image_sizes.rb +0 -31
- data/lib/middleman/features/automatic_image_sizes/fastimage.rb +0 -282
- data/lib/middleman/features/default_helpers.rb +0 -68
- data/lib/middleman/features/livereload.rb +0 -19
- data/lib/middleman/features/minify_javascript/rack.rb +0 -31
- data/lib/middleman/features/smush_pngs.rb +0 -38
- data/lib/middleman/features/ugly_haml.rb +0 -7
- data/lib/middleman/renderers.rb +0 -26
- data/lib/middleman/renderers/coffee.rb +0 -28
- data/lib/middleman/renderers/haml.rb +0 -47
- data/lib/middleman/renderers/sass.rb +0 -67
- data/lib/middleman/template/init.rbt +0 -57
- data/lib/middleman/template/views/index.html.haml +0 -4
- data/lib/middleman/template/views/stylesheets/site.css.sass +0 -27
- data/lib/middleman/templater+dynamic_renderer.rb +0 -26
- data/spec/fixtures/sample/public/images/blank.gif +0 -0
- data/spec/fixtures/sample/public/stylesheets/auto-css.css +0 -0
- data/spec/fixtures/sample/public/stylesheets/sub1/auto-css.css +0 -0
- data/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css +0 -0
- data/spec/fixtures/sample/views/asset_host.html.haml +0 -1
- data/spec/fixtures/sample/views/auto-css.html.haml +0 -1
- data/spec/fixtures/sample/views/auto-image-sizes.html.haml +0 -1
- data/spec/fixtures/sample/views/cache-buster.html.haml +0 -2
- data/spec/fixtures/sample/views/custom-layout.html.haml +0 -1
- data/spec/fixtures/sample/views/custom.haml +0 -5
- data/spec/fixtures/sample/views/inline-css.html.haml +0 -4
- data/spec/fixtures/sample/views/page-classes.html.haml +0 -1
- data/spec/fixtures/sample/views/stylesheets/asset_host.css.sass +0 -3
- data/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass +0 -3
- data/spec/fixtures/sample/views/stylesheets/site_scss.css.scss +0 -1
- data/spec/fixtures/sample/views/stylesheets/test_less.css.less +0 -5
- data/spec/helpers_spec.rb +0 -43
data/lib/middleman/builder.rb
CHANGED
@@ -1,59 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require 'templater'
|
3
|
-
require 'middleman/templater+dynamic_renderer.rb'
|
1
|
+
require 'rack/test'
|
4
2
|
|
5
|
-
# Placeholder for any methods the builder needs to abstract to allow feature integration
|
6
3
|
module Middleman
|
7
|
-
class Builder
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def destination_root; File.join(Dir.pwd, Middleman::Base.build_dir); end
|
14
|
-
|
15
|
-
# Override template to ask middleman for the correct extension to output
|
16
|
-
def self.template(name, *args, &block)
|
17
|
-
return if args[0].include?('layout')
|
18
|
-
|
19
|
-
args.first.split('/').each do |part|
|
20
|
-
return if part[0,1] == '_'
|
21
|
-
end
|
22
|
-
|
23
|
-
if (args[0] === args[1])
|
24
|
-
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "").gsub("#{File.basename(Middleman::Base.public)}/", "")
|
25
|
-
if File.extname(args[1]) != ".js"
|
26
|
-
args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
super(name, *args, &block)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.file(name, *args, &block)
|
34
|
-
file_ext = File.extname(args[0])
|
35
|
-
|
36
|
-
return unless ::Tilt[file_ext].nil?
|
37
|
-
|
38
|
-
if (args[0] === args[1])
|
39
|
-
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "").gsub("#{File.basename(Middleman::Base.public)}/", "")
|
40
|
-
end
|
41
|
-
super(name, *args, &block)
|
4
|
+
class Builder
|
5
|
+
def self.render_file(source, destination)
|
6
|
+
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
|
7
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
|
8
|
+
browser.get(request_path)
|
9
|
+
browser.last_response.body
|
42
10
|
end
|
43
|
-
|
44
|
-
def self.init!
|
45
|
-
glob! File.basename(Middleman::Base.public), @@template_extensions
|
46
|
-
glob! File.basename(Middleman::Base.views), @@template_extensions
|
47
|
-
end
|
48
|
-
|
49
|
-
def after_run
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
module Generators
|
54
|
-
extend ::Templater::Manifold
|
55
|
-
desc "Build a static site"
|
56
|
-
|
57
|
-
add :build, ::Middleman::Builder
|
58
11
|
end
|
59
|
-
end
|
12
|
+
end
|
@@ -1,43 +1,9 @@
|
|
1
|
-
class Middleman::Features::CacheBuster
|
2
|
-
def initialize(app)
|
3
|
-
Middleman::Assets.register :cache_buster do |path, prefix, request|
|
4
|
-
http_path = Middleman::Assets.before(:cache_buster, path, prefix, request)
|
5
1
|
|
6
|
-
if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
|
7
|
-
http_path
|
8
|
-
else
|
9
|
-
begin
|
10
|
-
prefix = Middleman::Base.images_dir if prefix == Middleman::Base.http_images_path
|
11
|
-
rescue
|
12
|
-
end
|
13
2
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
http_path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
Middleman::Base.after_feature_init do
|
28
|
-
::Compass.configuration do |config|
|
29
|
-
config.asset_cache_buster do |path, real_path|
|
30
|
-
real_path = real_path.path if real_path.is_a? File
|
31
|
-
real_path = real_path.gsub(File.join(Middleman::Base.root, Middleman::Base.build_dir), Middleman::Base.public)
|
32
|
-
if File.readable?(real_path)
|
33
|
-
File.mtime(real_path).strftime("%s")
|
34
|
-
else
|
35
|
-
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Middleman::Features.register :cache_buster, Middleman::Features::CacheBuster
|
3
|
+
# def cache_buster
|
4
|
+
# if File.readable?(real_path)
|
5
|
+
# File.mtime(real_path).strftime("%s")
|
6
|
+
# else
|
7
|
+
# $stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
|
8
|
+
# end
|
9
|
+
# end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'compass'
|
2
|
+
|
3
|
+
class Middleman::Base
|
4
|
+
configure do
|
5
|
+
::Compass.configuration do |config|
|
6
|
+
images_location = (self.environment == "build") ? self.build_dir : self.public
|
7
|
+
|
8
|
+
config.project_path = Dir.pwd
|
9
|
+
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
10
|
+
config.output_style = self.minify_css? ? :compressed : :nested
|
11
|
+
config.css_dir = File.join(File.basename(images_location), self.css_dir)
|
12
|
+
config.images_dir = File.join(File.basename(images_location), self.images_dir)
|
13
|
+
# File.expand_path(self.images_dir, self.public)
|
14
|
+
|
15
|
+
if !cache_buster?
|
16
|
+
config.asset_cache_buster do
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
config.http_images_path = "/#{self.images_dir}"
|
22
|
+
config.http_stylesheets_path = "/#{self.css_dir}"
|
23
|
+
config.add_import_path(config.sass_dir)
|
24
|
+
end
|
25
|
+
|
26
|
+
::Compass.configure_sass_plugin!
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module Middleman
|
2
|
+
module Haml
|
3
|
+
def self.included(base)
|
4
|
+
base.supported_formats << "haml"
|
5
|
+
base.helpers Middleman::HamlHelpers
|
6
|
+
end
|
7
|
+
|
8
|
+
def render_path(path)
|
9
|
+
if template_exists?(path, :haml)
|
10
|
+
result = nil
|
11
|
+
begin
|
12
|
+
result = haml(path.to_sym, :layout => File.extname(path) != ".xml")
|
13
|
+
rescue ::Haml::Error => e
|
14
|
+
result = "Haml Error: #{e}"
|
15
|
+
result << "<pre>Backtrace: #{e.backtrace.join("\n")}</pre>"
|
16
|
+
end
|
17
|
+
result
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module HamlHelpers
|
25
|
+
def haml_partial(name, options = {})
|
26
|
+
item_name = name.to_sym
|
27
|
+
counter_name = "#{name}_counter".to_sym
|
28
|
+
if collection = options.delete(:collection)
|
29
|
+
collection.enum_for(:each_with_index).collect do |item,index|
|
30
|
+
haml_partial name, options.merge(:locals => {item_name => item, counter_name => index+1})
|
31
|
+
end.join
|
32
|
+
elsif object = options.delete(:object)
|
33
|
+
haml_partial name, options.merge(:locals => {item_name => object, counter_name => nil})
|
34
|
+
else
|
35
|
+
haml "_#{name}".to_sym, options.merge(:layout => false)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Table
|
41
|
+
include ::Haml::Filters::Base
|
42
|
+
|
43
|
+
def render(text)
|
44
|
+
output = '<div class="table"><table cellspacing="0" cellpadding="0">'
|
45
|
+
line_num = 0
|
46
|
+
text.each_line do |line|
|
47
|
+
line_num += 1
|
48
|
+
next if line.strip.empty?
|
49
|
+
output << %Q{<tr class="#{(line_num % 2 == 0) ? "even" : "odd" }#{(line_num == 1) ? " first" : "" }">}
|
50
|
+
|
51
|
+
columns = line.split("|").map { |p| p.strip }
|
52
|
+
columns.each_with_index do |col, i|
|
53
|
+
output << %Q{<td class="col#{i+1}">#{col}</td>}
|
54
|
+
end
|
55
|
+
|
56
|
+
output << "</tr>"
|
57
|
+
end
|
58
|
+
output + "</table></div>"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
module Sass
|
63
|
+
def self.included(base)
|
64
|
+
base.supported_formats << "sass"
|
65
|
+
end
|
66
|
+
|
67
|
+
def render_path(path)
|
68
|
+
if template_exists?(path, :sass)
|
69
|
+
begin
|
70
|
+
static_version = options.public + request.path_info
|
71
|
+
send_file(static_version) if File.exists? static_version
|
72
|
+
|
73
|
+
location_of_sass_file = options.environment == "build" ? "build" : "views"
|
74
|
+
css_filename = File.join(Dir.pwd, location_of_sass_file) + request.path_info
|
75
|
+
sass(path.to_sym, Compass.sass_engine_options.merge({ :css_filename => css_filename }))
|
76
|
+
rescue Exception => e
|
77
|
+
sass_exception_string(e)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
super
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Handle Sass errors
|
85
|
+
def sass_exception_string(e)
|
86
|
+
e_string = "#{e.class}: #{e.message}"
|
87
|
+
|
88
|
+
if e.is_a? ::Sass::SyntaxError
|
89
|
+
e_string << "\non line #{e.sass_line}"
|
90
|
+
|
91
|
+
if e.sass_filename
|
92
|
+
e_string << " of #{e.sass_filename}"
|
93
|
+
|
94
|
+
if File.exists?(e.sass_filename)
|
95
|
+
e_string << "\n\n"
|
96
|
+
|
97
|
+
min = [e.sass_line - 5, 0].max
|
98
|
+
begin
|
99
|
+
File.read(e.sass_filename).rstrip.split("\n")[
|
100
|
+
min .. e.sass_line + 5
|
101
|
+
].each_with_index do |line, i|
|
102
|
+
e_string << "#{min + i + 1}: #{line}\n"
|
103
|
+
end
|
104
|
+
rescue
|
105
|
+
e_string << "Couldn't read sass file: #{e.sass_filename}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
<<END
|
111
|
+
/*
|
112
|
+
#{e_string}
|
113
|
+
|
114
|
+
Backtrace:\n#{e.backtrace.join("\n")}
|
115
|
+
*/
|
116
|
+
body:before {
|
117
|
+
white-space: pre;
|
118
|
+
font-family: monospace;
|
119
|
+
content: "#{e_string.gsub('"', '\"').gsub("\n", '\\A ')}"; }
|
120
|
+
END
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class Middleman::Base
|
126
|
+
include Middleman::Haml
|
127
|
+
include Middleman::Sass
|
128
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
begin
|
2
|
+
require 'markaby'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Markaby not available. Install it with: gem install markaby"
|
5
|
+
end
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
module Markaby
|
9
|
+
def self.included(base)
|
10
|
+
base.supported_formats << "mab"
|
11
|
+
end
|
12
|
+
|
13
|
+
def render_path(path)
|
14
|
+
if template_exists?(path, :mab)
|
15
|
+
markaby path.to_sym
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def markaby(template=nil, options={}, locals = {}, &block)
|
22
|
+
options, template = template, nil if template.is_a?(Hash)
|
23
|
+
template = lambda { block } if template.nil?
|
24
|
+
render :mab, template, options, locals
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
def render_mab(template, data, options, locals, &block)
|
29
|
+
filename = options.delete(:filename) || '<MARKABY>'
|
30
|
+
line = options.delete(:line) || 1
|
31
|
+
mab = ::Markaby::Builder.new(locals)
|
32
|
+
if data.respond_to?(:to_str)
|
33
|
+
eval(data.to_str, binding, filename, line)
|
34
|
+
elsif data.kind_of?(Proc)
|
35
|
+
data.call(mab)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Base
|
41
|
+
include Middleman::Markaby
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
begin
|
2
|
+
require 'maruku'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Maruku not available. Install it with: gem install maruku"
|
5
|
+
end
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
module Maruku
|
9
|
+
def self.included(base)
|
10
|
+
base.supported_formats << "maruku"
|
11
|
+
end
|
12
|
+
|
13
|
+
def render_path(path)
|
14
|
+
if template_exists?(path, :maruku)
|
15
|
+
maruku path.to_sym
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def maruku(template, options={}, locals={})
|
22
|
+
render :maruku, template, options, locals
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def render_maruku(data, options, locals, &block)
|
27
|
+
maruku_src = render_erb(data, options, locals, &block)
|
28
|
+
instance = ::Maruku.new(maruku_src, options)
|
29
|
+
if block_given?
|
30
|
+
# render layout
|
31
|
+
instance.to_html_document
|
32
|
+
else
|
33
|
+
# render template
|
34
|
+
instance.to_html
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Base
|
40
|
+
include Middleman::Maruku
|
41
|
+
end
|
42
|
+
end
|
@@ -1,9 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Middleman::Base.after_feature_init do
|
4
|
-
::Compass.configuration.output_style = :compressed
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
Middleman::Features.register :minify_css, Middleman::Features::MinifyCSS
|
1
|
+
# Otherwise use YUI
|
2
|
+
# Fine a way to minify inline/css
|
@@ -1,20 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require "middleman/features/minify_javascript/rack"
|
6
|
-
app.use Middleman::Rack::MinifyJavascript
|
7
|
-
end
|
8
|
-
|
9
|
-
module Haml
|
1
|
+
require "yui/compressor"
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Minified
|
10
5
|
module Javascript
|
6
|
+
include ::Haml::Filters::Base
|
11
7
|
def render_with_options(text, options)
|
12
8
|
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
13
9
|
data = compressor.compress(text)
|
14
|
-
|
10
|
+
<<END
|
11
|
+
<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>
|
12
|
+
END
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
|
17
|
+
module Compressor
|
18
|
+
def render_path(path)
|
19
|
+
if template_exists?(path, :js)
|
20
|
+
compressor = YUI::JavaScriptCompressor.new(:munge => true)
|
21
|
+
compressor.compress(super)
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Base
|
29
|
+
include Middleman::Compressor
|
30
|
+
end
|
31
|
+
end
|
@@ -1,35 +1,28 @@
|
|
1
|
-
class Middleman::
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
begin
|
7
|
-
prefix = Middleman::Base.images_dir if prefix == Middleman::Base.http_images_path
|
8
|
-
rescue
|
1
|
+
class Middleman::Base
|
2
|
+
if compass?
|
3
|
+
configure do
|
4
|
+
::Compass.configuration do |config|
|
5
|
+
config.relative_assets = true
|
9
6
|
end
|
10
|
-
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
helpers do
|
11
|
+
def asset_url(path)
|
11
12
|
if path.include?("://")
|
12
|
-
Middleman::Assets.before(:relative_assets, path, prefix, request)
|
13
|
-
elsif path[0,1] == "/"
|
14
13
|
path
|
15
14
|
else
|
16
|
-
path = File.join(prefix, path) if prefix.length > 0
|
17
15
|
request_path = request.path_info.dup
|
18
|
-
request_path <<
|
16
|
+
request_path << "index.html" if path.match(%r{/$})
|
19
17
|
request_path.gsub!(%r{^/}, '')
|
20
18
|
parts = request_path.split('/')
|
21
|
-
|
19
|
+
|
22
20
|
if parts.length > 1
|
23
|
-
|
24
|
-
(parts.length - 1).times { arry << ".." }
|
25
|
-
arry << path
|
26
|
-
File.join(*arry)
|
21
|
+
"../" * (parts.length - 1) + path
|
27
22
|
else
|
28
23
|
path
|
29
24
|
end
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
33
|
-
end
|
34
|
-
|
35
|
-
Middleman::Features.register :relative_assets, Middleman::Features::RelativeAssets
|
28
|
+
end
|