cortex-plugins-core 2.1.1 → 3.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +9 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +47 -0
  4. data/.gitignore +82 -0
  5. data/.npmignore +33 -0
  6. data/.rspec +3 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +14 -0
  9. data/Gemfile.lock +189 -0
  10. data/app/assets/config/cortex_plugins_core_manifest.js +2 -0
  11. data/app/assets/images/cortex-plugins-core/.keep +0 -0
  12. data/app/assets/stylesheets/cortex-plugins-core/application.scss +1 -2
  13. data/app/cells/plugins/core/cell.rb +2 -4
  14. data/app/cells/plugins/core/content_item_cell.rb +1 -1
  15. data/app/graphql/interfaces/.keep +0 -0
  16. data/app/graphql/types/.keep +0 -0
  17. data/app/models/asset_field_type.rb +1 -1
  18. data/app/models/author_field_type.rb +1 -1
  19. data/app/models/boolean_field_type.rb +1 -1
  20. data/app/models/content_item_field_type.rb +1 -1
  21. data/app/models/date_time_field_type.rb +1 -1
  22. data/app/models/float_field_type.rb +1 -1
  23. data/app/models/integer_field_type.rb +1 -1
  24. data/app/models/tag_field_type.rb +1 -1
  25. data/app/models/text_field_type.rb +1 -1
  26. data/app/models/tree_field_type.rb +1 -1
  27. data/app/models/user_field_type.rb +1 -1
  28. data/app/transactions/get_field_tree_list_transaction.rb +1 -1
  29. data/app/transactions/new_tag_field_item_transaction.rb +1 -1
  30. data/app/transactions/new_user_field_item_transaction.rb +1 -1
  31. data/app/transactions/update_tag_field_item_transaction.rb +1 -1
  32. data/bin/rails +13 -0
  33. data/cortex-plugins-core.gemspec +38 -0
  34. data/lib/cortex/plugins/core/engine.rb +4 -2
  35. data/lib/cortex/plugins/core/version.rb +1 -1
  36. data/lib/tasks/cortex/core/media.rake +10 -10
  37. data/node_package/.babelrc +26 -0
  38. data/node_package/src/actions/helloWorld2ActionCreators.jsx +8 -0
  39. data/node_package/src/components/asset_field_type.jsx +34 -0
  40. data/node_package/src/components/date_time_type.jsx +35 -0
  41. data/node_package/src/components/index.jsx +12 -0
  42. data/node_package/src/components/tag_field_type.jsx +41 -0
  43. data/node_package/src/components/text_field_type.jsx +82 -0
  44. data/node_package/src/constants/helloWorld2Constants.jsx +3 -0
  45. data/node_package/src/containers/HelloWorld2Container.jsx +13 -0
  46. data/node_package/src/index.jsx +15 -0
  47. data/node_package/src/reducers/helloWorld2Reducer.jsx +15 -0
  48. data/node_package/src/startup/HelloWorld2App.jsx +18 -0
  49. data/node_package/src/startup/registration.jsx +8 -0
  50. data/node_package/src/store/helloWorld2Store.jsx +8 -0
  51. data/package.json +43 -0
  52. data/yarn.lock +5229 -0
  53. metadata +33 -6
  54. data/app/assets/stylesheets/cortex-plugins-core/variables/_typography.scss +0 -114
  55. data/lib/tasks/cortex/core/db.rake +0 -30
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images/cortex-plugins-core
2
+ //= link ckeditor/config.js
File without changes
@@ -1,6 +1,5 @@
1
- // TODO: These two files should be removed once we abstract Cortex styles to a cortex-style-base lib
1
+ // TODO: This file should be removed once we abstract Cortex styles to a cortex-style-base lib
2
2
  @import 'variables/colors';
3
- @import 'variables/typography';
4
3
 
5
4
  @import 'components/tags-input';
6
5
  @import 'components/thumbnail-placeholder';
@@ -1,9 +1,7 @@
1
1
  module Plugins
2
2
  module Core
3
- class Cell < FieldCell
4
- include ReactOnRailsHelper
5
-
6
- view_paths << "#{Cortex::Plugins::Core::Engine.root}/app/cells"
3
+ class Cell < Cortex::FieldCell
4
+ self.view_paths = ["#{Cortex::Plugins::Core::Engine.root}/app/cells"]
7
5
 
8
6
  def required?
9
7
  field.validations["presence"]
@@ -12,7 +12,7 @@ module Plugins
12
12
  end
13
13
 
14
14
  def associated_content_item
15
- ContentItem.find_by_id(value)
15
+ Cortex::ContentItem.find_by_id(value)
16
16
  end
17
17
 
18
18
  def associated_primary_field
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  require 'shrine/storage/s3'
2
2
 
