Permalink
Browse files

Update docs

  • Loading branch information...
1 parent 327ef4c commit 356e0f946efdd9de8e4a0139ac7329798664bff9 @weppos committed Feb 3, 2012
View
@@ -1,7 +1,9 @@
# Changelog
-## Master
+## Release 2.1.0
+
+* NEW: Support for Rails 3.2.
* FIXED: Fixed Rails 3.2 ActiveSupport::Concern deprecation warning (GH-18).
View
@@ -1,308 +1,86 @@
-= Tabs on Rails
+# Tabs on Rails
-*TabsOnRails* is a simple Rails plugin for creating tabs and navigation menus.
-It provides helpers for generating navigation menus with a flexible interface.
+*TabsOnRails* is a simple Rails plugin for creating tabs and navigation menus. It provides helpers for generating navigation menus with a flexible interface.
-== Requirements
+## Requirements
* Rails 3
Please note
* TabsOnRails 2.x requires Rails 3. Use TabsOnRails 1.3.x with Rails 2.
* TabsOnRails doesn't work with Rails 2.1 or lower
-("comment":http://www.simonecarletti.com/blog/2009/04/tabsonrails/#comment-2901 and "commit":http://github.com/weppos/tabs_on_rails/commit/d5ae9f401e3d0acc87251fa8957a8625e90ba4b3).
+([comment](http://www.simonecarletti.com/blog/2009/04/tabsonrails/#comment-2901) and [commit](http://github.com/weppos/tabs_on_rails/commit/d5ae9f401e3d0acc87251fa8957a8625e90ba4b3)).
-== Installation
+## Installation
-"RubyGems":http://rubygems.org is the preferred way to install *TabsOnRails* and the best way if you want install a stable version.
+[RubyGems](http://rubygems.org) is the preferred way to install *TabsOnRails* and the best way if you want install a stable version.
- $ gem install tabs_on_rails
+ $ gem install tabs_on_rails
-Specify the Gem dependency in the "Bundler":http://gembundler.com Gemfile.
+Specify the Gem dependency in the [Bundler](http://gembundler.com) `Gemfile`.
- gem "tabs_on_rails"
+ gem "tabs_on_rails"
-Use "Bundler":http://gembundler.com and the ":git option":http://gembundler.com/v1.0/git.html if you want to grab the latest version from the Git repository.
+Use [Bundler](http://gembundler.com) and the [:git option](http://gembundler.com/v1.0/git.html) if you want to grab the latest version from the Git repository.
-== Usage
+## Usage
-In your template use the <tt>tabs_tag</tt> helper to create your tab.
+In your template use the `tabs_tag` helper to create your tab.
- <%= tabs_tag do |tab| %>
- <%= tab.home 'Homepage', root_path %>
- <%= tab.dashboard 'Dashboard', dashboard_path %>
- <%= tab.account 'Account', account_path %>
- <% end %>
+ <%= tabs_tag do |tab| %>
+ <%= tab.home 'Homepage', root_path %>
+ <%= tab.dashboard 'Dashboard', dashboard_path %>
+ <%= tab.account 'Account', account_path %>
+ <% end %>
The example above produces the following HTML output.
- <ul>
- <li><a href="/">Homepage</a></li>
- <li><a href="/dashboard">Dashboard</a></li>
- <li><a href="/account">Account</a></li>
- </ul>
+ <ul>
+ <li><a href="/">Homepage</a></li>
+ <li><a href="/dashboard">Dashboard</a></li>
+ <li><a href="/account">Account</a></li>
+ </ul>
-The usage is similar to the Rails route file.
-You create named tabs with the syntax <tt>tab.name_of_tab</tt>.
+The usage is similar to the Rails route file. You create named tabs with the syntax `tab.name_of_tab`. The name you use creating a tab is the same you're going to refer to in your controller when you want to mark a tab as the current tab.
-The name you use creating a tab is the same you're going to refer to
-in your controller when you want to mark a tab as the current tab.
+Now, if the action belongs to `DashboardController`, the template will automatically render the following HTML code.
- class DashboardController < ApplicationController
- set_tab :dashboard
- end
+ <ul>
+ <li><a href="/">Homepage</a></li>
+ <li class="custom"><span>Dashboard</span></li>
+ <li><a href="/account">Account</a></li>
+ </ul>
-Now, if the action belongs to <tt>DashboardController</tt>,
-the template will automatically render the following HTML code.
+Use the `current_tab` helper method if you need to access the value of current tab in your controller or template.
- <ul>
- <li><a href="/">Homepage</a></li>
- <li class="custom"><span>Dashboard</span></li>
- <li><a href="/account">Account</a></li>
- </ul>
-
-Use the <tt>current_tab</tt> helper method if you need to access
-the value of current tab in your controller or template.
-
- class DashboardController < ApplicationController
- set_tab :dashboard
- end
-
- # In your view
- <p>The name of current tab is <%= current_tab %>.</p>
-
-=== Customizing a Tab
-
-You can pass a hash of options to customize the style and the behavior of the tab item.
-Behind the scenes, each time you create a tab, the <tt>#tab_for</tt>
-method is invoked.
-
- <%= tabs_tag do |tab| %>
- <%= tab.home 'Homepage', root_path, :style => "padding: 10px" %>
- <%= tab.dashboard 'Dashboard', dashboard_path %>
- <% end %>
-
- <ul>
- <li style="padding: 10px"><a href="/">Homepage</a></li>
- <li class="custom"><span>Dashboard</span></li>
- <li><a href="/account">Account</a></li>
- </ul>
-
-See <tt>TabsOnRails::Tabs::TabsBuilder#tab_for</tt> for more details.
-
-=== Customizing open_tabs and close_tabs
-
-The open_tabs and the close_tabs methods can be customized with the <tt>:open_tabs</tt> and <tt>:close_tabs</tt> option.
-
- <%= tabs_tag :open_tabs => { :id => "tabs", :class => "cool" } do |tab| %>
- <%= tab.home 'Homepage', root_path %>
- <%= tab.dashboard 'Dashboard', dashboard_path %>
- <%= tab.account 'Account', account_path %>
- <% end %>
-
- <ul id="tabs" class="cool">
- <li><a href="/">Homepage</a></li>
- <li><a href="/dashboard">Dashboard</a></li>
- <li><a href="/account">Account</a></li>
- </ul>
-
-
-Further customizations require a custom <tt>Builder</tt> (see below).
-
-
-== Restricting set_tab scope
-
-The <tt>set_tab</tt> method understands all options you are used to pass to a Rails controller filter.
-In fact, behind the scenes this method uses a <tt>before_filter</tt> to store the tab in the <tt>@tab_stack</tt> variable.
-
-Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
-
- class PostsController < ApplicationController
- set_tab :admin
- set_tab :posts, :only => %w(index show)
- end
-
- class ApplicationController < ActionController::Base
- set_tab :admin, :if => :admin_controller?
-
- def admin_controller?
- self.class.name =~ /^Admin(::|Controller)/
- end
- end
-
-
-== Using Namespaces to create Multiple Tabs
-
-Namespaces enable you to create and manage tabs in parallels. The best way to demonstrate namespace usage is with an example.
-
-Let's assume your application provides a first level navigation menu with 3 elements: :home, :dashboard, :projects. The relationship between your tabs and your controllers is 1:1 so you should end up with the following source code.
-
- class HomeController
- set_tab :home
- end
-
- class DashboardController
- set_tab :dashboard
- end
-
- class ProjectsController
- set_tab :projects
-
- def first; end
- def second; end
- def third; end
- end
-
-The project controller contains 3 actions and you might want to create a second-level navigation menu. This menu should reflect the navigation status of the user in the project page.
-
-Without namespaces, you wouldn't be able to accomplish this task because you already set the current tab value to :projects. You need to create a parallel navigation menu and uniquely identify it with a custom namespace.
-Let's call it :navigation.
-
- class ProjectsController
- set_tab :projects
-
- # Create an other tab navigation level
- set_tab :first, :navigation, :only => %w(first)
- set_tab :second, :navigation, :only => %w(second)
- set_tab :third, :navigation, :only => %w(third)
-
- def first; end
- def second; end
- def third; end
- end
-
-Voilà! That's all you need to do. And you can create an unlimited number of namespaces as long as you use an unique name to identify them.
-
-The default namespace is called :default. Passing :default as name is the same as don't using any namespace at all. The following lines are equivalent.
-
- set_tab :projects
- set_tab :projects, :default
-
-
-=== Rendering Tabs with Namespaces
-
-To switch namespace in your template, just pass the :namespace option to the <tt>tabs_tag</tt> helper method.
-
- <%= tabs_tag do |tab| %>
- <%= tab.home 'Homepage', root_path %>
- <%= tab.dashboard 'Dashboard', dashboard_path %>
- <%= tab.projects 'Projects', projects_path %>
- <% end %>
-
- <%= tabs_tag :namespace => :navigation do |tab| %>
- <%= tab.first 'First', first_project_path %>
- <%= tab.second 'Second', second_project_path %>
- <%= tab.third 'Account', third_project_path %>
- <% end %>
-
-=== Namespace scope
-
-As a bonus feature, the namespace needs to be unique within current request scope, not necessarily across the entire application.
-
-Back to the previous example, you can reuse the same namespace in the other controllers. In this way, you can reuse your templates as well.
-
- class HomeController
- set_tab :home
- end
-
- class DashboardController
- set_tab :dashboard
-
- set_tab :index, :navigation, :only => %w(index)
- set_tab :common, :navigation, :only => %w(foo bar)
-
- # ...
- end
-
- class ProjectsController
- set_tab :projects
-
- set_tab :first, :navigation, :only => %w(first)
- set_tab :second, :navigation, :only => %w(second)
- set_tab :third, :navigation, :only => %w(third)
-
- # ...
- end
-
-== Tab Builders
-
-The <tt>Builder</tt> is responsible for creating the tabs HTML code. This library is bundled with two <tt>Builders</tt>:
-
-<tt>Tabs::Builder</tt>:: this is the abstract interface for any custom builder.
-<tt>Tabs::TabsBuilder</tt>:: this is the default builder.
-
-=== Understanding the Builder
-
-Builders act as formatters. A Builder encapsulates all the logic behind the tab creation including the code required to toggle tabs status.
-
-When the <tt>tabs_tag</tt> helper is called, it creates a new <tt>Tabs</tt> instance with selected Builder.
-If you don't provide a custom builder, then <tt>Tabs::TabsBuilder</tt> is used by default.
-
-=== Creating a custom Builder
-
-All builders must extend the base <tt>Tabs::Builder</tt> class and implement at least the <tt>tab_for</tt> method.
-Additional overridable methods include:
-
-<tt>open_tabs</tt>:: the method called before the tab set
-<tt>close_tabs</tt>:: the method called after the tab set
-<tt>tab_for</tt>:: the method called to create a single tab item
-
-The following example creates a custom tab builder called <tt>MenuTabBuilder</tt>.
-
- class MenuTabBuilder < TabsOnRails::Tabs::Builder
- def open_tabs(options = {})
- @context.tag("ul", options, open = true)
- end
-
- def close_tabs(options = {})
- "</ul>".html_safe
+ class DashboardController < ApplicationController
+ set_tab :dashboard
end
- def tab_for(tab, name, options, item_options = {})
- item_options[:class] = (current_tab?(tab) ? 'active' : '')
- @context.content_tag(:li, item_options) do
- @context.link_to(name, options)
- end
- end
- end
-
-=== Using a custom Builder
-
-In your view, simply pass the builder class to the <tt>tabs_tag</tt> method.
-
- <%= tabs_tag(:builder => MenuTabBuilder) do |tab| %>
- <%= tab.home 'Homepage', root_path %>
- <%= tab.dashboard, 'Dashboard', dashboard_path %>
- <%= tab.account 'Account', account_path, :style => 'float: right;' %>
- <% end %>
-
-This is the final result.
+ # In your view
+ <p>The name of current tab is <%= current_tab %>.</p>
- <ul>
- <li class=""><a href="/">Homepage</a></li>
- <li class="active"><a href="/dashboard">Dashboard</a></li>
- <li class="" style="float: right;"><a href="/account">Account</a></li>
- </ul>
+Read the [documentation](/code/tabs_on_rails/docs/) to learn more about advanced usage, builders and namespaces.
-== Author
+## Credits
-* {Simone Carletti}[http://www.simonecarletti.com] <weppos@weppos.net>
+* [Simone Carletti](http://www.simonecarletti.com/) <weppos@weppos.net> - The Author
-== Resources
+## Resources
-* {Homepage}[http://www.simonecarletti.com/code/tabs_on_rails]
-* {Source}[http://github.com/weppos/tabs_on_rails]
-* {API Documentation}[http://www.simonecarletti.com/code/tabs_on_rails/api/]
-* {Bugs & Features}[http://github.com/weppos/tabs_on_rails/issues]
+* [Homepage](http://www.simonecarletti.com/code/tabs_on_rails)
+* [Documentation](http://www.simonecarletti.com/code/tabs_on_rails/docs/)
+* [API](http://rubydoc.info/gems/tabs_on_rails)
+* [Repository](https://github.com/weppos/tabs_on_rails)
+* [Issue Tracker](http://github.com/weppos/tabs_on_rails/issues)
-== License
+## License
-TabsOnRails is Copyright (c) 2009-2011 Simone Carletti.
-This is Free Software distributed under the MIT license.
+*TabsOnRails* is Copyright (c) 2009-2012 Simone Carletti. This is Free Software distributed under the MIT license.
View
@@ -1,16 +1,9 @@
-#
-# = Tabs on Rails
+#--
+# Tabs on Rails
#
# A simple Ruby on Rails plugin for creating and managing Tabs.
-#
-#
-# Category:: Rails
-# Package:: TabsOnRails
-# Author:: Simone Carletti <weppos@weppos.net>
-# License:: MIT License
#
-#--
-#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
#++
@@ -19,6 +12,7 @@
require 'tabs_on_rails/action_controller'
require 'tabs_on_rails/railtie'
+
module TabsOnRails
NAME = "Tabs on Rails"
Oops, something went wrong.

0 comments on commit 356e0f9

Please sign in to comment.