navigator 4.1.4 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- ��*��M�%u�`e�����ҵ� �*8��~#K4eB���<x���_lonR��xœ��4�h#T��,1ELYG�/��^S�
2
- ����qcX6���#&
3
- �������؎�7msm9���aEI�H_�[�ҿr��S�ʒcJLHt
1
+ �y��� ? �Zv,�z2���^��v�m߁|Ti���^�ٖ���Z]�N�F�f�'{���Of��߀� ��Y"��`|emɊf���V�u�I�ϲe�y���'pB���f+ Sԥ��d�������c��Wh<Mڌ�j6�
2
+ ��I���d-���-o?R�N���R�fd��I*���5viԤ3��j��YRv.M����O5V�������V���w��_��q��-����l`o(B(���"��KMu
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).