weppos-tabs_on_rails 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +10 -0
- data/README.rdoc +151 -3
- data/Rakefile +5 -5
- data/init.rb +1 -1
- data/lib/tabs_on_rails/controller_mixin.rb +1 -1
- data/lib/tabs_on_rails/tabs.rb +1 -1
- data/lib/tabs_on_rails/version.rb +2 -2
- data/lib/tabs_on_rails.rb +1 -1
- data/rails/init.rb +5 -0
- data/tabs_on_rails.gemspec +6 -6
- metadata +8 -7
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
|
4
|
+
== Release 0.2.0
|
5
|
+
|
6
|
+
* ADDED: The README file is definitely more useful now, filled up with some basic documentation.
|
7
|
+
|
8
|
+
* CHANGED: Use the standard way to initialize a Rails plugin when packaged as a GEM (closes #146).
|
9
|
+
|
10
|
+
* CHANGED: Removed development version warning (closes #145).
|
11
|
+
|
12
|
+
|
3
13
|
== Release 0.1.0
|
4
14
|
|
5
15
|
* Initial version
|
data/README.rdoc
CHANGED
@@ -3,8 +3,156 @@
|
|
3
3
|
TabsOnRails is a simple Rails plugin for creating and managing Tabs.
|
4
4
|
It provides helpers for creating tabs with a flexible interface.
|
5
5
|
|
6
|
-
*WARNING*: This library has not been released yet.
|
7
|
-
This package seems stable, but should be considered a development release.
|
8
6
|
|
7
|
+
== Rails Installation
|
9
8
|
|
10
|
-
|
9
|
+
=== As a Gem
|
10
|
+
|
11
|
+
This is the preferred way to install TabsOnRails and the best way if you want install a stable version.
|
12
|
+
You can specify the GEM dependency in your application environment.rb file:
|
13
|
+
|
14
|
+
Rails::Initializer.run do |config|
|
15
|
+
|
16
|
+
# other configurations
|
17
|
+
|
18
|
+
config.gem "weppos-tabs_on_rails", :lib => "tabs_on_rails", :source => "http://gems.github.com"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
=== As a Plugin
|
23
|
+
|
24
|
+
This is the preferred way if you want to live on the edge and install a development version.
|
25
|
+
|
26
|
+
$ script/plugin install git://github.com/weppos/tabs_on_rails.git
|
27
|
+
|
28
|
+
|
29
|
+
== Quick Start
|
30
|
+
|
31
|
+
In your template use the <tt>tabs_tag</tt> helper to create your tab.
|
32
|
+
|
33
|
+
<% tabs_tab do |tab| %>
|
34
|
+
<%= tab.home, 'Homepage', root_path %>
|
35
|
+
<%= tab.dashboard, 'Dashboard', dashboard_path %>
|
36
|
+
<%= tab.account, 'Account', account_path %>
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
The example above produces the following HTML output.
|
40
|
+
|
41
|
+
<ul>
|
42
|
+
<li><a href="/">Homepage</a></li>
|
43
|
+
<li><a href="/dashboard">Dashboard</a></li>
|
44
|
+
<li><a href="/account">Account</a></li>
|
45
|
+
</ul>
|
46
|
+
|
47
|
+
The usage is similar to the Rails route file.
|
48
|
+
You create named tabs with the syntax <tt>tab.name_of_tab</tt>.
|
49
|
+
|
50
|
+
The name you use creating a tab is the same you're going to refer to in your controller
|
51
|
+
when you want to mark a tab as the current_tab.
|
52
|
+
|
53
|
+
class DashboardController < ApplicationController
|
54
|
+
current_tab :dashboard
|
55
|
+
end
|
56
|
+
|
57
|
+
Now, if the action belongs to DashboardController, the template will automatically render the following HTML code.
|
58
|
+
|
59
|
+
<ul>
|
60
|
+
<li><a href="/">Homepage</a></li>
|
61
|
+
<li><span>Dashboard</span></li>
|
62
|
+
<li><a href="/account">Account</a></li>
|
63
|
+
</ul>
|
64
|
+
|
65
|
+
|
66
|
+
== Restricting current_tab scope
|
67
|
+
|
68
|
+
The <tt>current_tab</tt> method understands all options you are used to pass to a Rails controller filter.
|
69
|
+
In fact, behind the scenes this method uses a <tt>before_filter</tt> to set a special <tt>@current_tab</tt> variable.
|
70
|
+
|
71
|
+
Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
|
72
|
+
|
73
|
+
class PostsController < ApplicationController
|
74
|
+
current_tab :admin
|
75
|
+
current_tab :posts, :only => [ :index, :show ]
|
76
|
+
end
|
77
|
+
|
78
|
+
class ApplicationController < ActionController::Base
|
79
|
+
current_tab :admin, :if => :admin_controller?
|
80
|
+
|
81
|
+
def admin_controller?
|
82
|
+
self.class.name =~ /^Admin(::|Controller)/
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
== Tab Builders
|
88
|
+
|
89
|
+
The <tt>Builder</tt> is responsible for creating the tabs HTML code. This library is bundled with two <tt>Builders</tt>:
|
90
|
+
|
91
|
+
<tt>Tabs::Builder</tt>:: this is the abstract interface for any custom builder.
|
92
|
+
<tt>Tabs::TabsBuilder</tt>:: this is the default builder.
|
93
|
+
|
94
|
+
=== Understanding the Builder
|
95
|
+
|
96
|
+
Builders act as formatters. A Builder incapsulates all the logic behind the tab creation including the code required to toggle tabs status.
|
97
|
+
|
98
|
+
When the <tt>tabs_tag</tt> helper is called, it creates a new <tt>Tabs</tt> instance with selected Builder.
|
99
|
+
If you don't provide a custom builder, then <tt>Tabs::TabsBuilder</tt> is used by default.
|
100
|
+
|
101
|
+
=== Creating a custom Builder
|
102
|
+
|
103
|
+
All builders must extend the base <tt>Tabs::Builder</tt> class and implement at least the <tt>tab_for</tt> method.
|
104
|
+
Additional overridable methods include:
|
105
|
+
|
106
|
+
<tt>open_tabs</tt>:: the method called before the tab set
|
107
|
+
<tt>close_tabs</tt>:: the method called after the tab set
|
108
|
+
<tt>tab_for</tt>:: the method called to create a single tab item
|
109
|
+
|
110
|
+
The following example creates a custom tab builder called MainTabBuilder.
|
111
|
+
|
112
|
+
class MenuTabBuilder < TabsOnRails::Tabs::Builder
|
113
|
+
def tab_for(tab, name, options, item_options = {})
|
114
|
+
item_options[:class] = (current_tab?(tab) ? 'active' : '')
|
115
|
+
@context.content_tag(:li, item_options) do
|
116
|
+
@context.link_to(name, options)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
=== Using a custom Builder
|
122
|
+
|
123
|
+
In your view, simply pass the builder class to the <tt>tabs_tag</tt> method.
|
124
|
+
|
125
|
+
<% tabs_tag(MenuTabBuilder) do |tab| %>
|
126
|
+
<%= tab.home, 'Homepage', root_path %>
|
127
|
+
<%= tab.dashboard, 'Dashboard', dashboard_path %>
|
128
|
+
<%= tab.account, 'Account', account_path, :style => 'float: right;' %>
|
129
|
+
<% end %>
|
130
|
+
|
131
|
+
This is the final result.
|
132
|
+
|
133
|
+
<ul>
|
134
|
+
<li class=""><a href="/">Homepage</a></li>
|
135
|
+
<li class="active"><a href="/dashboard">Dashboard</a></li>
|
136
|
+
<li class="" style="float: right;"><a href="/account">Account</a></li>
|
137
|
+
</ul>
|
138
|
+
|
139
|
+
== Documentation
|
140
|
+
|
141
|
+
The library is still under development and this README file might not be contain the latest changes.
|
142
|
+
For the full documentation, development roadmap and more information please visit the {project page}[http://code.simonecarletti.com/wiki/tabsonrails].
|
143
|
+
|
144
|
+
|
145
|
+
== Credits
|
146
|
+
|
147
|
+
Author:: {Simone Carletti}[http://www.simonecarletti.com/] <weppos@weppos.net>
|
148
|
+
|
149
|
+
|
150
|
+
== Resources
|
151
|
+
|
152
|
+
* {Homepage}[http://code.simonecarletti.com/tabsonrails]
|
153
|
+
* {GitHub}[http://github.com/weppos/tabs_on_rails/]
|
154
|
+
|
155
|
+
|
156
|
+
== License
|
157
|
+
|
158
|
+
Copyright (c) 2009 Simone Carletti, TabsOnRails is released under the MIT license.
|
data/Rakefile
CHANGED
@@ -8,8 +8,8 @@ require 'tabs_on_rails'
|
|
8
8
|
|
9
9
|
PKG_NAME = ENV['PKG_NAME'] || TabsOnRails::GEM
|
10
10
|
PKG_VERSION = ENV['PKG_VERSION'] || TabsOnRails::VERSION
|
11
|
-
PKG_SUMMARY = "
|
12
|
-
PKG_FILES = FileList.new("{lib,tasks,test}/**/*") do |files|
|
11
|
+
PKG_SUMMARY = "A simple Ruby on Rails plugin for creating and managing Tabs."
|
12
|
+
PKG_FILES = FileList.new("{lib,rails,tasks,test}/**/*") do |files|
|
13
13
|
files.include %w(*.{rdoc,rb})
|
14
14
|
files.include %w(Rakefile)
|
15
15
|
end
|
@@ -25,10 +25,10 @@ Echoe.new(PKG_NAME, PKG_VERSION) do |p|
|
|
25
25
|
p.email = "weppos@weppos.net"
|
26
26
|
p.summary = PKG_SUMMARY
|
27
27
|
p.description = <<-EOD
|
28
|
-
TabsOnRails is a simple Rails plugin for creating and managing Tabs. \
|
28
|
+
TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. \
|
29
29
|
It provides helpers for creating tabs with a flexible interface.
|
30
30
|
EOD
|
31
|
-
p.url = "http://code.simonecarletti.com/
|
31
|
+
p.url = "http://code.simonecarletti.com/tabsonrails"
|
32
32
|
p.project = RUBYFORGE_PROJECT
|
33
33
|
|
34
34
|
p.need_zip = true
|
@@ -44,7 +44,7 @@ begin
|
|
44
44
|
require 'code_statistics'
|
45
45
|
desc "Show library's code statistics"
|
46
46
|
task :stats do
|
47
|
-
CodeStatistics.new(["
|
47
|
+
CodeStatistics.new(["TabsOnRails", "lib"],
|
48
48
|
["Tests", "test"]).to_s
|
49
49
|
end
|
50
50
|
rescue LoadError
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), 'rails', 'init')
|
data/lib/tabs_on_rails/tabs.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# = Tabs on Rails
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# A simple Ruby on Rails plugin for creating and managing Tabs.
|
5
5
|
#
|
6
6
|
#
|
7
7
|
# Category:: Rails
|
@@ -18,7 +18,7 @@ module TabsOnRails
|
|
18
18
|
|
19
19
|
module Version
|
20
20
|
MAJOR = 0
|
21
|
-
MINOR =
|
21
|
+
MINOR = 2
|
22
22
|
TINY = 0
|
23
23
|
|
24
24
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
data/lib/tabs_on_rails.rb
CHANGED
data/rails/init.rb
ADDED
data/tabs_on_rails.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tabs_on_rails}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{2009-02-
|
10
|
-
s.description = %q{TabsOnRails is a simple Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.}
|
9
|
+
s.date = %q{2009-02-17}
|
10
|
+
s.description = %q{TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.}
|
11
11
|
s.email = %q{weppos@weppos.net}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb", "LICENSE.rdoc", "README.rdoc"]
|
13
|
-
s.files = ["CHANGELOG.rdoc", "init.rb", "install.rb", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb", "LICENSE.rdoc", "
|
13
|
+
s.files = ["CHANGELOG.rdoc", "init.rb", "install.rb", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb", "LICENSE.rdoc", "rails/init.rb", "Rakefile", "README.rdoc", "tabs_on_rails.gemspec", "tasks/tabs_on_rails_tasks.rake", "test/builder_test.rb", "test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/fixtures/mixin/standard.html.erb", "test/tabs_builder_test.rb", "test/tabs_on_rails_test.rb", "test/test_helper.rb", "uninstall.rb", "Manifest"]
|
14
14
|
s.has_rdoc = true
|
15
|
-
s.homepage = %q{http://code.simonecarletti.com/
|
15
|
+
s.homepage = %q{http://code.simonecarletti.com/tabsonrails}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tabs_on_rails", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubygems_version = %q{1.3.1}
|
19
|
-
s.summary = %q{
|
19
|
+
s.summary = %q{A simple Ruby on Rails plugin for creating and managing Tabs.}
|
20
20
|
s.test_files = ["test/builder_test.rb", "test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/tabs_builder_test.rb", "test/tabs_on_rails_test.rb", "test/test_helper.rb"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weppos-tabs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "3.1"
|
34
34
|
version:
|
35
|
-
description: TabsOnRails is a simple Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.
|
35
|
+
description: TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.
|
36
36
|
email: weppos@weppos.net
|
37
37
|
executables: []
|
38
38
|
|
@@ -55,9 +55,10 @@ files:
|
|
55
55
|
- lib/tabs_on_rails/version.rb
|
56
56
|
- lib/tabs_on_rails.rb
|
57
57
|
- LICENSE.rdoc
|
58
|
-
-
|
58
|
+
- rails/init.rb
|
59
59
|
- Rakefile
|
60
60
|
- README.rdoc
|
61
|
+
- tabs_on_rails.gemspec
|
61
62
|
- tasks/tabs_on_rails_tasks.rake
|
62
63
|
- test/builder_test.rb
|
63
64
|
- test/controller_mixin_helpers_test.rb
|
@@ -67,9 +68,9 @@ files:
|
|
67
68
|
- test/tabs_on_rails_test.rb
|
68
69
|
- test/test_helper.rb
|
69
70
|
- uninstall.rb
|
70
|
-
-
|
71
|
+
- Manifest
|
71
72
|
has_rdoc: true
|
72
|
-
homepage: http://code.simonecarletti.com/
|
73
|
+
homepage: http://code.simonecarletti.com/tabsonrails
|
73
74
|
post_install_message:
|
74
75
|
rdoc_options:
|
75
76
|
- --line-numbers
|
@@ -98,7 +99,7 @@ rubyforge_project:
|
|
98
99
|
rubygems_version: 1.2.0
|
99
100
|
signing_key:
|
100
101
|
specification_version: 2
|
101
|
-
summary:
|
102
|
+
summary: A simple Ruby on Rails plugin for creating and managing Tabs.
|
102
103
|
test_files:
|
103
104
|
- test/builder_test.rb
|
104
105
|
- test/controller_mixin_helpers_test.rb
|