menuizer 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +43 -17
- data/lib/menuizer/menu/item.rb +8 -10
- data/lib/menuizer.rb +1 -0
- data/menuizer.gemspec +1 -0
- data/version.txt +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjkzYmM0MGQ2YWIxMDQ1MTU2ZjFjMDNkZDZmNjNlYjllODVhMjAxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmQxNTBmY2EwNDAyZjE5MTRmMmQ1ZDliNzMxOWNkMjk5Y2QwNTZlZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODI4ZTkzMTZiM2ZjODYzNDQ1Y2VlMmZlNzJlOWI3YTJjMjE2YjM5M2VlZWI2
|
10
|
+
N2EyNDcyNTgzMGRjNDg4ZmVkZmJjOWYzNTAzMmQxMjMyYjRkMDlkZDA0YzVm
|
11
|
+
Yzg2MTUxNzM5MjM5M2ZhMDQ2MDU3YjM2N2U3OTdhNjAyYjA5OGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjgzODQwNTQ2NDVmMGM4ZjZlN2RiNjFkZjUwMmU2ZDAzODIwODQ0OTA3OWRi
|
14
|
+
YzMwYzU2YTQ0MGZkMTBiOGM1YzVlOGMxOGI3ZGM1NzhmOWM2NzBiYzEzOWY4
|
15
|
+
MGRhMTNkM2EyZjhiYzgyMjY2YzU2Y2NhMjY1NDc2M2VkYWE0YjQ=
|
data/README.md
CHANGED
@@ -54,9 +54,9 @@ end
|
|
54
54
|
- item: Settings
|
55
55
|
icon: fa fa-cog
|
56
56
|
children:
|
57
|
-
- item: :
|
57
|
+
- item: :admin
|
58
58
|
icon: fa fa-circle-o
|
59
|
-
- item: :
|
59
|
+
- item: :user
|
60
60
|
icon: fa fa-circle-o
|
61
61
|
|
62
62
|
- item: nested
|
@@ -74,7 +74,7 @@ class ApplicationController < ActionController::Base
|
|
74
74
|
|
75
75
|
def set_menuizer
|
76
76
|
@menuizer = Menuizer.menu
|
77
|
-
# or
|
77
|
+
# or
|
78
78
|
# @menuizer = Menuizer.menu(request: request)
|
79
79
|
# @menuizer.data[:request] #=> request
|
80
80
|
end
|
@@ -86,7 +86,7 @@ end
|
|
86
86
|
|
87
87
|
```erb
|
88
88
|
<%# app/views/admins/index.html.erb %>
|
89
|
-
<% menuizer.activate :
|
89
|
+
<% menuizer.activate :admin # item's value %>
|
90
90
|
<% content_for :title do %><%= menuizer.active_item.try(:title) %><% end %>
|
91
91
|
|
92
92
|
...
|
@@ -142,7 +142,30 @@ end
|
|
142
142
|
### get item
|
143
143
|
|
144
144
|
```ruby
|
145
|
-
menuizer.item(:
|
145
|
+
menuizer.item(:admin) #=> menu item
|
146
|
+
```
|
147
|
+
|
148
|
+
### short cut
|
149
|
+
|
150
|
+
```yaml
|
151
|
+
- item: :admin
|
152
|
+
# =>
|
153
|
+
# path:
|
154
|
+
# - :admins
|
155
|
+
```
|
156
|
+
|
157
|
+
(auto convert path)
|
158
|
+
|
159
|
+
## i18n
|
160
|
+
|
161
|
+
```yaml
|
162
|
+
ja:
|
163
|
+
menuizer:
|
164
|
+
admin: Admin Title
|
165
|
+
# or
|
166
|
+
activerecord:
|
167
|
+
models:
|
168
|
+
admin: Admin Title
|
146
169
|
```
|
147
170
|
|
148
171
|
## Generators
|
@@ -181,10 +204,12 @@ Convert menu item's property:
|
|
181
204
|
# config/initializers/menuizer.rb
|
182
205
|
Menuizer.configure do |config|
|
183
206
|
config.converter = {
|
184
|
-
icon: ->(
|
207
|
+
icon: ->(value,opts){
|
208
|
+
# value : item.#{key} value
|
209
|
+
# opts : item yml data
|
185
210
|
case
|
186
|
-
when
|
187
|
-
when
|
211
|
+
when value.blank? || value.starts_with?("fa") then value
|
212
|
+
when value then "fa fa-#{value}"
|
188
213
|
else
|
189
214
|
"fa fa-circle-o"
|
190
215
|
end
|
@@ -193,15 +218,16 @@ Menuizer.configure do |config|
|
|
193
218
|
end
|
194
219
|
```
|
195
220
|
|
196
|
-
```
|
197
|
-
|
198
|
-
|
199
|
-
|
221
|
+
```yaml
|
222
|
+
- item: no icon
|
223
|
+
- item: enverope
|
224
|
+
icon: enverope
|
200
225
|
```
|
201
226
|
|
202
|
-
|
203
|
-
|
204
|
-
|
227
|
+
```ruby
|
228
|
+
menuizer.item("no icon").icon # => "fa fa-circle-o"
|
229
|
+
menuizer.item("envelope").icon # => "fa fa-envelope"
|
230
|
+
```
|
205
231
|
|
206
232
|
### auto converters
|
207
233
|
|
@@ -215,7 +241,7 @@ I18n.translate "menuizer.#{item}", defaults: ["activerecord.models.#{item}","#{i
|
|
215
241
|
|
216
242
|
**path**
|
217
243
|
|
218
|
-
if not specified, and item is symbol: `[namespace,item]`
|
244
|
+
if not specified, and item is symbol: `[namespace,item.to_s.pluralize.to_sym]`
|
219
245
|
|
220
246
|
**what is namespace?**
|
221
247
|
|
@@ -235,7 +261,7 @@ end
|
|
235
261
|
```yaml
|
236
262
|
# config/menuizer/namespace.yml
|
237
263
|
- header: NAMESPACE MENU
|
238
|
-
- item: :
|
264
|
+
- item: :admin
|
239
265
|
```
|
240
266
|
|
241
267
|
```ruby
|
data/lib/menuizer/menu/item.rb
CHANGED
@@ -12,21 +12,19 @@ class Menuizer::Menu::Item < OpenStruct
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
def path
|
15
|
-
|
15
|
+
unless path = @opts[:path]
|
16
|
+
case item
|
17
|
+
when Symbol
|
18
|
+
path = [item.to_s.pluralize.to_sym]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if path
|
16
23
|
if namespace
|
17
24
|
[namespace[0..-2].to_sym,*path]
|
18
25
|
else
|
19
26
|
path
|
20
27
|
end
|
21
|
-
else
|
22
|
-
case item
|
23
|
-
when Symbol
|
24
|
-
if namespace
|
25
|
-
[namespace[0..-2].to_sym,item]
|
26
|
-
else
|
27
|
-
[item]
|
28
|
-
end
|
29
|
-
end
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
data/lib/menuizer.rb
CHANGED
data/menuizer.gemspec
CHANGED
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: menuizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shun
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: build menu items for admin page ( like AdminLTE )
|
84
98
|
email:
|
85
99
|
- shun@getto.systems
|