navigator 5.0.0 → 5.5.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/{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
data/lib/navigator/identity.rb
CHANGED
@@ -3,20 +3,9 @@
|
|
3
3
|
module Navigator
|
4
4
|
# Gem identity information.
|
5
5
|
module Identity
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.label
|
11
|
-
"Navigator"
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.version
|
15
|
-
"5.0.0"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.version_label
|
19
|
-
"#{label} #{version}"
|
20
|
-
end
|
6
|
+
NAME = "navigator"
|
7
|
+
LABEL = "Navigator"
|
8
|
+
VERSION = "5.5.0"
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
21
10
|
end
|
22
11
|
end
|
data/lib/navigator/menu.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module Navigator
|
4
4
|
# Renders a HTML menu.
|
5
5
|
class Menu
|
6
|
-
# rubocop:disable
|
6
|
+
# rubocop:disable Layout/LineLength
|
7
7
|
def self.allowed_methods
|
8
8
|
/^(div|section|header|h[1-6]|nav|ul|li|a|img|b|em|s|small|span|strong|sub|sup|form|label|select|option|input|button)$/
|
9
9
|
end
|
10
|
-
# rubocop:enable
|
10
|
+
# rubocop:enable Layout/LineLength
|
11
11
|
|
12
12
|
def initialize template,
|
13
13
|
tag: "ul",
|
@@ -19,12 +19,12 @@ module Navigator
|
|
19
19
|
@tag = Navigator::Tag.new tag, attributes: attributes, activator: activator
|
20
20
|
@menu_activator = activator
|
21
21
|
@items = []
|
22
|
-
instance_eval(&block) if
|
22
|
+
instance_eval(&block) if block
|
23
23
|
end
|
24
24
|
|
25
25
|
def add name, content = nil, attributes: {}, activator: menu_activator, &block
|
26
26
|
tag = Navigator::Tag.new name, content, attributes: attributes, activator: activator
|
27
|
-
return items << tag.render unless
|
27
|
+
return items << tag.render unless block
|
28
28
|
|
29
29
|
items << tag.prefix
|
30
30
|
items << tag.content
|
@@ -71,7 +71,7 @@ module Navigator
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def render
|
74
|
-
[tag.prefix, tag.content, items.compact.join
|
74
|
+
[tag.prefix, tag.content, items.compact.join, tag.suffix].compact.join
|
75
75
|
end
|
76
76
|
|
77
77
|
private
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navigator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
|
15
|
+
NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,15 +20,15 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
|
24
|
+
XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
|
25
|
+
bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
|
26
|
+
Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
|
27
|
+
7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
|
28
|
+
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
|
+
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-
|
31
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rails
|
@@ -45,240 +45,30 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: refinements
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
54
|
-
type: :
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.6'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: capybara
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '3.1'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '3.1'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: gemsmith
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '14.0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '14.0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: git-cop
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '4.0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '4.0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: guard-rspec
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '4.7'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '4.7'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: pg
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '1.2'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '1.2'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: pry
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0.12'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0.12'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: pry-byebug
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '3.7'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '3.7'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rake
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - "~>"
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '13.0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '13.0'
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: reek
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '5.4'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "~>"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '5.4'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: rspec-rails
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "~>"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '3.9'
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - "~>"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '3.9'
|
201
|
-
- !ruby/object:Gem::Dependency
|
202
|
-
name: rubocop
|
203
|
-
requirement: !ruby/object:Gem::Requirement
|
204
|
-
requirements:
|
205
|
-
- - "~>"
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
version: '0.78'
|
208
|
-
type: :development
|
209
|
-
prerelease: false
|
210
|
-
version_requirements: !ruby/object:Gem::Requirement
|
211
|
-
requirements:
|
212
|
-
- - "~>"
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version: '0.78'
|
215
|
-
- !ruby/object:Gem::Dependency
|
216
|
-
name: rubocop-performance
|
217
|
-
requirement: !ruby/object:Gem::Requirement
|
218
|
-
requirements:
|
219
|
-
- - "~>"
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: '1.5'
|
222
|
-
type: :development
|
223
|
-
prerelease: false
|
224
|
-
version_requirements: !ruby/object:Gem::Requirement
|
225
|
-
requirements:
|
226
|
-
- - "~>"
|
227
|
-
- !ruby/object:Gem::Version
|
228
|
-
version: '1.5'
|
229
|
-
- !ruby/object:Gem::Dependency
|
230
|
-
name: rubocop-rake
|
231
|
-
requirement: !ruby/object:Gem::Requirement
|
232
|
-
requirements:
|
233
|
-
- - "~>"
|
234
|
-
- !ruby/object:Gem::Version
|
235
|
-
version: '0.5'
|
236
|
-
type: :development
|
237
|
-
prerelease: false
|
238
|
-
version_requirements: !ruby/object:Gem::Requirement
|
239
|
-
requirements:
|
240
|
-
- - "~>"
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
version: '0.5'
|
243
|
-
- !ruby/object:Gem::Dependency
|
244
|
-
name: rubocop-rspec
|
245
|
-
requirement: !ruby/object:Gem::Requirement
|
246
|
-
requirements:
|
247
|
-
- - "~>"
|
248
|
-
- !ruby/object:Gem::Version
|
249
|
-
version: '1.37'
|
250
|
-
type: :development
|
251
|
-
prerelease: false
|
252
|
-
version_requirements: !ruby/object:Gem::Requirement
|
253
|
-
requirements:
|
254
|
-
- - "~>"
|
255
|
-
- !ruby/object:Gem::Version
|
256
|
-
version: '1.37'
|
257
|
-
- !ruby/object:Gem::Dependency
|
258
|
-
name: simplecov
|
259
|
-
requirement: !ruby/object:Gem::Requirement
|
260
|
-
requirements:
|
261
|
-
- - "~>"
|
262
|
-
- !ruby/object:Gem::Version
|
263
|
-
version: '0.17'
|
264
|
-
type: :development
|
53
|
+
version: '7.16'
|
54
|
+
type: :runtime
|
265
55
|
prerelease: false
|
266
56
|
version_requirements: !ruby/object:Gem::Requirement
|
267
57
|
requirements:
|
268
58
|
- - "~>"
|
269
59
|
- !ruby/object:Gem::Version
|
270
|
-
version: '
|
271
|
-
description:
|
60
|
+
version: '7.16'
|
61
|
+
description:
|
272
62
|
email:
|
273
63
|
- brooke@alchemists.io
|
274
64
|
executables: []
|
275
65
|
extensions: []
|
276
66
|
extra_rdoc_files:
|
277
|
-
- README.
|
278
|
-
- LICENSE.
|
67
|
+
- README.adoc
|
68
|
+
- LICENSE.adoc
|
279
69
|
files:
|
280
|
-
- LICENSE.
|
281
|
-
- README.
|
70
|
+
- LICENSE.adoc
|
71
|
+
- README.adoc
|
282
72
|
- app/helpers/navigator/navigation_helper.rb
|
283
73
|
- lib/navigator.rb
|
284
74
|
- lib/navigator/engine.rb
|
@@ -286,14 +76,15 @@ files:
|
|
286
76
|
- lib/navigator/menu.rb
|
287
77
|
- lib/navigator/tag.rb
|
288
78
|
- lib/navigator/tag_activator.rb
|
289
|
-
homepage: https://
|
79
|
+
homepage: https://www.alchemists.io/projects/navigator
|
290
80
|
licenses:
|
291
81
|
- Apache-2.0
|
292
82
|
metadata:
|
293
|
-
source_code_uri: https://github.com/bkuhlmann/navigator
|
294
|
-
changelog_uri: https://github.com/bkuhlmann/navigator/blob/master/CHANGES.md
|
295
83
|
bug_tracker_uri: https://github.com/bkuhlmann/navigator/issues
|
296
|
-
|
84
|
+
changelog_uri: https://www.alchemists.io/projects/navigator/changes.html
|
85
|
+
documentation_uri: https://www.alchemists.io/projects/navigator
|
86
|
+
source_code_uri: https://github.com/bkuhlmann/navigator
|
87
|
+
post_install_message:
|
297
88
|
rdoc_options: []
|
298
89
|
require_paths:
|
299
90
|
- lib
|
@@ -308,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
99
|
- !ruby/object:Gem::Version
|
309
100
|
version: '0'
|
310
101
|
requirements: []
|
311
|
-
rubygems_version: 3.
|
312
|
-
signing_key:
|
102
|
+
rubygems_version: 3.2.0
|
103
|
+
signing_key:
|
313
104
|
specification_version: 4
|
314
105
|
summary: Enhances Rails with a DSL for menu navigation.
|
315
106
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,419 +0,0 @@
|
|
1
|
-
<p align="center">
|
2
|
-
<img src="navigator.png" alt="Navigator Icon"/>
|
3
|
-
</p>
|
4
|
-
|
5
|
-
# Navigator
|
6
|
-
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/navigator.svg)](http://badge.fury.io/rb/navigator)
|
8
|
-
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/2f8632ec1f734ea9561a/maintainability)](https://codeclimate.com/github/bkuhlmann/navigator/maintainability)
|
9
|
-
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/2f8632ec1f734ea9561a/test_coverage)](https://codeclimate.com/github/bkuhlmann/navigator/test_coverage)
|
10
|
-
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/navigator.svg?style=svg)](https://circleci.com/gh/bkuhlmann/navigator)
|
11
|
-
|
12
|
-
Enhances Rails with a DSL for menu navigation.
|
13
|
-
|
14
|
-
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
15
|
-
|
16
|
-
## Table of Contents
|
17
|
-
|
18
|
-
- [Features](#features)
|
19
|
-
- [Requirements](#requirements)
|
20
|
-
- [Setup](#setup)
|
21
|
-
- [Usage](#usage)
|
22
|
-
- [Unordered List (simple)](#unordered-list-simple)
|
23
|
-
- [Unordered List (with attributes)](#unordered-list-with-attributes)
|
24
|
-
- [Unordered List (with multiple data attributes)](#unordered-list-with-multiple-data-attributes)
|
25
|
-
- [Nav (with links)](#nav-with-links)
|
26
|
-
- [Foundation Menu](#foundation-menu)
|
27
|
-
- [Bootstrap Dropdown](#bootstrap-dropdown)
|
28
|
-
- [Menu Helpers](#menu-helpers)
|
29
|
-
- [Customization](#customization)
|
30
|
-
- [Tests](#tests)
|
31
|
-
- [Versioning](#versioning)
|
32
|
-
- [Code of Conduct](#code-of-conduct)
|
33
|
-
- [Contributions](#contributions)
|
34
|
-
- [License](#license)
|
35
|
-
- [History](#history)
|
36
|
-
- [Credits](#credits)
|
37
|
-
|
38
|
-
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
39
|
-
|
40
|
-
## Features
|
41
|
-
|
42
|
-
- Provides a DSL for building navigation menus.
|
43
|
-
- Supports auto-detection/highlighting of active menu items based on current path (customizable for
|
44
|
-
non-path usage too).
|
45
|
-
- Supports sub-menus, nested tags, HTML attributes, etc.
|
46
|
-
- Supports the following HTML tags:
|
47
|
-
- div
|
48
|
-
- section
|
49
|
-
- header
|
50
|
-
- h1 - h6
|
51
|
-
- nav
|
52
|
-
- ul
|
53
|
-
- li
|
54
|
-
- a
|
55
|
-
- img
|
56
|
-
- b
|
57
|
-
- em
|
58
|
-
- s
|
59
|
-
- small
|
60
|
-
- span
|
61
|
-
- strong
|
62
|
-
- sub
|
63
|
-
- sup
|
64
|
-
- form
|
65
|
-
- label
|
66
|
-
- select
|
67
|
-
- option
|
68
|
-
- input
|
69
|
-
- button
|
70
|
-
- Provides `link`, `image`, and `item` convenience methods for succinct ways to build commonly used
|
71
|
-
menu elements.
|
72
|
-
|
73
|
-
## Requirements
|
74
|
-
|
75
|
-
1. [Ruby 2.6.x](https://www.ruby-lang.org).
|
76
|
-
1. [Ruby on Rails 5.x.x](http://rubyonrails.org).
|
77
|
-
|
78
|
-
## Setup
|
79
|
-
|
80
|
-
Type the following to install:
|
81
|
-
|
82
|
-
gem install navigator
|
83
|
-
|
84
|
-
Add the following to your Gemfile:
|
85
|
-
|
86
|
-
gem "navigator"
|
87
|
-
|
88
|
-
## Usage
|
89
|
-
|
90
|
-
The following are examples using the navigation view helper:
|
91
|
-
|
92
|
-
### Unordered List (simple)
|
93
|
-
|
94
|
-
Code:
|
95
|
-
|
96
|
-
navigation do
|
97
|
-
item "Dashboard", "/dashboard"
|
98
|
-
item "News", "/posts"
|
99
|
-
end
|
100
|
-
|
101
|
-
Result:
|
102
|
-
|
103
|
-
<ul>
|
104
|
-
<li><a href="/dashboard">Dashboard</a></li>
|
105
|
-
<li><a href="/posts">Posts</a></li>
|
106
|
-
</ul>
|
107
|
-
|
108
|
-
### Unordered List (with attributes)
|
109
|
-
|
110
|
-
Code:
|
111
|
-
|
112
|
-
navigation "ul", attributes: {class: "nav"} do
|
113
|
-
item "Dashboard", "/dashboard", item_attributes: {class: "active"}
|
114
|
-
item "News", "/posts"
|
115
|
-
end
|
116
|
-
|
117
|
-
Result:
|
118
|
-
|
119
|
-
<ul class="nav">
|
120
|
-
<li class="active"><a href="/dashboard">Dashboard</a></li>
|
121
|
-
<li><a href="/posts">Posts</a></li>
|
122
|
-
</ul>
|
123
|
-
|
124
|
-
### Unordered List (with multiple data attributes)
|
125
|
-
|
126
|
-
Code:
|
127
|
-
|
128
|
-
navigation do
|
129
|
-
item "Home", "/home", item_attributes: {data: {id: 1, type: "public"}}
|
130
|
-
end
|
131
|
-
|
132
|
-
Result:
|
133
|
-
|
134
|
-
<ul>
|
135
|
-
<li data-id="1" data-type="public"><a href="/home">Home</a></li>
|
136
|
-
</ul>
|
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
|
-
navigation "nav" do
|
146
|
-
a "Dashboard", attributes: {href: "/dashboard"}
|
147
|
-
a "News", attributes: {href: "/posts"}
|
148
|
-
end
|
149
|
-
|
150
|
-
Result:
|
151
|
-
|
152
|
-
<nav>
|
153
|
-
<a href="/dashboard">Dashboard</a>
|
154
|
-
<a href="/posts">Posts</a>
|
155
|
-
</nav>
|
156
|
-
|
157
|
-
### Foundation Menu
|
158
|
-
|
159
|
-
Code:
|
160
|
-
|
161
|
-
navigation "nav", attributes: {class: "top-bar", "data-topbar" => nil} do
|
162
|
-
ul attributes: {class: "title-area"} do
|
163
|
-
li attributes: {class: "name"} do
|
164
|
-
h1 do
|
165
|
-
a "Demo", attributes: {href: "/home"}
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
section attributes: {class: "top-bar-section"} do
|
171
|
-
ul attributes: {class: "left"} do
|
172
|
-
item "Home", "/"
|
173
|
-
item "About", "/about"
|
174
|
-
end
|
175
|
-
|
176
|
-
ul attributes: {class: "right"} do
|
177
|
-
item "v1.0.0", '#'
|
178
|
-
end
|
179
|
-
|
180
|
-
ul attributes: {class: "right"} do
|
181
|
-
item "Login", "/login", link_attributes: {class: "button tiny round"}
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
Result:
|
187
|
-
|
188
|
-
<nav class="top-bar" data-topbar="">
|
189
|
-
<ul class="title-area">
|
190
|
-
<li class="name">
|
191
|
-
<h1><a href="/" class="active">Demo</a></h1>
|
192
|
-
</li>
|
193
|
-
</ul>
|
194
|
-
|
195
|
-
<section class="top-bar-section">
|
196
|
-
<ul class="left">
|
197
|
-
<li class="active"><a href="/">Home</a></li>
|
198
|
-
<li><a href="/about">About</a></li>
|
199
|
-
</ul>
|
200
|
-
|
201
|
-
<ul class="right">
|
202
|
-
<li><a href="#">v1.0.0</a></li>
|
203
|
-
</ul>
|
204
|
-
|
205
|
-
<ul class="right">
|
206
|
-
<li><a class="button tiny round" href="/login">Login</a></li>
|
207
|
-
</ul>
|
208
|
-
</section>
|
209
|
-
</nav>
|
210
|
-
|
211
|
-
### Bootstrap Dropdown
|
212
|
-
|
213
|
-
Code:
|
214
|
-
|
215
|
-
navigation "nav" do
|
216
|
-
item "Dashboard", admin_dashboard_path
|
217
|
-
li attributes: {class: "dropdown"} do
|
218
|
-
a "Manage", attributes: {href: "#", class: "dropdown-toggle", "data-toggle" => "dropdown"} do
|
219
|
-
b attributes: {class: "caret"}
|
220
|
-
end
|
221
|
-
ul attributes: {class: "dropdown-menu"} do
|
222
|
-
item "Dashboard", admin_dashboard_path
|
223
|
-
item "Users", admin_users_path
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
Result:
|
229
|
-
|
230
|
-
<ul class="nav">
|
231
|
-
<li><a href="/admin/dashboard">Dashboard</a></li>
|
232
|
-
<li class="dropdown">
|
233
|
-
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
234
|
-
Manage
|
235
|
-
<b class="caret"></b>
|
236
|
-
</a>
|
237
|
-
<ul class="dropdown-menu">
|
238
|
-
<li><a href="/admin/dashboard">Dashboard</a></li>
|
239
|
-
<li><a href="/admin/users">Users</a></li>
|
240
|
-
</ul>
|
241
|
-
</li>
|
242
|
-
</ul>
|
243
|
-
|
244
|
-
### Menu Helpers
|
245
|
-
|
246
|
-
There are several convenience methods, in addition to the standard HTML tags, that can make for
|
247
|
-
shorter lines of code. The following describes each:
|
248
|
-
|
249
|
-
When building links, the default is:
|
250
|
-
|
251
|
-
navigation "nav", activator: activator do
|
252
|
-
a "Home", attributes: {href: home_path}
|
253
|
-
end
|
254
|
-
|
255
|
-
...but can be written as:
|
256
|
-
|
257
|
-
navigation "nav", activator: activator do
|
258
|
-
link "Home", home_path
|
259
|
-
end
|
260
|
-
|
261
|
-
When building images, the default is:
|
262
|
-
|
263
|
-
navigation "nav", activator: activator do
|
264
|
-
img attributes: {src: "https://placehold.it/50x50", alt: "Example"}
|
265
|
-
end
|
266
|
-
|
267
|
-
...but can be written as:
|
268
|
-
|
269
|
-
navigation "nav", activator: activator do
|
270
|
-
image "https://placehold.it/50x50", "Example"
|
271
|
-
end
|
272
|
-
|
273
|
-
When building menu items, the default is:
|
274
|
-
|
275
|
-
navigation "nav", activator: activator do
|
276
|
-
li do
|
277
|
-
a "Home", attributes: {href: home_path}
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
...but can be written as:
|
282
|
-
|
283
|
-
navigation "nav", activator: activator do
|
284
|
-
item "Home", "/dashboard"
|
285
|
-
end
|
286
|
-
|
287
|
-
These are just a few, simple, examples of what can be achieved. See the specs for additional usage
|
288
|
-
and customization.
|
289
|
-
|
290
|
-
## Customization
|
291
|
-
|
292
|
-
The `navigation` view helper can accept an optional `Navigator::TagActivator` instance. Example:
|
293
|
-
|
294
|
-
# Code
|
295
|
-
activator = Navigator::TagActivator.new search_value: request.env["PATH_INFO"]
|
296
|
-
|
297
|
-
navigation "nav", activator: activator do
|
298
|
-
link "Home", home_path
|
299
|
-
link "About", about_path
|
300
|
-
end
|
301
|
-
|
302
|
-
<!-- Result -->
|
303
|
-
<nav>
|
304
|
-
<a href="/home" class="active">Home</a>
|
305
|
-
<a href="/about" class="active">About</a>
|
306
|
-
</nav>
|
307
|
-
|
308
|
-
This is the default behavior for all navigation menus and is how menu items automaticaly get the
|
309
|
-
"active" class when the item URL (in this case "/home") matches the `request.env[“PATH_INFO"]` to
|
310
|
-
indicate current page/active tab.
|
311
|
-
|
312
|
-
`Navigator::TagActivator` instances can be configured as follows:
|
313
|
-
|
314
|
-
- search_key = Optional. The HTML tag attribute to search for. Default: :href.
|
315
|
-
- search_value = Required. The value to match against the search_key value in order to update the
|
316
|
-
value of the target_key. Default: nil.
|
317
|
-
- target_key = Optional. The HTML tag attribute key value to update when the search_value and
|
318
|
-
search_key value match. Default: :class.
|
319
|
-
- target_value = Optional. The value to be applied to the target_key value. If no value exists, then
|
320
|
-
the value is added. Otherwise, if a value exists then the value is appended to the existing value.
|
321
|
-
Default: "active".
|
322
|
-
|
323
|
-
This customization allows for more sophisticated detection/updating of active HTML tags. For
|
324
|
-
example, the example code (above) could be rewritten to use `data-*` attributes and customized
|
325
|
-
styles as follows:
|
326
|
-
|
327
|
-
# Code
|
328
|
-
activator = Navigator::TagActivator.new search_key: "data-id",
|
329
|
-
search_value: "123",
|
330
|
-
target_key: "data-style"
|
331
|
-
target_value: "current"
|
332
|
-
|
333
|
-
navigation "nav", activator: activator do
|
334
|
-
link "Home", home_path, attributes: {data: {id: "123", data-style="info"}}
|
335
|
-
link "About", about_path attributes: {data: {id: "789"}}
|
336
|
-
end
|
337
|
-
|
338
|
-
<!-- Result -->
|
339
|
-
<nav>
|
340
|
-
<a href="/home" data-id="123" data-style="info current">Home</a>
|
341
|
-
<a href="/about" data-id="789">About</a>
|
342
|
-
</nav>
|
343
|
-
|
344
|
-
Lastly, the search value can be a *regular expression* to make things easier when dealing with
|
345
|
-
complicated routes, sub- menus, etc. Example:
|
346
|
-
|
347
|
-
# Code
|
348
|
-
profile_activator = Navigator::TagActivator.new search_value: /^profile.+/
|
349
|
-
|
350
|
-
navigation do
|
351
|
-
item "Dashboard", dashboard_path
|
352
|
-
li activator: profile_activator do
|
353
|
-
link "Profile", '#'
|
354
|
-
|
355
|
-
ul do
|
356
|
-
item "Addresses", profile_addresses_path
|
357
|
-
item "Emails", profile_emails_path
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
<!-- Result -->
|
363
|
-
<ul>
|
364
|
-
<li><a href="/dashboard">Dashboard</a></li>
|
365
|
-
<li class="active">
|
366
|
-
<a href="#">Profile</a>
|
367
|
-
<ul>
|
368
|
-
<li><a href="profile/addresses">Addresses</a></li>
|
369
|
-
<li><a href="profile/emails">Emails</a></li>
|
370
|
-
</ul>
|
371
|
-
</li>
|
372
|
-
</ul>
|
373
|
-
|
374
|
-
Assuming either the `Addresses` or `Emails` menu item was clicked, the `Profile` menu item would be
|
375
|
-
active due to the regular expression (i.e. `/^profile.+/`) matching one of the the `profile/*`
|
376
|
-
paths.
|
377
|
-
|
378
|
-
## Tests
|
379
|
-
|
380
|
-
To test, run:
|
381
|
-
|
382
|
-
bundle exec rake
|
383
|
-
|
384
|
-
To test the dummy application, run:
|
385
|
-
|
386
|
-
cd spec/dummy
|
387
|
-
bin/rails server
|
388
|
-
|
389
|
-
## Versioning
|
390
|
-
|
391
|
-
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
392
|
-
|
393
|
-
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
394
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
395
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
396
|
-
|
397
|
-
## Code of Conduct
|
398
|
-
|
399
|
-
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
400
|
-
participating in this project you agree to abide by its terms.
|
401
|
-
|
402
|
-
## Contributions
|
403
|
-
|
404
|
-
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
405
|
-
|
406
|
-
## License
|
407
|
-
|
408
|
-
Copyright 2012 [Alchemists](https://www.alchemists.io).
|
409
|
-
Read [LICENSE](LICENSE.md) for details.
|
410
|
-
|
411
|
-
## History
|
412
|
-
|
413
|
-
Read [CHANGES](CHANGES.md) for details.
|
414
|
-
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
415
|
-
|
416
|
-
## Credits
|
417
|
-
|
418
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
419
|
-
[Alchemists](https://www.alchemists.io).
|