ruby_cms 0.1.1 → 0.1.2
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/CHANGELOG.md +5 -0
- data/README.md +68 -164
- data/app/components/ruby_cms/admin/admin_page.rb +19 -19
- data/app/components/ruby_cms/admin/admin_page_header.rb +81 -0
- data/app/components/ruby_cms/admin/admin_resource_card.rb +55 -0
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table.rb +4 -4
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_actions.rb +5 -5
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_body.rb +1 -1
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_cell.rb +15 -13
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_head.rb +13 -11
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_delete_modal.rb +9 -9
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_header.rb +2 -2
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_header_bar.rb +8 -8
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_pagination.rb +9 -9
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_row.rb +3 -4
- data/app/components/ruby_cms/admin/bulk_action_table/bulk_actions.rb +25 -24
- data/app/controllers/ruby_cms/admin/base_controller.rb +10 -4
- data/app/controllers/ruby_cms/admin/content_blocks_controller.rb +4 -3
- data/app/controllers/ruby_cms/admin/locale_controller.rb +2 -1
- data/app/controllers/ruby_cms/admin/user_permissions_controller.rb +25 -7
- data/app/helpers/ruby_cms/settings_helper.rb +19 -9
- data/app/javascript/controllers/ruby_cms/bulk_action_table_controller.js +53 -12
- data/app/models/ruby_cms/permission.rb +38 -9
- data/app/models/ruby_cms/permittable.rb +0 -2
- data/app/views/layouts/ruby_cms/_admin_sidebar.html.erb +2 -2
- data/app/views/layouts/ruby_cms/admin.html.erb +13 -17
- data/app/views/ruby_cms/admin/content_blocks/index.html.erb +0 -11
- data/app/views/ruby_cms/admin/content_blocks/show.html.erb +204 -85
- data/app/views/ruby_cms/admin/settings/index.html.erb +214 -175
- data/app/views/ruby_cms/admin/user_permissions/index.html.erb +32 -2
- data/app/views/ruby_cms/admin/users/_row.html.erb +4 -1
- data/config/locales/en.yml +4 -0
- data/lib/ruby_cms/engine.rb +20 -12
- data/lib/ruby_cms/version.rb +1 -1
- data/lib/ruby_cms.rb +24 -0
- metadata +4 -3
- data/app/views/ruby_cms/admin/content_blocks/edit.html.erb +0 -17
data/lib/ruby_cms/engine.rb
CHANGED
|
@@ -98,6 +98,14 @@ module RubyCms
|
|
|
98
98
|
RubyCms::Settings.import_initializer_values!
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
# After host initializers (e.g. register_permission_keys), ensure Permission rows exist
|
|
102
|
+
# so can?(:manage_backups) and other keys do not fail on Permission.exists? checks.
|
|
103
|
+
initializer "ruby_cms.ensure_permission_rows", after: :load_config_initializers do
|
|
104
|
+
RubyCms::Permission.ensure_defaults!
|
|
105
|
+
rescue StandardError => e
|
|
106
|
+
Rails.logger.warn("[RubyCMS] Permission.ensure_defaults! skipped: #{e.message}")
|
|
107
|
+
end
|
|
108
|
+
|
|
101
109
|
def self.register_main_nav_items
|
|
102
110
|
RubyCms.nav_register(
|
|
103
111
|
key: :dashboard,
|
|
@@ -105,6 +113,7 @@ module RubyCms
|
|
|
105
113
|
path: lambda(&:ruby_cms_admin_root_path),
|
|
106
114
|
icon: dashboard_icon_path,
|
|
107
115
|
section: RubyCms::NAV_SECTION_MAIN,
|
|
116
|
+
permission: :manage_admin,
|
|
108
117
|
order: 1
|
|
109
118
|
)
|
|
110
119
|
RubyCms.nav_register(
|
|
@@ -113,6 +122,7 @@ module RubyCms
|
|
|
113
122
|
path: lambda(&:ruby_cms_admin_visual_editor_path),
|
|
114
123
|
icon: visual_editor_icon_path,
|
|
115
124
|
section: RubyCms::NAV_SECTION_MAIN,
|
|
125
|
+
permission: :manage_content_blocks,
|
|
116
126
|
order: 2
|
|
117
127
|
)
|
|
118
128
|
RubyCms.nav_register(
|
|
@@ -121,6 +131,7 @@ module RubyCms
|
|
|
121
131
|
path: lambda(&:ruby_cms_admin_content_blocks_path),
|
|
122
132
|
icon: content_blocks_icon_path,
|
|
123
133
|
section: RubyCms::NAV_SECTION_MAIN,
|
|
134
|
+
permission: :manage_content_blocks,
|
|
124
135
|
order: 3
|
|
125
136
|
)
|
|
126
137
|
end
|
|
@@ -163,6 +174,7 @@ module RubyCms
|
|
|
163
174
|
path: lambda(&:ruby_cms_admin_permissions_path),
|
|
164
175
|
section: RubyCms::NAV_SECTION_BOTTOM,
|
|
165
176
|
icon: permissions_icon_path,
|
|
177
|
+
permission: :manage_permissions,
|
|
166
178
|
order: 2
|
|
167
179
|
)
|
|
168
180
|
RubyCms.nav_register(
|
|
@@ -171,6 +183,7 @@ module RubyCms
|
|
|
171
183
|
path: lambda(&:ruby_cms_admin_visitor_errors_path),
|
|
172
184
|
section: RubyCms::NAV_SECTION_BOTTOM,
|
|
173
185
|
icon: visitor_errors_icon_path,
|
|
186
|
+
permission: :manage_visitor_errors,
|
|
174
187
|
order: 3
|
|
175
188
|
)
|
|
176
189
|
RubyCms.nav_register(
|
|
@@ -179,6 +192,7 @@ module RubyCms
|
|
|
179
192
|
path: lambda(&:ruby_cms_admin_users_path),
|
|
180
193
|
section: RubyCms::NAV_SECTION_BOTTOM,
|
|
181
194
|
icon: users_icon_path,
|
|
195
|
+
permission: :manage_permissions,
|
|
182
196
|
order: 4
|
|
183
197
|
)
|
|
184
198
|
RubyCms.nav_register(
|
|
@@ -187,6 +201,7 @@ module RubyCms
|
|
|
187
201
|
path: lambda(&:ruby_cms_admin_settings_path),
|
|
188
202
|
section: RubyCms::NAV_SECTION_BOTTOM,
|
|
189
203
|
icon: settings_icon_path,
|
|
204
|
+
permission: :manage_admin,
|
|
190
205
|
order: 5
|
|
191
206
|
)
|
|
192
207
|
end
|
|
@@ -358,13 +373,7 @@ module RubyCms
|
|
|
358
373
|
def self.grant_admin_permissions_to_admin_users
|
|
359
374
|
return unless defined?(::User) && User.column_names.include?("admin")
|
|
360
375
|
|
|
361
|
-
permission_keys =
|
|
362
|
-
manage_admin
|
|
363
|
-
manage_permissions
|
|
364
|
-
manage_content_blocks
|
|
365
|
-
manage_visitor_errors
|
|
366
|
-
manage_analytics
|
|
367
|
-
]
|
|
376
|
+
permission_keys = RubyCms::Permission.all_keys
|
|
368
377
|
permissions = RubyCms::Permission.where(key: permission_keys).index_by(&:key)
|
|
369
378
|
User.where(admin: true).find_each do |u|
|
|
370
379
|
permission_keys.each do |key|
|
|
@@ -416,11 +425,10 @@ module RubyCms
|
|
|
416
425
|
|
|
417
426
|
def self.grant_manage_admin_permission(user, email)
|
|
418
427
|
RubyCms::Permission.ensure_defaults!
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
perm = RubyCms::Permission.find_by!(key:)
|
|
428
|
+
RubyCms::Permission.all_keys.each do |key|
|
|
429
|
+
perm = RubyCms::Permission.find_by(key:)
|
|
430
|
+
next unless perm
|
|
431
|
+
|
|
424
432
|
RubyCms::UserPermission.find_or_create_by!(user: user, permission: perm)
|
|
425
433
|
end
|
|
426
434
|
puts "Granted full admin permissions to #{email}" # rubocop:disable Rails/Output
|
data/lib/ruby_cms/version.rb
CHANGED
data/lib/ruby_cms.rb
CHANGED
|
@@ -15,6 +15,30 @@ module RubyCms
|
|
|
15
15
|
mattr_accessor :nav_registry
|
|
16
16
|
self.nav_registry = []
|
|
17
17
|
|
|
18
|
+
# Permission configuration (available at boot, before models load)
|
|
19
|
+
DEFAULT_PERMISSION_KEYS = %w[
|
|
20
|
+
manage_admin
|
|
21
|
+
manage_permissions
|
|
22
|
+
manage_content_blocks
|
|
23
|
+
manage_visitor_errors
|
|
24
|
+
manage_analytics
|
|
25
|
+
].freeze
|
|
26
|
+
|
|
27
|
+
mattr_accessor :extra_permission_keys, default: []
|
|
28
|
+
mattr_accessor :permission_templates, default: {}
|
|
29
|
+
|
|
30
|
+
def self.register_permission_keys(*keys)
|
|
31
|
+
self.extra_permission_keys = (extra_permission_keys + keys.flatten.map(&:to_s)).uniq
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.register_permission_template(name, label:, keys:, description: nil)
|
|
35
|
+
permission_templates[name.to_sym] = {
|
|
36
|
+
label: label,
|
|
37
|
+
keys: keys.map(&:to_s),
|
|
38
|
+
description: description
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
18
42
|
# Navigation section keys. Order in sidebar: main, then Settings (bottom).
|
|
19
43
|
# User can add items to either via nav_register with section: NAV_SECTION_MAIN (order 10+)
|
|
20
44
|
# or section: NAV_SECTION_BOTTOM (order 10+).
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_cms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codebyjob
|
|
@@ -75,6 +75,8 @@ files:
|
|
|
75
75
|
- Rakefile
|
|
76
76
|
- app/components/ruby_cms/admin/admin_page.rb
|
|
77
77
|
- app/components/ruby_cms/admin/admin_page/admin_table_content.rb
|
|
78
|
+
- app/components/ruby_cms/admin/admin_page_header.rb
|
|
79
|
+
- app/components/ruby_cms/admin/admin_resource_card.rb
|
|
78
80
|
- app/components/ruby_cms/admin/base_component.rb
|
|
79
81
|
- app/components/ruby_cms/admin/bulk_action_table/bulk_action_table.rb
|
|
80
82
|
- app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_actions.rb
|
|
@@ -147,7 +149,6 @@ files:
|
|
|
147
149
|
- app/views/ruby_cms/admin/analytics/visitor_details.html.erb
|
|
148
150
|
- app/views/ruby_cms/admin/content_blocks/_form.html.erb
|
|
149
151
|
- app/views/ruby_cms/admin/content_blocks/_row.html.erb
|
|
150
|
-
- app/views/ruby_cms/admin/content_blocks/edit.html.erb
|
|
151
152
|
- app/views/ruby_cms/admin/content_blocks/index.html.erb
|
|
152
153
|
- app/views/ruby_cms/admin/content_blocks/new.html.erb
|
|
153
154
|
- app/views/ruby_cms/admin/content_blocks/show.html.erb
|
|
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
217
218
|
- !ruby/object:Gem::Version
|
|
218
219
|
version: '0'
|
|
219
220
|
requirements: []
|
|
220
|
-
rubygems_version: 4.0.
|
|
221
|
+
rubygems_version: 4.0.8
|
|
221
222
|
specification_version: 4
|
|
222
223
|
summary: Complete CMS engine for Rails with visual editor and content management
|
|
223
224
|
test_files: []
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<div class="flex flex-wrap items-center justify-between gap-4 mb-4">
|
|
2
|
-
<h1 class="text-lg font-semibold tracking-tight text-gray-900">Edit content block</h1>
|
|
3
|
-
<div class="flex items-center gap-2">
|
|
4
|
-
<%= link_to "Cancel",
|
|
5
|
-
ruby_cms_admin_content_block_path(@content_block),
|
|
6
|
-
class: "inline-flex h-9 items-center justify-center rounded-md border border-gray-200 bg-white px-4 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 transition-colors no-underline" %>
|
|
7
|
-
<button type="submit"
|
|
8
|
-
form="content-block-form"
|
|
9
|
-
class="inline-flex h-9 items-center justify-center rounded-md bg-gray-900 px-4 text-sm font-medium text-white shadow-sm hover:bg-gray-800 transition-colors">
|
|
10
|
-
Save
|
|
11
|
-
</button>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<div class="rounded-lg border border-gray-200/80 bg-white shadow-sm overflow-hidden">
|
|
16
|
-
<%= render "form" %>
|
|
17
|
-
</div>
|