navigator 5.0.0 → 5.5.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +498 -0
- data/lib/navigator/identity.rb +4 -15
- data/lib/navigator/menu.rb +5 -5
- metadata +29 -238
- metadata.gz.sig +0 -0
- data/README.md +0 -419
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d51966858f7e4d95ea10f0ae9f94010b23c7f7f980d89caa717862acb9ff7c
|
4
|
+
data.tar.gz: d1bb4c5514d1cdc6a56f15ed3a705d0e4ab8417519f5aebd7e11656213b84c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63f0fb171e36398ac79b7c6a1a783285a804f2f90d43c1a33f026f4a7ad528e4703e7debd92068d5ee01f78dba1625917c8745d422699852b69ea9e48abcad63
|
7
|
+
data.tar.gz: 486778d7294780c7c823163bcf3a47d45e2c826cfe9905b933575f13c87e67ca7dd18ca34ea5777c6fdbc494afb561258e040def7eb5b58f47f484b6d03c9ad3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/{LICENSE.md → LICENSE.adoc}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
= Apache License
|
2
2
|
|
3
3
|
Version 2.0, January 2004
|
4
4
|
|
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
|
|
6
6
|
|
7
7
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
8
|
|
9
|
-
|
9
|
+
== 1. Definitions
|
10
10
|
|
11
11
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
12
12
|
Sections 1 through 9 of this document.
|
@@ -54,14 +54,14 @@ Contribution."
|
|
54
54
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
55
55
|
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
56
56
|
|
57
|
-
|
57
|
+
== 2. Grant of Copyright License
|
58
58
|
|
59
59
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
60
60
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
61
61
|
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
62
62
|
distribute the Work and such Derivative Works in Source or Object form.
|
63
63
|
|
64
|
-
|
64
|
+
== 3. Grant of Patent License
|
65
65
|
|
66
66
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
67
67
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
|
|
74
74
|
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
75
75
|
date such litigation is filed.
|
76
76
|
|
77
|
-
|
77
|
+
== 4. Redistribution
|
78
78
|
|
79
79
|
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
80
80
|
or without modifications, and in Source or Object form, provided that You meet the following
|
81
81
|
conditions:
|
82
82
|
|
83
|
-
|
83
|
+
. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
. You must cause any modified files to carry prominent notices stating that You changed the files;
|
86
|
+
and
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
89
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
90
|
+
notices that do not pertain to any part of the Derivative Works; and
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
construed as modifying the License.
|
92
|
+
. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
|
93
|
+
that You distribute must include a readable copy of the attribution notices contained within such
|
94
|
+
NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
|
95
|
+
at least one of the following places: within a NOTICE text file distributed as part of the
|
96
|
+
Derivative Works; within the Source form or documentation, if provided along with the Derivative
|
97
|
+
Works; or, within a display generated by the Derivative Works, if and wherever such third-party
|
98
|
+
notices normally appear. The contents of the NOTICE file are for informational purposes only and
|
99
|
+
do not modify the License. You may add Your own attribution notices within Derivative Works that
|
100
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
|
101
|
+
additional attribution notices cannot be construed as modifying the License.
|
103
102
|
|
104
103
|
You may add Your own copyright statement to Your modifications and may provide additional or
|
105
104
|
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
106
105
|
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
107
106
|
the Work otherwise complies with the conditions stated in this License.
|
108
107
|
|
109
|
-
|
108
|
+
== 5. Submission of Contributions
|
110
109
|
|
111
110
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
112
111
|
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
114
113
|
the terms of any separate license agreement you may have executed with Licensor regarding such
|
115
114
|
Contributions.
|
116
115
|
|
117
|
-
|
116
|
+
== 6. Trademarks
|
118
117
|
|
119
118
|
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
120
119
|
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
121
120
|
of the Work and reproducing the content of the NOTICE file.
|
122
121
|
|
123
|
-
|
122
|
+
== 7. Disclaimer of Warranty
|
124
123
|
|
125
124
|
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
126
125
|
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
|
|
129
128
|
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
130
129
|
risks associated with Your exercise of permissions under this License.
|
131
130
|
|
132
|
-
|
131
|
+
== 8. Limitation of Liability
|
133
132
|
|
134
133
|
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
135
134
|
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
|
|
139
138
|
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
140
139
|
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
141
140
|
|
142
|
-
|
141
|
+
== 9. Accepting Warranty or Additional Liability
|
143
142
|
|
144
143
|
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
145
144
|
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
@@ -151,11 +150,11 @@ additional liability.
|
|
151
150
|
|
152
151
|
END OF TERMS AND CONDITIONS
|
153
152
|
|
154
|
-
Copyright 2012
|
153
|
+
Copyright 2012 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
155
154
|
|
156
155
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
157
|
-
compliance with the License. You may obtain a
|
158
|
-
the License.
|
156
|
+
compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
|
157
|
+
of the License.
|
159
158
|
|
160
159
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
161
160
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
data/README.adoc
ADDED
@@ -0,0 +1,498 @@
|
|
1
|
+
:toc: macro
|
2
|
+
:toclevels: 5
|
3
|
+
:figure-caption!:
|
4
|
+
|
5
|
+
= Navigator
|
6
|
+
|
7
|
+
[link=http://badge.fury.io/rb/navigator]
|
8
|
+
image::https://badge.fury.io/rb/navigator.svg[Gem Version]
|
9
|
+
[link=https://www.alchemists.io/projects/code_quality]
|
10
|
+
image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
|
11
|
+
[link=https://circleci.com/gh/bkuhlmann/navigator]
|
12
|
+
image::https://circleci.com/gh/bkuhlmann/navigator.svg?style=svg[Circle CI Status]
|
13
|
+
|
14
|
+
Enhances Rails with a DSL for menu navigation.
|
15
|
+
|
16
|
+
toc::[]
|
17
|
+
|
18
|
+
== Features
|
19
|
+
|
20
|
+
* Provides a DSL for building navigation menus.
|
21
|
+
* Supports auto-detection/highlighting of active menu items based on current path (customizable for
|
22
|
+
non-path usage too).
|
23
|
+
* Supports sub-menus, nested tags, HTML attributes, etc.
|
24
|
+
* Supports the following HTML tags:
|
25
|
+
** div
|
26
|
+
** section
|
27
|
+
** header
|
28
|
+
** h1 - h6
|
29
|
+
** nav
|
30
|
+
** ul
|
31
|
+
** li
|
32
|
+
** a
|
33
|
+
** img
|
34
|
+
** b
|
35
|
+
** em
|
36
|
+
** s
|
37
|
+
** small
|
38
|
+
** span
|
39
|
+
** strong
|
40
|
+
** sub
|
41
|
+
** sup
|
42
|
+
** form
|
43
|
+
** label
|
44
|
+
** select
|
45
|
+
** option
|
46
|
+
** input
|
47
|
+
** button
|
48
|
+
* Provides `+link+`, `+image+`, and `+item+` convenience methods for succinct ways to build commonly
|
49
|
+
used menu elements.
|
50
|
+
|
51
|
+
== Requirements
|
52
|
+
|
53
|
+
. link:https://www.ruby-lang.org[Ruby]
|
54
|
+
. link:https://rubyonrails.org[Ruby on Rails]
|
55
|
+
|
56
|
+
== Setup
|
57
|
+
|
58
|
+
To install, run:
|
59
|
+
|
60
|
+
....
|
61
|
+
gem install navigator
|
62
|
+
....
|
63
|
+
|
64
|
+
Add the following to your Gemfile:
|
65
|
+
|
66
|
+
....
|
67
|
+
gem "navigator"
|
68
|
+
....
|
69
|
+
|
70
|
+
== Usage
|
71
|
+
|
72
|
+
The following are examples using the navigation view helper:
|
73
|
+
|
74
|
+
=== Unordered List (simple)
|
75
|
+
|
76
|
+
Code:
|
77
|
+
|
78
|
+
[source,ruby]
|
79
|
+
----
|
80
|
+
navigation do
|
81
|
+
item "Dashboard", "/dashboard"
|
82
|
+
item "News", "/posts"
|
83
|
+
end
|
84
|
+
----
|
85
|
+
|
86
|
+
Result:
|
87
|
+
|
88
|
+
[source,html]
|
89
|
+
----
|
90
|
+
<ul>
|
91
|
+
<li><a href="/dashboard">Dashboard</a></li>
|
92
|
+
<li><a href="/posts">Posts</a></li>
|
93
|
+
</ul>
|
94
|
+
----
|
95
|
+
|
96
|
+
=== Unordered List (with attributes)
|
97
|
+
|
98
|
+
Code:
|
99
|
+
|
100
|
+
[source,ruby]
|
101
|
+
----
|
102
|
+
navigation "ul", attributes: {class: "nav"} do
|
103
|
+
item "Dashboard", "/dashboard", item_attributes: {class: "active"}
|
104
|
+
item "News", "/posts"
|
105
|
+
end
|
106
|
+
----
|
107
|
+
|
108
|
+
Result:
|
109
|
+
|
110
|
+
[source,html]
|
111
|
+
----
|
112
|
+
<ul class="nav">
|
113
|
+
<li class="active"><a href="/dashboard">Dashboard</a></li>
|
114
|
+
<li><a href="/posts">Posts</a></li>
|
115
|
+
</ul>
|
116
|
+
----
|
117
|
+
|
118
|
+
=== Unordered List (with multiple data attributes)
|
119
|
+
|
120
|
+
Code:
|
121
|
+
|
122
|
+
[source,ruby]
|
123
|
+
----
|
124
|
+
navigation do
|
125
|
+
item "Home", "/home", item_attributes: {data: {id: 1, type: "public"}}
|
126
|
+
end
|
127
|
+
----
|
128
|
+
|
129
|
+
Result:
|
130
|
+
|
131
|
+
[source,html]
|
132
|
+
----
|
133
|
+
<ul>
|
134
|
+
<li data-id="1" data-type="public"><a href="/home">Home</a></li>
|
135
|
+
</ul>
|
136
|
+
----
|
137
|
+
|
138
|
+
_TIP: Nested data– attributes can be applied to any menu item in the same manner as Rails view
|
139
|
+
helpers._
|
140
|
+
|
141
|
+
=== Nav (with links)
|
142
|
+
|
143
|
+
Code:
|
144
|
+
|
145
|
+
[source,ruby]
|
146
|
+
----
|
147
|
+
navigation "nav" do
|
148
|
+
a "Dashboard", attributes: {href: "/dashboard"}
|
149
|
+
a "News", attributes: {href: "/posts"}
|
150
|
+
end
|
151
|
+
----
|
152
|
+
|
153
|
+
Result:
|
154
|
+
|
155
|
+
[source,html]
|
156
|
+
----
|
157
|
+
<nav>
|
158
|
+
<a href="/dashboard">Dashboard</a>
|
159
|
+
<a href="/posts">Posts</a>
|
160
|
+
</nav>
|
161
|
+
----
|
162
|
+
|
163
|
+
=== Foundation Menu
|
164
|
+
|
165
|
+
Code:
|
166
|
+
|
167
|
+
[source,ruby]
|
168
|
+
----
|
169
|
+
navigation "nav", attributes: {class: "top-bar", "data-topbar" => nil} do
|
170
|
+
ul attributes: {class: "title-area"} do
|
171
|
+
li attributes: {class: "name"} do
|
172
|
+
h1 do
|
173
|
+
a "Demo", attributes: {href: "/home"}
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
section attributes: {class: "top-bar-section"} do
|
179
|
+
ul attributes: {class: "left"} do
|
180
|
+
item "Home", "/"
|
181
|
+
item "About", "/about"
|
182
|
+
end
|
183
|
+
|
184
|
+
ul attributes: {class: "right"} do
|
185
|
+
item "v1.0.0", '#'
|
186
|
+
end
|
187
|
+
|
188
|
+
ul attributes: {class: "right"} do
|
189
|
+
item "Login", "/login", link_attributes: {class: "button tiny round"}
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
----
|
194
|
+
|
195
|
+
Result:
|
196
|
+
|
197
|
+
[source,html]
|
198
|
+
----
|
199
|
+
<nav class="top-bar" data-topbar="">
|
200
|
+
<ul class="title-area">
|
201
|
+
<li class="name">
|
202
|
+
<h1><a href="/" class="active">Demo</a></h1>
|
203
|
+
</li>
|
204
|
+
</ul>
|
205
|
+
|
206
|
+
<section class="top-bar-section">
|
207
|
+
<ul class="left">
|
208
|
+
<li class="active"><a href="/">Home</a></li>
|
209
|
+
<li><a href="/about">About</a></li>
|
210
|
+
</ul>
|
211
|
+
|
212
|
+
<ul class="right">
|
213
|
+
<li><a href="#">v1.0.0</a></li>
|
214
|
+
</ul>
|
215
|
+
|
216
|
+
<ul class="right">
|
217
|
+
<li><a class="button tiny round" href="/login">Login</a></li>
|
218
|
+
</ul>
|
219
|
+
</section>
|
220
|
+
</nav>
|
221
|
+
----
|
222
|
+
|
223
|
+
=== Bootstrap Dropdown
|
224
|
+
|
225
|
+
Code:
|
226
|
+
|
227
|
+
[source,ruby]
|
228
|
+
----
|
229
|
+
navigation "nav" do
|
230
|
+
item "Dashboard", admin_dashboard_path
|
231
|
+
li attributes: {class: "dropdown"} do
|
232
|
+
a "Manage", attributes: {href: "#", class: "dropdown-toggle", "data-toggle" => "dropdown"} do
|
233
|
+
b attributes: {class: "caret"}
|
234
|
+
end
|
235
|
+
ul attributes: {class: "dropdown-menu"} do
|
236
|
+
item "Dashboard", admin_dashboard_path
|
237
|
+
item "Users", admin_users_path
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
----
|
242
|
+
|
243
|
+
Result:
|
244
|
+
|
245
|
+
[source,html]
|
246
|
+
----
|
247
|
+
<ul class="nav">
|
248
|
+
<li><a href="/admin/dashboard">Dashboard</a></li>
|
249
|
+
<li class="dropdown">
|
250
|
+
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
251
|
+
Manage
|
252
|
+
<b class="caret"></b>
|
253
|
+
</a>
|
254
|
+
<ul class="dropdown-menu">
|
255
|
+
<li><a href="/admin/dashboard">Dashboard</a></li>
|
256
|
+
<li><a href="/admin/users">Users</a></li>
|
257
|
+
</ul>
|
258
|
+
</li>
|
259
|
+
</ul>
|
260
|
+
----
|
261
|
+
|
262
|
+
=== Menu Helpers
|
263
|
+
|
264
|
+
There are several convenience methods, in addition to the standard HTML tags, that can make for
|
265
|
+
shorter lines of code. The following describes each:
|
266
|
+
|
267
|
+
When building links, the default is:
|
268
|
+
|
269
|
+
[source,ruby]
|
270
|
+
----
|
271
|
+
navigation "nav", activator: activator do
|
272
|
+
a "Home", attributes: {href: home_path}
|
273
|
+
end
|
274
|
+
----
|
275
|
+
|
276
|
+
...but can be written as:
|
277
|
+
|
278
|
+
[source,ruby]
|
279
|
+
----
|
280
|
+
navigation "nav", activator: activator do
|
281
|
+
link "Home", home_path
|
282
|
+
end
|
283
|
+
----
|
284
|
+
|
285
|
+
When building images, the default is:
|
286
|
+
|
287
|
+
[source,ruby]
|
288
|
+
----
|
289
|
+
navigation "nav", activator: activator do
|
290
|
+
img attributes: {src: "https://placehold.it/50x50", alt: "Example"}
|
291
|
+
end
|
292
|
+
----
|
293
|
+
|
294
|
+
..but can be written as:
|
295
|
+
|
296
|
+
[source,ruby]
|
297
|
+
----
|
298
|
+
navigation "nav", activator: activator do
|
299
|
+
image "https://placehold.it/50x50", "Example"
|
300
|
+
end
|
301
|
+
----
|
302
|
+
|
303
|
+
When building menu items, the default is:
|
304
|
+
|
305
|
+
[source,ruby]
|
306
|
+
----
|
307
|
+
navigation "nav", activator: activator do
|
308
|
+
li do
|
309
|
+
a "Home", attributes: {href: home_path}
|
310
|
+
end
|
311
|
+
end
|
312
|
+
----
|
313
|
+
|
314
|
+
...but can be written as:
|
315
|
+
|
316
|
+
[source,ruby]
|
317
|
+
----
|
318
|
+
navigation "nav", activator: activator do
|
319
|
+
item "Home", "/dashboard"
|
320
|
+
end
|
321
|
+
----
|
322
|
+
|
323
|
+
These are just a few, simple, examples of what can be achieved. See the specs for additional usage
|
324
|
+
and customization.
|
325
|
+
|
326
|
+
== Customization
|
327
|
+
|
328
|
+
The `+navigation+` view helper can accept an optional `+Navigator::TagActivator+` instance.
|
329
|
+
|
330
|
+
Code:
|
331
|
+
|
332
|
+
[source,ruby]
|
333
|
+
----
|
334
|
+
activator = Navigator::TagActivator.new search_value: request.env["PATH_INFO"]
|
335
|
+
|
336
|
+
navigation "nav", activator: activator do
|
337
|
+
link "Home", home_path
|
338
|
+
link "About", about_path
|
339
|
+
end
|
340
|
+
----
|
341
|
+
|
342
|
+
Result:
|
343
|
+
|
344
|
+
[source,html]
|
345
|
+
----
|
346
|
+
<nav>
|
347
|
+
<a href="/home" class="active">Home</a>
|
348
|
+
<a href="/about" class="active">About</a>
|
349
|
+
</nav>
|
350
|
+
----
|
351
|
+
|
352
|
+
This is the default behavior for all navigation menus and is how menu items automaticaly get the
|
353
|
+
"`active`" class when the item URL (in this case "`/home`") matches the `+request.env[“PATH_INFO"]+`
|
354
|
+
to indicate current page/active tab.
|
355
|
+
|
356
|
+
`+Navigator::TagActivator+` instances can be configured as follows:
|
357
|
+
|
358
|
+
* search_key = Optional. The HTML tag attribute to search for. Default: :href.
|
359
|
+
* search_value = Required. The value to match against the search_key value in order to update the
|
360
|
+
value of the target_key. Default: nil.
|
361
|
+
* target_key = Optional. The HTML tag attribute key value to update when the search_value and
|
362
|
+
search_key value match. Default: :class.
|
363
|
+
* target_value = Optional. The value to be applied to the target_key value. If no value exists, then
|
364
|
+
the value is added. Otherwise, if a value exists then the value is appended to the existing value.
|
365
|
+
Default: "`active`".
|
366
|
+
|
367
|
+
This customization allows for more sophisticated detection/updating of active HTML tags. For
|
368
|
+
example, the example code (above) could be rewritten to use `data` attributes and customized
|
369
|
+
styles.
|
370
|
+
|
371
|
+
Code:
|
372
|
+
|
373
|
+
[source,ruby]
|
374
|
+
----
|
375
|
+
activator = Navigator::TagActivator.new search_key: "data-id",
|
376
|
+
search_value: "123",
|
377
|
+
target_key: "data-style"
|
378
|
+
target_value: "current"
|
379
|
+
|
380
|
+
navigation "nav", activator: activator do
|
381
|
+
link "Home", home_path, attributes: {data: {id: "123", data-style="info"}}
|
382
|
+
link "About", about_path attributes: {data: {id: "789"}}
|
383
|
+
end
|
384
|
+
----
|
385
|
+
|
386
|
+
Result:
|
387
|
+
|
388
|
+
[source,html]
|
389
|
+
----
|
390
|
+
<nav>
|
391
|
+
<a href="/home" data-id="123" data-style="info current">Home</a>
|
392
|
+
<a href="/about" data-id="789">About</a>
|
393
|
+
</nav>
|
394
|
+
----
|
395
|
+
|
396
|
+
Lastly, the search value can be a _regular expression_ to make things easier when dealing with
|
397
|
+
complicated routes, sub- menus, etc.
|
398
|
+
|
399
|
+
Code:
|
400
|
+
|
401
|
+
[source,ruby]
|
402
|
+
----
|
403
|
+
profile_activator = Navigator::TagActivator.new search_value: /^profile.+/
|
404
|
+
|
405
|
+
navigation do
|
406
|
+
item "Dashboard", dashboard_path
|
407
|
+
li activator: profile_activator do
|
408
|
+
link "Profile", '#'
|
409
|
+
|
410
|
+
ul do
|
411
|
+
item "Addresses", profile_addresses_path
|
412
|
+
item "Emails", profile_emails_path
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
----
|
417
|
+
|
418
|
+
Result:
|
419
|
+
|
420
|
+
[source,html]
|
421
|
+
----
|
422
|
+
<ul>
|
423
|
+
<li><a href="/dashboard">Dashboard</a></li>
|
424
|
+
<li class="active">
|
425
|
+
<a href="#">Profile</a>
|
426
|
+
<ul>
|
427
|
+
<li><a href="profile/addresses">Addresses</a></li>
|
428
|
+
<li><a href="profile/emails">Emails</a></li>
|
429
|
+
</ul>
|
430
|
+
</li>
|
431
|
+
</ul>
|
432
|
+
----
|
433
|
+
|
434
|
+
Assuming either the `Addresses` or `Emails` menu item was clicked, the `Profile` menu item
|
435
|
+
would be active due to the regular expression (i.e. `/^profile.+/) matching one of the the
|
436
|
+
`profile/` paths.
|
437
|
+
|
438
|
+
== Development
|
439
|
+
|
440
|
+
To contribute, run:
|
441
|
+
|
442
|
+
....
|
443
|
+
git clone https://github.com/bkuhlmann/navigator.git
|
444
|
+
cd navigator
|
445
|
+
bin/setup
|
446
|
+
....
|
447
|
+
|
448
|
+
You can also use the IRB console for direct access to all objects:
|
449
|
+
|
450
|
+
....
|
451
|
+
bin/console
|
452
|
+
....
|
453
|
+
|
454
|
+
== Tests
|
455
|
+
|
456
|
+
To test, run:
|
457
|
+
|
458
|
+
[source,bash]
|
459
|
+
----
|
460
|
+
bundle exec rake
|
461
|
+
----
|
462
|
+
|
463
|
+
To test the dummy application, run:
|
464
|
+
|
465
|
+
[source,bash]
|
466
|
+
----
|
467
|
+
cd spec/dummy
|
468
|
+
bin/rails server
|
469
|
+
----
|
470
|
+
|
471
|
+
== Versioning
|
472
|
+
|
473
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
474
|
+
|
475
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
476
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
477
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
478
|
+
|
479
|
+
== Code of Conduct
|
480
|
+
|
481
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
482
|
+
participating in this project you agree to abide by its terms.
|
483
|
+
|
484
|
+
== Contributions
|
485
|
+
|
486
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
487
|
+
|
488
|
+
== License
|
489
|
+
|
490
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
491
|
+
|
492
|
+
== History
|
493
|
+
|
494
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
495
|
+
|
496
|
+
== Credits
|
497
|
+
|
498
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|