3
- class AssetFieldType < FieldType
3
+ class AssetFieldType < Cortex::FieldType
4
4
  attr_reader :asset
5
5
  attr_accessor :asset_data
6
6
 
@@ -1,4 +1,4 @@
1
- class AuthorFieldType < FieldType
1
+ class AuthorFieldType < Cortex::FieldType
2
2
  attr_accessor :author_name
3
3
  jsonb_accessor :data, author_name: :string
4
4
 
@@ -1,4 +1,4 @@
1
- class BooleanFieldType < FieldType
1
+ class BooleanFieldType < Cortex::FieldType
2
2
  attr_accessor :value
3
3
 
4
4
  def elasticsearch_mapping
@@ -1,4 +1,4 @@
1
- class ContentItemFieldType < FieldType
1
+ class ContentItemFieldType < Cortex::FieldType
2
2
  attr_accessor :content_item_id
3
3
 
4
4
  def elasticsearch_mapping
@@ -1,4 +1,4 @@
1
- class DateTimeFieldType < FieldType
1
+ class DateTimeFieldType < Cortex::FieldType
2
2
  attr_accessor :timestamp
3
3
 
4
4
  validates :timestamp, presence: true, if: :validate_presence?
@@ -1,4 +1,4 @@
1
- class FloatFieldType < FieldType
1
+ class FloatFieldType < Cortex::FieldType
2
2
  attr_accessor :float
3
3
 
4
4
  validates :float, presence: true, if: Proc.new { |float| validate_key(:presence) }
@@ -1,4 +1,4 @@
1
- class IntegerFieldType < FieldType
1
+ class IntegerFieldType < Cortex::FieldType
2
2
  attr_accessor :integer
3
3
 
4
4
  validates :integer, presence: true, if: Proc.new { |int| validate_key(:presence) }
@@ -1,4 +1,4 @@
1
- class TagFieldType < FieldType
1
+ class TagFieldType < Cortex::FieldType
2
2
  attr_accessor :tag_list
3
3
 
4
4
  validates :tag_list, presence: true, if: :validate_presence?
@@ -1,4 +1,4 @@
1
- class TextFieldType < FieldType
1
+ class TextFieldType < Cortex::FieldType
2
2
  PRIMARY_DATA_KEY = 'text'.freeze
3
3
 
4
4
  attr_accessor :text
@@ -1,4 +1,4 @@
1
- class TreeFieldType < FieldType
1
+ class TreeFieldType < Cortex::FieldType
2
2
  attr_accessor :values
3
3
 
4
4
  validates :values, presence: true, if: :validate_presence?
@@ -1,4 +1,4 @@
1
- class UserFieldType < FieldType
1
+ class UserFieldType < Cortex::FieldType
2
2
  attr_accessor :user_id
3
3
 
4
4
  validates :user_id, presence: true, if: :validate_presence?
@@ -1,4 +1,4 @@
1
- class GetFieldTreeListTransaction < ApplicationTransaction
1
+ class GetFieldTreeListTransaction < Cortex::ApplicationTransaction
2
2
  step :init
3
3
  step :process
4
4
 
@@ -1,4 +1,4 @@
1
- class NewTagFieldItemTransaction < ApplicationTransaction
1
+ class NewTagFieldItemTransaction < Cortex::ApplicationTransaction
2
2
  step :process
3
3
 
4
4
  def process(field_item)
@@ -1,4 +1,4 @@
1
- class NewUserFieldItemTransaction < ApplicationTransaction
1
+ class NewUserFieldItemTransaction < Cortex::ApplicationTransaction
2
2
  step :process
3
3
 
4
4
  def process(field_item)
@@ -1,4 +1,4 @@
1
- class UpdateTagFieldItemTransaction < ApplicationTransaction
1
+ class UpdateTagFieldItemTransaction < Cortex::ApplicationTransaction
2
2
  step :process
3
3
 
4
4
  def process(field_item)
