cortex 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,22 +6,32 @@ module Cortex
6
6
 
7
7
  def create_content_item
8
8
  CreateContentItemTransaction.new
9
- .with_step_args(
10
- execute_content_item_state_change: [state: params[:content_item][:state]]
11
- )
12
- .call(id: params[:id], content_type: content_type,
13
- content_item_params: content_item_params, current_user: current_user)
14
- .value!
15
9
  end
16
10
 
17
11
  def update_content_item
18
12
  UpdateContentItemTransaction.new
19
- .with_step_args(
20
- execute_content_item_state_change: [state: params[:content_item][:state]]
21
- )
22
- .call(id: params[:id], content_type: content_type,
23
- content_item_params: content_item_params, current_user: current_user)
24
- .value!
13
+ end
14
+
15
+ def render_create_content_item_error
16
+ @content_item = content_item_reload(content_type.content_items.new)
17
+ @wizard = wizard_decorator(@content_item.content_type)
18
+
19
+ add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
20
+ add_breadcrumb 'New'
21
+
22
+ render :new
23
+ end
24
+
25
+ def render_update_content_item_error
26
+ @content_item = content_item_reload(content_type.content_items.find_by_id(params[:id]))
27
+ @wizard = wizard_decorator(@content_item.content_type)
28
+
29
+ title = @content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text'] # TODO: refactor this hardcoded Field reference
30
+ add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
31
+ add_breadcrumb title
32
+ add_breadcrumb 'Edit'
33
+
34
+ render :edit
25
35
  end
26
36
 
27
37
  def content_item_reload(content_item)
@@ -98,9 +108,8 @@ module Cortex
98
108
  params_hash['data'] || {}
99
109
  end
100
110
 
101
- def validation_message(base_message)
102
- msg_array = base_message.gsub('Validation failed:', '').gsub('Field items', '').split(',')
103
- msg_array.map {|message| message.strip.titleize}
111
+ def clean_error_messages(messages)
112
+ messages.map {|message| message.gsub('Field items', '').strip.titleize}
104
113
  end
105
114
  end
106
115
  end
@@ -4,14 +4,11 @@ module Cortex
4
4
 
5
5
  result = nil
6
6
 
7
- begin
8
- ActiveRecord::Base.transaction do
9
- result = block.(Success(input))
10
- raise ActiveRecord::Rollback if result.failure?
11
- result
12
- end
13
- rescue ActiveRecord::Rollback
14
- result
7
+ ActiveRecord::Base.transaction do
8
+ result = block.(Success(input))
9
+ raise ActiveRecord::Rollback if result.failure?
15
10
  end
11
+
12
+ result
16
13
  }
17
14
  end
@@ -5,8 +5,11 @@ module Cortex
5
5
  include Dry::Transaction::Operation
6
6
 
7
7
  def call(input)
8
- input.save!
9
- Success(input)
8
+ if input.save
9
+ Success(input)
10
+ else
11
+ Failure(input.errors)
12
+ end
10
13
  end
11
14
  end
12
15
  end
@@ -1,11 +1,11 @@
1
1
  = form_for [@content_type, @content_item], html: { multipart: true } do |form|
2
2
  = form.hidden_field :creator_id, value: current_user.id
3
3
  = form.hidden_field :content_type_id, value: @content_type.id
4
- -# TODO: remove conditional once cortex plugins fields are properly converted
5
- - if @content_type.name == 'Media'
6
- = react_component('CortexApp', props: { temporary_render: 'Wizard' })
7
- - else
8
- = cell(Cortex::WizardCell, @wizard, context: { content_item: @content_item, form: form }).()
4
+ -# TODO: remove conditional once fields are properly converted to React
5
+ -# if @content_type.name == 'Media'
6
+ =# react_component('CortexApp', props: { temporary_render: 'Wizard' })
7
+ -# else
8
+ = cell(Cortex::WizardCell, @wizard, context: { content_item: @content_item, form: form }).()
9
9
 
10
10
  %footer.mdl-grid
11
11
  .mdl-cell.mdl-cell--12-col
@@ -8,7 +8,7 @@
8
8
  = title
9
9
  = favicon_link_tag 'cortex/favicon.ico'
10
10
  = stylesheet_link_tag :application, {media: 'all'}
11
- // = stylesheet_pack_tag 'cortex-bundle', {media: 'all'} # Enable once assets migrated
11
+ // = stylesheet_pack_tag 'cortex_cms', {media: 'all'} # Enable once assets migrated
12
12
  = stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons'
13
13
  = csrf_meta_tags
14
14
  %body
@@ -23,8 +23,8 @@
23
23
  = yield
24
24
  = render 'cortex/partials/flash'
25
25
 
26
- %script{src: '//cdn.ckeditor.com/4.8.0/standard-all/ckeditor.js', type: 'text/javascript'}
26
+ %script{src: '//cdn.ckeditor.com/4.10.0/standard-all/ckeditor.js', type: 'text/javascript'}
27
27
  = javascript_include_tag :application
