brightcontent 2.1.5 → 2.2.0
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 +88 -1
- data/VERSION +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800182b4749990ccc8ef59573dbdf6fa6cc4093b
|
4
|
+
data.tar.gz: 484c9676dc21e37938f0c6b47b51f4e6acb88884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2abef9adc1716146aea208e4c5fbc639b3065c90d401f0d772177272e37bd71d5306a5983d20c25f95e2f3b18abdf080694dbca0688f51b9e5debeed3d5d712
|
7
|
+
data.tar.gz: 7162bc6bc2ede2f89d113d63f2b836570878958369f98943240212b221b9280412818a88012d7dd7c3fa4a87d2bfe233b3ed03f66c67c8ff25428e8384430dc6
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Brightcontent, yet another rails CMS / admin panel
|
|
11
11
|
* No standard 'cms-modules', we hate those, making custom is easy enough
|
12
12
|
* Built in the rails way, use your normals models, only controllers and views are provided
|
13
13
|
* Only exception: Page model is provided with tree structure, sorting, hidden and pretty urls like `/services/cleaning/houses`
|
14
|
-
* Rails 4 only
|
14
|
+
* Rails 4 only (currently >= 4.2 is not supported)
|
15
15
|
* Strong Parameters support
|
16
16
|
|
17
17
|

|
@@ -48,6 +48,93 @@ To add the resource to brightcontent run:
|
|
48
48
|
|
49
49
|
Gratz! Projects can now be controlled with Brightcontent.
|
50
50
|
|
51
|
+
Filters
|
52
|
+
-------
|
53
|
+
|
54
|
+
Using `filter_fields` you may define filters for your index pages:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
class BlogsController < Brightcontent::BaseController
|
58
|
+
filter_fields :author, :name
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
The above will render two filters on the blogs index page. Blog belongs to Author, therefore by default the filter is displayed as a drop-down list containing all authors that have blogs. The name-filter is displayed as a drop-down list containing all values for the `name` attribute found in the blogs table.
|
63
|
+
|
64
|
+
### Options
|
65
|
+
|
66
|
+
In order to control the way filters are displayed and how they behave you can supply options:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
# Supplying options:
|
70
|
+
filter_fields author: { ... }, name: { ... }
|
71
|
+
|
72
|
+
# Combining filters without options and filters with options:
|
73
|
+
filter_fields :author, name: { ... }
|
74
|
+
```
|
75
|
+
|
76
|
+
Basically all options are delegated to `SimpleForm::FormBuilder#input`, such as `:as`, `:input_html`, and `:label_method`. Refer to [Simple Form's documentation](http://www.rubydoc.info/github/plataformatec/simple_form/master/SimpleForm/FormBuilder#input-instance_method) for more information.
|
77
|
+
|
78
|
+
#### Other options
|
79
|
+
|
80
|
+
##### <tt>:collection</tt>
|
81
|
+
|
82
|
+
Extends SimpleForm's `:collection` option. It also accepts a Proc, or method name as a symbol. It defaults to either a list of all existing values for the corresponding attribute or a list of all associated records in case of a belongs-to relationship.
|
83
|
+
|
84
|
+
##### <tt>:predicate</tt>
|
85
|
+
|
86
|
+
Allows for specifying the Ransack search predicate to be used. Set it to `false` to avoid a predicate. Defaults to "cont" (contains) for string type filters (`:string` or `:search`) and to "eq" (equals) for all other types. It defaults to `false` if the field name refers to [a ransackable scope](https://github.com/activerecord-hackery/ransack#using-scopesclass-methods). For more information refer to [Ransack's documentation](https://github.com/activerecord-hackery/ransack/wiki/Basic-Searching).
|
87
|
+
|
88
|
+
### Examples
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
class BlogsController < Brightcontent::BaseController
|
92
|
+
# Two default drop-down list filters:
|
93
|
+
filter_fields :name, :author
|
94
|
+
|
95
|
+
# Free form text filter, returns all blogs where name contains given query:
|
96
|
+
filter_fields name: { as: :string, predicate: "cont" }
|
97
|
+
|
98
|
+
# Same as above:
|
99
|
+
filter_fields name: { as: :string }
|
100
|
+
|
101
|
+
# Customized label:
|
102
|
+
filter_fields author: { label: "Written by" }
|
103
|
+
|
104
|
+
# Select filter with custom options:
|
105
|
+
filter_fields name: { collection: ["Game reviews", "Programming tips", "Arthur's blog"] }
|
106
|
+
|
107
|
+
# Belongs-to filter with custom options:
|
108
|
+
filter_fields author: { collection: ->{ Author.order(:name) }, label_method: :display_name }
|
109
|
+
|
110
|
+
# Or by means of a controller method:
|
111
|
+
filter_fields author: { collection: :published_authors }
|
112
|
+
|
113
|
+
# Or even a fully customized filter, using a fictitious custom SimpleForm input field:
|
114
|
+
filter_fields author: { as: :remote_select, url: "/authors.json?order=name" }
|
115
|
+
|
116
|
+
# Filter by start date:
|
117
|
+
filter_fields created_at: { as: :date, predicate: "gteq", label: "Posted since" }
|
118
|
+
|
119
|
+
# Filter by scope (see definition of Blog below):
|
120
|
+
filter_fields exclude_inactive: { as: :select, collection: [["Yes", true], ["No", false]] }
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def published_authors
|
125
|
+
Author.published
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def Blog < ActiveRecord::Base
|
130
|
+
scope :exclude_inactive, ->{ where(active: true) }
|
131
|
+
|
132
|
+
def self.ransackable_scopes(auth_object = nil)
|
133
|
+
[:exclude_inactive]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
```
|
137
|
+
|
51
138
|
Pages
|
52
139
|
-----
|
53
140
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightcontent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Developers at Brightin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brightcontent-core
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: brightcontent-pages
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: brightcontent-attachments
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.2.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.2.0
|
55
55
|
description: Brightcontent, yet another Rails CMS / admin panel
|
56
56
|
email: developers@brightin.nl
|
57
57
|
executables: []
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.4.5
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Brightcontent gem
|