remove slickmap into own extension

This commit is contained in:
Thomas Reynolds 2011-04-20 13:16:12 -07:00
parent 856d1398c2
commit f237cf014a
8 changed files with 19 additions and 133 deletions

View file

@ -38,8 +38,9 @@ module Middleman
end
end
def source_paths
[
@source_paths ||= [
Middleman::Server.public,
Middleman::Server.views
]

View file

@ -60,10 +60,6 @@ module Middleman::Features
# MinifyJavascript uses the YUI compressor to shrink JS files
autoload :MinifyJavascript, "middleman/features/minify_javascript"
# Slickmap (http://astuteo.com/slickmap/) is a beautiful sitemap tool which
# will attempt to generate a `sitemap.html` file from your project.
autoload :Slickmap, "middleman/features/slickmap"
# CodeRay is a syntax highlighter.
autoload :CodeRay, "middleman/features/code_ray"

View file

@ -1,90 +0,0 @@
Entry = Struct.new(:dir, :children)
module Middleman::Features::Slickmap
class << self
def registered(app)
require 'slickmap'
@sitemap_url = "sitemap.html"
@sitemap_url = app.sitemap_url if app.respond_to?(:slickmap_url)
if app.environment == :build
Middleman::Builder.template :slickmap, @sitemap_url, @sitemap_url
end
app.helpers do
def sitemap_node(n, first=false)
if n.children.length < 1
if !first && File.extname(n.dir).length > 0
haml_tag :li do
path = n.dir.gsub(self.class.views, '')
haml_concat link_to(File.basename(path), path)
end
end
else
haml_tag(:li, :id => first ? "home" : nil) do
if first
haml_concat link_to("Homepage", "/" + self.class.index_file)
else
# we are a dir
index = n.children.find { |c| c.dir.include?(self.class.index_file) }
haml_concat link_to(index.dir.gsub(self.class.views + "/", '').gsub("/" + File.basename(index.dir), '').capitalize, index.dir.gsub(self.class.views, ''))
end
other_children = n.children.select { |c| !c.dir.include?(self.class.index_file) }
if other_children.length > 0
if first
other_children.each { |i| sitemap_node(i) }
else
haml_tag :ul do
other_children.each { |i| sitemap_node(i) }
end
end
end
end
end
end
end
app.get "/#{@sitemap_url}" do
# Return :utility to put it util top menu. False to ignore
@tree, @utility = Middleman::Features::Slickmap.build_sitemap do |file_name|
:valid
end
haml "template.html".to_sym, :layout => false, :views => File.expand_path(File.join(File.dirname(__FILE__), "slickmap"))
end
end
alias :included :registered
end
def self.build_sitemap(&block)
@@utility = []
[recurse_sitemap(Middleman::Server.views, &block), @@utility]
end
def self.recurse_sitemap(path, &block)
bad_ext = path.split('.html')[1]
path = path.gsub(bad_ext, '') if bad_ext
entry = Entry.new(path, [])
#no "." or ".." dirs
Dir[File.join(path, "*")].each do |e|
next if !File.directory?(e) && !e.include?(".html")
if File.directory?(e)
entry.children << recurse_sitemap(e, &block)
elsif block_given?
how_to_handle = block.call(e)
if how_to_handle == :valid
entry.children << recurse_sitemap(e, &block)
elsif how_to_handle == :utility
bad_ext = e.split('.html')[1]
e = e.gsub(bad_ext, '') if bad_ext
@@utility << e.gsub(Middleman::Server.views + "/", '')
end
end
end
entry
end
end

View file

@ -1,27 +0,0 @@
!!!
%html{ :xmlns => "http://www.w3.org/1999/xhtml" }
%head
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-type" }
%title Sitemap
%style{ :type => "text/css" }
:sass
@import "slickmap"
+slickmap
:javascript
window.onload = function() {
document.getElementById('primaryNav').className = "col" + document.querySelectorAll("#primaryNav > li:not(#home)").length;
};
%body
.logo
%h1= @project_name || "Sitemap"
- if @project_subtitle
%h2= @project_subtitle
- if @utility.length > 0
%ul#utilityNav
- @utility.each do |u|
%li= link_to u, u
%ul#primaryNav
- sitemap_node(@tree, true)

View file

@ -1,9 +1,10 @@
# Automatic sitemaps
# activate :slickmap
# CodeRay syntax highlighting in Haml
# activate :code_ray
# Automatic sitemaps (gem install middleman-slickmap)
# require "middleman-slickmap"
# activate :slickmap
# Automatic image dimension calculations
# activate :automatic_image_sizes
@ -54,6 +55,10 @@ configure :build do
# Use relative URLs
# activate :relative_assets
# Compress PNGs after build (gem install middleman-smusher)
# require "middleman-smusher"
# activate :smusher
# Generate ugly/obfuscated HTML from Haml
# activate :ugly_haml

View file

@ -20,12 +20,13 @@ helpers do
end
end
# Automatic sitemaps
# activate :slickmap
# CodeRay syntax highlighting in Haml
# activate :code_ray
# Automatic sitemaps (gem install middleman-slickmap)
# require "middleman-slickmap"
# activate :slickmap
# Automatic image dimension calculations in Haml
# activate :automatic_image_sizes
@ -42,9 +43,10 @@ configure :build do
# Use relative URLs
# activate :relative_assets
# Generate ugly/obfuscated HTML from Haml
# activate :ugly_haml
# Compress PNGs after build (gem install middleman-smusher)
# require "middleman-smusher"
# activate :smusher
# Or use a different image path
# set :http_path, "/Content/images/"

View file

@ -1,3 +1,3 @@
module Middleman
VERSION = "1.1.3"
VERSION = "1.1.4"
end

View file

@ -34,7 +34,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("compass", ["0.11.beta.6"])
s.add_runtime_dependency("chunky_png", ["~> 1.1.0"])
s.add_runtime_dependency("oily_png", ["~> 1.0"]) unless defined?(JRUBY_VERSION)
s.add_runtime_dependency("compass-slickmap", ["~> 0.4.0"])
s.add_runtime_dependency("coffee-script", ["~> 2.1.0"])
s.add_runtime_dependency("less", ["~> 1.2.0"])
# s.add_runtime_dependency("fssm", ["~> 0.2.0"])