middleman 0.14.1 → 0.99.0.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 +14 -18
- data/VERSION +1 -1
- data/features/automatic_image_sizes.feature +7 -7
- data/features/cache_buster.feature +10 -10
- data/features/minify_css.feature +10 -10
- data/features/minify_javascript.feature +6 -6
- data/features/step_definitions/asset_host_steps.rb +1 -0
- data/features/step_definitions/middleman_steps.rb +1 -1
- data/lib/middleman.rb +1 -18
- data/lib/middleman/assets.rb +33 -0
- data/lib/middleman/base.rb +25 -66
- data/lib/middleman/builder.rb +8 -4
- data/lib/middleman/features.rb +39 -0
- data/lib/middleman/features/asset_host.rb +16 -19
- data/lib/middleman/features/automatic_image_sizes.rb +24 -24
- data/lib/middleman/{fastimage.rb → features/automatic_image_sizes/fastimage.rb} +0 -0
- data/lib/middleman/features/cache_buster.rb +31 -38
- data/lib/middleman/{helpers.rb → features/default_helpers.rb} +8 -11
- data/lib/middleman/features/livereload.rb +19 -0
- data/lib/middleman/features/minify_css.rb +9 -0
- data/lib/middleman/features/minify_javascript.rb +15 -17
- data/lib/middleman/features/minify_javascript/rack.rb +31 -0
- data/lib/middleman/features/relative_assets.rb +29 -40
- data/lib/middleman/features/slickmap.rb +69 -70
- data/lib/middleman/features/smush_pngs.rb +8 -6
- data/lib/middleman/features/ugly_haml.rb +7 -0
- data/lib/middleman/renderers.rb +26 -0
- data/lib/middleman/renderers/coffee.rb +28 -0
- data/lib/middleman/renderers/haml.rb +2 -25
- data/lib/middleman/renderers/sass.rb +40 -87
- data/lib/middleman/template/init.rbt +30 -7
- data/middleman.gemspec +58 -69
- data/spec/builder_spec.rb +10 -4
- data/spec/fixtures/sample/views/stylesheets/site_scss.css.scss +1 -0
- data/spec/fixtures/sample/views/stylesheets/test_less.css.less +5 -0
- metadata +125 -113
- data/lib/middleman/rack/minify_css.rb +0 -25
- data/lib/middleman/rack/minify_javascript.rb +0 -25
- data/lib/middleman/rack/sprockets.rb +0 -61
- data/lib/middleman/renderers/builder.rb +0 -23
- data/lib/middleman/renderers/erb.rb +0 -24
- data/lib/middleman/renderers/less.rb +0 -23
- data/spec/fixtures/sample/public/javascripts/to-be-included.js +0 -1
- data/spec/fixtures/sample/views/javascripts/empty-with-include.js +0 -1
@@ -1,24 +1,21 @@
|
|
1
|
-
class Middleman::
|
2
|
-
|
3
|
-
::
|
4
|
-
|
1
|
+
class Middleman::Features::AssetHost
|
2
|
+
def initialize(app)
|
3
|
+
Middleman::Base.after_feature_init do
|
4
|
+
if Middleman::Base.asset_host.is_a?(Proc)
|
5
|
+
::Compass.configuration.asset_host(&Middleman::Base.asset_host)
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end if self.enabled?(:asset_host) && self.asset_host && self.asset_host.is_a?(Proc)
|
7
|
-
end
|
8
|
-
|
9
|
-
class << Middleman::Base
|
10
|
-
alias_method :pre_asset_host_asset_url, :asset_url
|
11
|
-
def asset_url(path, prefix="", request=nil)
|
12
|
-
original_output = pre_asset_host_asset_url(path, prefix, request)
|
13
|
-
|
14
|
-
valid_extensions = %w(.png .gif .jpg .jpeg .js .css)
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
9
|
+
Middleman::Assets.register :asset_host do |path, prefix, request|
|
10
|
+
original_output = Middleman::Assets.before(:asset_host, path, prefix, request)
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
valid_extensions = %w(.png .gif .jpg .jpeg .js .css)
|
13
|
+
|
14
|
+
asset_prefix = Middleman::Base.asset_host.call(original_output)
|
15
|
+
|
16
|
+
File.join(asset_prefix, original_output)
|
17
|
+
end
|
23
18
|
end
|
24
19
|
end
|
20
|
+
|
21
|
+
Middleman::Features.register :asset_host, Middleman::Features::AssetHost
|
@@ -1,31 +1,31 @@
|
|
1
|
-
|
1
|
+
class Middleman::Features::AutomaticImageSizes
|
2
|
+
def initialize(app)
|
3
|
+
require "middleman/features/automatic_image_sizes/fastimage"
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
if (!params[:width] || !params[:height]) && !path.include?("://")
|
12
|
-
params[:alt] ||= ""
|
13
|
-
http_prefix = settings.http_images_path rescue settings.images_dir
|
5
|
+
Middleman::Base.send :alias_method, :pre_automatic_image_tag, :image_tag
|
6
|
+
Middleman::Base.helpers do
|
7
|
+
def image_tag(path, params={})
|
8
|
+
if (!params[:width] || !params[:height]) && !path.include?("://")
|
9
|
+
params[:alt] ||= ""
|
10
|
+
http_prefix = settings.http_images_path rescue settings.images_dir
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
begin
|
13
|
+
real_path = File.join(settings.public, settings.images_dir, path)
|
14
|
+
if File.exists? real_path
|
15
|
+
dimensions = Middleman::FastImage.size(real_path, :raise_on_failure => true)
|
16
|
+
params[:width] ||= dimensions[0]
|
17
|
+
params[:height] ||= dimensions[1]
|
18
|
+
end
|
19
|
+
rescue
|
21
20
|
end
|
22
|
-
rescue
|
23
|
-
end
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
capture_haml { haml_tag(:img, params.merge(:src => asset_url(path, http_prefix))) }
|
23
|
+
else
|
24
|
+
pre_automatic_image_tag(path, params)
|
25
|
+
end
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
31
|
-
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Middleman::Features.register :automatic_image_sizes, Middleman::Features::AutomaticImageSizes
|
File without changes
|
@@ -1,50 +1,43 @@
|
|
1
|
-
class Middleman::
|
2
|
-
|
3
|
-
::
|
4
|
-
|
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
|
+
|
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
|
+
|
14
|
+
real_path_static = File.join(Middleman::Base.public, prefix, path)
|
15
|
+
|
16
|
+
if File.readable?(real_path_static)
|
17
|
+
http_path << "?" + File.mtime(real_path_static).strftime("%s")
|
18
|
+
elsif Middleman::Base.environment == "build"
|
19
|
+
real_path_dynamic = File.join(Middleman::Base.root, Middleman::Base.build_dir, prefix, path)
|
20
|
+
http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic)
|
21
|
+
end
|
22
|
+
|
23
|
+
http_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Middleman::Base.after_feature_init do
|
28
|
+
::Compass.configuration do |config|
|
5
29
|
config.asset_cache_buster do |path, real_path|
|
6
30
|
real_path = real_path.path if real_path.is_a? File
|
7
|
-
real_path = real_path.gsub(File.join(
|
31
|
+
real_path = real_path.gsub(File.join(Middleman::Base.root, Middleman::Base.build_dir), Middleman::Base.public)
|
8
32
|
if File.readable?(real_path)
|
9
33
|
File.mtime(real_path).strftime("%s")
|
10
34
|
else
|
11
35
|
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
|
12
36
|
end
|
13
37
|
end
|
14
|
-
else
|
15
|
-
config.asset_cache_buster { false }
|
16
38
|
end
|
17
39
|
end
|
18
|
-
|
19
|
-
::Compass.configure_sass_plugin!
|
20
40
|
end
|
21
41
|
end
|
22
|
-
|
23
|
-
|
24
|
-
alias_method :pre_cache_buster_asset_url, :asset_url
|
25
|
-
def asset_url(path, prefix="", request=nil)
|
26
|
-
http_path = pre_cache_buster_asset_url(path, prefix, request)
|
27
|
-
|
28
|
-
return http_path unless self.enabled?(:cache_buster)
|
29
|
-
|
30
|
-
if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
|
31
|
-
http_path
|
32
|
-
else
|
33
|
-
begin
|
34
|
-
prefix = self.images_dir if prefix == self.http_images_path
|
35
|
-
rescue
|
36
|
-
end
|
37
|
-
|
38
|
-
real_path_static = File.join(self.public, prefix, path)
|
39
|
-
|
40
|
-
if File.readable?(real_path_static)
|
41
|
-
http_path << "?" + File.mtime(real_path_static).strftime("%s")
|
42
|
-
elsif Middleman::Base.environment == "build"
|
43
|
-
real_path_dynamic = File.join(self.root, self.build_dir, prefix, path)
|
44
|
-
http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic)
|
45
|
-
end
|
46
|
-
|
47
|
-
http_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
42
|
+
|
43
|
+
Middleman::Features.register :cache_buster, Middleman::Features::CacheBuster
|
@@ -1,15 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
path.include?("://") ? path : File.join(self.http_prefix || "/", prefix, path)
|
5
|
-
end
|
1
|
+
class Middleman::Features::DefaultHelpers
|
2
|
+
def initialize(app)
|
3
|
+
Middleman::Base.helpers Helpers
|
6
4
|
end
|
7
5
|
|
8
6
|
module Helpers
|
9
|
-
def haml_partial(name, options = {})
|
10
|
-
haml name.to_sym, options.merge(:layout => false)
|
11
|
-
end
|
12
|
-
|
13
7
|
def auto_stylesheet_link_tag(separator="/")
|
14
8
|
path = request.path_info.dup
|
15
9
|
path << self.class.index_file if path.match(%r{/$})
|
@@ -19,8 +13,9 @@ module Middleman
|
|
19
13
|
|
20
14
|
css_file = File.join(self.class.public, self.class.css_dir, "#{path}.css")
|
21
15
|
sass_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.sass")
|
16
|
+
scss_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.scss")
|
22
17
|
|
23
|
-
if File.exists?(css_file) || File.exists?(sass_file)
|
18
|
+
if File.exists?(css_file) || File.exists?(sass_file) || File.exists?(scss_file)
|
24
19
|
stylesheet_link_tag "#{path}.css"
|
25
20
|
end
|
26
21
|
end
|
@@ -38,7 +33,7 @@ module Middleman
|
|
38
33
|
end
|
39
34
|
|
40
35
|
def asset_url(path, prefix="")
|
41
|
-
|
36
|
+
Middleman::Assets.get_url(path, prefix, request)
|
42
37
|
end
|
43
38
|
|
44
39
|
def link_to(title, url="#", params={})
|
@@ -69,3 +64,5 @@ module Middleman
|
|
69
64
|
end
|
70
65
|
end
|
71
66
|
end
|
67
|
+
|
68
|
+
Middleman::Features.register :default_helpers, Middleman::Features::DefaultHelpers, { :auto_enable => true }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Middleman::Features::LiveReload
|
2
|
+
def initialize(app)
|
3
|
+
return unless Middleman::Base.environment == :development
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'livereload'
|
7
|
+
rescue LoadError
|
8
|
+
puts "Livereload not available. Install it with: gem install livereload"
|
9
|
+
end
|
10
|
+
|
11
|
+
new_config = ::LiveReload::Config.new do |config|
|
12
|
+
config.exts = %w(haml sass scss coffee less builder)
|
13
|
+
end
|
14
|
+
|
15
|
+
::LiveReload.run [Middleman::Base.public, Middleman::Base.views], new_config
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Middleman::Features.register :livereload, Middleman::Features::LiveReload
|
@@ -1,22 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
class Middleman::Features::MinifyJavascript
|
2
|
+
def initialize(app)
|
3
|
+
Haml::Javascript.send :include, ::Haml::Filters::Base
|
4
|
+
|
5
|
+
require "middleman/features/minify_javascript/rack"
|
6
|
+
app.use Middleman::Rack::MinifyJavascript
|
7
|
+
end
|
8
|
+
|
9
|
+
module Haml
|
3
10
|
module Javascript
|
4
|
-
include ::Haml::Filters::Base
|
5
11
|
def render_with_options(text, options)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
%Q{<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>}
|
10
|
-
else
|
11
|
-
<<END
|
12
|
-
<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>
|
13
|
-
//<![CDATA[
|
14
|
-
#{text.rstrip.gsub("\n", "\n ")}
|
15
|
-
//]]>
|
16
|
-
</script>
|
17
|
-
END
|
18
|
-
end
|
12
|
+
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
13
|
+
data = compressor.compress(text)
|
14
|
+
%Q{<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>}
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
22
|
-
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Middleman::Features.register :minify_javascript, Middleman::Features::MinifyJavascript
|
@@ -0,0 +1,31 @@
|
|
1
|
+
begin
|
2
|
+
require "yui/compressor"
|
3
|
+
rescue LoadError
|
4
|
+
puts "YUI-Compressor not available. Install it with: gem install yui-compressor"
|
5
|
+
end
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
module Rack
|
9
|
+
|
10
|
+
class MinifyJavascript
|
11
|
+
def initialize(app, options={})
|
12
|
+
@app = app
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
status, headers, response = @app.call(env)
|
17
|
+
|
18
|
+
if env["PATH_INFO"].match(/\.js$/)
|
19
|
+
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
20
|
+
|
21
|
+
uncompressed_source = response.is_a?(::Rack::File) ? File.read(response.path) : response
|
22
|
+
response = compressor.compress(uncompressed_source)
|
23
|
+
headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
[status, headers, response]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -1,46 +1,35 @@
|
|
1
|
-
class Middleman::
|
2
|
-
|
3
|
-
::Compass.configuration
|
4
|
-
|
5
|
-
|
1
|
+
class Middleman::Features::RelativeAssets
|
2
|
+
def initialize(app)
|
3
|
+
::Compass.configuration.relative_assets = true
|
4
|
+
|
5
|
+
Middleman::Assets.register :relative_assets do |path, prefix, request|
|
6
|
+
begin
|
7
|
+
prefix = Middleman::Base.images_dir if prefix == Middleman::Base.http_images_path
|
8
|
+
rescue
|
6
9
|
end
|
7
|
-
end
|
8
|
-
|
9
|
-
::Compass.configure_sass_plugin!
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class << Middleman::Base
|
14
|
-
alias_method :pre_relative_asset_url, :asset_url
|
15
|
-
def asset_url(path, prefix="", request=nil)
|
16
|
-
if !self.enabled?(:relative_assets)
|
17
|
-
return pre_relative_asset_url(path, prefix, request)
|
18
|
-
end
|
19
|
-
|
20
|
-
begin
|
21
|
-
prefix = self.images_dir if prefix == self.http_images_path
|
22
|
-
rescue
|
23
|
-
end
|
24
10
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
path
|
29
|
-
else
|
30
|
-
path = File.join(prefix, path) if prefix.length > 0
|
31
|
-
request_path = request.path_info.dup
|
32
|
-
request_path << self.index_file if path.match(%r{/$})
|
33
|
-
request_path.gsub!(%r{^/}, '')
|
34
|
-
parts = request_path.split('/')
|
35
|
-
|
36
|
-
if parts.length > 1
|
37
|
-
arry = []
|
38
|
-
(parts.length - 1).times { arry << ".." }
|
39
|
-
arry << path
|
40
|
-
File.join(*arry)
|
41
|
-
else
|
11
|
+
if path.include?("://")
|
12
|
+
Middleman::Assets.before(:relative_assets, path, prefix, request)
|
13
|
+
elsif path[0,1] == "/"
|
42
14
|
path
|
15
|
+
else
|
16
|
+
path = File.join(prefix, path) if prefix.length > 0
|
17
|
+
request_path = request.path_info.dup
|
18
|
+
request_path << Middleman::Base.index_file if path.match(%r{/$})
|
19
|
+
request_path.gsub!(%r{^/}, '')
|
20
|
+
parts = request_path.split('/')
|
21
|
+
|
22
|
+
if parts.length > 1
|
23
|
+
arry = []
|
24
|
+
(parts.length - 1).times { arry << ".." }
|
25
|
+
arry << path
|
26
|
+
File.join(*arry)
|
27
|
+
else
|
28
|
+
path
|
29
|
+
end
|
43
30
|
end
|
44
31
|
end
|
45
32
|
end
|
46
|
-
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Middleman::Features.register :relative_assets, Middleman::Features::RelativeAssets
|
@@ -1,92 +1,91 @@
|
|
1
|
-
|
2
|
-
require 'slickmap'
|
3
|
-
::Compass.configure_sass_plugin!
|
4
|
-
rescue LoadError
|
5
|
-
puts "Slickmap not available. Install it with: gem install compass-slickmap"
|
6
|
-
end
|
1
|
+
Entry = Struct.new(:dir, :children)
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
class Middleman::Features::Slickmap
|
4
|
+
def initialize(app)
|
5
|
+
require 'slickmap'
|
11
6
|
|
12
|
-
|
7
|
+
if Middleman::Base.environment == "build"
|
8
|
+
Middleman::Builder.template :slickmap, "sitemap.html", "sitemap.html"
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def recurse_sitemap(path, &block)
|
21
|
-
bad_ext = path.split('.html')[1]
|
22
|
-
path = path.gsub(bad_ext, '') if bad_ext
|
23
|
-
entry = Entry.new(path, [])
|
11
|
+
def build_sitemap(&block)
|
12
|
+
@@utility = []
|
13
|
+
[recurse_sitemap(Middleman::Base.views, &block), @@utility]
|
14
|
+
end
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if
|
16
|
+
def recurse_sitemap(path, &block)
|
17
|
+
bad_ext = path.split('.html')[1]
|
18
|
+
path = path.gsub(bad_ext, '') if bad_ext
|
19
|
+
entry = Entry.new(path, [])
|
20
|
+
|
21
|
+
#no "." or ".." dirs
|
22
|
+
Dir[File.join(path, "*")].each do |e|
|
23
|
+
next if !File.directory?(e) && !e.include?(".html")
|
24
|
+
if File.directory?(e)
|
33
25
|
entry.children << recurse_sitemap(e, &block)
|
34
|
-
elsif
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
elsif block_given?
|
27
|
+
how_to_handle = block.call(e)
|
28
|
+
if how_to_handle == :valid
|
29
|
+
entry.children << recurse_sitemap(e, &block)
|
30
|
+
elsif how_to_handle == :utility
|
31
|
+
bad_ext = e.split('.html')[1]
|
32
|
+
e = e.gsub(bad_ext, '') if bad_ext
|
33
|
+
@@utility << e.gsub(Middleman::Base.views + "/", '')
|
34
|
+
end
|
38
35
|
end
|
39
36
|
end
|
40
|
-
end
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
else
|
55
|
-
haml_tag(:li, :id => first ? "home" : nil) do
|
56
|
-
if first
|
57
|
-
haml_concat link_to("Homepage", "/" + self.class.index_file)
|
58
|
-
else
|
59
|
-
# we are a dir
|
60
|
-
index = n.children.find { |c| c.dir.include?(self.class.index_file) }
|
61
|
-
haml_concat link_to(index.dir.gsub(self.class.views + "/", '').gsub("/" + File.basename(index.dir), '').capitalize, index.dir.gsub(self.class.views, ''))
|
38
|
+
entry
|
39
|
+
end
|
40
|
+
|
41
|
+
Middleman::Base.helpers do
|
42
|
+
def sitemap_node(n, first=false)
|
43
|
+
if n.children.length < 1
|
44
|
+
if !first && File.extname(n.dir).length > 0
|
45
|
+
haml_tag :li do
|
46
|
+
path = n.dir.gsub(self.class.views, '')
|
47
|
+
haml_concat link_to(File.basename(path), path)
|
48
|
+
end
|
62
49
|
end
|
63
|
-
|
64
|
-
|
65
|
-
if other_children.length > 0
|
50
|
+
else
|
51
|
+
haml_tag(:li, :id => first ? "home" : nil) do
|
66
52
|
if first
|
67
|
-
|
53
|
+
haml_concat link_to("Homepage", "/" + self.class.index_file)
|
68
54
|
else
|
69
|
-
|
55
|
+
# we are a dir
|
56
|
+
index = n.children.find { |c| c.dir.include?(self.class.index_file) }
|
57
|
+
haml_concat link_to(index.dir.gsub(self.class.views + "/", '').gsub("/" + File.basename(index.dir), '').capitalize, index.dir.gsub(self.class.views, ''))
|
58
|
+
end
|
59
|
+
|
60
|
+
other_children = n.children.select { |c| !c.dir.include?(self.class.index_file) }
|
61
|
+
if other_children.length > 0
|
62
|
+
if first
|
70
63
|
other_children.each { |i| sitemap_node(i) }
|
64
|
+
else
|
65
|
+
haml_tag :ul do
|
66
|
+
other_children.each { |i| sitemap_node(i) }
|
67
|
+
end
|
71
68
|
end
|
72
69
|
end
|
73
|
-
end
|
74
|
-
end
|
70
|
+
end
|
71
|
+
end
|
75
72
|
end
|
76
73
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
|
75
|
+
Middleman::Base.get '/sitemap.html' do
|
76
|
+
# Return :utility to put it util top menu. False to ignore
|
77
|
+
@tree, @utility = build_sitemap do |file_name|
|
78
|
+
:valid
|
79
|
+
end
|
80
|
+
haml :sitemap, :layout => false
|
83
81
|
end
|
84
|
-
haml :sitemap, :layout => false
|
85
|
-
end
|
86
82
|
|
87
|
-
|
83
|
+
Middleman::Base.use_in_file_templates!
|
84
|
+
end
|
88
85
|
end
|
89
86
|
|
87
|
+
Middleman::Features.register :slickmap, Middleman::Features::Slickmap
|
88
|
+
|
90
89
|
__END__
|
91
90
|
|
92
91
|
@@ sitemap
|
@@ -97,7 +96,7 @@ __END__
|
|
97
96
|
%title Sitemap
|
98
97
|
%style{ :type => "text/css" }
|
99
98
|
:sass
|
100
|
-
@import slickmap
|
99
|
+
@import "slickmap"
|
101
100
|
+slickmap
|
102
101
|
:javascript
|
103
102
|
window.onload = function() {
|