28
- = javascript_pack_tag 'cortex'
28
+ = javascript_pack_tag 'cortex_cms'
29
29
  = render 'cortex/partials/trackers/google_analytics' if extra_config[:google_analytics_id?]
30
30
  = render 'cortex/partials/trackers/qualtrics' if extra_config[:qualtrics_id?]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.authors = ['CareerBuilder Employer Site & Content Products']
11
11
  s.email = 'toastercup@gmail.com'
12
12
  s.homepage = 'https://github.com/cortex-cms/cortex'
13
- s.summary = 'An API-driven multitenant identity, dynamic content distribution/management and reporting platform powered by Rails, GraphQL and ElasticSearch'
13
+ s.summary = 'An API-driven multitenant identity, custom content distribution/management and reporting platform powered by Rails, React, GraphQL and ElasticSearch'
14
14
  s.license = 'Apache-2.0'
15
15
 
16
16
  s.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -1,3 +1,3 @@
1
1
  module Cortex
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "cortex",
3
- "version": "0.1.0",
2
+ "name": "cortex-cms",
3
+ "version": "0.1.2",
4
4
  "main": "node_package/lib/index.js",
5
5
  "homepage": "https://github.com/cortex-cms/cortex",
6
6
  "repository": {
@@ -0,0 +1 @@
1
+ import 'cortex-cms';
@@ -1,105 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'bundle' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "rubygems"
12
-
13
- m = Module.new do
14
- module_function
15
-
16
- def invoked_as_script?
17
- File.expand_path($0) == File.expand_path(__FILE__)
18
- end
19
-
20
- def env_var_version
21
- ENV["BUNDLER_VERSION"]
22
- end
23
-
24
- def cli_arg_version
25
- return unless invoked_as_script? # don't want to hijack other binstubs
26
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
- bundler_version = nil
28
- update_index = nil
29
- ARGV.each_with_index do |a, i|
30
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
- bundler_version = a
32
- end
33
- next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
- bundler_version = $1 || ">= 0.a"
35
- update_index = i
36
- end
37
- bundler_version
38
- end
39
-
40
- def gemfile
41
- gemfile = ENV["BUNDLE_GEMFILE"]
42
- return gemfile if gemfile && !gemfile.empty?
43
-
44
- File.expand_path("../../Gemfile", __FILE__)
45
- end
46
-
47
- def lockfile
48
- lockfile =
49
- case File.basename(gemfile)
50
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
- else "#{gemfile}.lock"
52
- end
53
- File.expand_path(lockfile)
54
- end
55
-
56
- def lockfile_version
57
- return unless File.file?(lockfile)
58
- lockfile_contents = File.read(lockfile)
59
- return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
- Regexp.last_match(1)
61
- end
62
-
63
- def bundler_version
64
- @bundler_version ||= begin
65
- env_var_version || cli_arg_version ||
66
- lockfile_version || "#{Gem::Requirement.default}.a"
67
- end
68
- end
69
-
70
- def load_bundler!
71
- ENV["BUNDLE_GEMFILE"] ||= gemfile
72
-
73
- # must dup string for RG < 1.8 compatibility
74
- activate_bundler(bundler_version.dup)
75
- end
76
-
77
- def activate_bundler(bundler_version)
78
- if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
- bundler_version = "< 2"
80
- end
81
- gem_error = activation_error_handling do
82
- gem "bundler", bundler_version
83
- end
84
- return if gem_error.nil?
85
- require_error = activation_error_handling do
86
- require "bundler/version"
87
- end
88
- return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
- warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
- exit 42
91
- end
92
-
93
- def activation_error_handling
94
- yield
95
- nil
96
- rescue StandardError, LoadError => e
97
- e
98
- end
99
- end
100
-
101
- m.load_bundler!
102
-
103
- if m.invoked_as_script?
104
- load Gem.bin_path("bundler", "bundle")
105
- end
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../Gemfile",
12
12
  Pathname.new(__FILE__).realpath)
13
13
 
14
14
  require "rubygems"
@@ -1,35 +1,35 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
11
10
  end
12
11
 
13
12
  chdir APP_ROOT do
14
- # This script is a starting point to setup your application.
15
- # Add necessary setup steps to this file.
16
-
17
13
  puts '== Installing dependencies =='
18
14
  system! 'gem install bundler --conservative'
19
15
  system('bundle check') || system!('bundle install')
20
16
 
21
- # Install JavaScript dependencies if using Yarn
22
- # system('bin/yarn')
23
-
17
+ system!('bin/yarn')
24
18
 
25
- # puts "\n== Copying sample files =="
26
- # unless File.exist?('config/database.yml')
27
- # cp 'config/database.yml.sample', 'config/database.yml'
28
- # end
19
+ puts "\n== Copying sample files =="
20
+ unless File.exist?('.env')
21
+ cp '.env.example', '.env'
22
+ end
29
23
 
