rubyguy-simple_tabs 0.1.1 → 0.1.2

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.
@@ -8,7 +8,7 @@ Super simple plugin/gem to easily add tabbed navigation to your Ruby on Rails ap
8
8
 
9
9
  In config/environment.rb:
10
10
 
11
- config.gem 'rubyguy-simple_tabs', :version => '0.1.1', :source => 'http://gems.github.com/', :lib => 'simple_tabs'
11
+ config.gem 'rubyguy-simple_tabs', :version => '0.1.2', :source => 'http://gems.github.com/', :lib => 'simple_tabs'
12
12
 
13
13
  And then run:
14
14
 
@@ -24,13 +24,20 @@ In your layout:
24
24
 
25
25
  <%
26
26
  tabbed_menu do
27
- tab 'Home', :root # A tab with no children that links to root_path
28
- tab 'Our products', products_path do # A tab with one child that links to products_path
29
- child :controller => 'products', :action => 'show' # This tab will not only be active when we're at the index action (products_path)
27
+ tab 'Home', :root # Use symbols. Instead of typing root_path, just type :root
28
+
29
+ tab 'Blog', :controller => 'blog' do # The second argument accepts anything that is accepted by the link_to_unless_current helper
30
+ child :controller => 'posts' # The children of a tab and the tab it self does not have to be from the same controller
31
+ end
32
+
33
+ tab 'Our products', products_path do # You can specify as many children as you like
34
+ child :controller => 'products', :action => 'show' # The 'Our products' tab will also be active when showing a product, ...
35
+ child :controller => 'products', :action => 'edit' # ... editing a product, ...
36
+ child :controller => 'products', :action => 'update' # ... and updating a product
30
37
  end
31
38
 
32
- tab 'About', :controller => 'about', :action => 'index' do # A tab with one child with two actions that links to AboutController#index
33
- child :controller => 'about', :action => ['company', 'contact']
39
+ tab 'About', :about, :confirm => 'Are you sure you want to know?' do # Use all the HTML options you know from the URL helper methods.
40
+ child :controller => 'about', :action => ['company', 'contact'] # You can specify multiple actions (or controllers or any other parameter) by using arrays
34
41
  end
35
42
  end
36
43
  %>
@@ -39,16 +46,18 @@ The output will look like this if we're at the show action of ProductsController
39
46
 
40
47
  <ul id="menu">
41
48
  <li><a href="/">Home</a></li>
42
- <li class="active"><a href="/products">Our products</a></li>
43
- <li><a href="/about">About</a></li>
49
+ <li><a href="/blog">Blog</a></li>
50
+ <li class="active"><a href="/products">Our products</a></li> <!-- The tab is active but you can still click it to get back to /products -->
51
+ <li><a href="/about" onclick="return confirm('Are you sure you want to know?');">About</a></li>
44
52
  </ul>
45
53
 
46
- But if we were at the show action, the output would look like this:
54
+ But if we were at the index action, the output would look like this:
47
55
 
48
56
  <ul id="menu">
49
57
  <li><a href="/">Home</a></li>
50
- <li class="active">Our products</a></li>
51
- <li><a href="/about">About</a>
58
+ <li><a href="/blog">Blog</a></li>
59
+ <li class="active">Our products</li> <!-- The tab is active and unclickable -->
60
+ <li><a href="/about" onclick="return confirm('Are you sure you want to know?');">About</a></li>
52
61
  </ul>
53
62
 
54
63
  The tabbed_menu method accepts the following options:
@@ -56,13 +65,12 @@ The tabbed_menu method accepts the following options:
56
65
  :id => 'string' or :symbol - The id of the <ul> representing the menu.
57
66
  :active_class => 'string' or :symbol - The class of the <li> of the active tab.
58
67
 
59
- Keep in mind:
68
+ Two ground rules to keep in mind:
60
69
 
61
- 1. A tab is active if we're at the URL of the tab it self or any of its children.
62
- 2. You can use symbols (:root instead of root_path) or hashes to specify URLs both in tabs and their children.
63
- 3. You can specify as many children for a tab as you want.
64
- 4. You can use arrays to (for example) specify multiple actions that will activate a child.
65
- 5. The link itself will be generated by the Rails helper link_to_unless_current.
70
+ 1. A tab is active if:
71
+ a. we're at the URL of the tab it self or
72
+ b. we're at the URL of one of the children of the tab.
73
+ 2. The link itself will be generated by the Rails helper link_to_unless_current.
66
74
 
67
75
  == License
68
76
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('simple_tabs', '0.1.1') do |p|
5
+ Echoe.new('simple_tabs', '0.1.2') do |p|
6
6
  p.description = 'Super simple plugin/gem to easily add tabbed navigation to your Ruby on Rails application.'
7
7
  p.url = 'http://github.com/rubyguy/simple_tabs'
8
8
  p.author = 'David Knorr'
@@ -3,10 +3,10 @@ module SimpleTabs
3
3
  @options = options.reverse_merge(:id => 'menu', :active_class => 'active')
4
4
  concat "<ul id='#{@options[:id]}'>"
5
5
  yield if block_given?
6
- concat('</ul>')
6
+ concat '</ul>'
7
7
  end
8
8
 
9
- def tab(name, url)
9
+ def tab(name, url, link_attributes={})
10
10
  @active = false
11
11
  url = url_to_string(url)
12
12
  if current_page? url
@@ -15,15 +15,15 @@ module SimpleTabs
15
15
  if block_given?
16
16
  yield
17
17
  if @active
18
- concat concat "<li class='#{@options[:active_class]}'>"
18
+ concat "<li class='#{@options[:active_class]}'>"
19
19
  else
20
- concat tag(:li)
20
+ concat '<li>'
21
21
  end
22
22
  else
23
- concat tag(:li)
23
+ concat '<li>'
24
24
  end
25
25
  end
26
- concat link_to_unless_current name, url
26
+ concat link_to_unless_current(name, url, link_attributes)
27
27
  concat '</li>'
28
28
  end
29
29
 
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{simple_tabs}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["David Knorr"]
9
- s.date = %q{2009-03-30}
9
+ s.date = %q{2009-04-01}
10
10
  s.description = %q{Super simple plugin/gem to easily add tabbed navigation to your Ruby on Rails application.}
11
11
  s.email = %q{rubyguy@ymail.com}
12
12
  s.extra_rdoc_files = ["lib/simple_tabs.rb", "README.rdoc"]
13
- s.files = ["init.rb", "lib/simple_tabs.rb", "Rakefile", "README.rdoc", "simple_tabs.gemspec", "Manifest"]
13
+ s.files = ["init.rb", "lib/simple_tabs.rb", "Manifest", "Rakefile", "README.rdoc", "simple_tabs.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/rubyguy/simple_tabs}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Simple_tabs", "--main", "README.rdoc"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyguy-simple_tabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Knorr
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-30 00:00:00 -07:00
12
+ date: 2009-04-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,10 +25,10 @@ extra_rdoc_files:
25
25
  files:
26
26
  - init.rb
27
27
  - lib/simple_tabs.rb
28
+ - Manifest
28
29
  - Rakefile
29
30
  - README.rdoc
30
31
  - simple_tabs.gemspec
31
- - Manifest
32
32
  has_rdoc: true
33
33
  homepage: http://github.com/rubyguy/simple_tabs
34
34
  post_install_message: