navigator 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +62 -8
- data/lib/navigator/menu.rb +16 -5
- data/lib/navigator/tag.rb +8 -0
- data/lib/navigator/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50aeb1e3d4da2ff847558e659609b7c05eb9943b
|
4
|
+
data.tar.gz: a5d04fbcb4d629600980986a8c393fab5f7fbc18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb8decf8ffa561b31ea79bb521e5998dec794c7e409d9b6baac45283fd91b56a69dfe563176526ef1059c922543e1337f29fe1f2a655c2a94de0fac1c656a14
|
7
|
+
data.tar.gz: 62ae481797701da993c1fa1c9a656574c433e6f02c147e0aefe9ca2ea50b637048aaed266eb9db7fd869eb37ad721bc8d7006ac7efba0ddb88073c2595e4fe43
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Enhances Rails with a DSL for menu navigation.
|
|
14
14
|
* Provides a simple DSL for building navigation menus.
|
15
15
|
* Supports auto-detection/highlighting of active menu items based on current path (customizable for non-path usage too).
|
16
16
|
* Supports sub-menus, nested tags, HTML attributes, etc.
|
17
|
-
* Supports the following HTML tags: nav, ul, li, a, b, em, s, small, span, strong, sub, and sup.
|
17
|
+
* Supports the following HTML tags: nav, section, h1-h6, ul, li, a, b, em, s, small, span, strong, sub, and sup.
|
18
18
|
* Provides an "item" convenience method which combines the "li" and "a" HTML tags into a single method for less typing.
|
19
19
|
|
20
20
|
# Requirements
|
@@ -79,6 +79,22 @@ Result:
|
|
79
79
|
<li><a href="/posts">Posts</a></li>
|
80
80
|
</ul>
|
81
81
|
|
82
|
+
## Unordered List (with multiple data attributes)
|
83
|
+
|
84
|
+
Code:
|
85
|
+
|
86
|
+
navigation do
|
87
|
+
item "Home", "/home", data: {id: 1, type: "public"}
|
88
|
+
end
|
89
|
+
|
90
|
+
Result:
|
91
|
+
|
92
|
+
<ul>
|
93
|
+
<li data-id="1" data-type="public"><a href="/home">Home</a></li>
|
94
|
+
</ul>
|
95
|
+
|
96
|
+
*TIP: Nested data-* attributes can be applied to any menu item in the same manner as Rails view helpers.*
|
97
|
+
|
82
98
|
## Nav (with links)
|
83
99
|
|
84
100
|
Code:
|
@@ -99,17 +115,55 @@ Result:
|
|
99
115
|
|
100
116
|
Code:
|
101
117
|
|
102
|
-
navigation "
|
103
|
-
|
104
|
-
|
118
|
+
navigation "nav", class: "top-bar", "data-topbar" => nil do
|
119
|
+
ul nil, class: "title-area" do
|
120
|
+
li nil, class: "name" do
|
121
|
+
h1 do
|
122
|
+
a "Demo", href: "/home"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
section nil, class: "top-bar-section" do
|
128
|
+
ul nil, class: "left" do
|
129
|
+
item "Home", "/"
|
130
|
+
item "About", "/about"
|
131
|
+
end
|
132
|
+
|
133
|
+
ul nil, class: "right" do
|
134
|
+
item "v1.0.0", '#'
|
135
|
+
end
|
136
|
+
|
137
|
+
ul nil, class: "right" do
|
138
|
+
item "Login", "/login", {}, {class: "button tiny round"}
|
139
|
+
end
|
140
|
+
end
|
105
141
|
end
|
106
142
|
|
107
143
|
Result:
|
108
144
|
|
109
|
-
<
|
110
|
-
<
|
111
|
-
|
112
|
-
|
145
|
+
<nav class="top-bar" data-topbar="">
|
146
|
+
<ul class="title-area">
|
147
|
+
<li class="name">
|
148
|
+
<h1><a href="/" class="active">Demo</a></h1>
|
149
|
+
</li>
|
150
|
+
</ul>
|
151
|
+
|
152
|
+
<section class="top-bar-section">
|
153
|
+
<ul class="left">
|
154
|
+
<li class="active"><a href="/">Home</a></li>
|
155
|
+
<li><a href="/about">About</a></li>
|
156
|
+
</ul>
|
157
|
+
|
158
|
+
<ul class="right">
|
159
|
+
<li><a href="#">v1.0.0</a></li>
|
160
|
+
</ul>
|
161
|
+
|
162
|
+
<ul class="right">
|
163
|
+
<li><a class="button tiny round" href="/login">Login</a></li>
|
164
|
+
</ul>
|
165
|
+
</section>
|
166
|
+
</nav>
|
113
167
|
|
114
168
|
## Bootstrap Dropdown
|
115
169
|
|
data/lib/navigator/menu.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Navigator
|
2
2
|
# Renders a HTML menu.
|
3
3
|
class Menu
|
4
|
+
def self.allowed_methods
|
5
|
+
%r(^(section|h[1-6]|ul|li|a|b|em|s|small|span|strong|sub|sup)$)
|
6
|
+
end
|
7
|
+
|
4
8
|
def initialize template, tag = "ul", attributes = {}, menu_activator = Navigator::TagActivator.new, &block
|
5
9
|
@template = template
|
6
10
|
@tag = Tag.new tag, nil, attributes, menu_activator
|
@@ -33,12 +37,15 @@ module Navigator
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
40
|
+
def respond_to? name
|
41
|
+
method_allowed?(name) || super(name)
|
42
|
+
end
|
43
|
+
|
36
44
|
def method_missing name, *args, &block
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
template.public_send name, *args
|
45
|
+
if method_allowed?(name.to_s)
|
46
|
+
add(*args.unshift(name), &block)
|
47
|
+
else
|
48
|
+
template.public_send name, *args
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
@@ -49,5 +56,9 @@ module Navigator
|
|
49
56
|
private
|
50
57
|
|
51
58
|
attr_accessor :template, :tag, :menu_activator, :items
|
59
|
+
|
60
|
+
def method_allowed? name
|
61
|
+
self.class.allowed_methods === name
|
62
|
+
end
|
52
63
|
end
|
53
64
|
end
|
data/lib/navigator/tag.rb
CHANGED
@@ -26,7 +26,15 @@ module Navigator
|
|
26
26
|
|
27
27
|
attr_reader :attributes, :activator
|
28
28
|
|
29
|
+
def expand_data_attributes!
|
30
|
+
if attributes.key? :data
|
31
|
+
attributes[:data].each { |key, value| attributes["data-#{key}"] = value }
|
32
|
+
attributes.delete :data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
29
36
|
def formatted_attributes
|
37
|
+
expand_data_attributes!
|
30
38
|
attrs = activator.activate(attributes).map { |key, value| %(#{key}="#{value}") } * ' '
|
31
39
|
attrs.empty? ? nil : " #{attrs}"
|
32
40
|
end
|
data/lib/navigator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navigator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
fMlZDUGx3lQarp/vPjK+6XH7DLXjBEKqeIGBIpLthYUvDxJRp23C+T3liGSL32vg
|
31
31
|
mSpxxwmK95GDFuEy2mNPaxnazdkw8c+7DbrSpzd/CnNZkRgitxOavs8=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-07-
|
33
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: pry-byebug
|
metadata.gz.sig
CHANGED
Binary file
|