tabit 0.1.2 → 0.2.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/.rvmrc +1 -20
- data/LICENSE.md +1 -1
- data/README.md +9 -6
- data/lib/tabit.rb +1 -0
- data/lib/tabit/builder.rb +11 -33
- data/lib/tabit/helper.rb +4 -7
- data/lib/tabit/item.rb +104 -0
- data/lib/tabit/version.rb +2 -2
- data/tabit.gemspec +4 -3
- metadata +33 -12
data/.rvmrc
CHANGED
@@ -1,20 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
environment_id="ruby-1.9.3-head@langwhich"
|
4
|
-
|
5
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
6
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
7
|
-
then
|
8
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
9
|
-
|
10
|
-
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
11
|
-
then
|
12
|
-
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
13
|
-
fi
|
14
|
-
else
|
15
|
-
if ! rvm --create use "$environment_id"
|
16
|
-
then
|
17
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
18
|
-
return 1
|
19
|
-
fi
|
20
|
-
fi
|
1
|
+
rvm use ruby-1.9.3-head@tabit --create
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
# Tabit [](https://secure.travis-ci.org/Langwhich/tabit.png)
|
2
2
|
|
3
3
|
Tabit is a simple tab menu generator. It depends on `active_link_to`
|
4
4
|
helper. If you dont know how to set an item active take a look at it first.
|
5
|
+
The generated source is compatible to bootstrap tabs with dropdowns.
|
5
6
|
|
6
7
|
## Install
|
7
8
|
|
@@ -12,12 +13,14 @@ helper. If you dont know how to set an item active take a look at it first.
|
|
12
13
|
## Usage
|
13
14
|
|
14
15
|
```ruby
|
15
|
-
= tabit 'nav nav-tabs' do |
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
= tabit :class => 'nav nav-tabs' do |t1|
|
17
|
+
- t1.add 'Videos', videos_path
|
18
|
+
- t1.add 'Movies', movies_path, :active => /movies(\/\d)*(\/edit)*$/
|
19
|
+
- t1.add 'Movies, movies_path, :active => :exclusive, :type => :dropdown do |t2|
|
20
|
+
- t2.add 'Add movie', new_movie_path, :active => :exclusive
|
19
21
|
```
|
20
22
|
|
21
23
|
## Credits
|
22
24
|
|
23
|
-
Copyright (c)
|
25
|
+
Copyright (c) 20112 Langwhich GmbH <http://www.langwhich.com>
|
26
|
+
|
data/lib/tabit.rb
CHANGED
data/lib/tabit/builder.rb
CHANGED
@@ -1,43 +1,21 @@
|
|
1
1
|
module Tabit
|
2
|
-
class Builder
|
3
|
-
|
4
|
-
|
2
|
+
class Builder < Item
|
3
|
+
def initialize(template, options, &block)
|
4
|
+
@@template = template
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
@children = []
|
7
|
+
@options = options
|
8
8
|
|
9
|
-
|
10
|
-
@template = template
|
9
|
+
yield self if block_given?
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
url ||= '#'
|
19
|
-
|
20
|
-
clazz = template.active_link_to_class(
|
21
|
-
url,
|
22
|
-
{
|
23
|
-
:active => options[:active],
|
24
|
-
:class_active => configuration.active_class
|
25
|
-
}
|
12
|
+
def to_s
|
13
|
+
template.content_tag(
|
14
|
+
:ul,
|
15
|
+
children.collect(&:to_s).join.html_safe,
|
16
|
+
options
|
26
17
|
)
|
27
|
-
|
28
|
-
options[:outer][:class] = '' if options[:outer][:class].nil?
|
29
|
-
options[:outer][:class] << " #{clazz}"
|
30
|
-
options[:outer][:class].strip!
|
31
|
-
|
32
|
-
content_tag(:li, name, options[:outer]) do
|
33
|
-
template.link_to name, url, options[:inner]
|
34
|
-
end
|
35
18
|
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
def configuration
|
39
|
-
Tabit.configuration
|
40
|
-
end
|
41
19
|
end
|
42
20
|
end
|
43
21
|
|
data/lib/tabit/helper.rb
CHANGED
@@ -2,14 +2,11 @@ module Tabit
|
|
2
2
|
module Helper
|
3
3
|
include ActionView::Helpers::TagHelper
|
4
4
|
include ActionView::Helpers::UrlHelper
|
5
|
-
include ActionView::Helpers::CaptureHelper
|
6
5
|
|
7
|
-
def tabit(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
yield(configuration.builder_class.new(self))
|
12
|
-
end
|
6
|
+
def tabit(options = {}, &block)
|
7
|
+
configuration
|
8
|
+
.builder_class
|
9
|
+
.new(self, options, &block).to_s
|
13
10
|
end
|
14
11
|
|
15
12
|
protected
|
data/lib/tabit/item.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
module Tabit
|
2
|
+
class Item
|
3
|
+
include ActionView::Helpers::TagHelper
|
4
|
+
include ActionView::Helpers::UrlHelper
|
5
|
+
|
6
|
+
cattr_accessor :template
|
7
|
+
attr_accessor :children
|
8
|
+
|
9
|
+
attr_accessor :name
|
10
|
+
attr_accessor :url
|
11
|
+
attr_accessor :options
|
12
|
+
|
13
|
+
def initialize(name, url = nil, options = {})
|
14
|
+
@name, @url, @options = name, url, options
|
15
|
+
|
16
|
+
@active = @options.delete(:active) || configuration.active_detect
|
17
|
+
@type = @options.delete(:type) || :default
|
18
|
+
|
19
|
+
@children = []
|
20
|
+
|
21
|
+
@options[:inner] ||= {}
|
22
|
+
@options[:outer] ||= {}
|
23
|
+
|
24
|
+
clazz = template.active_link_to_class(
|
25
|
+
url,
|
26
|
+
{
|
27
|
+
active: @active,
|
28
|
+
class_active: configuration.active_class
|
29
|
+
}
|
30
|
+
)
|
31
|
+
|
32
|
+
@options[:outer][:class] = '' if @options[:outer][:class].nil?
|
33
|
+
@options[:outer][:class] << " #{clazz}"
|
34
|
+
@options[:outer][:class].strip!
|
35
|
+
end
|
36
|
+
|
37
|
+
def add(name, url = nil, options = {})
|
38
|
+
Item.new(name, url, options).tap do |adding|
|
39
|
+
@children << adding
|
40
|
+
yield adding if block_given?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
case @type
|
46
|
+
when :dropdown
|
47
|
+
options[:outer][:class] = '' if @options[:outer][:class].nil?
|
48
|
+
options[:outer][:class] << " dropdown"
|
49
|
+
options[:outer][:class].strip!
|
50
|
+
|
51
|
+
options[:inner][:class] = '' if @options[:inner][:class].nil?
|
52
|
+
options[:inner][:class] << " dropdown-toggle"
|
53
|
+
options[:inner][:class].strip!
|
54
|
+
|
55
|
+
options[:inner][:data] ||= {}
|
56
|
+
options[:inner][:data][:toggle] = 'dropdown'
|
57
|
+
|
58
|
+
template.content_tag(
|
59
|
+
:li,
|
60
|
+
[
|
61
|
+
template.link_to([name, content_tag(:b, '', :class => 'caret')].join.html_safe, url, options[:inner]),
|
62
|
+
output
|
63
|
+
].compact.join.html_safe,
|
64
|
+
options[:outer]
|
65
|
+
)
|
66
|
+
else
|
67
|
+
template.content_tag(
|
68
|
+
:li,
|
69
|
+
[
|
70
|
+
template.link_to(name, url, options[:inner]),
|
71
|
+
output
|
72
|
+
].compact.join.html_safe,
|
73
|
+
options[:outer]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
def output
|
80
|
+
if children.empty?
|
81
|
+
nil
|
82
|
+
else
|
83
|
+
case @type
|
84
|
+
when :dropdown
|
85
|
+
template.content_tag(
|
86
|
+
:ul,
|
87
|
+
children.collect(&:to_s).join.html_safe,
|
88
|
+
:class => 'dropdown-menu'
|
89
|
+
)
|
90
|
+
else
|
91
|
+
template.content_tag(
|
92
|
+
:ul,
|
93
|
+
children.collect(&:to_s).join.html_safe
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def configuration
|
100
|
+
Tabit.configuration
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
data/lib/tabit/version.rb
CHANGED
data/tabit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "tabit"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thomas Boerger", "Tim Rudat"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-30"
|
13
13
|
s.email = "thomas.boerger@langwhich.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.md",
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/tabit/cell.rb",
|
30
30
|
"lib/tabit/config.rb",
|
31
31
|
"lib/tabit/helper.rb",
|
32
|
+
"lib/tabit/item.rb",
|
32
33
|
"lib/tabit/railtie.rb",
|
33
34
|
"lib/tabit/version.rb",
|
34
35
|
"tabit.gemspec"
|
@@ -36,7 +37,7 @@ Gem::Specification.new do |s|
|
|
36
37
|
s.homepage = "https://github.com/Langwhich/tabit"
|
37
38
|
s.licenses = ["MIT"]
|
38
39
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = "1.8.
|
40
|
+
s.rubygems_version = "1.8.21"
|
40
41
|
s.summary = "Tabit is a simple tab menu generator"
|
41
42
|
|
42
43
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-04-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_link_to
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.0
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: redcarpet
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ~>
|
@@ -33,10 +38,15 @@ dependencies:
|
|
33
38
|
version: 2.1.0
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.1.0
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: yard
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ~>
|
@@ -44,10 +54,15 @@ dependencies:
|
|
44
54
|
version: 0.7.5
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.7.5
|
48
63
|
- !ruby/object:Gem::Dependency
|
49
64
|
name: jeweler
|
50
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
51
66
|
none: false
|
52
67
|
requirements:
|
53
68
|
- - ~>
|
@@ -55,7 +70,12 @@ dependencies:
|
|
55
70
|
version: 1.8.3
|
56
71
|
type: :development
|
57
72
|
prerelease: false
|
58
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.3
|
59
79
|
description:
|
60
80
|
email: thomas.boerger@langwhich.com
|
61
81
|
executables: []
|
@@ -77,6 +97,7 @@ files:
|
|
77
97
|
- lib/tabit/cell.rb
|
78
98
|
- lib/tabit/config.rb
|
79
99
|
- lib/tabit/helper.rb
|
100
|
+
- lib/tabit/item.rb
|
80
101
|
- lib/tabit/railtie.rb
|
81
102
|
- lib/tabit/version.rb
|
82
103
|
- tabit.gemspec
|
@@ -95,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
116
|
version: '0'
|
96
117
|
segments:
|
97
118
|
- 0
|
98
|
-
hash:
|
119
|
+
hash: -786843556050653153
|
99
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
121
|
none: false
|
101
122
|
requirements:
|
@@ -104,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
125
|
version: '0'
|
105
126
|
requirements: []
|
106
127
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
128
|
+
rubygems_version: 1.8.21
|
108
129
|
signing_key:
|
109
130
|
specification_version: 3
|
110
131
|
summary: Tabit is a simple tab menu generator
|