data/bin/rails ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/cortex/plugins/core/engine', __FILE__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
@@ -0,0 +1,38 @@
1
+ $:.push File.expand_path("lib", __dir__)
2
+
3
+ # Maintain your gem's version:
4
+ require "cortex/plugins/core/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "cortex-plugins-core"
9
+ s.version = Cortex::Plugins::Core::VERSION
10
+ s.authors = ['CareerBuilder Employer Site & Content Products']
11
+ s.email = 'toastercup@gmail.com'
12
+
13
+ s.summary = %q{The combined set of Core FieldTypes for the Cortex CMS platform}
14
+ s.homepage = "https://github.com/cortex-cms/cortex-plugins-core"
15
+ s.license = "Apache-2.0"
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ s.test_files = Dir["spec/**/*"]
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency "rails", ">= 5"
24
+ s.add_dependency "cells", "~> 4.1"
25
+ s.add_dependency "cells-rails", "~> 0.0"
26
+ s.add_dependency "cells-haml", "~> 0.0"
27
+ s.add_dependency "jsonb_accessor", "~> 1.0"
28
+
29
+ # AssetFieldType
30
+ s.add_dependency "shrine", "~> 2.7"
31
+ s.add_dependency "aws-sdk-s3", "~> 1.5"
32
+ s.add_dependency "mimemagic", "~> 0.3"
33
+ s.add_dependency "image_processing", "~> 0.4"
34
+ s.add_dependency "mini_magick", "~> 4.8"
35
+ s.add_dependency "fastimage", "~> 2.1"
36
+ s.add_dependency "image_optim", "~> 0.25"
37
+ s.add_dependency "image_optim_pack", "~> 0.5"
38
+ end
@@ -5,8 +5,10 @@ module Cortex
5
5
  module Plugins
6
6
  module Core
7
7
  class Engine < ::Rails::Engine
8
- initializer 'cortex-plugins-core.assets.precompile' do |app|
9
- app.config.assets.precompile += %w(ckeditor/config.js)
8
+ isolate_namespace Cortex::Plugins::Core
9
+
10
+ initializer "cortex-plugins-core.precompile_manifest" do |app|
11
+ app.config.assets.precompile += %w(cortex_plugins_core_manifest)
10
12
  end
11
13
  end
12
14
  end
@@ -1,7 +1,7 @@
1
1
  module Cortex
2
2
  module Plugins
3
3
  module Core
4
- VERSION = '2.1.1'
4
+ VERSION = '3.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -5,17 +5,17 @@ namespace :cortex do
5
5
  namespace :media do
6
6
  desc 'Seed Cortex Media ContentType and Fields'
7
7
  task seed: :environment do
8
- example_tenant = Tenant.find_by_name('Example')
8
+ example_tenant = Cortex::Tenant.find_by_name('Example')
9
9
 
10
10
  puts "Creating Media ContentType..."
11
- media = ContentType.new({
11
+ media = Cortex::ContentType.new({
12
12
  name: "Media",
13
13
  name_id: "media",
14
14
  description: "Media for Cortex",
15
15
  icon: "collections",
16
16
  tenant: example_tenant,
17
- creator: User.first,
18
- contract: Contract.first # TODO: This is obviously bad. This whole file is bad.
17
+ creator: Cortex::User.first,
18
+ contract: Cortex::Contract.first # TODO: This is obviously bad. This whole file is bad.
19
19
  })
20
20
  media.save!
21
21
 
@@ -162,13 +162,13 @@ namespace :cortex do
162
162
  ]
163
163
  }
164
164
 
165
- media_wizard_decorator = Decorator.new(name: "Wizard", data: wizard_hash, tenant: example_tenant)
165
+ media_wizard_decorator = Cortex::Decorator.new(name: "Wizard", data: wizard_hash, tenant: example_tenant)
166
166
  media_wizard_decorator.save!
167
167
 
168
- ContentableDecorator.create!({
168
+ Cortex::ContentableDecorator.create!({
169
169
  decorator_id: media_wizard_decorator.id,
170
170
  contentable_id: media.id,
171
- contentable_type: 'ContentType',
171
+ contentable_type: 'Cortex::ContentType',
172
172
  tenant: example_tenant
173
173
  })
174
174
 
@@ -246,13 +246,13 @@ namespace :cortex do
246
246
  ]
247
247
  }
248
248
 
249
- media_index_decorator = Decorator.new(name: "Index", data: index_hash, tenant: example_tenant)
249
+ media_index_decorator = Cortex::Decorator.new(name: "Index", data: index_hash, tenant: example_tenant)
250
250
  media_index_decorator.save!
251
251
 
