dynamic_menu 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +5 -0
- data/README.rdoc +32 -0
- data/Rakefile +14 -0
- data/dynamic_menu.gemspec +29 -0
- data/lib/dynamic_menu.rb +24 -0
- metadata +57 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
=Dynamic Menu
|
2
|
+
==Introduction
|
3
|
+
Dynamic Menu is a gem to make it easy to add a custom menu to your application via a controller.
|
4
|
+
== Install
|
5
|
+
You need to add:
|
6
|
+
|
7
|
+
gem "dynamic_menu",:git=>"git://github.com/plowdawg/dynamic_menu.git"
|
8
|
+
|
9
|
+
to your gemfile
|
10
|
+
== How to use
|
11
|
+
You can create an array in a controller like so:
|
12
|
+
|
13
|
+
@actionMenuItem = Array.new
|
14
|
+
|
15
|
+
option1 = DynamicMenu::ActionMenuItem.new("Name",link_to_path)
|
16
|
+
|
17
|
+
@actionMenuItem[0] = option1
|
18
|
+
|
19
|
+
then you can refrence it by using a loop such as
|
20
|
+
|
21
|
+
@actionMenuItem.each do |menu|
|
22
|
+
|
23
|
+
menu.link_tag #this generates the entire link
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
if you need a delete and confirmation method then you can declare it like so:
|
28
|
+
|
29
|
+
option1 = DynamicMenu::ActionMenuItem.new("Link Name", link_to_path, :delete, "Are you sure?")
|
30
|
+
|
31
|
+
the first is what the link will look like on the view, second is the view, third is the method (only works
|
32
|
+
for delete) and the fourth is the confirmation method (which also only works on delete)
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('dynamic_menu', '0.1.0') do |p|
|
6
|
+
p.description = "Allow the creation of Menus"
|
7
|
+
p.url = "http://es3inc.com"
|
8
|
+
p.author = "Travis Pessettto"
|
9
|
+
p.email = "travis@pessetto.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{dynamic_menu}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [%q{Travis Pessettto}]
|
9
|
+
s.date = %q{2011-08-01}
|
10
|
+
s.description = %q{Allow the creation of Menus}
|
11
|
+
s.email = %q{travis@pessetto.com}
|
12
|
+
s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/dynamic_menu.rb}]
|
13
|
+
s.files = [%q{README.rdoc}, %q{Rakefile}, %q{dynamic_menu.gemspec}, %q{lib/dynamic_menu.rb}, %q{Manifest}]
|
14
|
+
s.homepage = %q{http://es3inc.com}
|
15
|
+
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Dynamic_menu}, %q{--main}, %q{README.rdoc}]
|
16
|
+
s.require_paths = [%q{lib}]
|
17
|
+
s.rubyforge_project = %q{dynamic_menu}
|
18
|
+
s.rubygems_version = %q{1.8.6}
|
19
|
+
s.summary = %q{Allow the creation of Menus}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
else
|
26
|
+
end
|
27
|
+
else
|
28
|
+
end
|
29
|
+
end
|
data/lib/dynamic_menu.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module DynamicMenu
|
2
|
+
|
3
|
+
class ActionMenuItem
|
4
|
+
include ActionView::Helpers::UrlHelper
|
5
|
+
|
6
|
+
attr_accessor :name, :link, :method, :link_tag
|
7
|
+
|
8
|
+
def initialize(name, link, method = :get, confirm="Are You Sure?")
|
9
|
+
@name = name
|
10
|
+
@link = link
|
11
|
+
@method = method
|
12
|
+
@link_tag = ""
|
13
|
+
|
14
|
+
if method == :delete
|
15
|
+
@link_tag = link_to name, link, :method=>method, :confirm=>confirm
|
16
|
+
else
|
17
|
+
@link_tag = link_to name, link
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynamic_menu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Travis Pessettto
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-01 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Allow the creation of Menus
|
15
|
+
email: travis@pessetto.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- README.rdoc
|
20
|
+
- lib/dynamic_menu.rb
|
21
|
+
files:
|
22
|
+
- README.rdoc
|
23
|
+
- Rakefile
|
24
|
+
- dynamic_menu.gemspec
|
25
|
+
- lib/dynamic_menu.rb
|
26
|
+
- Manifest
|
27
|
+
homepage: http://es3inc.com
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options:
|
31
|
+
- --line-numbers
|
32
|
+
- --inline-source
|
33
|
+
- --title
|
34
|
+
- Dynamic_menu
|
35
|
+
- --main
|
36
|
+
- README.rdoc
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '1.2'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project: dynamic_menu
|
53
|
+
rubygems_version: 1.8.6
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Allow the creation of Menus
|
57
|
+
test_files: []
|