30
24
  puts "\n== Preparing database =="
31
25
  system! 'bin/rails db:setup'
32
26
 
27
+ puts "\n== Seed initial ContentType/Decorator data =="
28
+ system! 'bin/rails cortex_starter:content_types:seed'
29
+
30
+ puts "\n== Rebuild ElasticSearch indices =="
31
+ system! 'bin/rails cortex:rebuild_indexes'
32
+
33
33
  puts "\n== Removing old logs and tempfiles =="
34
34
  system! 'bin/rails log:clear tmp:clear'
35
35
 
@@ -1,23 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
11
10
  end
12
11
 
13
12
  chdir APP_ROOT do
14
- # This script is a way to update your development environment automatically.
15
- # Add necessary update steps to this file.
16
-
17
13
  puts '== Installing dependencies =='
18
14
  system! 'gem install bundler --conservative'
19
15
  system('bundle check') || system!('bundle install')
20
16
 
17
+ system!('bin/yarn')
18
+
21
19
  puts "\n== Updating database =="
22
20
  system! 'bin/rails db:migrate'
23
21
 
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- VENDOR_PATH = File.expand_path('..', __dir__)
3
- Dir.chdir(VENDOR_PATH) do
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
4
  begin
5
- exec "yarnpkg #{ARGV.join(" ")}"
5
+ exec "yarnpkg", *ARGV
6
6
  rescue Errno::ENOENT
7
7
  $stderr.puts "Yarn executable was not detected in the system."
8
8
  $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
@@ -1,11 +1,5 @@
1
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
2
3
 
3
- require 'bundler/setup'
4
-
5
- # Cache requires
6
- begin
7
- puts 'Initializing bootscale..'
8
- require 'bootscale/setup'
9
- rescue LoadError
10
- puts 'Skipping bootscale initialization - not loaded.'
11
- end
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,31 +1,33 @@
1
1
  Bundler.require(:default, Rails.env)
2
2
 
3
- namespace :content_types do
4
- desc 'Re-Seeds (will wipe existing ContentTypes!) CortexStarter with Core Custom Content Seed Data'
5
- task reseed: :environment do
6
- Rake::Task['content_types:clear'].execute
7
- Rake::Task['content_types:seed'].execute
8
- end
3
+ namespace :cortex_starter do
4
+ namespace :content_types do
5
+ desc 'Re-Seeds (will wipe existing ContentTypes!) CortexStarter with Core Custom Content Seed Data'
6
+ task reseed: :environment do
7
+ Rake::Task['cortex_starter:content_types:clear'].execute
8
+ Rake::Task['cortex_starter:content_types:seed'].execute
9
+ end
9
10
 
10
- desc 'Seeds CortexStarter with Core Custom Content Seed Data'
11
- task seed: :environment do
12
- Rake::Task['cortex:core:media:seed'].execute
13
- Rake::Task['employer:blog:seed'].execute
14
- end
11
+ desc 'Seeds CortexStarter with Core Custom Content Seed Data'
12
+ task seed: :environment do
13
+ Rake::Task['cortex:core:media:seed'].execute
14
+ Rake::Task['employer:blog:seed'].execute
15
+ end
15
16
 
16
- desc 'Clear Existing Custom Content Data From DB'
17
- task clear: :environment do
18
- puts "Clearing ContentTypes..."
19
- Cortex::ContentType.destroy_all
20
- puts "Clearing Fields..."
21
- Cortex::Field.destroy_all
22
- puts "Clearing ContentItems..."
23
- Cortex::ContentItem.destroy_all
24
- puts "Clearing FieldItems..."
25
- Cortex::FieldItem.destroy_all
26
- puts "Clearing ContentableDecorators..."
27
- Cortex::ContentableDecorator.destroy_all
28
- puts "Clearing Decorators..."
29
- Cortex::Decorator.destroy_all
17
+ desc 'Clear Existing Custom Content Data From DB'
18
+ task clear: :environment do
19
+ puts "Clearing ContentTypes..."
20
+ Cortex::ContentType.destroy_all
21
+ puts "Clearing Fields..."
22
+ Cortex::Field.destroy_all
23
+ puts "Clearing ContentItems..."
24
+ Cortex::ContentItem.destroy_all
25
+ puts "Clearing FieldItems..."
26
+ Cortex::FieldItem.destroy_all
27
+ puts "Clearing ContentableDecorators..."
28
+ Cortex::ContentableDecorator.destroy_all
29
+ puts "Clearing Decorators..."
30
+ Cortex::Decorator.destroy_all
31
+ end
30
32
  end
31
33
  end
@@ -13,7 +13,7 @@
13
13
  "redux": "^3.7.2",
14
14
  "redux-logger": "^3.0.6",
15
15
 
16
- "cortex": "/Users/atharp/Repos/cortex",
16
+ "cortex-cms": "0.1.2",
17
17
  "cortex-plugins-core": "2.0.1"
18
18
  },
19
19
  "devDependencies": {