cas-cms 0.1.3 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +30 -18
- data/app/assets/config/cas_manifest.js +2 -0
- data/app/assets/javascripts/cas/application.js +4 -2
- data/app/assets/javascripts/cas/fileupload_manifest.js +14 -18
- data/app/assets/stylesheets/cas/application.sass +4 -4
- data/app/assets/stylesheets/cas/form.sass +2 -0
- data/app/assets/stylesheets/cas/layout.sass +2 -0
- data/app/assets/stylesheets/cas/tables.sass +3 -0
- data/app/assets/stylesheets/cas/typography.sass +2 -0
- data/app/controllers/cas/activities_controller.rb +9 -0
- data/app/controllers/cas/api/files_controller.rb +21 -13
- data/app/controllers/cas/application_controller.rb +13 -0
- data/app/controllers/cas/file_uploads_controller.rb +1 -1
- data/app/controllers/cas/sites/application_controller.rb +0 -13
- data/app/controllers/cas/sites/sections/contents_controller.rb +13 -1
- data/app/controllers/cas/sites/users_controller.rb +1 -1
- data/app/jobs/cas/images/delete_job.rb +5 -2
- data/app/jobs/cas/images/promote_job.rb +12 -3
- data/app/models/cas/activity.rb +30 -0
- data/app/models/cas/content.rb +14 -5
- data/app/models/cas/media_file.rb +33 -9
- data/app/models/cas/sites_user.rb +1 -1
- data/app/models/cas/user.rb +3 -2
- data/app/uploaders/file_uploader.rb +7 -8
- data/app/views/cas/activities/index.html.erb +56 -0
- data/app/views/cas/sites/sections/contents/index.html.erb +0 -1
- data/app/views/layouts/cas/application.html.erb +3 -2
- data/config/initializers/acts_as_taggable.rb +1 -1
- data/config/initializers/shrine.rb +38 -27
- data/config/routes.rb +11 -2
- data/db/migrate/20180114124600_create_cas_activities.rb +16 -0
- data/db/migrate/20230220165900_add_subject_title_to_activities.rb +6 -0
- data/lib/cas/config.rb +8 -3
- data/lib/cas/engine.rb +5 -1
- data/lib/cas/exceptions.rb +7 -0
- data/lib/cas/form_field.rb +6 -2
- data/lib/cas/installation.rb +103 -0
- data/lib/cas/remote_callbacks.rb +3 -3
- data/lib/cas/section_config.rb +25 -31
- data/lib/cas/version.rb +1 -1
- data/lib/cas.rb +3 -1
- data/lib/generators/cas/USAGE +14 -0
- data/lib/generators/cas/install_generator.rb +14 -0
- data/lib/generators/cas/templates/cas.config.yml +82 -0
- data/lib/tasks/cas_tasks.rake +6 -4
- metadata +62 -26
- data/lib/cas/setup.rb +0 -60
- /data/app/assets/stylesheets/cas/vendors/{selectize.default.css → selectize.css} +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
<div class="grid">
|
2
|
+
<div class="col-1-1">
|
3
|
+
<h1>Atividades</h1>
|
4
|
+
</div>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<br />
|
8
|
+
|
9
|
+
<table>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th>
|
13
|
+
</th>
|
14
|
+
<th>
|
15
|
+
</th>
|
16
|
+
<th>Data</th>
|
17
|
+
</tr>
|
18
|
+
</thead>
|
19
|
+
|
20
|
+
<tbody>
|
21
|
+
<% @activities.each do |activity| %>
|
22
|
+
<tr>
|
23
|
+
<td>
|
24
|
+
<%= activity.site.name %>
|
25
|
+
</td>
|
26
|
+
<td>
|
27
|
+
<% if activity.user.present? %>
|
28
|
+
<strong><%= activity.user.name %></strong>
|
29
|
+
<% else %>
|
30
|
+
<strong><%= activity.user_description %></strong>
|
31
|
+
<% end %>
|
32
|
+
<% if activity.event_name == 'create' %>
|
33
|
+
criou
|
34
|
+
<% elsif activity.event_name == 'update'%>
|
35
|
+
editou
|
36
|
+
<% end %>
|
37
|
+
<% if activity.subject.present? %>
|
38
|
+
<strong>
|
39
|
+
<%= link_to activity.subject.title,
|
40
|
+
edit_site_section_content_path(@site, activity.subject.section, activity.subject)
|
41
|
+
%>
|
42
|
+
</strong>
|
43
|
+
<% else %>
|
44
|
+
<%= activity.subject_description %>
|
45
|
+
<% end %>
|
46
|
+
</td>
|
47
|
+
<td>
|
48
|
+
<%= l(activity.created_at, format: :short) %>
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
<% end %>
|
52
|
+
</tbody>
|
53
|
+
</table>
|
54
|
+
<br>
|
55
|
+
|
56
|
+
<%= paginate @activities %>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
<%= csrf_meta_tags %>
|
28
28
|
</head>
|
29
|
-
<body class="<%= "site-#{@site.id}" if @current_user.present? %>">
|
29
|
+
<body class="<%= "site-#{@site.id}" if @current_user.present? && @site.present? %>">
|
30
30
|
|
31
31
|
<header>
|
32
32
|
<div class="grid top">
|
@@ -43,7 +43,7 @@
|
|
43
43
|
<% else %>
|
44
44
|
<select id="select-site">
|
45
45
|
<% @user_sites.each do |site| %>
|
46
|
-
<% selected = site.id == @site
|
46
|
+
<% selected = site.id == @site&.id %>
|
47
47
|
<option
|
48
48
|
value="<%= site_sections_path(site) %>"
|
49
49
|
<%= 'selected="selected"' if selected %>
|
@@ -70,6 +70,7 @@
|
|
70
70
|
<ul>
|
71
71
|
<% if user_signed_in? %>
|
72
72
|
<li><%= link_to "Conteúdo", cas.site_sections_path(@site) %></li>
|
73
|
+
<li><%= link_to "Atividades", cas.activities_path, id: "go-to-activities" %></li>
|
73
74
|
<% end %>
|
74
75
|
<% if user_signed_in? && current_user.admin? %>
|
75
76
|
<li><%= link_to "Pessoas", cas.site_users_path(@site), id: "list-people" %></li>
|
@@ -1 +1 @@
|
|
1
|
-
ActsAsTaggableOn.delimiter = [','
|
1
|
+
ActsAsTaggableOn.delimiter = [',']
|
@@ -1,16 +1,18 @@
|
|
1
|
+
# On why we use Shrine over Active Storage:
|
2
|
+
# https://github.com/shrinerb/shrine/blob/d9aba64bd5515584645f8885c76d56fa1a842bac/doc/advantages.md
|
3
|
+
|
1
4
|
require 'shrine'
|
2
5
|
|
3
6
|
Shrine.plugin :activerecord
|
4
|
-
Shrine.plugin :presign_endpoint
|
5
7
|
Shrine.plugin :backgrounding
|
6
8
|
|
9
|
+
Shrine.plugin(
|
10
|
+
:derivatives,
|
11
|
+
create_on_promote: true, # automatically create derivatives on promotion
|
12
|
+
versions_compatibility: true # handle versions column format
|
13
|
+
)
|
14
|
+
|
7
15
|
if Rails.env.test?
|
8
|
-
s3_options = {
|
9
|
-
access_key_id: 'access_key_id',
|
10
|
-
secret_access_key: 'secret_access_key',
|
11
|
-
region: 'us-east-1',
|
12
|
-
bucket: 'com.bucket'
|
13
|
-
}
|
14
16
|
require "shrine/storage/file_system"
|
15
17
|
|
16
18
|
Shrine.storages = {
|
@@ -19,32 +21,41 @@ if Rails.env.test?
|
|
19
21
|
}
|
20
22
|
else
|
21
23
|
if ENV["S3_ACCESS_KEY_ID"].blank?
|
22
|
-
msg = "You need to configure S3 credentials. See the README.md for more details."
|
23
|
-
puts msg
|
24
|
+
msg = "You need to configure S3 credentials. See the README.md for more details. File uploads will be broken until you fix it."
|
24
25
|
Rails.logger.error msg
|
25
|
-
|
26
|
+
puts msg
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
else
|
29
|
+
Shrine.plugin :presign_endpoint
|
30
|
+
s3_options = {
|
31
|
+
access_key_id: ENV.fetch("S3_ACCESS_KEY_ID"),
|
32
|
+
secret_access_key: ENV.fetch("S3_SECRET_ACCESS_KEY"),
|
33
|
+
region: ENV.fetch("S3_REGION"),
|
34
|
+
bucket: ENV.fetch("S3_BUCKET"),
|
35
|
+
}
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
require "shrine/storage/s3"
|
38
|
+
config = Cas::Config.new.uploads
|
39
|
+
Shrine.storages = {
|
40
|
+
cache: Shrine::Storage::S3.new(prefix: config[:cache_directory_prefix], **s3_options),
|
41
|
+
store: Shrine::Storage::S3.new(prefix: config[:store_directory_prefix], **s3_options),
|
42
|
+
}
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
|
-
Shrine::Attacher.
|
43
|
-
Rails.logger.info "Shrine promoting file scheduled"
|
44
|
-
::Cas::Images::PromoteJob.perform_async(
|
46
|
+
Shrine::Attacher.promote_block do
|
47
|
+
Rails.logger.info "Shrine promoting #{record.class.name} file scheduled"
|
48
|
+
::Cas::Images::PromoteJob.perform_async(
|
49
|
+
self.class.name,
|
50
|
+
record.class.name,
|
51
|
+
record.id,
|
52
|
+
name.to_s,
|
53
|
+
file_data
|
54
|
+
)
|
45
55
|
end
|
46
56
|
|
47
|
-
|
57
|
+
|
58
|
+
Shrine::Attacher.destroy_block do
|
48
59
|
Rails.logger.info "Shrine deleting file scheduled"
|
49
|
-
::Cas::Images::DeleteJob.perform_async(data)
|
60
|
+
::Cas::Images::DeleteJob.perform_async(self.class.name, data)
|
50
61
|
end
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'sidekiq/web'
|
2
|
-
|
2
|
+
# TODO - need to migrate Sidekiq
|
3
|
+
#Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
|
3
4
|
|
4
5
|
Cas::Engine.routes.draw do
|
5
|
-
|
6
|
+
if Shrine.respond_to?(:presign_endpoint)
|
7
|
+
mount Shrine.presign_endpoint(:cache) => "/files/cache/presign"
|
8
|
+
else
|
9
|
+
Rails.logger.info "Shrine's presign endpoint is disabled"
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO - fix
|
13
|
+
# mount Shrine.upload_endpoint(:cache) => "/files/upload"
|
6
14
|
|
7
15
|
authenticate :user, ->(u){ u.roles.include?('admin') } do
|
8
16
|
mount Sidekiq::Web => '/sidekiq'
|
@@ -14,6 +22,7 @@ Cas::Engine.routes.draw do
|
|
14
22
|
controllers: { sessions: "cas/devise/sessions" },
|
15
23
|
skip: :registrations
|
16
24
|
|
25
|
+
resources :activities, only: [:index]
|
17
26
|
resources :sites, only: [:index] do
|
18
27
|
resources :users, controller: 'sites/users'
|
19
28
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateCasActivities < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :cas_activities, id: :uuid do |t|
|
4
|
+
t.uuid :site_id
|
5
|
+
t.uuid :user_id
|
6
|
+
t.string :event_name
|
7
|
+
t.uuid :subject_id
|
8
|
+
t.string :subject_type
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :cas_activities, :site_id
|
13
|
+
add_index :cas_activities, :user_id
|
14
|
+
add_index :cas_activities, [:subject_id, :subject_type]
|
15
|
+
end
|
16
|
+
end
|
data/lib/cas/config.rb
CHANGED
@@ -10,6 +10,7 @@ module Cas
|
|
10
10
|
def uploads
|
11
11
|
uploads = config["uploads"] || {}
|
12
12
|
|
13
|
+
# TODO - clarify what this is and how to configure
|
13
14
|
{
|
14
15
|
cache_directory_prefix: uploads["cache_directory_prefix"] || "cache",
|
15
16
|
store_directory_prefix: uploads["store_directory_prefix"] || "store"
|
@@ -19,13 +20,17 @@ module Cas
|
|
19
20
|
private
|
20
21
|
|
21
22
|
def read_file
|
22
|
-
|
23
|
+
begin
|
24
|
+
@file ||= YAML.safe_load_file(filename, aliases: true)
|
25
|
+
rescue NoMethodError, ArgumentError
|
26
|
+
@file ||= YAML.load_file(filename)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
def filename
|
26
31
|
@filename ||= begin
|
27
|
-
if File.exists?(
|
28
|
-
|
32
|
+
if File.exists?(Cas::CONFIG_PATH)
|
33
|
+
Cas::CONFIG_PATH
|
29
34
|
elsif ENV['RAILS_ENV'] == 'test'
|
30
35
|
"spec/fixtures/cas.yml"
|
31
36
|
else
|
data/lib/cas/engine.rb
CHANGED
@@ -16,7 +16,11 @@ module Cas
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
config.assets.precompile += [
|
19
|
+
config.assets.precompile += [
|
20
|
+
"cas/application.css",
|
21
|
+
"cas/application.js",
|
22
|
+
"cas/fileupload_manifest.js"
|
23
|
+
]
|
20
24
|
|
21
25
|
config.active_record.primary_key = :uuid
|
22
26
|
config.generators do |g|
|
data/lib/cas/form_field.rb
CHANGED
@@ -15,13 +15,17 @@ module Cas
|
|
15
15
|
if Rails.env.test?
|
16
16
|
"spec/fixtures/cas.yml"
|
17
17
|
else
|
18
|
-
|
18
|
+
Cas::CONFIG_PATH
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def load_field
|
23
23
|
@config ||= begin
|
24
|
-
|
24
|
+
begin
|
25
|
+
config_file = YAML.safe_load_file(filename, aliases: true)
|
26
|
+
rescue NoMethodError, ArgumentError
|
27
|
+
config_file = YAML.load_file(filename)
|
28
|
+
end
|
25
29
|
sites = config_file["sites"]
|
26
30
|
site = sites[@section.site.slug]
|
27
31
|
section = site["sections"]
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Cas
|
2
|
+
class Installation
|
3
|
+
def initialize(filename: nil, logger: Rails.logger)
|
4
|
+
@logger = logger
|
5
|
+
@filename = filename
|
6
|
+
@filename ||= begin
|
7
|
+
if Rails.env.test?
|
8
|
+
"spec/fixtures/cas.yml"
|
9
|
+
else
|
10
|
+
Cas::CONFIG_PATH
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Ruby 3.0 comes with Psych 3, while Ruby 3.1 comes with Psych 4, which
|
15
|
+
# has a major breaking change (diff 3.3.2 → 4.0.0).
|
16
|
+
#
|
17
|
+
# The new YAML loading methods (Psych 4) do not load aliases unless
|
18
|
+
# they get the aliases: true argument. The old YAML loading methods
|
19
|
+
# (Psych 3) do not support the :aliases keyword.
|
20
|
+
begin
|
21
|
+
@config = YAML.safe_load_file(@filename, aliases: true)
|
22
|
+
rescue NoMethodError, ArgumentError
|
23
|
+
@config = YAML.load_file(@filename)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_sites
|
28
|
+
@logger.info "Creating data..."
|
29
|
+
ActiveRecord::Base.transaction do
|
30
|
+
@logger.info " - admins"
|
31
|
+
create_initial_admins
|
32
|
+
@logger.info " - sites"
|
33
|
+
create_sites
|
34
|
+
@logger.info " - setting superadmins"
|
35
|
+
set_superadmins
|
36
|
+
end
|
37
|
+
@logger.info "Done."
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def create_sites
|
43
|
+
@config["sites"].each do |site_slug, site_config|
|
44
|
+
site = ::Cas::Site.where(slug: site_slug).first_or_create!
|
45
|
+
site.update!(
|
46
|
+
domains: site_config["domains"],
|
47
|
+
name: site_config["name"]
|
48
|
+
)
|
49
|
+
|
50
|
+
site_config["sections"].each do |key, section|
|
51
|
+
model = ::Cas::Section.where(
|
52
|
+
slug: key,
|
53
|
+
site_id: site.id
|
54
|
+
).first_or_create!(
|
55
|
+
name: section["name"],
|
56
|
+
section_type: section["type"],
|
57
|
+
)
|
58
|
+
|
59
|
+
model.update!(
|
60
|
+
name: section["name"],
|
61
|
+
section_type: section["type"],
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def create_initial_admins
|
68
|
+
return if @config["config"]["initial_admins"].blank?
|
69
|
+
|
70
|
+
@config["config"]["initial_admins"].each do |item|
|
71
|
+
::Cas::User.where(email: item).first_or_create!(
|
72
|
+
password: "12345678",
|
73
|
+
name: "User",
|
74
|
+
roles: ["admin"]
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def set_superadmins
|
80
|
+
return if @config["config"]["superadmins"].blank?
|
81
|
+
|
82
|
+
updated_users = []
|
83
|
+
@config["config"]["superadmins"].each do |email_or_login|
|
84
|
+
user = ::Cas::User.where(
|
85
|
+
'cas_users.email = :value OR cas_users.login = :value',
|
86
|
+
value: email_or_login
|
87
|
+
).first
|
88
|
+
|
89
|
+
if user.blank?
|
90
|
+
@logger.info "Cannot set user '#{email_or_login}' as superadmin because it doesn't exist"
|
91
|
+
next
|
92
|
+
end
|
93
|
+
|
94
|
+
next if updated_users.include?(user.id)
|
95
|
+
|
96
|
+
user.sites = ::Cas::Site.all
|
97
|
+
user.save!
|
98
|
+
|
99
|
+
updated_users << user.id
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/cas/remote_callbacks.rb
CHANGED
@@ -9,9 +9,9 @@ module Cas
|
|
9
9
|
# big: big_image
|
10
10
|
# }
|
11
11
|
#
|
12
|
-
# `original` should
|
13
|
-
# afterwards automatically.
|
14
|
-
uploaded_image_versions: ->(
|
12
|
+
# `original` should not be present after Shrine 3.0. If it is not, we will
|
13
|
+
# merge it afterwards automatically.
|
14
|
+
uploaded_image_versions: ->(original) {
|
15
15
|
{}
|
16
16
|
},
|
17
17
|
|
data/lib/cas/section_config.rb
CHANGED
@@ -5,26 +5,12 @@ module Cas
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def list_order_by
|
8
|
-
|
9
|
-
sites = config["sites"]
|
10
|
-
site = sites[@section.site.slug]
|
11
|
-
section = site["sections"]
|
12
|
-
|
13
|
-
order_field = section.find { |key, value|
|
14
|
-
key == @section.slug
|
15
|
-
}[1]['list_order_by']
|
16
|
-
|
8
|
+
order_field = load_section_config[1]['list_order_by']
|
17
9
|
order_field || ['created_at']
|
18
10
|
end
|
19
11
|
|
20
12
|
def list_fields
|
21
|
-
|
22
|
-
sites = config["sites"]
|
23
|
-
site = sites[@section.site.slug]
|
24
|
-
section = site["sections"]
|
25
|
-
fields = section.find { |key, value|
|
26
|
-
key == @section.slug
|
27
|
-
}[1]["list_fields"]
|
13
|
+
fields = load_section_config[1]["list_fields"]
|
28
14
|
fields || ['title', 'created_at']
|
29
15
|
end
|
30
16
|
|
@@ -40,13 +26,7 @@ module Cas
|
|
40
26
|
end
|
41
27
|
|
42
28
|
def form_has_field?(field)
|
43
|
-
|
44
|
-
sites = config["sites"]
|
45
|
-
site = sites[@section.site.slug]
|
46
|
-
section = site["sections"]
|
47
|
-
section_fields = section.find { |key, value|
|
48
|
-
key == @section.slug
|
49
|
-
}[1]["fields"]
|
29
|
+
section_fields = load_section_config[1]["fields"]
|
50
30
|
|
51
31
|
Array.wrap(section_fields).any? do |section_field|
|
52
32
|
if section_field.is_a?(Hash)
|
@@ -63,22 +43,36 @@ module Cas
|
|
63
43
|
if Rails.env.test?
|
64
44
|
"spec/fixtures/cas.yml"
|
65
45
|
else
|
66
|
-
|
46
|
+
Cas::CONFIG_PATH
|
67
47
|
end
|
68
48
|
end
|
69
49
|
|
70
50
|
def load_field
|
71
51
|
@config ||= begin
|
72
|
-
|
73
|
-
sites = config_file["sites"]
|
74
|
-
site = sites[@section.site.slug]
|
75
|
-
section = site["sections"]
|
76
|
-
field = section.find { |key, value|
|
77
|
-
key == @section.slug
|
78
|
-
}
|
52
|
+
field = load_section_config
|
79
53
|
(field && field[1]) || {}
|
80
54
|
end
|
81
55
|
end
|
56
|
+
|
57
|
+
def load_section_config
|
58
|
+
begin
|
59
|
+
config = YAML.safe_load_file(filename, aliases: true)
|
60
|
+
rescue NoMethodError, ArgumentError
|
61
|
+
config = YAML.load_file(filename)
|
62
|
+
end
|
63
|
+
|
64
|
+
sites = config["sites"]
|
65
|
+
site = sites[@section.site.slug]
|
66
|
+
|
67
|
+
if site.blank?
|
68
|
+
raise(
|
69
|
+
Cas::Exceptions::UndefinedSite,
|
70
|
+
"Site #{@section.site.slug} is undefined in the #{filename} file."
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
site["sections"].find { |key, value| key == @section.slug }
|
75
|
+
end
|
82
76
|
end
|
83
77
|
end
|
84
78
|
|
data/lib/cas/version.rb
CHANGED
data/lib/cas.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "cas/engine"
|
2
|
+
require "cas/exceptions"
|
2
3
|
require "cas/config"
|
3
4
|
require "cas/remote_callbacks"
|
4
|
-
require "cas/
|
5
|
+
require "cas/installation"
|
5
6
|
require "cas/section_config"
|
6
7
|
require "cas/form_field"
|
7
8
|
|
@@ -19,4 +20,5 @@ require 'sidekiq'
|
|
19
20
|
require 'pg_search'
|
20
21
|
|
21
22
|
module Cas
|
23
|
+
CONFIG_PATH = "config/cas.config.yml"
|
22
24
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Generates new cas.yml and configures database for it.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate cas:install
|
6
|
+
|
7
|
+
This will:
|
8
|
+
- run Cas migrations
|
9
|
+
- add an `/admin` route for Cas
|
10
|
+
- create a configuration file in config/cas.config.yml. After you edit
|
11
|
+
this file, run
|
12
|
+
|
13
|
+
bin/rails cas:apply_config
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cas
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
4
|
+
|
5
|
+
def copy_initializer_file
|
6
|
+
rake("db:migrate")
|
7
|
+
copy_file "cas.config.yml", Cas::CONFIG_PATH
|
8
|
+
route 'mount Cas::Engine, at: "/admin"'
|
9
|
+
|
10
|
+
puts ""
|
11
|
+
puts "Config generated. Now edit `#{Cas::CONFIG_PATH}` and run `bin/rails cas:apply_config`"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# CAS CONFIG
|
2
|
+
#
|
3
|
+
# This file is used to generate the data for the sites you want to manage.
|
4
|
+
|
5
|
+
# Config: global configuration across all sites
|
6
|
+
config:
|
7
|
+
|
8
|
+
# TODO - clarify what is the initial password
|
9
|
+
initial_admins:
|
10
|
+
- admin@example.com
|
11
|
+
|
12
|
+
# Superadmins can create other admins and users. Define which emails or logins
|
13
|
+
# you want set as superadmin.
|
14
|
+
superadmins:
|
15
|
+
- admin@example.com
|
16
|
+
- superadmin-login
|
17
|
+
|
18
|
+
# DEPRECATED
|
19
|
+
uploads:
|
20
|
+
cache_directory_prefix: 'cache'
|
21
|
+
store_directory_prefix: 'uploads'
|
22
|
+
|
23
|
+
# Sites: define the ones you want to manage. If you have multiple, you will be
|
24
|
+
# able to switch between them inside Cas dashboard.
|
25
|
+
#
|
26
|
+
# Each site has Sections, and each Section has their own Categories.
|
27
|
+
sites:
|
28
|
+
mysite:
|
29
|
+
name: mysite.net
|
30
|
+
|
31
|
+
# Depending on this, Cas will automatically switch the site it is managing.
|
32
|
+
domains:
|
33
|
+
- mysite.net
|
34
|
+
|
35
|
+
# These are entire sections, like 'articles', 'pages', 'ads' etc
|
36
|
+
sections:
|
37
|
+
news:
|
38
|
+
name: news
|
39
|
+
type: content
|
40
|
+
list_fields:
|
41
|
+
- title
|
42
|
+
- category
|
43
|
+
fields:
|
44
|
+
- category
|
45
|
+
- tags
|
46
|
+
- title
|
47
|
+
- summary
|
48
|
+
- text
|
49
|
+
- images
|
50
|
+
- files
|
51
|
+
- tags
|
52
|
+
- date
|
53
|
+
biography:
|
54
|
+
name: Biography
|
55
|
+
type: content
|
56
|
+
fields:
|
57
|
+
- title
|
58
|
+
- text
|
59
|
+
- image
|
60
|
+
agenda:
|
61
|
+
name: Agenda
|
62
|
+
type: content
|
63
|
+
accessible_roles:
|
64
|
+
- admin
|
65
|
+
list_fields:
|
66
|
+
- title
|
67
|
+
- date_time
|
68
|
+
list_order_by:
|
69
|
+
- order_field
|
70
|
+
fields:
|
71
|
+
- title
|
72
|
+
- location
|
73
|
+
- date:
|
74
|
+
language: pt-br
|
75
|
+
format:
|
76
|
+
- day
|
77
|
+
- month
|
78
|
+
- year
|
79
|
+
- text
|
80
|
+
survey:
|
81
|
+
name: Survey
|
82
|
+
type: survey
|
data/lib/tasks/cas_tasks.rake
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
desc "Generate sites based on the YAML config file"
|
2
|
+
namespace :cas do
|
3
|
+
task apply_config: :environment do
|
4
|
+
Cas::Installation.new(logger: Logger.new(STDOUT)).generate_sites
|
5
|
+
end
|
6
|
+
end
|