navigasmic 0.5.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/LICENSE +7 -1
  2. data/lib/generators/navigasmic/install/POST_INSTALL +6 -0
  3. data/lib/generators/navigasmic/install/install_generator.rb +17 -0
  4. data/lib/generators/navigasmic/install/templates/initializer.rb +145 -0
  5. data/lib/navigasmic.rb +5 -146
  6. data/lib/navigasmic/builders/crumb_builder.rb +20 -0
  7. data/lib/navigasmic/builders/list_builder.rb +90 -0
  8. data/lib/navigasmic/builders/map_builder.rb +77 -0
  9. data/lib/navigasmic/core/builders.rb +109 -0
  10. data/lib/navigasmic/core/configuration.rb +38 -0
  11. data/lib/navigasmic/core/item.rb +66 -0
  12. data/lib/navigasmic/rails.rb +2 -0
  13. data/lib/navigasmic/rails/engine.rb +9 -0
  14. data/lib/navigasmic/rails/view_helpers.rb +18 -0
  15. data/lib/navigasmic/version.rb +3 -0
  16. data/spec/dummy/Rakefile +7 -0
  17. data/spec/dummy/app/controllers/application_controller.rb +13 -0
  18. data/spec/dummy/app/controllers/blog/links_controller.rb +7 -0
  19. data/spec/dummy/app/controllers/blog/posts_controller.rb +7 -0
  20. data/spec/dummy/app/views/application/welcome.html.erb +4 -0
  21. data/spec/dummy/app/views/application/welcome.xml.builder +2 -0
  22. data/spec/dummy/app/views/blog/links/index.html +4 -0
  23. data/spec/dummy/app/views/blog/links/show.html +4 -0
  24. data/spec/dummy/app/views/blog/posts/index.html +4 -0
  25. data/spec/dummy/app/views/blog/posts/show.html +4 -0
  26. data/spec/dummy/app/views/layouts/_navigation.html.erb +73 -0
  27. data/spec/dummy/app/views/layouts/application.html.erb +40 -0
  28. data/spec/dummy/config.ru +4 -0
  29. data/spec/dummy/config/application.rb +57 -0
  30. data/spec/dummy/config/boot.rb +9 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +37 -0
  33. data/spec/dummy/config/environments/test.rb +37 -0
  34. data/spec/dummy/config/evergreen.rb +47 -0
  35. data/spec/dummy/config/initializers/additional_navigasmic.rb +14 -0
  36. data/spec/dummy/config/initializers/navigasmic.rb +145 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  38. data/spec/dummy/config/initializers/session_store.rb +8 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +68 -0
  41. data/spec/dummy/log/.gitkeep +0 -0
  42. data/spec/dummy/public/bootstrap.min.css +9 -0
  43. data/spec/dummy/public/bootstrap.min.js +6 -0
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/dummy/public/jquery.min.js +2 -0
  46. data/spec/dummy/script/rails +6 -0
  47. data/spec/spec_helper.rb +39 -0
  48. metadata +139 -63
  49. data/.document +0 -5
  50. data/README.textile +0 -276
  51. data/Rakefile +0 -57
  52. data/VERSION +0 -1
  53. data/lib/builders/html_builder.rb +0 -69
  54. data/lib/builders/xml_builder.rb +0 -51
  55. data/navigasmic.gemspec +0 -49
  56. data/test/navigasmic_test.rb +0 -7
  57. data/test/test_helper.rb +0 -10
