cortex-plugins-core 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/plugins/core/asset/input.haml +6 -0
- data/app/cells/plugins/core/asset_cell.rb +9 -0
- data/app/cells/plugins/core/text/input.haml +1 -0
- data/app/cells/plugins/core/text/multiline_input.haml +4 -3
- data/app/cells/plugins/core/text_cell.rb +8 -4
- data/app/models/asset_field_type.rb +32 -30
- data/app/models/boolean_field_type.rb +1 -14
- data/app/models/date_time_field_type.rb +7 -44
- data/app/models/tag_field_type.rb +1 -34
- data/app/models/text_field_type.rb +1 -44
- data/app/models/tree_field_type.rb +1 -45
- data/app/models/user_field_type.rb +1 -34
- data/lib/cortex/plugins/core/version.rb +1 -1
- data/lib/tasks/cortex/core/media.rake +113 -84
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ba8f598906bf3fcbcb195dfeba41cc2e3cc060
|
4
|
+
data.tar.gz: 5eeb2df6aaca564832b6995120194382d1246f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0530f8c7a10dc9a770c4a67a316b58311c1dac467fc6007b7a0fa4dd5e98fbe25ca916729fcf90b24fcdc57b51508b17dad972188957468e1d373d39b63a0ea9
|
7
|
+
data.tar.gz: dd131c537b78e03bd4941d903b826df82c5b0f998f496a2ce49075ef5ccacbe02dc2e90e3d0784a42f2031d2b4f510721990d8a5f85eb2e95ccbf471eb37825a
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Plugins
|
2
2
|
module Core
|
3
3
|
class AssetCell < Plugins::Core::Cell
|
4
|
+
include ActionView::Helpers::NumberHelper
|
4
5
|
include UtilityHelper
|
5
6
|
|
6
7
|
def input
|
@@ -9,6 +10,14 @@ module Plugins
|
|
9
10
|
|
10
11
|
private
|
11
12
|
|
13
|
+
def render_allowed_asset_extensions
|
14
|
+
field.validations['allowed_extensions']&.join(', ')
|
15
|
+
end
|
16
|
+
|
17
|
+
def render_max_asset_size
|
18
|
+
number_to_human_size(field.validations['size']&.[]('less_than'))
|
19
|
+
end
|
20
|
+
|
12
21
|
def input_classes
|
13
22
|
@options[:input_options]&.[](:display)&.[](:classes)
|
14
23
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
-
|
2
|
-
=
|
3
|
-
=
|
1
|
+
.mdl-textfield.mdl-js-textfield
|
2
|
+
= render_label
|
3
|
+
= render_field_id
|
4
|
+
= render_multiline_input
|
@@ -15,14 +15,18 @@ module Plugins
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def input_display
|
19
|
+
@options[:input_options]&.[](:display)
|
20
|
+
end
|
21
|
+
|
18
22
|
def input_classes
|
19
|
-
|
23
|
+
input_display&.[](:classes)
|
20
24
|
end
|
21
25
|
|
22
26
|
def input_styles
|
23
|
-
|
27
|
+
input_display&.[](:styles)
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
def value
|
27
31
|
data&.[]('text') || @options[:default_value]
|
28
32
|
end
|
@@ -46,7 +50,7 @@ module Plugins
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def render_multiline_input
|
49
|
-
@options[:form].
|
53
|
+
@options[:form].text_area 'data[text]', value: value , placeholder: @options[:placeholder], rows: input_display&.[](:rows) , class: 'mdl-textfield__input'
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
@@ -1,26 +1,22 @@
|
|
1
1
|
class AssetFieldType < FieldType
|
2
|
-
VALIDATION_TYPES = {
|
3
|
-
presence: :valid_presence_validation?,
|
4
|
-
size: :valid_size_validation?,
|
5
|
-
content_type: :valid_content_type_validation?
|
6
|
-
}.freeze
|
7
|
-
|
8
2
|
attr_accessor :asset_file_name,
|
9
3
|
:asset_content_type,
|
10
4
|
:asset_file_size,
|
11
5
|
:asset_updated_at,
|
12
|
-
:
|
6
|
+
:asset
|
13
7
|
|
14
|
-
attr_reader :
|
8
|
+
attr_reader :dimensions
|
15
9
|
|
16
|
-
has_attached_file :asset
|
17
|
-
do_not_validate_attachment_file_type :asset
|
18
10
|
before_save :extract_dimensions
|
19
11
|
|
12
|
+
do_not_validate_attachment_file_type :asset
|
20
13
|
validates :asset, attachment_presence: true, if: :validate_presence?
|
14
|
+
validate :validate_asset_size, if: :validate_size?
|
15
|
+
validate :validate_asset_content_type, if: :validate_content_type?
|
21
16
|
|
22
|
-
def
|
23
|
-
@
|
17
|
+
def metadata=(metadata_hash)
|
18
|
+
@metadata = metadata_hash.deep_symbolize_keys
|
19
|
+
Paperclip::HasAttachedFile.define_on(self.class, :asset, metadata)
|
24
20
|
end
|
25
21
|
|
26
22
|
def data=(data_hash)
|
@@ -40,10 +36,6 @@ class AssetFieldType < FieldType
|
|
40
36
|
}
|
41
37
|
end
|
42
38
|
|
43
|
-
def acceptable_validations?
|
44
|
-
valid_types? && valid_options?
|
45
|
-
end
|
46
|
-
|
47
39
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
48
40
|
json = {}
|
49
41
|
json[mapping_field_name] = asset_file_name
|
@@ -72,43 +64,53 @@ class AssetFieldType < FieldType
|
|
72
64
|
end
|
73
65
|
end
|
74
66
|
|
67
|
+
def allowed_content_types
|
68
|
+
validations[:allowed_extensions].collect do |allowed_content_type|
|
69
|
+
MimeMagic.by_extension(allowed_content_type).type
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
75
73
|
def mapping_field_name
|
76
74
|
"#{field_name.parameterize('_')}_asset_file_name"
|
77
75
|
end
|
78
76
|
|
79
|
-
def
|
80
|
-
validations.
|
81
|
-
VALIDATION_TYPES.include?(type.to_sym)
|
82
|
-
end
|
77
|
+
def validate_presence?
|
78
|
+
@validations.key? :presence
|
83
79
|
end
|
84
80
|
|
85
|
-
def
|
86
|
-
validations.
|
87
|
-
self.send(VALIDATION_TYPES[type])
|
88
|
-
end
|
81
|
+
def attachment_size_validator
|
82
|
+
AttachmentSizeValidator.new(validations[:size].merge(attributes: :asset))
|
89
83
|
end
|
90
84
|
|
91
|
-
def
|
92
|
-
|
85
|
+
def attachment_content_type_validator
|
86
|
+
AttachmentContentTypeValidator.new({content_type: allowed_content_types}.merge(attributes: :asset))
|
93
87
|
end
|
94
88
|
|
95
89
|
alias_method :valid_presence_validation?, :validate_presence?
|
96
90
|
|
97
|
-
def
|
91
|
+
def validate_size?
|
98
92
|
begin
|
99
|
-
|
93
|
+
attachment_size_validator
|
100
94
|
true
|
101
95
|
rescue ArgumentError, NoMethodError
|
102
96
|
false
|
103
97
|
end
|
104
98
|
end
|
105
99
|
|
106
|
-
def
|
100
|
+
def validate_content_type?
|
107
101
|
begin
|
108
|
-
|
102
|
+
attachment_content_type_validator
|
109
103
|
true
|
110
104
|
rescue ArgumentError, NoMethodError
|
111
105
|
false
|
112
106
|
end
|
113
107
|
end
|
108
|
+
|
109
|
+
def validate_asset_size
|
110
|
+
attachment_size_validator.validate_each(self, :asset, asset)
|
111
|
+
end
|
112
|
+
|
113
|
+
def validate_asset_content_type
|
114
|
+
attachment_content_type_validator.validate_each(self, :asset, asset)
|
115
|
+
end
|
114
116
|
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
class BooleanFieldType < FieldType
|
2
|
-
attr_accessor :
|
3
|
-
attr_reader :validations, :metadata
|
4
|
-
|
5
|
-
def validations=(validations_hash)
|
6
|
-
@validations = {}
|
7
|
-
end
|
2
|
+
attr_accessor :value
|
8
3
|
|
9
4
|
def data=(data_hash)
|
10
5
|
@value = data_hash.deep_symbolize_keys[:value]
|
11
6
|
end
|
12
7
|
|
13
|
-
def metadata=(metadata_hash)
|
14
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
15
|
-
end
|
16
|
-
|
17
8
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
18
9
|
json = {}
|
19
10
|
json[mapping_field_name] = field_item.data['boolean']
|
@@ -24,10 +15,6 @@ class BooleanFieldType < FieldType
|
|
24
15
|
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
25
16
|
end
|
26
17
|
|
27
|
-
def acceptable_validations?
|
28
|
-
true
|
29
|
-
end
|
30
|
-
|
31
18
|
private
|
32
19
|
|
33
20
|
def mapping_field_name
|
@@ -1,30 +1,13 @@
|
|
1
1
|
class DateTimeFieldType < FieldType
|
2
|
-
|
3
|
-
presence: :valid_presence_validation?
|
4
|
-
}.freeze
|
5
|
-
|
6
|
-
attr_accessor :data, :timestamp, :field_name
|
7
|
-
attr_reader :validations, :metadata
|
2
|
+
attr_accessor :timestamp
|
8
3
|
|
9
4
|
validates :timestamp, presence: true, if: :validate_presence?
|
10
|
-
validate :timestamp_is_valid?
|
11
|
-
|
12
|
-
def validations=(validations_hash)
|
13
|
-
@validations = validations_hash.deep_symbolize_keys
|
14
|
-
end
|
5
|
+
validate :timestamp_is_valid?, if: :validate_presence?
|
15
6
|
|
16
7
|
def data=(data_hash)
|
17
8
|
@timestamp = data_hash.deep_symbolize_keys[:timestamp]
|
18
9
|
end
|
19
10
|
|
20
|
-
def metadata=(metadata_hash)
|
21
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
22
|
-
end
|
23
|
-
|
24
|
-
def acceptable_validations?
|
25
|
-
valid_types? && valid_options?
|
26
|
-
end
|
27
|
-
|
28
11
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
29
12
|
json = {}
|
30
13
|
json[mapping_field_name] = field_item.data['date_time']
|
@@ -42,35 +25,15 @@ class DateTimeFieldType < FieldType
|
|
42
25
|
end
|
43
26
|
|
44
27
|
def timestamp_is_valid?
|
45
|
-
|
28
|
+
begin
|
29
|
+
DateTime.parse(@timestamp)
|
46
30
|
true
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
true
|
51
|
-
rescue ArgumentError
|
52
|
-
errors.add(:timestamp, 'must be a valid date')
|
53
|
-
false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def valid_types?
|
59
|
-
validations.all? do |type, options|
|
60
|
-
VALIDATION_TYPES.include?(type)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def valid_options?
|
65
|
-
validations.all? do |type, options|
|
66
|
-
self.send(VALIDATION_TYPES[type])
|
31
|
+
rescue ArgumentError
|
32
|
+
errors.add(:timestamp, 'must be a valid date')
|
33
|
+
false
|
67
34
|
end
|
68
35
|
end
|
69
36
|
|
70
|
-
def valid_presence_validation?
|
71
|
-
@validations.key? :presence
|
72
|
-
end
|
73
|
-
|
74
37
|
def validate_presence?
|
75
38
|
@validations.key? :presence
|
76
39
|
end
|
@@ -1,30 +1,13 @@
|
|
1
1
|
class TagFieldType < FieldType
|
2
|
-
|
3
|
-
presence: :valid_presence_validation?
|
4
|
-
}.freeze
|
5
|
-
|
6
|
-
attr_accessor :data, :tag_list, :field_name
|
7
|
-
attr_reader :validations, :metadata
|
2
|
+
attr_accessor :tag_list
|
8
3
|
|
9
4
|
validates :tag_list, presence: true, if: :validate_presence?
|
10
5
|
|
11
|
-
def validations=(validations_hash)
|
12
|
-
@validations = validations_hash.deep_symbolize_keys
|
13
|
-
end
|
14
|
-
|
15
6
|
def data=(data_hash)
|
16
7
|
@tag_list = data_hash.deep_symbolize_keys[:tag_list]
|
17
8
|
@tag_list.nil? ? nil : (@tag_list = @tag_list.split(","))
|
18
9
|
end
|
19
10
|
|
20
|
-
def metadata=(metadata_hash)
|
21
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
22
|
-
end
|
23
|
-
|
24
|
-
def acceptable_validations?
|
25
|
-
valid_types? && valid_options?
|
26
|
-
end
|
27
|
-
|
28
11
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
29
12
|
json = {}
|
30
13
|
json[mapping_field_name] = field_item.data['tag']
|
@@ -41,22 +24,6 @@ class TagFieldType < FieldType
|
|
41
24
|
"#{field_name.parameterize('_')}_tag"
|
42
25
|
end
|
43
26
|
|
44
|
-
def valid_types?
|
45
|
-
validations.all? do |type, options|
|
46
|
-
VALIDATION_TYPES.include?(type)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def valid_options?
|
51
|
-
validations.all? do |type, options|
|
52
|
-
self.send(VALIDATION_TYPES[type])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def valid_presence_validation?
|
57
|
-
@validations.key? :presence
|
58
|
-
end
|
59
|
-
|
60
27
|
def validate_presence?
|
61
28
|
@validations.key? :presence
|
62
29
|
end
|
@@ -1,31 +1,13 @@
|
|
1
1
|
class TextFieldType < FieldType
|
2
|
-
|
3
|
-
length: :valid_length_validation?,
|
4
|
-
presence: :valid_presence_validation?
|
5
|
-
}.freeze
|
6
|
-
|
7
|
-
attr_accessor :data, :text, :field_name
|
8
|
-
attr_reader :validations, :metadata
|
2
|
+
attr_accessor :text
|
9
3
|
|
10
4
|
validates :text, presence: true, if: :validate_presence?
|
11
5
|
validate :text_length, if: :validate_length?
|
12
6
|
|
13
|
-
def validations=(validations_hash)
|
14
|
-
@validations = validations_hash.deep_symbolize_keys
|
15
|
-
end
|
16
|
-
|
17
7
|
def data=(data_hash)
|
18
8
|
@text = data_hash.deep_symbolize_keys[:text]
|
19
9
|
end
|
20
10
|
|
21
|
-
def metadata=(metadata_hash)
|
22
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
23
|
-
end
|
24
|
-
|
25
|
-
def acceptable_validations?
|
26
|
-
valid_types? && valid_options?
|
27
|
-
end
|
28
|
-
|
29
11
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
30
12
|
json = {}
|
31
13
|
json[mapping_field_name] = field_item.data['text']
|
@@ -42,31 +24,6 @@ class TextFieldType < FieldType
|
|
42
24
|
"#{field_name.parameterize('_')}_text"
|
43
25
|
end
|
44
26
|
|
45
|
-
def valid_types?
|
46
|
-
validations.all? do |type, options|
|
47
|
-
VALIDATION_TYPES.include?(type)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def valid_options?
|
52
|
-
validations.all? do |type, options|
|
53
|
-
self.send(VALIDATION_TYPES[type])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def valid_length_validation?
|
58
|
-
begin
|
59
|
-
LengthValidator.new(validations[:length].merge(attributes: [:text]))
|
60
|
-
true
|
61
|
-
rescue ArgumentError, NoMethodError
|
62
|
-
false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def valid_presence_validation?
|
67
|
-
@validations.key? :presence
|
68
|
-
end
|
69
|
-
|
70
27
|
def text_present
|
71
28
|
errors.add(:text, "must be present") if @text.empty?
|
72
29
|
end
|
@@ -1,21 +1,10 @@
|
|
1
1
|
class TreeFieldType < FieldType
|
2
|
-
|
3
|
-
presence: :valid_presence_validation?,
|
4
|
-
maximum: :valid_maximum_validation?,
|
5
|
-
minimum: :valid_minimum_validation?
|
6
|
-
}.freeze
|
7
|
-
|
8
|
-
attr_accessor :data, :values, :field_name
|
9
|
-
attr_reader :validations, :metadata
|
2
|
+
attr_accessor :values
|
10
3
|
|
11
4
|
validates :values, presence: true, if: :validate_presence?
|
12
5
|
validate :minimum, if: :validate_minimum?
|
13
6
|
validate :maximum, if: :validate_maximum?
|
14
7
|
|
15
|
-
def validations=(validations_hash)
|
16
|
-
@validations = validations_hash.deep_symbolize_keys
|
17
|
-
end
|
18
|
-
|
19
8
|
def data=(data_hash)
|
20
9
|
values = data_hash.deep_symbolize_keys[:values]
|
21
10
|
|
@@ -26,14 +15,6 @@ class TreeFieldType < FieldType
|
|
26
15
|
end
|
27
16
|
end
|
28
17
|
|
29
|
-
def metadata=(metadata_hash)
|
30
|
-
@metadata = metadata_hash.deep_symbolize_keys.extend(Hashie::Extensions::DeepLocate)
|
31
|
-
end
|
32
|
-
|
33
|
-
def acceptable_validations?
|
34
|
-
valid_types? && valid_options?
|
35
|
-
end
|
36
|
-
|
37
18
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
38
19
|
json = {}
|
39
20
|
json[mapping_field_name] = field_item.data['tree']
|
@@ -72,30 +53,6 @@ class TreeFieldType < FieldType
|
|
72
53
|
end
|
73
54
|
end
|
74
55
|
|
75
|
-
def valid_types?
|
76
|
-
validations.all? do |type, options|
|
77
|
-
VALIDATION_TYPES.include?(type)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def valid_options?
|
82
|
-
validations.all? do |type, options|
|
83
|
-
self.send(VALIDATION_TYPES[type])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def valid_presence_validation?
|
88
|
-
@validations.key? :presence
|
89
|
-
end
|
90
|
-
|
91
|
-
def valid_maximum_validation?
|
92
|
-
@validations.key? :maximum
|
93
|
-
end
|
94
|
-
|
95
|
-
def valid_minimum_validation?
|
96
|
-
@validations.key? :minimum
|
97
|
-
end
|
98
|
-
|
99
56
|
def validate_presence?
|
100
57
|
@validations.key? :presence
|
101
58
|
end
|
@@ -107,5 +64,4 @@ class TreeFieldType < FieldType
|
|
107
64
|
def validate_maximum?
|
108
65
|
@validations.key? :maximum
|
109
66
|
end
|
110
|
-
|
111
67
|
end
|
@@ -1,30 +1,13 @@
|
|
1
1
|
class UserFieldType < FieldType
|
2
|
-
|
3
|
-
presence: :valid_presence_validation?
|
4
|
-
}.freeze
|
5
|
-
|
6
|
-
attr_accessor :data, :user_id, :field_name
|
7
|
-
attr_reader :validations, :metadata
|
2
|
+
attr_accessor :user_id
|
8
3
|
|
9
4
|
validates :user_id, presence: true, if: :validate_presence?
|
10
5
|
validate :valid_user_id?
|
11
6
|
|
12
|
-
def validations=(validations_hash)
|
13
|
-
@validations = validations_hash.deep_symbolize_keys
|
14
|
-
end
|
15
|
-
|
16
7
|
def data=(data_hash)
|
17
8
|
@user_id = data_hash.deep_symbolize_keys[:user_id]
|
18
9
|
end
|
19
10
|
|
20
|
-
def metadata=(metadata_hash)
|
21
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
22
|
-
end
|
23
|
-
|
24
|
-
def acceptable_validations?
|
25
|
-
valid_types? && valid_options?
|
26
|
-
end
|
27
|
-
|
28
11
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
29
12
|
json = {}
|
30
13
|
json[mapping_field_name] = field_item.data['user']
|
@@ -50,22 +33,6 @@ class UserFieldType < FieldType
|
|
50
33
|
end
|
51
34
|
end
|
52
35
|
|
53
|
-
def valid_types?
|
54
|
-
validations.all? do |type, options|
|
55
|
-
VALIDATION_TYPES.include?(type)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def valid_options?
|
60
|
-
validations.all? do |type, options|
|
61
|
-
self.send(VALIDATION_TYPES[type])
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def valid_presence_validation?
|
66
|
-
@validations.key? :presence
|
67
|
-
end
|
68
|
-
|
69
36
|
def validate_presence?
|
70
37
|
@validations.key? :presence
|
71
38
|
end
|
@@ -7,21 +7,46 @@ namespace :cortex do
|
|
7
7
|
task seed: :environment do
|
8
8
|
puts "Creating Media ContentType..."
|
9
9
|
media = ContentType.new({
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
name: "Media",
|
11
|
+
description: "Media for Cortex",
|
12
|
+
icon: "collections",
|
13
|
+
creator_id: 1,
|
14
|
+
contract_id: 1
|
15
|
+
})
|
16
16
|
media.save
|
17
17
|
|
18
18
|
puts "Creating Fields..."
|
19
|
-
|
20
|
-
|
21
|
-
media.fields.new(name: '
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
|
20
|
+
allowed_asset_content_types = %w(txt pdf doc docx xls xlsx png jpg gif bmp)
|
21
|
+
media.fields.new(name: 'Asset', field_type: 'asset_field_type',
|
22
|
+
validations:
|
23
|
+
{
|
24
|
+
presence: true,
|
25
|
+
allowed_extensions: allowed_asset_content_types,
|
26
|
+
size: {
|
27
|
+
less_than: 50.megabytes
|
28
|
+
}
|
29
|
+
},
|
30
|
+
metadata:
|
31
|
+
{
|
32
|
+
styles: {
|
33
|
+
large: {geometry: '1800x1800>', format: :jpg},
|
34
|
+
medium: {geometry: '800x800>', format: :jpg},
|
35
|
+
default: {geometry: '300x300>', format: :jpg},
|
36
|
+
mini: {geometry: '100x100>', format: :jpg},
|
37
|
+
micro: {geometry: '50x50>', format: :jpg},
|
38
|
+
post_tile: {geometry: '1140x', format: :jpg}
|
39
|
+
},
|
40
|
+
processors: [:thumbnail, :paperclip_optimizer],
|
41
|
+
preserve_files: true,
|
42
|
+
path: ':class/:attachment/careerbuilder-:style-:id.:extension',
|
43
|
+
s3_headers: {'Cache-Control': 'public, max-age=315576000'}
|
44
|
+
})
|
45
|
+
media.fields.new(name: 'Title', field_type: 'text_field_type', validations: {presence: true})
|
46
|
+
media.fields.new(name: 'Description', field_type: 'text_field_type', validations: {presence: true})
|
47
|
+
media.fields.new(name: 'Tags', field_type: 'tag_field_type')
|
48
|
+
media.fields.new(name: 'Expiration Date', field_type: 'date_time_field_type')
|
49
|
+
media.fields.new(name: 'Alt Tag', field_type: 'text_field_type', order_position: 6)
|
25
50
|
media.save
|
26
51
|
|
27
52
|
puts "Creating Wizard Decorators..."
|
@@ -54,7 +79,11 @@ namespace :cortex do
|
|
54
79
|
"id": media.fields[1].id
|
55
80
|
},
|
56
81
|
{
|
57
|
-
"id": media.fields[2].id
|
82
|
+
"id": media.fields[2].id,
|
83
|
+
"render_method": "multiline_input",
|
84
|
+
"display": {
|
85
|
+
"rows": 3
|
86
|
+
}
|
58
87
|
},
|
59
88
|
{
|
60
89
|
"id": media.fields[3].id
|
@@ -76,89 +105,89 @@ namespace :cortex do
|
|
76
105
|
media_wizard_decorator.save
|
77
106
|
|
78
107
|
ContentableDecorator.create({
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
108
|
+
decorator_id: media_wizard_decorator.id,
|
109
|
+
contentable_id: media.id,
|
110
|
+
contentable_type: 'ContentType'
|
111
|
+
})
|
83
112
|
|
84
113
|
puts "Creating Index Decorators..."
|
85
114
|
index_hash = {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
"columns":
|
116
|
+
[
|
117
|
+
{
|
118
|
+
"name": "Thumbnail",
|
119
|
+
"cells": [{
|
120
|
+
"field": {
|
121
|
+
"method": "author_image"
|
122
|
+
},
|
123
|
+
"display": {
|
124
|
+
"classes": [
|
125
|
+
"circular"
|
126
|
+
]
|
127
|
+
}
|
128
|
+
}]
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"name": "Creator",
|
132
|
+
"cells": [{
|
133
|
+
"field": {
|
134
|
+
"method": "author_image"
|
135
|
+
},
|
136
|
+
"display": {
|
137
|
+
"classes": [
|
138
|
+
"circular"
|
139
|
+
]
|
140
|
+
}
|
141
|
+
}]
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"name": "Details",
|
145
|
+
"cells": [
|
146
|
+
{
|
147
|
+
"field": {
|
148
|
+
"id": media.fields[1].id
|
149
|
+
},
|
150
|
+
"display": {
|
151
|
+
"classes": [
|
152
|
+
"bold",
|
153
|
+
"upcase"
|
154
|
+
]
|
155
|
+
}
|
120
156
|
},
|
121
|
-
|
122
|
-
"
|
123
|
-
"
|
124
|
-
|
125
|
-
]
|
126
|
-
}
|
127
|
-
},
|
128
|
-
{
|
129
|
-
"field": {
|
130
|
-
"id": media.fields[1].id
|
157
|
+
{
|
158
|
+
"field": {
|
159
|
+
"id": media.fields[2].id
|
160
|
+
}
|
131
161
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
162
|
+
]
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"name": "Tags",
|
166
|
+
"cells": [
|
167
|
+
{
|
168
|
+
"field": {
|
169
|
+
"id": media.fields[3].id
|
170
|
+
},
|
171
|
+
"display": {
|
172
|
+
"classes": [
|
173
|
+
"tag",
|
174
|
+
"rounded"
|
175
|
+
]
|
176
|
+
}
|
147
177
|
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
]
|
178
|
+
]
|
179
|
+
}
|
180
|
+
]
|
152
181
|
}
|
153
182
|
|
154
183
|
media_index_decorator = Decorator.new(name: "Index", data: index_hash)
|
155
184
|
media_index_decorator.save
|
156
185
|
|
157
186
|
ContentableDecorator.create({
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
187
|
+
decorator_id: media_index_decorator.id,
|
188
|
+
contentable_id: media.id,
|
189
|
+
contentable_type: 'ContentType'
|
190
|
+
})
|
162
191
|
end
|
163
192
|
end
|
164
193
|
end
|
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.
|
4
|
+
version: 0.4.0
|
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: 2016-10-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.10
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mimemagic
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.3.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.2
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: ckeditor
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|