middleman-slickmap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in middleman-slickmap.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,98 @@
1
+ require 'slickmap'
2
+ require "middleman/builder"
3
+
4
+ Entry = Struct.new(:dir, :children)
5
+
6
+ module Middleman
7
+ module Features
8
+ module Slickmap
9
+
10
+ class << self
11
+ def registered(app)
12
+ sitemap_url = "sitemap.html"
13
+ sitemap_url = app.sitemap_url if app.respond_to?(:slickmap_url) && !app.sitemap_url.nil?
14
+
15
+ Middleman::Builder.after_run "smush_pngs" do
16
+ source_paths << File.expand_path(File.join(File.dirname(__FILE__), "middleman-slickmap", "templates"))
17
+ tilt_template "slickmap.html.haml", File.join(Middleman::Server.build_dir, sitemap_url), { :force => true }
18
+ end
19
+
20
+ app.helpers do
21
+ def sitemap_node(n, first=false)
22
+ if n.children.length < 1
23
+ if !first && File.extname(n.dir).length > 0
24
+ haml_tag :li do
25
+ path = n.dir.gsub(self.class.views, '')
26
+ haml_concat link_to(File.basename(path), path)
27
+ end
28
+ end
29
+ else
30
+ haml_tag(:li, :id => first ? "home" : nil) do
31
+ if first
32
+ haml_concat link_to("Homepage", "/" + self.class.index_file)
33
+ else
34
+ # we are a dir
35
+ index = n.children.find { |c| c.dir.include?(self.class.index_file) }
36
+ haml_concat link_to(index.dir.gsub(self.class.views + "/", '').gsub("/" + File.basename(index.dir), '').capitalize, index.dir.gsub(self.class.views, ''))
37
+ end
38
+
39
+ other_children = n.children.select { |c| !c.dir.include?(self.class.index_file) }
40
+ if other_children.length > 0
41
+ if first
42
+ other_children.each { |i| sitemap_node(i) }
43
+ else
44
+ haml_tag :ul do
45
+ other_children.each { |i| sitemap_node(i) }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ app.get "/#{sitemap_url}" do
55
+ # Return :utility to put it util top menu. False to ignore
56
+ @tree, @utility = Middleman::Features::Slickmap.build_sitemap do |file_name|
57
+ :valid
58
+ end
59
+
60
+ haml "slickmap.html".to_sym, :layout => false, :views => File.expand_path(File.join(File.dirname(__FILE__), "middleman-slickmap", "templates"))
61
+ end
62
+ end
63
+ alias :included :registered
64
+ end
65
+
66
+ def self.build_sitemap(&block)
67
+ @@utility = []
68
+ [recurse_sitemap(Middleman::Server.views, &block), @@utility]
69
+ end
70
+
71
+ def self.recurse_sitemap(path, &block)
72
+ bad_ext = path.split('.html')[1]
73
+ path = path.gsub(bad_ext, '') if bad_ext
74
+ entry = Entry.new(path, [])
75
+
76
+ #no "." or ".." dirs
77
+ Dir[File.join(path, "*")].each do |e|
78
+ next if !File.directory?(e) && !e.include?(".html")
79
+ if File.directory?(e)
80
+ entry.children << recurse_sitemap(e, &block)
81
+ elsif block_given?
82
+ how_to_handle = block.call(e)
83
+ if how_to_handle == :valid
84
+ entry.children << recurse_sitemap(e, &block)
85
+ elsif how_to_handle == :utility
86
+ bad_ext = e.split('.html')[1]
87
+ e = e.gsub(bad_ext, '') if bad_ext
88
+ @@utility << e.gsub(Middleman::Server.views + "/", '')
89
+ end
90
+ end
91
+ end
92
+
93
+ entry
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,27 @@
1
+ !!!
2
+ %html{ :xmlns => "http://www.w3.org/1999/xhtml" }
3
+ %head
4
+ %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-type" }
5
+ %title Sitemap
6
+ %style{ :type => "text/css" }
7
+ :sass
8
+ @import "slickmap"
9
+ +slickmap
10
+ :javascript
11
+ window.onload = function() {
12
+ document.getElementById('primaryNav').className = "col" + document.querySelectorAll("#primaryNav > li:not(#home)").length;
13
+ };
14
+
15
+ %body
16
+ .logo
17
+ %h1= @project_name || "Sitemap"
18
+ - if @project_subtitle
19
+ %h2= @project_subtitle
20
+
21
+ - if @utility.length > 0
22
+ %ul#utilityNav
23
+ - @utility.each do |u|
24
+ %li= link_to u, u
25
+
26
+ %ul#primaryNav
27
+ - sitemap_node(@tree, true)
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Slickmap
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "middleman-slickmap/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "middleman-slickmap"
7
+ s.version = Middleman::Slickmap::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Thomas Reynolds"]
10
+ s.email = ["tdreyno@gmail.com"]
11
+ s.homepage = "https://github.com/tdreyno/middleman-slickmap"
12
+ s.summary = %q{Automatic sitemaps in your Middleman project}
13
+ s.description = %q{Automatic sitemaps in your Middleman project}
14
+
15
+ s.rubyforge_project = "middleman-slickmap"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency("middleman", ["~> 1.1.0"])
23
+ s.add_runtime_dependency("compass-slickmap", ["~> 0.4.0"])
24
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-slickmap
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Thomas Reynolds
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-20 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: middleman
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 0
34
+ version: 1.1.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: compass-slickmap
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 0
48
+ - 4
49
+ - 0
50
+ version: 0.4.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Automatic sitemaps in your Middleman project
54
+ email:
55
+ - tdreyno@gmail.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - Rakefile
66
+ - lib/middleman-slickmap.rb
67
+ - lib/middleman-slickmap/.DS_Store
68
+ - lib/middleman-slickmap/templates/slickmap.html.haml
69
+ - lib/middleman-slickmap/version.rb
70
+ - middleman-slickmap.gemspec
71
+ has_rdoc: true
72
+ homepage: https://github.com/tdreyno/middleman-slickmap
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project: middleman-slickmap
101
+ rubygems_version: 1.5.0
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Automatic sitemaps in your Middleman project
105
+ test_files: []
106
+