252
- ContentableDecorator.create!({
252
+ Cortex::ContentableDecorator.create!({
253
253
  decorator_id: media_index_decorator.id,
254
254
  contentable_id: media.id,
255
- contentable_type: 'ContentType',
255
+ contentable_type: 'Cortex::ContentType',
256
256
  tenant: example_tenant
257
257
  })
258
258
  end
@@ -0,0 +1,26 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "env",
5
+ {
6
+ "modules": false,
7
+ "targets": {
8
+ "browsers": "> 1%",
9
+ "uglify": true
10
+ },
11
+ "useBuiltIns": true
12
+ }
13
+ ],
14
+ "react"
15
+ ],
16
+ "plugins": [
17
+ "syntax-dynamic-import",
18
+ "transform-object-rest-spread",
19
+ [
20
+ "transform-class-properties",
21
+ {
22
+ "spec": true
23
+ }
24
+ ]
25
+ ]
26
+ }
@@ -0,0 +1,8 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+
3
+ import { HELLO_WORLD2_NAME_UPDATE } from '../constants/helloWorld2Constants';
4
+
5
+ export const updateName = (text) => ({
6
+ type: HELLO_WORLD2_NAME_UPDATE,
7
+ text,
8
+ });
@@ -0,0 +1,34 @@
1
+ import React from 'react'
2
+
3
+ const ToolTip = ({id, tooltip}) => (<p>{ tooltip }</p>)
4
+
5
+ const allowedExtensions = ({allowed_extensions}) => allowed_extensions === undefined ? '' : allowed_extensions.join(', ')
6
+ const allowedExtensionsForFor = ({allowed_extensions}) => allowed_extensions === undefined ? '' : '.' + allowed_extensions.join(',.')
7
+ const maxFileSize = ({max_size}) => max_size
8
+
9
+ class AssetFieldType extends React.PureComponent {
10
+ render() {
11
+ const { field_item, id, metadata, required=false, name, validations } = this.props
12
+ console.log('AssetFieldType', this.props)
13
+ return (
14
+ <div>
15
+ <strong>Allowed extensions: </strong>
16
+ { allowedExtensions(validations) }
17
+ <br/>
18
+ <strong>Allowed filesize: </strong>
19
+ { maxFileSize(validations) }
20
+ <br />
21
+ <input type='hidden' value={id} />
22
+ { field_item.tooltip && ToolTip(field_item) }
23
+ <label>{ name } </label>
24
+ <input
25
+ type='file'
26
+ accept={ allowedExtensionsForFor(validations) }
27
+ name={name} />
28
+ </div>
29
+
30
+ )
31
+ }
32
+ }
33
+
34
+ export default AssetFieldType
@@ -0,0 +1,35 @@
1
+ import React from 'react'
2
+ const ToolTip = ({id, tooltip}) => (
3
+ <div>
4
+ <div className='icon material-icons tooltip-icon' id={id}>help</div>
5
+ <div className='mdl-tooltip mdl-tooltip--large' data-mdl-for={id}>
6
+ {tooltip}
7
+ </div>
8
+ </div>
9
+ )
10
+
11
+ class DateTimeType extends React.PureComponent {
12
+ render() {
13
+ const {
14
+ field_item,
15
+ id,
16
+ value = '',
17
+ metadata,
18
+ required = false,
19
+ name,
20
+ validations
21
+ } = this.props
22
+ console.log('DateTimeType', this.props)
23
+ return (
24
+ <div className='mdl-textfield mdl-js-textfield mdl-textfield--floating-label'>
25
+ <input type='hidden' value={id}/>
26
+ <label className='mdl-textfield__label'>{name}</label>
27
+ {field_item.tooltip && ToolTip(field_item)}
28
+ <input defaultValue={value} required={required} className='datepicker mdl-textfield__input'/>
29
+ </div>
30
+
31
+ )
32
+ }
33
+ }
34
+
35
+ export default DateTimeType
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import TextFieldType from './text_field_type'
3
+ import DateTimeType from './date_time_type'
4
+ import AssetFieldType from './asset_field_type'
5
+ import TagFieldType from './tag_field_type'
6
+
7
+ export {
8
+ TextFieldType,
9
+ DateTimeType,
10
+ AssetFieldType,
11
+ TagFieldType
12
+ }
@@ -0,0 +1,41 @@
1
+ import React from 'react'
2
+ const ToolTip = ({id, tooltip}) => (
3
+ <div>
4
+ <div className='icon material-icons tooltip-icon' id={id}>help</div>
5
+ <div className='mdl-tooltip mdl-tooltip--large' data-mdl-for={id}>
6
+ {tooltip}
7
+ </div>
8
+ </div>
9
+ )
10
+
11
+ class TagFieldType extends React.PureComponent {
12
+ render() {
13
+ const {
14
+ field_item,
15
+ id,
16
+ metadata,
17
+ value,
18
+ required = false,
19
+ name,
20
+ validations
21
+ } = this.props
22
+ console.log('TagFieldType', this.props)
23
+ return (
24
+ <div>
25
+ <input type='hidden' value={id}/>
26
+ <label htmlFor={name}>{name}</label>
27
+ { field_item.tooltip && ToolTip(field_item) }
28
+ <br/>
29
+ <span className='cortex-bootstrap'>
30
+ <input
31
+ className='mdl-textfield__input'
32
+ value={ value }
33
+ data-role='tagsinput'
34
+ required={ required } />
35
+ </span>
36
+ </div>
37
+ )
38
+ }
39
+ }
40
+
41
+ export default TagFieldType