data/Rakefile DELETED
@@ -1,57 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "navigasmic"
8
- gem.summary = %Q{Semantic navigation for Rails}
9
- gem.description = %Q{Semantic navigation; a semantic way to build beautifully simple navigation structures in Rails.}
10
- gem.email = "jejacks0n@gmail.com"
11
- gem.homepage = "http://github.com/jejacks0n/navigasmic"
12
- gem.authors = ["Jeremy Jackson"]
13
- gem.add_development_dependency "thoughtbot-shoulda"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/*_test.rb'
25
- test.verbose = true
26
- end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/*_test.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- if File.exist?('VERSION')
48
- version = File.read('VERSION')
49
- else
50
- version = ""
51
- end
52
-
53
- rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "navigasmic #{version}"
55
- rdoc.rdoc_files.include('README*')
56
- rdoc.rdoc_files.include('lib/**/*.rb')
57
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.5.6
@@ -1,69 +0,0 @@
1
- module Navigasmic
2
- class HtmlNavigationBuilder
3
-
4
- @@classnames = {
5
- :with_group => 'with-group',
6
- :disabled => 'disabled',
7
- :highlighted => 'highlighted'
8
- }
9
- @@wrapper_tag = :ul
10
- @@group_tag = :ul
11
- @@item_tag = :li
12
- @@label_tag = :span
13
-
14
- attr_accessor :template, :name, :items
15
-
16
- def initialize(template, name, options = {}, &proc)
17
- @template, @name, @items = template, name.to_s, []
18
- render(options.delete(:html), &proc)
19
- end
20
-
21
- def render(options, &proc)
22
- buffer = template.capture(self, &proc)
23
- template.concat(template.content_tag(@@wrapper_tag, buffer, options))
24
- end
25
-
26
- def group(label = nil, options = {}, &proc)
27
- raise ArgumentError, "Missing block" unless block_given?
28
-
29
- options[:html] ||= {}
30
- options[:html][:class] = template.add_html_class(options[:html][:class], @@classnames[:with_group])
31
- options[:html][:id] ||= label.to_s.gsub(/\s/, '_').underscore unless label.blank? || options[:html].has_key?(:id)
32
-
33
- buffer = template.capture(self, &proc)
34
- group = template.content_tag(@@group_tag, buffer)
35
- label = label_for_group(label) unless label.blank?
36
-
37
- visible = options[:hidden_unless].nil? ? true : options[:hidden_unless].is_a?(Proc) ? template.instance_eval(&options[:hidden_unless]) : options[:hidden_unless]
38
- visible ? template.content_tag(@@item_tag, (label.to_s + group).html_safe, options.delete(:html)) : ''
39
- end
40
-
41
- def item(label, options = {}, &proc)
42
- buffer = block_given? ? template.capture(self, &proc) : ''
43
-
44
- item = NavigationItem.new(label, options, template)
45
-
46
- options[:html] ||= {}
47
- options[:html][:id] = label.to_s.gsub(/\s/, '_').underscore unless options[:html].has_key?(:id)
48
-
49
- options[:html][:class] = template.add_html_class(options[:html][:class], @@classnames[:disabled]) if item.disabled?
50
- options[:html][:class] = template.add_html_class(options[:html][:class], @@classnames[:highlighted]) if item.highlighted?(template.request.path, template.params, template)
51
-
52
- label = label_for_item(label)
53
- link = item.link.is_a?(Proc) ? template.instance_eval(&item.link) : item.link
54
-
55
- label = template.link_to(label, link, options.delete(:link_html)) unless !item.link? || item.disabled?
56
-
57
- item.hidden? ? '' : template.content_tag(@@item_tag, label + buffer, options.delete(:html))
58
- end
59
-
60
- def label_for_group(label)
61
- template.content_tag(@@label_tag, label.to_s)
62
- end
63
-
64
- def label_for_item(label)
65
- template.content_tag(@@label_tag, label.to_s)
66
- end
67
-
68
- end
69
- end
@@ -1,51 +0,0 @@
1
- module Navigasmic
2
- class XmlNavigationBuilder
3
-
4
- @@wrapper_tag = :urlset
5
- @@group_tag = :urlset
6
- @@item_tag = :url
7
-
8
- attr_accessor :template, :name, :items, :host
9
-
10
- def initialize(template, name, options = {}, &proc)
11
- @template, @name, @items = template, name.to_s, []
12
- @host = options[:host] || "http://#{template.request.host_with_port}"
13
- @changefreq = options[:changefreq] || 'yearly'
14
- render(options.delete(:xml), &proc)
15
- end
16
-
17
- def render(options, &proc)
18
- buffer = template.capture(self, &proc)
19
-
20
- options ||= {}
21
- options['xmlns'] ||= 'http://www.sitemaps.org/schemas/sitemap/0.9'
22
- options['xmlns:xsi'] ||= 'http://www.w3.org/2001/XMLSchema-instance'
23
- options['xsi:schemaLocation'] ||= 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'
24
-
25
- template.concat(template.content_tag(@@wrapper_tag, buffer, options))
26
- end
27
-
28
- def group(label = nil, options = {}, &proc)
29
- raise ArgumentError, "Missing block" unless block_given?
30
-
31
- buffer = template.capture(self, &proc)
32
-
33
- visible = options[:hidden_unless].nil? ? true : options[:hidden_unless].is_a?(Proc) ? template.instance_eval(&options[:hidden_unless]) : options[:hidden_unless]
34
- visible ? template.concat(template.content_tag(@@group_tag, buffer)) : ''
35
- end
36
-
37
- def item(label, options = {}, &proc)
38
- buffer = block_given? ? template.capture(self, &proc) : ''
39
-
40
- item = NavigationItem.new(label, options, template)
41
-
42
- contents = template.content_tag(:loc, @host + template.url_for(item.link))
43
- contents << template.content_tag(:changefreq, options[:changefreq] || @changefreq)
44
- contents << template.content_tag(:lastmod, options[:lastmod]) if options[:lastmod]
45
- contents << template.content_tag(:priority, options[:priority]) if options[:priority]
46
-
47
- item.hidden? ? '' : template.concat(template.content_tag(@@item_tag, contents + buffer, options.delete(:xml)))
48
- end
49
-
50
- end
51
- end
data/navigasmic.gemspec DELETED
@@ -1,49 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{navigasmic}
8
- s.version = "0.5.6"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jeremy Jackson"]
12
- s.date = %q{2011-07-01}
13
- s.description = %q{Semantic navigation; a semantic way to build beautifully simple navigation structures in Rails.}
14
- s.email = %q{jejacks0n@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.textile"
18
- ]
19
- s.files = [
20
- ".document",
21
- "LICENSE",
22
- "README.textile",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/builders/html_builder.rb",
26
- "lib/builders/xml_builder.rb",
27
- "lib/navigasmic.rb",
28
- "navigasmic.gemspec",
29
- "test/navigasmic_test.rb",
30
- "test/test_helper.rb"
31
- ]
32
- s.homepage = %q{http://github.com/jejacks0n/navigasmic}
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.7.2}
35
- s.summary = %q{Semantic navigation for Rails}
36
-
37
- if s.respond_to? :specification_version then
38
- s.specification_version = 3
39
-
40
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
42
- else
43
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
44
- end
45
- else
46
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
- end
48
- end
49
-
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigasmicTest < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'navigasmic'
8
-
9
- class Test::Unit::TestCase
10
- end