cortex-plugins-core 0.12.4 → 1.0.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/app/assets/stylesheets/cortex-plugins-core/application.scss +1 -0
- data/app/assets/stylesheets/cortex-plugins-core/components/tags-input.scss +21 -0
- data/app/cells/plugins/core/asset_info/show.haml +1 -1
- data/app/cells/plugins/core/tree/checkboxes.haml +0 -3
- data/app/models/asset_field_type.rb +1 -1
- data/app/models/author_field_type.rb +1 -1
- data/app/models/date_time_field_type.rb +1 -1
- data/app/models/float_field_type.rb +4 -4
- data/app/models/integer_field_type.rb +3 -3
- data/app/models/tag_field_type.rb +1 -1
- data/app/models/text_field_type.rb +3 -3
- data/app/models/tree_field_type.rb +5 -5
- data/app/models/user_field_type.rb +1 -1
- data/app/transactions/concerns/update_tags.rb +6 -0
- data/{lib/tasks/cortex/test/dummy/db/development.sqlite3 → app/transactions/get_content_item_tags_transaction.rb} +0 -0
- data/app/transactions/get_field_tree_list_transaction.rb +18 -0
- data/app/transactions/new_tag_field_item_transaction.rb +7 -0
- data/app/transactions/new_user_field_item_transaction.rb +7 -0
- data/app/transactions/update_tag_field_item_transaction.rb +7 -0
- data/app/uploaders/asset_uploader.rb +5 -6
- data/app/uploaders/concerns/imageable.rb +30 -0
- data/lib/cortex/plugins/core/version.rb +1 -1
- data/lib/tasks/cortex/core/media.rake +37 -9
- metadata +45 -11
- data/lib/tasks/cortex/test/dummy/db/test.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e86996214ab1af991435ee71b2289eed0d776400
|
4
|
+
data.tar.gz: c08a47c80f73e4d5cbc1a35227ebea1d72e57c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4e0d5fe38e0cdb08eea25590481494c3cd8e6fcd4f195367f70d1b2233512cc8418de0c429256f84a2791ca183853ac2db5e0a19264a0e74125cd1cee064f7
|
7
|
+
data.tar.gz: de2b55abef7fbe6f5e4e83ca5101973650e176d2869dd4128463135db8c512eb8e3717438deef3c2c7b9fe354d5bebfcde04e19281a59d9ec96dec4acc6b752a
|
@@ -0,0 +1,21 @@
|
|
1
|
+
.bootstrap-tagsinput {
|
2
|
+
width: 100%;
|
3
|
+
border-radius: 0 !important;
|
4
|
+
border-top: none;
|
5
|
+
border-right: none;
|
6
|
+
border-left: none;
|
7
|
+
border-bottom: 1px solid $color-grey-light;
|
8
|
+
box-shadow: none;
|
9
|
+
}
|
10
|
+
.cortex-bootstrap .label {
|
11
|
+
border-radius: 0.75em;
|
12
|
+
font-weight: normal;
|
13
|
+
}
|
14
|
+
|
15
|
+
.cortex-bootstrap .label-info {
|
16
|
+
background-color: $color-grey;
|
17
|
+
}
|
18
|
+
|
19
|
+
.bootstrap-tagsinput .tag {
|
20
|
+
text-transform: uppercase;
|
21
|
+
}
|
@@ -8,7 +8,7 @@
|
|
8
8
|
- if asset_is_image?
|
9
9
|
.mdl-card__title
|
10
10
|
%h2.mdl-card__title-text
|
11
|
-
= image_tag(asset['versions']['original']['url'], style: 'max-height: 200px;')
|
11
|
+
= image_tag(asset['versions']['original']['url'], style: 'min-height: 50px; max-height: 200px;')
|
12
12
|
.mdl-card__supporting-text
|
13
13
|
%dl
|
14
14
|
%dt Original Filename
|
@@ -1,9 +1,6 @@
|
|
1
1
|
= render_label
|
2
2
|
= render_tooltip unless @options[:tooltip].nil?
|
3
3
|
|
4
|
-
%p
|
5
|
-
Please select 1-2 Categories.
|
6
|
-
|
7
4
|
- @options[:metadata]["data"]["tree_array"].each do |node|
|
8
5
|
= render_field_id
|
9
6
|
= cell(Plugins::Core::CheckboxCell, nil, form: @options[:form], node: node, data: data).(:checkbox)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class FloatFieldType < FieldType
|
2
2
|
attr_accessor :float
|
3
|
-
|
3
|
+
|
4
4
|
validates :float, presence: true, if: Proc.new { |float| validate_key(:presence) }
|
5
5
|
validates_numericality_of :float, unless: "float.nil?"
|
6
6
|
validate :less_than, if: Proc.new { |float| validate_key(:max) }
|
@@ -27,14 +27,14 @@ class FloatFieldType < FieldType
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def validate_key(key)
|
30
|
-
|
30
|
+
validations.key? key
|
31
31
|
end
|
32
32
|
|
33
33
|
def less_than
|
34
|
-
errors.add(:float, "must be less_than #{
|
34
|
+
errors.add(:float, "must be less_than #{validations[:max]}") if :float <= validations[:max]
|
35
35
|
end
|
36
36
|
|
37
37
|
def greater_than
|
38
|
-
errors.add(:float, "must be greater_than #{
|
38
|
+
errors.add(:float, "must be greater_than #{validations[:min]}") if :float >= validations[:min]
|
39
39
|
end
|
40
40
|
end
|
@@ -27,14 +27,14 @@ class IntegerFieldType < FieldType
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def validate_key
|
30
|
-
|
30
|
+
validations.key? key
|
31
31
|
end
|
32
32
|
|
33
33
|
def less_than
|
34
|
-
errors.add(:integer, "must be less_than #{
|
34
|
+
errors.add(:integer, "must be less_than #{validations[:max]}") if :integer <= validations[:max]
|
35
35
|
end
|
36
36
|
|
37
37
|
def greater_than
|
38
|
-
errors.add(:integer, "must be greater_than #{
|
38
|
+
errors.add(:integer, "must be greater_than #{validations[:min]}") if :integer >= validations[:min]
|
39
39
|
end
|
40
40
|
end
|
@@ -39,14 +39,14 @@ class TextFieldType < FieldType
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def validate_uniqueness?
|
42
|
-
|
42
|
+
validations.key? :uniqueness
|
43
43
|
end
|
44
44
|
|
45
45
|
def validate_presence?
|
46
|
-
|
46
|
+
validations.key? :presence
|
47
47
|
end
|
48
48
|
|
49
49
|
def validate_length?
|
50
|
-
|
50
|
+
validations.key? :length
|
51
51
|
end
|
52
52
|
end
|
@@ -36,7 +36,7 @@ class TreeFieldType < FieldType
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def minimum
|
39
|
-
if !@values.nil? && @values[:values].length >=
|
39
|
+
if !@values.nil? && @values[:values].length >= validations[:minimum]
|
40
40
|
true
|
41
41
|
else
|
42
42
|
errors.add(:minimum, "You have selected too few values.")
|
@@ -46,7 +46,7 @@ class TreeFieldType < FieldType
|
|
46
46
|
|
47
47
|
def maximum
|
48
48
|
unless @values.nil?
|
49
|
-
if @values[:values].length <=
|
49
|
+
if @values[:values].length <= validations[:maximum]
|
50
50
|
true
|
51
51
|
else
|
52
52
|
errors.add(:maximum, "You have selected too many values.")
|
@@ -56,14 +56,14 @@ class TreeFieldType < FieldType
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def validate_presence?
|
59
|
-
|
59
|
+
validations.key? :presence
|
60
60
|
end
|
61
61
|
|
62
62
|
def validate_minimum?
|
63
|
-
|
63
|
+
validations.key? :minimum
|
64
64
|
end
|
65
65
|
|
66
66
|
def validate_maximum?
|
67
|
-
|
67
|
+
validations.key? :maximum
|
68
68
|
end
|
69
69
|
end
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class GetFieldTreeListTransaction < ApplicationTransaction
|
2
|
+
step :init
|
3
|
+
step :process
|
4
|
+
|
5
|
+
def init(input)
|
6
|
+
field = Field.find_by_id(input[:args]['field_id'])
|
7
|
+
|
8
|
+
field ? Right({ content_item: input[:content_item], field: field }) : Left(:not_found)
|
9
|
+
end
|
10
|
+
|
11
|
+
def process(input)
|
12
|
+
tree_array = input[:field].metadata['allowed_values']['data']['tree_array']
|
13
|
+
tree_values = input[:content_item].field_items.find {|field_item| field_item.field_id == input[:field].id}.data['values']
|
14
|
+
|
15
|
+
tree_list = tree_values.map {|value| tree_array.find {|node| node['id'] == value.to_i}['node']['name']}.join(',')
|
16
|
+
Right(tree_list)
|
17
|
+
end
|
18
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'image_processing/mini_magick'
|
2
|
+
require 'image_optim'
|
2
3
|
|
3
4
|
class AssetUploader < Shrine
|
4
5
|
include ImageProcessing::MiniMagick
|
6
|
+
include Imageable
|
5
7
|
|
6
8
|
plugin :determine_mime_type
|
7
9
|
plugin :store_dimensions
|
@@ -25,14 +27,15 @@ class AssetUploader < Shrine
|
|
25
27
|
end
|
26
28
|
|
27
29
|
process(:store) do |io, context|
|
28
|
-
# TODO:
|
30
|
+
# TODO: support versions without processors
|
29
31
|
context[:generated_hex] = SecureRandom.hex(8)
|
30
32
|
versions = { original: io.download }
|
31
33
|
|
32
34
|
if image?(io)
|
35
|
+
image_optim = image_optim_for(context[:config][:metadata][:image_optim_config])
|
33
36
|
versions.merge!(context[:config][:metadata][:versions].transform_values do |version|
|
34
37
|
processed_version = send("#{version[:process][:method]}!", io.download, *version[:process][:config].values)
|
35
|
-
|
38
|
+
optimize_image!(processed_version, image_optim) # TODO: per-version image_optim_config
|
36
39
|
end)
|
37
40
|
end
|
38
41
|
|
@@ -48,8 +51,4 @@ class AssetUploader < Shrine
|
|
48
51
|
|
49
52
|
ERB.new(context[:config][:metadata][:path]).result(binding)
|
50
53
|
end
|
51
|
-
|
52
|
-
def image?(io)
|
53
|
-
MimeMagic.new(io.data['metadata']['mime_type']).mediatype == 'image'
|
54
|
-
end
|
55
54
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Imageable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
def image?(io)
|
6
|
+
MimeMagic.new(io.data['metadata']['mime_type']).mediatype == 'image'
|
7
|
+
end
|
8
|
+
|
9
|
+
def optimize_image!(image, image_optim)
|
10
|
+
pathname = image_optim.optimize_image!(image) # TODO: move to ActiveJob
|
11
|
+
pathname ? pathname.open : image
|
12
|
+
end
|
13
|
+
|
14
|
+
def image_optim_for(image_optim_config)
|
15
|
+
ImageOptim.new(process_image_optim_config(image_optim_config))
|
16
|
+
end
|
17
|
+
|
18
|
+
def process_image_optim_config(image_optim_config)
|
19
|
+
processed_image_optim_config = image_optim_config.merge(pngout: false, svgo: false, verbose: true, skip_missing_workers: false)
|
20
|
+
processed_image_optim_config.extend(Hashie::Extensions::DeepLocate)
|
21
|
+
quality_range_hashes = processed_image_optim_config.deep_locate -> (key, value, object) { key == :quality_range }
|
22
|
+
quality_range_hashes.each do |quality_range_hash|
|
23
|
+
quality_range_hash[:quality] = quality_range_hash[:quality_range][:begin]..quality_range_hash[:quality_range][:end]
|
24
|
+
quality_range_hash.delete(:quality_range)
|
25
|
+
end
|
26
|
+
|
27
|
+
processed_image_optim_config
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -32,16 +32,17 @@ namespace :cortex do
|
|
32
32
|
naming_data: {
|
33
33
|
title: fieldTitle.id
|
34
34
|
},
|
35
|
-
versions: {
|
36
|
-
large: { process: { method: 'resize_to_limit', config: { width: '1800', height: '1800' } }
|
37
|
-
medium: { process: { method: 'resize_to_limit', config: { width: '800', height: '800' } }
|
38
|
-
default: { process: { method: 'resize_to_limit', config: { width: '300', height: '300' } }
|
39
|
-
mini: { process: { method: 'resize_to_limit', config: { width: '100', height: '100' } }
|
40
|
-
micro: { process: { method: 'resize_to_limit', config: { width: '50', height: '50' } }
|
35
|
+
versions: { # Move to YAML
|
36
|
+
large: { process: { method: 'resize_to_limit', config: { width: '1800', height: '1800' } } },
|
37
|
+
medium: { process: { method: 'resize_to_limit', config: { width: '800', height: '800' } } },
|
38
|
+
default: { process: { method: 'resize_to_limit', config: { width: '300', height: '300' } } },
|
39
|
+
mini: { process: { method: 'resize_to_limit', config: { width: '100', height: '100' } } },
|
40
|
+
micro: { process: { method: 'resize_to_limit', config: { width: '50', height: '50' } } },
|
41
|
+
rss: { process: { method: 'resize_to_limit', config: { width: '840', height: '840' } } },
|
41
42
|
},
|
42
43
|
keep_files: [:destroyed, :replaced],
|
43
44
|
path: 'media/<%= attachment %>/<%= original_name %>-<%= style %>-<%= generated_hex %>.<%= extension %>',
|
44
|
-
storage: {
|
45
|
+
storage: { # Move to YAML
|
45
46
|
type: 's3',
|
46
47
|
host_alias: ENV['HOST_ALIAS'],
|
47
48
|
config: {
|
@@ -54,6 +55,33 @@ namespace :cortex do
|
|
54
55
|
cache_control: 'public, max-age=315576000'
|
55
56
|
}
|
56
57
|
}
|
58
|
+
},
|
59
|
+
image_optim_config: { # Move to YAML
|
60
|
+
allow_lossy: true,
|
61
|
+
jpegoptim: {
|
62
|
+
allow_lossy: true,
|
63
|
+
strip: 'all',
|
64
|
+
max_quality: 60
|
65
|
+
},
|
66
|
+
pngquant: {
|
67
|
+
allow_lossy: true,
|
68
|
+
quality_range: {
|
69
|
+
begin: 33,
|
70
|
+
end: 50
|
71
|
+
},
|
72
|
+
speed: 3
|
73
|
+
},
|
74
|
+
gifsicle: {
|
75
|
+
interlace: true
|
76
|
+
},
|
77
|
+
advpng: false,
|
78
|
+
jhead: false,
|
79
|
+
jpegrecompress: false,
|
80
|
+
jpegtran: false,
|
81
|
+
optipng: false,
|
82
|
+
pngcrush: false,
|
83
|
+
pngout: false,
|
84
|
+
svgo: false
|
57
85
|
}
|
58
86
|
})
|
59
87
|
media.fields.new(name: 'Description', field_type: 'text_field_type', validations: {presence: true})
|
@@ -76,7 +104,7 @@ namespace :cortex do
|
|
76
104
|
"elements": [
|
77
105
|
{
|
78
106
|
"id": media.fields.find_by_name('Asset').id,
|
79
|
-
"tooltip": "Recommended
|
107
|
+
"tooltip": "Recommended Size: 840 x 400 if you want to use a single image as your tile and blog header image."
|
80
108
|
}
|
81
109
|
]
|
82
110
|
}
|
@@ -164,7 +192,7 @@ namespace :cortex do
|
|
164
192
|
"name": "Creator",
|
165
193
|
"cells": [{
|
166
194
|
"field": {
|
167
|
-
"method": "
|
195
|
+
"method": "creator.email"
|
168
196
|
},
|
169
197
|
"display": {
|
170
198
|
"classes": [
|
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: 1.0.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: 2017-
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0
|
89
|
+
version: '1.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0
|
96
|
+
version: '1.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: shrine
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
103
|
+
version: '2.7'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2.
|
110
|
+
version: '2.7'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: mimemagic
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '4.
|
145
|
+
version: '4.8'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '4.
|
152
|
+
version: '4.8'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: fastimage
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +164,34 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '2.1'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: image_optim
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.25'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.25'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: image_optim_pack
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.5'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.5'
|
167
195
|
description:
|
168
196
|
email:
|
169
197
|
- EmployerSiteContentProducts@cb.com
|
@@ -181,6 +209,7 @@ files:
|
|
181
209
|
- app/assets/javascripts/cortex-plugins-core/cells/content_item.js
|
182
210
|
- app/assets/javascripts/cortex-plugins-core/cells/text.js
|
183
211
|
- app/assets/stylesheets/cortex-plugins-core/application.scss
|
212
|
+
- app/assets/stylesheets/cortex-plugins-core/components/tags-input.scss
|
184
213
|
- app/assets/stylesheets/cortex-plugins-core/components/thumbnail-placeholder.scss
|
185
214
|
- app/assets/stylesheets/cortex-plugins-core/variables/_colors.scss
|
186
215
|
- app/assets/stylesheets/cortex-plugins-core/variables/_typography.scss
|
@@ -232,7 +261,14 @@ files:
|
|
232
261
|
- app/models/text_field_type.rb
|
233
262
|
- app/models/tree_field_type.rb
|
234
263
|
- app/models/user_field_type.rb
|
264
|
+
- app/transactions/concerns/update_tags.rb
|
265
|
+
- app/transactions/get_content_item_tags_transaction.rb
|
266
|
+
- app/transactions/get_field_tree_list_transaction.rb
|
267
|
+
- app/transactions/new_tag_field_item_transaction.rb
|
268
|
+
- app/transactions/new_user_field_item_transaction.rb
|
269
|
+
- app/transactions/update_tag_field_item_transaction.rb
|
235
270
|
- app/uploaders/asset_uploader.rb
|
271
|
+
- app/uploaders/concerns/imageable.rb
|
236
272
|
- config/initializers/react_on_rails.rb
|
237
273
|
- config/initializers/shrine.rb
|
238
274
|
- lib/cortex/plugins/core.rb
|
@@ -241,8 +277,6 @@ files:
|
|
241
277
|
- lib/shrine/plugins/cortex_validation_helpers.rb
|
242
278
|
- lib/tasks/cortex/core/db.rake
|
243
279
|
- lib/tasks/cortex/core/media.rake
|
244
|
-
- lib/tasks/cortex/test/dummy/db/development.sqlite3
|
245
|
-
- lib/tasks/cortex/test/dummy/db/test.sqlite3
|
246
280
|
homepage: https://github.com/cortex-cms/cortex-plugins-core
|
247
281
|
licenses:
|
248
282
|
- Apache-2.0
|
@@ -263,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
297
|
version: '0'
|
264
298
|
requirements: []
|
265
299
|
rubyforge_project:
|
266
|
-
rubygems_version: 2.
|
300
|
+
rubygems_version: 2.6.11
|
267
301
|
signing_key:
|
268
302
|
specification_version: 4
|
269
303
|
summary: The combined set of Core FieldTypes for the Cortex CMS platform
|
File without changes
|