partial_menu 1.0.0 → 1.0.1
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
- data/README.md +44 -2
- data/lib/generators/views/USAGE +2 -0
- data/lib/generators/yaml/USAGE +3 -2
- data/lib/generators/yaml/templates/menu.yml +2 -2
- data/lib/partial_menu/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2714223d904bafa97e9f92736314f96bf06f6e66
|
4
|
+
data.tar.gz: 85215decc146153e1873d643563f502991c87868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2ec14fb7443b91e39d4fab6def404cc89dfaf76ad7e36db48ad0946d610ab8c9443096926abc39bc942232f33de82a12568683c4c5fa2f5182e48bb9b0bc8f
|
7
|
+
data.tar.gz: 1a879c100269a83d747b20fdb4c0dcafff8c612b5dfc46b38c892425cb2a19847b0a61aa87119b686e792e40ba9259f129356585093bf82871d1ec99e9b44042
|
data/README.md
CHANGED
@@ -1,8 +1,50 @@
|
|
1
1
|
# PartialMenu
|
2
|
-
|
2
|
+
Generating hierarchical menus in Rails should utilize Rails' built-in partial views instead of using some kind on HTML code generators. This gem just do that.
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
|
5
|
+
After installing the gem you can generate the views and the config file to create your own menus, even more than one can be generated by using name prefixes.
|
6
|
+
|
7
|
+
```bash
|
8
|
+
rails generate partial_menu:yaml
|
9
|
+
```
|
10
|
+
This will generate an example menu description yaml file in `config/main_menu.yaml`
|
11
|
+
|
12
|
+
You can have multiple menu definitiions in an app. For this you can use the `--type` parameter to set the name of the file
|
13
|
+
|
14
|
+
```bash
|
15
|
+
rails generate partial_menu:yaml -t side
|
16
|
+
```
|
17
|
+
This will create `config/side_menu.yaml`
|
18
|
+
|
19
|
+
You can define your menu structure in the generated yaml file:
|
20
|
+
```yml
|
21
|
+
---
|
22
|
+
menu: # Marks the beginnin of the menu
|
23
|
+
- first_item: # Adds a menu item. Text here will be parsed as id for the item.
|
24
|
+
title: "First item" # Optional title of the item. If not set, ID will be used
|
25
|
+
uri: root # Optional URI, in any format url_for would parse
|
26
|
+
icon: test # Optional icon for the item.
|
27
|
+
- second_item: separator # A second menu item, specifing that its just a separator.
|
28
|
+
- third_item:
|
29
|
+
icontype: glyph # You can add any arbitarty property to an item, it will be parsed and can be used in templates.
|
30
|
+
menu: # Here comes the submenu
|
31
|
+
- first_submenu: link # First submenu, with specifing its link as a shortcut.
|
32
|
+
- second_submenu:
|
33
|
+
title: menu.second_submenu.title # You can use any text as title. In your template you can use it as you whish, like translate it with I18N::t()
|
34
|
+
uri: second
|
35
|
+
|
36
|
+
```
|
37
|
+
Now about the views:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
rails generate partial_menu:views -d side
|
41
|
+
```
|
42
|
+
This will create:
|
43
|
+
- `app/views/side_menu/_menu.html.erb` -- menu root template
|
44
|
+
- `app/views/side_menu/_item.html.erb` -- menu items template
|
45
|
+
- `app/views/side_menu/_separator.html.erb` -- separator template
|
46
|
+
- `app/views/side_menu/_submenu_item.html.erb` -- submenu root template
|
47
|
+
- `app/views/side_menu/_item.html.erb` -- submenu items template
|
6
48
|
|
7
49
|
## Installation
|
8
50
|
Add this line to your application's Gemfile:
|
data/lib/generators/views/USAGE
CHANGED
@@ -8,6 +8,7 @@ Examples:
|
|
8
8
|
This will create:
|
9
9
|
app/views/main_menu/_mneu.html.erb -- menu root template
|
10
10
|
app/views/main_menu/_item.html.erb -- menu items template
|
11
|
+
app/views/main_menu/_separator.html.erb -- separator template
|
11
12
|
app/views/main_menu/_submenu_item.html.erb -- submenu root template
|
12
13
|
app/views/main_menu/_item.html.erb -- submenu items template
|
13
14
|
|
@@ -16,5 +17,6 @@ Examples:
|
|
16
17
|
This will create:
|
17
18
|
app/views/side_menu/_menu.html.erb -- menu root template
|
18
19
|
app/views/side_menu/_item.html.erb -- menu items template
|
20
|
+
app/views/side_menu/_separator.html.erb -- separator template
|
19
21
|
app/views/side_menu/_submenu_item.html.erb -- submenu root template
|
20
22
|
app/views/side_menu/_item.html.erb -- submenu items template
|
data/lib/generators/yaml/USAGE
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Description:
|
2
|
-
Generates an example menu description yaml file
|
2
|
+
Generates an example menu description yaml file at config/main_menu.yml
|
3
3
|
You can have multiple menu definitiions in an app. For this you can use
|
4
4
|
the '--type' parameter to set the name of the file
|
5
5
|
|
@@ -10,6 +10,7 @@ Examples:
|
|
10
10
|
config/main_menu.yaml
|
11
11
|
|
12
12
|
rails generate partial_menu:yaml -t side
|
13
|
+
rails generate partial_menu:yaml --type side
|
13
14
|
|
14
15
|
This will create:
|
15
|
-
config/side_menu.
|
16
|
+
config/side_menu.yml
|
@@ -2,7 +2,7 @@
|
|
2
2
|
menu:
|
3
3
|
- first_item:
|
4
4
|
title: "First item"
|
5
|
-
uri:
|
5
|
+
uri: root
|
6
6
|
icon: test
|
7
7
|
- second_item: separator
|
8
8
|
- third_item:
|
@@ -11,4 +11,4 @@ menu:
|
|
11
11
|
- first_submenu: link
|
12
12
|
- second_submenu:
|
13
13
|
title: menu.second_submenu.title
|
14
|
-
uri:
|
14
|
+
uri: second
|
data/lib/partial_menu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partial_menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Nagy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_link_to
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.3'
|
139
139
|
description: |-
|
140
|
-
Generating hierarchical
|
140
|
+
Generating hierarchical menus in Rails should utilize Rails'
|
141
141
|
built-in partial views instead of using some kind on HTML code generators.
|
142
142
|
This gem just do that.
|
143
143
|
email:
|