ants 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +79 -2
- data/app/assets/javascripts/ants/menu.coffee +28 -0
- data/app/controllers/admin/menus_controller.rb +3 -0
- data/app/helpers/menu_helper.rb +18 -0
- data/app/models/menu.rb +19 -0
- data/app/models/menu_link.rb +14 -0
- data/lib/ants/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 473241abeff9161336290855d89a455e3c9ca416
|
4
|
+
data.tar.gz: dbb4139bad372a87b141c26470d46089ff5e66ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8f7568cde05ea717805a96ecb18053a92656e8eb450b9b0d30bc96de353f3ef18738d34596282407e1f7bab332d88698022c8e6b32f11f0cef666fbc989017
|
7
|
+
data.tar.gz: 84e4f5afba7c3056005bca4fefb1494b32bb382a2a48bac5d9e01a5751d81b2f7ac6cd69feacf52108f4c16aadf51258497a96399b3075876953db4d9dd5aa48
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
Ants
|
3
3
|
======
|
4
4
|
[![GitHub version](https://badge.fury.io/gh/slate-studio%2Fants.svg)](http://badge.fury.io/gh/slate-studio%2Fants)
|
5
5
|
[![Build Status](https://travis-ci.org/slate-studio/ants.svg)](https://travis-ci.org/slate-studio/ants)
|
@@ -9,6 +9,65 @@ ants
|
|
9
9
|
Collection of concerns and helpers for Rails + Mongoid + Character web development
|
10
10
|
|
11
11
|
|
12
|
+
### Orderable
|
13
|
+
|
14
|
+
Adds ordering functionality to the model. Default order is assending by `_position` field.
|
15
|
+
|
16
|
+
Usage:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
include Ants:Orderable
|
20
|
+
```
|
21
|
+
|
22
|
+
**NOTE:** If this concern is added to model with already existing documents, value for `_position` field should be initialized with this command:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
ModelClass.all.set(_position: 1000)
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
### Meta
|
30
|
+
|
31
|
+
Adds set of page meta fields and creates default methods that should be overriden if necessary:
|
32
|
+
|
33
|
+
- `_meta_title`
|
34
|
+
- `_meta_description`
|
35
|
+
- `_meta_keywords`
|
36
|
+
- `_opengraph_image_url`
|
37
|
+
|
38
|
+
Usage:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
include Ants:Meta
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
### Hideable
|
46
|
+
|
47
|
+
When you need to hide some documents from public or often used as draft analogue:
|
48
|
+
|
49
|
+
Usage:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
include Ants:Hideable
|
53
|
+
```
|
54
|
+
|
55
|
+
Scopes:
|
56
|
+
|
57
|
+
- `hidden`
|
58
|
+
- `not_hidden`
|
59
|
+
|
60
|
+
Helpers:
|
61
|
+
|
62
|
+
- `hide!`
|
63
|
+
- `unhide!`
|
64
|
+
- `hidden?`
|
65
|
+
|
66
|
+
|
67
|
+
### Slug
|
68
|
+
|
69
|
+
|
70
|
+
|
12
71
|
### Sorted Relations
|
13
72
|
|
14
73
|
In Mongoid, the HM & HABTM relations return docs in random order. This workaround provides an ability to retrieve related documents in the same order it was stored.
|
@@ -33,5 +92,23 @@ Usage example:
|
|
33
92
|
|
34
93
|
post.sorted_authors.map(&:name)
|
35
94
|
#=> ['Alexander Kravets', 'Roman Brazhnyk', 'Maxim Melnyk']
|
36
|
-
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
### Versions
|
99
|
+
|
100
|
+
Provides a helper method to get a list of document versions, used by `chr` + `mongosteen`:
|
101
|
+
|
102
|
+
Usage:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
include Ants:Versions
|
106
|
+
```
|
107
|
+
|
108
|
+
Helpers:
|
109
|
+
|
110
|
+
- `_document_versions`
|
111
|
+
|
112
|
+
|
113
|
+
|
37
114
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class @AntsMenu
|
2
|
+
constructor: (title, apiPath) ->
|
3
|
+
config =
|
4
|
+
title: title
|
5
|
+
|
6
|
+
objectStore: new RailsObjectStore({
|
7
|
+
resource: 'menu'
|
8
|
+
path: "#{ apiPath }"
|
9
|
+
})
|
10
|
+
|
11
|
+
formSchema:
|
12
|
+
links:
|
13
|
+
type: 'documents'
|
14
|
+
newButtonLabel: 'Add a Link'
|
15
|
+
sortBy: '_position'
|
16
|
+
formSchema:
|
17
|
+
title:
|
18
|
+
type: 'string'
|
19
|
+
|
20
|
+
url:
|
21
|
+
type: 'string'
|
22
|
+
|
23
|
+
target_blank:
|
24
|
+
type: 'checkbox'
|
25
|
+
default: false
|
26
|
+
label: 'Open in a new tab'
|
27
|
+
|
28
|
+
return config
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module MenuHelper
|
2
|
+
def menu(name)
|
3
|
+
menu = Menu.find_by(name: name)
|
4
|
+
html = ''
|
5
|
+
|
6
|
+
menu.links.each do |l|
|
7
|
+
if l.target_blank
|
8
|
+
html << link_to(l.title, l.url, _target: '_blank')
|
9
|
+
|
10
|
+
else
|
11
|
+
html << link_to(l.title, l.url)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
html.html_safe
|
17
|
+
end
|
18
|
+
end
|
data/app/models/menu.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Menu
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
include Ants::Id
|
5
|
+
include Ants::Slug
|
6
|
+
|
7
|
+
## Attributes
|
8
|
+
field :name
|
9
|
+
|
10
|
+
## Slug
|
11
|
+
slug :name
|
12
|
+
|
13
|
+
## Relations
|
14
|
+
embeds_many :links, class_name: 'MenuLink'
|
15
|
+
accepts_nested_attributes_for :links, allow_destroy: true
|
16
|
+
|
17
|
+
## Index
|
18
|
+
index name: 1
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class MenuLink
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
include Ants::Id
|
5
|
+
include Ants::Orderable
|
6
|
+
|
7
|
+
## Attributes
|
8
|
+
field :title
|
9
|
+
field :url
|
10
|
+
field :target_blank, type: Boolean, default: false
|
11
|
+
|
12
|
+
## Relations
|
13
|
+
embedded_in :menu, class_name: 'Menu'
|
14
|
+
end
|
data/lib/ants/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kravets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -155,14 +155,19 @@ files:
|
|
155
155
|
- ants.gemspec
|
156
156
|
- app/assets/javascripts/ants.coffee
|
157
157
|
- app/assets/javascripts/ants/admins.coffee
|
158
|
+
- app/assets/javascripts/ants/menu.coffee
|
158
159
|
- app/assets/javascripts/ants/redirects.coffee
|
159
160
|
- app/assets/stylesheets/ants.scss
|
160
161
|
- app/assets/stylesheets/chr/header.scss
|
161
162
|
- app/controllers/admin/admins_controller.rb
|
163
|
+
- app/controllers/admin/menus_controller.rb
|
162
164
|
- app/controllers/admin/redirects_controller.rb
|
163
165
|
- app/controllers/redirects_controller.rb
|
166
|
+
- app/helpers/menu_helper.rb
|
164
167
|
- app/mailers/admin_mailer.rb
|
165
168
|
- app/models/admin.rb
|
169
|
+
- app/models/menu.rb
|
170
|
+
- app/models/menu_link.rb
|
166
171
|
- app/models/redirect.rb
|
167
172
|
- lib/ants.rb
|
168
173
|
- lib/ants/engine.rb
|