cortex 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +103 -0
- data/CONTRIBUTING.md +7 -6
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -1
- data/README.md +6 -217
- data/app/controllers/cortex/content_items_controller.rb +37 -27
- data/app/helpers/cortex/content_item_helper.rb +24 -15
- data/app/operations/cortex/database_transact_operation.rb +5 -8
- data/app/operations/cortex/persist_content_item_operation.rb +5 -2
- data/app/views/cortex/content_items/_form.html.haml +5 -5
- data/app/views/layouts/cortex/application.html.haml +3 -3
- data/cortex.gemspec +1 -1
- data/lib/cortex/version.rb +1 -1
- data/package.json +2 -2
- data/spec/dummy/app/javascript/packs/cortex_cms.jsx +1 -0
- data/spec/dummy/bin/bundle +2 -104
- data/spec/dummy/bin/rspec +1 -1
- data/spec/dummy/bin/setup +12 -12
- data/spec/dummy/bin/update +3 -5
- data/spec/dummy/bin/yarn +3 -3
- data/spec/dummy/config/boot.rb +4 -10
- data/spec/dummy/lib/tasks/content_types_tasks.rake +27 -25
- data/spec/dummy/package.json +1 -1
- data/spec/dummy/yarn.lock +525 -746
- metadata +42479 -156
- data/spec/dummy/app/javascript/packs/cortex.jsx +0 -1
- data/spec/dummy/bin/webpack +0 -29
- data/spec/dummy/bin/webpack-dev-server +0 -29
@@ -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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
102
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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
|
@@ -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
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 '
|
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.
|
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 '
|
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?]
|
data/cortex.gemspec
CHANGED
@@ -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,
|
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|
|
data/lib/cortex/version.rb
CHANGED
data/package.json
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
import 'cortex-cms';
|
data/spec/dummy/bin/bundle
CHANGED
@@ -1,105 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
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')
|
data/spec/dummy/bin/rspec
CHANGED
data/spec/dummy/bin/setup
CHANGED
@@ -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 =
|
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
|
-
|
22
|
-
# system('bin/yarn')
|
23
|
-
|
17
|
+
system!('bin/yarn')
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
|
data/spec/dummy/bin/update
CHANGED
@@ -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 =
|
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
|
|
data/spec/dummy/bin/yarn
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
Dir.chdir(
|
2
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(APP_ROOT) do
|
4
4
|
begin
|
5
|
-
exec "yarnpkg
|
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"
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
|
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 :
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|