active_navigation 0.1.0
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/MIT-LICENSE +20 -0
- data/README +8 -0
- data/Rakefile +92 -0
- data/app/views/navigation/_active_navigation.html.haml +14 -0
- data/app/views/navigation/_nav_active.html.haml +14 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/active_navigation/helpers.rb +20 -0
- data/lib/active_navigation/nav_menu_class.rb +44 -0
- data/lib/active_navigation.rb +11 -0
- data/rails/init.rb +2 -0
- data/test/active_navigation_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +96 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
require "rubygems"
|
3
|
+
require 'rake'
|
4
|
+
require "rake/gempackagetask"
|
5
|
+
require "rake/rdoctask"
|
6
|
+
|
7
|
+
require "rake/testtask"
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << "test"
|
10
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
11
|
+
t.verbose = true
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
desc 'Default: run unit tests.'
|
16
|
+
task :default => ["test"]
|
17
|
+
|
18
|
+
# This builds the actual gem. For details of what all these options
|
19
|
+
# mean, and other ones you can add, check the documentation here:
|
20
|
+
#
|
21
|
+
# http://rubygems.org/read/chapter/20
|
22
|
+
#
|
23
|
+
spec = Gem::Specification.new do |s|
|
24
|
+
|
25
|
+
# Change these as appropriate
|
26
|
+
s.name = "active_navigation"
|
27
|
+
s.version = "0.1.0"
|
28
|
+
s.summary = "Active Navigation is Rails plugin that helps building navigation menus"
|
29
|
+
s.author = "Vlad Alive"
|
30
|
+
s.email = "vladalive@gmail.com"
|
31
|
+
s.homepage = "http://github.com/vladalive/active_navigation"
|
32
|
+
|
33
|
+
s.has_rdoc = true
|
34
|
+
s.extra_rdoc_files = %w(README)
|
35
|
+
s.rdoc_options = %w(--main README)
|
36
|
+
s.platform = Gem::Platform::RUBY
|
37
|
+
|
38
|
+
PKG_FILES = FileList[
|
39
|
+
'[a-zA-Z]*',
|
40
|
+
'generators/**/*',
|
41
|
+
'lib/**/*',
|
42
|
+
'app/**/*',
|
43
|
+
'rails/**/*',
|
44
|
+
'tasks/**/*',
|
45
|
+
'test/**/*'
|
46
|
+
]
|
47
|
+
|
48
|
+
# Add any extra files to include in the gem
|
49
|
+
# s.files = %w(README init.rb uninstall.rb MIT-LICENSE Rakefile install.rb) + Dir.glob("{test,lib/**/*}")
|
50
|
+
s.files = PKG_FILES.to_a
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
|
53
|
+
# If you want to depend on other gems, add them here, along with any
|
54
|
+
# relevant versions
|
55
|
+
# s.add_dependency("some_other_gem", "~> 0.1.0")
|
56
|
+
s.add_dependency("haml", "~> 3.0.0")
|
57
|
+
|
58
|
+
# If your tests use any gems, include them here
|
59
|
+
# s.add_development_dependency("mocha") # for example
|
60
|
+
end
|
61
|
+
|
62
|
+
# This task actually builds the gem. We also regenerate a static
|
63
|
+
# .gemspec file, which is useful if something (i.e. GitHub) will
|
64
|
+
# be automatically building a gem for this project. If you're not
|
65
|
+
# using GitHub, edit as appropriate.
|
66
|
+
#
|
67
|
+
# To publish your gem online, install the 'gemcutter' gem; Read more
|
68
|
+
# about that here: http://gemcutter.org/pages/gem_docs
|
69
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
70
|
+
pkg.gem_spec = spec
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
74
|
+
task :gemspec do
|
75
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
76
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
77
|
+
end
|
78
|
+
|
79
|
+
task :package => :gemspec
|
80
|
+
|
81
|
+
# Generate documentation
|
82
|
+
Rake::RDocTask.new do |rd|
|
83
|
+
rd.main = "README"
|
84
|
+
rd.rdoc_files.include("README", "lib/**/*.rb")
|
85
|
+
rd.rdoc_dir = "rdoc"
|
86
|
+
end
|
87
|
+
|
88
|
+
desc 'Clear out RDoc and generated packages'
|
89
|
+
task :clean => [:clobber_rdoc, :clobber_package] do
|
90
|
+
rm "#{spec.name}.gemspec"
|
91
|
+
end
|
92
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- if menu
|
2
|
+
%ul{:class => menu.options[:class] }
|
3
|
+
- menu.items.each do |item|
|
4
|
+
%li{:class => (item.class_name unless item.class_name.nil?) || (item.title.parameterize if menu.options[:items_classify]) }
|
5
|
+
- if item.path.nil?
|
6
|
+
%span= item.title
|
7
|
+
- elsif item.path.empty? || item.path == "#"
|
8
|
+
= link_to item.title, "#", :class => :disabled
|
9
|
+
- elsif item.path == "#active"
|
10
|
+
= link_to item.title, item.path, :class => menu.options[:class_for_active]
|
11
|
+
- else
|
12
|
+
= link_to_unless_current item.title, item.path do
|
13
|
+
= link_to item.title, item.path, :class => menu.options[:class_for_active]
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- unless menu.empty?
|
2
|
+
%ul{:class => options[:class] }
|
3
|
+
- menu.each do |item|
|
4
|
+
- item.each_pair do |title, path|
|
5
|
+
%li{:class => (title.parameterize if options[:items_classify]) }
|
6
|
+
- if path.nil? || path == "#"
|
7
|
+
= link_to title, "#", :class => :disabled
|
8
|
+
- elsif path.empty?
|
9
|
+
%span= title
|
10
|
+
- elsif path == "#active"
|
11
|
+
= link_to title, path, :class => options[:class_for_active]
|
12
|
+
- else
|
13
|
+
= link_to_unless_current title, path do
|
14
|
+
= link_to title, path, :class => options[:class_for_active]
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveNavigation
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
def active_nav_menu(*args)
|
5
|
+
ActiveNavigation::Classes::NavMenu.new(*args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def active_navigation(menu)
|
9
|
+
render :partial => "navigation/active_navigation", :locals => { :menu => menu }
|
10
|
+
end
|
11
|
+
|
12
|
+
def nav_active(menu, *args)
|
13
|
+
default_options = { :class => "nav", :class_for_active => "active", :items_classify => false }
|
14
|
+
options = args.extract_options!.reverse_merge!(default_options)
|
15
|
+
render :partial => "navigation/nav_active", :locals => { :menu => menu, :options => options}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module ActiveNavigation
|
4
|
+
|
5
|
+
module Classes
|
6
|
+
|
7
|
+
class NavMenu < Struct.new(:items, :options)
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
self.items = []
|
11
|
+
self.options = menu_default_options.merge(args.extract_options!)
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(title, path = nil, *args)
|
15
|
+
new_options = menu_item_default_options(title, path).merge(args.extract_options!)
|
16
|
+
self.items << NavMenuItem.new(new_options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_options(*new_options)
|
20
|
+
self.options.merge!(new_options.extract_options!) if new_options
|
21
|
+
end
|
22
|
+
|
23
|
+
class NavMenuItem < OpenStruct; end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def menu_default_options
|
28
|
+
{
|
29
|
+
:class => "nav",
|
30
|
+
:class_for_active => "active",
|
31
|
+
:items_classify => false
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def menu_item_default_options(title, path)
|
36
|
+
{ :title => title, :path => path }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
require 'active_navigation/helpers'
|
4
|
+
require 'active_navigation/nav_menu_class'
|
5
|
+
|
6
|
+
ActionView::Base.send :include, ActiveNavigation::Helpers
|
7
|
+
|
8
|
+
ActionController::Base.class_eval do
|
9
|
+
append_view_path File.join(File.dirname(__FILE__), '..', 'app', 'views')
|
10
|
+
end
|
11
|
+
|
data/rails/init.rb
ADDED
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_navigation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Vlad Alive
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-05 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: haml
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 3.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description:
|
38
|
+
email: vladalive@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README
|
45
|
+
files:
|
46
|
+
- README
|
47
|
+
- init.rb
|
48
|
+
- uninstall.rb
|
49
|
+
- MIT-LICENSE
|
50
|
+
- Rakefile
|
51
|
+
- install.rb
|
52
|
+
- lib/active_navigation/nav_menu_class.rb
|
53
|
+
- lib/active_navigation/helpers.rb
|
54
|
+
- lib/active_navigation.rb
|
55
|
+
- app/views/navigation/_active_navigation.html.haml
|
56
|
+
- app/views/navigation/_nav_active.html.haml
|
57
|
+
- rails/init.rb
|
58
|
+
- test/test_helper.rb
|
59
|
+
- test/active_navigation_test.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/vladalive/active_navigation
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --main
|
67
|
+
- README
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Active Navigation is Rails plugin that helps building navigation menus
|
95
|
+
test_files: []
|
96
|
+
|