cortex-plugins-core 0.11.0 → 0.11.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/app/cells/plugins/core/author/input.haml +5 -0
- data/app/cells/plugins/core/author_cell.rb +29 -0
- data/app/models/asset_field_type.rb +6 -5
- data/app/models/author_field_type.rb +35 -0
- data/app/models/tree_field_type.rb +6 -8
- data/lib/cortex/plugins/core/version.rb +1 -1
- data/lib/tasks/cortex/core/media.rake +22 -17
- data/lib/tasks/cortex/test/dummy/db/development.sqlite3 +0 -0
- data/lib/tasks/cortex/test/dummy/db/test.sqlite3 +0 -0
- metadata +7 -3
- data/lib/cortex/plugins/core/version.rb.orig +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4bd07a0ea13aa49a90ed6a2dbf4afe23b84bf3b
|
4
|
+
data.tar.gz: ad25af70b6ae11d015c2f86d598d553b1d3b990f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb61b3e99019a6f57eef80df805a9518dd5785f15c3c1081156bc87fa593c8dd732d3bb1e5cc9bdbe5b4fd79f456139c3e7c34851e61134f9c26db03f943cfb
|
7
|
+
data.tar.gz: 2c63e3f1748256b1ee7da486582862be68bb18ee507e433129ce4989165f86757a0fb495eec9eb4c23dd06bef21a0e610feeddaca1cc0aa0bbae278641add3dc
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Plugins
|
2
|
+
module Core
|
3
|
+
class AuthorCell < Plugins::Core::Cell
|
4
|
+
include Devise::Controllers::Helpers
|
5
|
+
|
6
|
+
def input
|
7
|
+
render
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def value
|
13
|
+
data&.[]('author_name') || current_user.fullname
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_label
|
17
|
+
@options[:form].label 'data[author_name]', field.name, class: 'mdl-textfield__label'
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_input
|
21
|
+
@options[:form].text_field 'data[author_name]', value: value, placeholder: @options[:placeholder], class: 'mdl-textfield__input', required: required?
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_default_value
|
25
|
+
@options[:form].hidden_field 'data[default_author_name]', value: current_user.fullname
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -36,6 +36,7 @@ class AssetFieldType < FieldType
|
|
36
36
|
'file_size': asset_file_size,
|
37
37
|
'updated_at': asset_updated_at
|
38
38
|
},
|
39
|
+
'media_title': media_title,
|
39
40
|
'asset_field_type_id': id
|
40
41
|
}
|
41
42
|
end
|
@@ -74,6 +75,10 @@ class AssetFieldType < FieldType
|
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
78
|
+
def media_title
|
79
|
+
existing_data['media_title'] || ContentItemService.form_fields[@metadata[:naming_data][:title]][:text].parameterize.underscore
|
80
|
+
end
|
81
|
+
|
77
82
|
def mapping_field_name
|
78
83
|
"#{field_name.parameterize('_')}_asset_file_name"
|
79
84
|
end
|
@@ -128,11 +133,7 @@ class AssetFieldType < FieldType
|
|
128
133
|
|
129
134
|
def existing_metadata
|
130
135
|
metadata.except!(:existing_data)
|
131
|
-
|
132
|
-
unless existing_data.empty?
|
133
|
-
metadata[:path].gsub!(":id", existing_data['asset_field_type_id']) if metadata[:path]
|
134
|
-
end
|
135
|
-
|
136
|
+
metadata[:path].gsub!(":media_title", media_title) if metadata[:path]
|
136
137
|
metadata
|
137
138
|
end
|
138
139
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class AuthorFieldType < FieldType
|
2
|
+
attr_accessor :author_name
|
3
|
+
jsonb_accessor :data, author_name: :string
|
4
|
+
|
5
|
+
validates :author_name, presence: true, if: :validate_presence?
|
6
|
+
|
7
|
+
def data=(data_hash)
|
8
|
+
data_hash[:author_name] = data_hash[:default_author_name] if data_hash.deep_symbolize_keys[:author_name].blank?
|
9
|
+
@author_name = data_hash.deep_symbolize_keys[:author_name]
|
10
|
+
end
|
11
|
+
|
12
|
+
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
13
|
+
json = {}
|
14
|
+
json[mapping_field_name] = field_item.data['author_name']
|
15
|
+
json
|
16
|
+
end
|
17
|
+
|
18
|
+
def mapping
|
19
|
+
{author_name: mapping_field_name, type: :string, analyzer: :snowball}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def mapping_field_name
|
25
|
+
"#{field_name.parameterize('_')}_author_name"
|
26
|
+
end
|
27
|
+
|
28
|
+
def author_name_present
|
29
|
+
errors.add(:author_name, 'must be present') if @author_name.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_presence?
|
33
|
+
@validations.key? :presence
|
34
|
+
end
|
35
|
+
end
|
@@ -36,19 +36,17 @@ class TreeFieldType < FieldType
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def minimum
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
false
|
45
|
-
end
|
39
|
+
if !@values.nil? && @values[:values].length >= @validations[:minimum]
|
40
|
+
true
|
41
|
+
else
|
42
|
+
errors.add(:minimum, "You have selected too few values.")
|
43
|
+
false
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
47
|
def maximum
|
50
48
|
unless @values.nil?
|
51
|
-
if @values.length <= @validations[:maximum]
|
49
|
+
if @values[:values].length <= @validations[:maximum]
|
52
50
|
true
|
53
51
|
else
|
54
52
|
errors.add(:maximum, "You have selected too many values.")
|
@@ -13,11 +13,13 @@ namespace :cortex do
|
|
13
13
|
creator_id: 1,
|
14
14
|
contract_id: 1
|
15
15
|
})
|
16
|
-
media.save
|
16
|
+
media.save!
|
17
17
|
|
18
18
|
puts "Creating Fields..."
|
19
19
|
|
20
20
|
allowed_asset_content_types = %w(txt css js pdf doc docx ppt pptx csv xls xlsx svg ico png jpg gif bmp)
|
21
|
+
fieldTitle = media.fields.new(name: 'Title', field_type: 'text_field_type', validations: {presence: true, uniqueness: true})
|
22
|
+
fieldTitle.save
|
21
23
|
media.fields.new(name: 'Asset', field_type: 'asset_field_type',
|
22
24
|
validations:
|
23
25
|
{
|
@@ -29,6 +31,9 @@ namespace :cortex do
|
|
29
31
|
},
|
30
32
|
metadata:
|
31
33
|
{
|
34
|
+
naming_data: {
|
35
|
+
title: fieldTitle.id
|
36
|
+
},
|
32
37
|
styles: {
|
33
38
|
large: {geometry: '1800x1800>', format: :jpg},
|
34
39
|
medium: {geometry: '800x800>', format: :jpg},
|
@@ -39,15 +44,15 @@ namespace :cortex do
|
|
39
44
|
},
|
40
45
|
processors: [:thumbnail, :paperclip_optimizer],
|
41
46
|
preserve_files: true,
|
42
|
-
path: ':class/:attachment
|
47
|
+
path: ':class/:attachment/:media_title-:style.:extension',
|
43
48
|
s3_headers: {'Cache-Control': 'public, max-age=315576000'}
|
44
49
|
})
|
45
|
-
media.fields.new(name: 'Title', field_type: 'text_field_type', validations: {presence: true})
|
46
50
|
media.fields.new(name: 'Description', field_type: 'text_field_type', validations: {presence: true})
|
47
51
|
media.fields.new(name: 'Tags', field_type: 'tag_field_type')
|
48
52
|
media.fields.new(name: 'Expiration Date', field_type: 'date_time_field_type')
|
49
53
|
media.fields.new(name: 'Alt Tag', field_type: 'text_field_type')
|
50
|
-
|
54
|
+
|
55
|
+
media.save!
|
51
56
|
|
52
57
|
puts "Creating Wizard Decorators..."
|
53
58
|
wizard_hash = {
|
@@ -61,7 +66,7 @@ namespace :cortex do
|
|
61
66
|
"grid_width": 12,
|
62
67
|
"elements": [
|
63
68
|
{
|
64
|
-
"id": media.fields
|
69
|
+
"id": media.fields.find_by_name('Asset').id
|
65
70
|
}
|
66
71
|
]
|
67
72
|
}
|
@@ -76,23 +81,23 @@ namespace :cortex do
|
|
76
81
|
"grid_width": 6,
|
77
82
|
"elements": [
|
78
83
|
{
|
79
|
-
"id": media.fields
|
84
|
+
"id": media.fields.find_by_name('Title').id
|
80
85
|
},
|
81
86
|
{
|
82
|
-
"id": media.fields
|
87
|
+
"id": media.fields.find_by_name('Description').id,
|
83
88
|
"render_method": "multiline_input",
|
84
89
|
"display": {
|
85
90
|
"rows": 3
|
86
91
|
}
|
87
92
|
},
|
88
93
|
{
|
89
|
-
"id": media.fields
|
94
|
+
"id": media.fields.find_by_name('Tags').id
|
90
95
|
},
|
91
96
|
{
|
92
|
-
"id": media.fields
|
97
|
+
"id": media.fields.find_by_name('Expiration Date').id
|
93
98
|
},
|
94
99
|
{
|
95
|
-
"id": media.fields
|
100
|
+
"id": media.fields.find_by_name('Alt Tag').id
|
96
101
|
}
|
97
102
|
]
|
98
103
|
},
|
@@ -116,9 +121,9 @@ namespace :cortex do
|
|
116
121
|
}
|
117
122
|
|
118
123
|
media_wizard_decorator = Decorator.new(name: "Wizard", data: wizard_hash)
|
119
|
-
media_wizard_decorator.save
|
124
|
+
media_wizard_decorator.save!
|
120
125
|
|
121
|
-
ContentableDecorator.create({
|
126
|
+
ContentableDecorator.create!({
|
122
127
|
decorator_id: media_wizard_decorator.id,
|
123
128
|
contentable_id: media.id,
|
124
129
|
contentable_type: 'ContentType'
|
@@ -163,7 +168,7 @@ namespace :cortex do
|
|
163
168
|
"cells": [
|
164
169
|
{
|
165
170
|
"field": {
|
166
|
-
"id": media.fields
|
171
|
+
"id": media.fields.find_by_name('Title').id
|
167
172
|
},
|
168
173
|
"display": {
|
169
174
|
"classes": [
|
@@ -174,7 +179,7 @@ namespace :cortex do
|
|
174
179
|
},
|
175
180
|
{
|
176
181
|
"field": {
|
177
|
-
"id": media.fields
|
182
|
+
"id": media.fields.find_by_name('Description').id
|
178
183
|
}
|
179
184
|
}
|
180
185
|
]
|
@@ -184,7 +189,7 @@ namespace :cortex do
|
|
184
189
|
"cells": [
|
185
190
|
{
|
186
191
|
"field": {
|
187
|
-
"id": media.fields
|
192
|
+
"id": media.fields.find_by_name('Tags').id
|
188
193
|
},
|
189
194
|
"display": {
|
190
195
|
"classes": [
|
@@ -199,9 +204,9 @@ namespace :cortex do
|
|
199
204
|
}
|
200
205
|
|
201
206
|
media_index_decorator = Decorator.new(name: "Index", data: index_hash)
|
202
|
-
media_index_decorator.save
|
207
|
+
media_index_decorator.save!
|
203
208
|
|
204
|
-
ContentableDecorator.create({
|
209
|
+
ContentableDecorator.create!({
|
205
210
|
decorator_id: media_index_decorator.id,
|
206
211
|
contentable_id: media.id,
|
207
212
|
contentable_type: 'ContentType'
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cortex-plugins-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CareerBuilder Employer Site & Content Products
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -130,6 +130,8 @@ files:
|
|
130
130
|
- app/cells/plugins/core/asset_info/index.haml
|
131
131
|
- app/cells/plugins/core/asset_info/show.haml
|
132
132
|
- app/cells/plugins/core/asset_info_cell.rb
|
133
|
+
- app/cells/plugins/core/author/input.haml
|
134
|
+
- app/cells/plugins/core/author_cell.rb
|
133
135
|
- app/cells/plugins/core/boolean/checkbox.haml
|
134
136
|
- app/cells/plugins/core/boolean/switch.haml
|
135
137
|
- app/cells/plugins/core/boolean_cell.rb
|
@@ -158,6 +160,7 @@ files:
|
|
158
160
|
- app/cells/plugins/core/user/dropdown.haml
|
159
161
|
- app/cells/plugins/core/user_cell.rb
|
160
162
|
- app/models/asset_field_type.rb
|
163
|
+
- app/models/author_field_type.rb
|
161
164
|
- app/models/boolean_field_type.rb
|
162
165
|
- app/models/content_item_field_type.rb
|
163
166
|
- app/models/date_time_field_type.rb
|
@@ -171,9 +174,10 @@ files:
|
|
171
174
|
- lib/cortex/plugins/core.rb
|
172
175
|
- lib/cortex/plugins/core/engine.rb
|
173
176
|
- lib/cortex/plugins/core/version.rb
|
174
|
-
- lib/cortex/plugins/core/version.rb.orig
|
175
177
|
- lib/tasks/cortex/core/db.rake
|
176
178
|
- lib/tasks/cortex/core/media.rake
|
179
|
+
- lib/tasks/cortex/test/dummy/db/development.sqlite3
|
180
|
+
- lib/tasks/cortex/test/dummy/db/test.sqlite3
|
177
181
|
homepage: https://github.com/cortex-cms/cortex-plugins-core
|
178
182
|
licenses:
|
179
183
|
- Apache-2.0
|