plutonium 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -2
- data/app/assets/application.js.bk +31419 -0
- data/app/assets/plutonium-logo-original.png +0 -0
- data/app/assets/plutonium-logo-white.png +0 -0
- data/app/assets/plutonium-logo.png +0 -0
- data/app/assets/plutonium.css +1 -0
- data/app/assets/plutonium.ico +0 -0
- data/app/assets/plutonium.js +12416 -0
- data/app/assets/plutonium.js.map +7 -0
- data/app/assets/plutonium.min.js +39 -0
- data/app/assets/plutonium.min.js.map +7 -0
- data/app/views/application/_flash_alerts.html.erb +5 -2
- data/app/views/application/_flash_toasts.html.erb +2 -0
- data/app/views/application/_resource_header.html.erb +263 -697
- data/app/views/application/_resource_sidebar.html.erb +14 -12
- data/app/views/components/action_button/action_button_component.rb +3 -3
- data/app/views/components/attributes.rb +184 -0
- data/app/views/components/base.rb +19 -40
- data/app/views/components/block/block_component.html.erb +1 -1
- data/app/views/components/block/block_component.rb +11 -7
- data/app/views/components/breadcrumbs/breadcrumbs_component.rb +3 -3
- data/app/views/components/button/button_component.html.erb +2 -2
- data/app/views/components/button/button_component.rb +10 -5
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.html.erb +1 -0
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.rb +3 -3
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.html.erb +1 -2
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.rb +12 -5
- data/app/views/components/empty_card/empty_card_component.rb +3 -3
- data/app/views/components/form/form_builder.rb +1 -1
- data/app/views/components/form/form_component.rb +3 -3
- data/app/views/components/has_many_panel/has_many_panel_component.html.erb +25 -0
- data/app/views/components/has_many_panel/has_many_panel_component.rb +16 -0
- data/app/views/components/header/header_component.rb +3 -3
- data/app/views/components/interactive_action_form/interactive_action_form_component.rb +3 -3
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.html.erb +24 -0
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.rb +23 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.html.erb +4 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.rb +20 -0
- data/app/views/components/nav_user/nav_user_component.html.erb +50 -0
- data/app/views/components/nav_user/nav_user_component.rb +32 -0
- data/app/views/components/nav_user_link/nav_user_link_component.html.erb +7 -0
- data/app/views/components/nav_user_link/nav_user_link_component.rb +23 -0
- data/app/views/components/nav_user_section/nav_user_section_component.html.erb +7 -0
- data/app/views/components/nav_user_section/nav_user_section_component.rb +18 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +1 -3
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.rb +11 -5
- data/app/views/components/pagination/pagination_component.html.erb +1 -1
- data/app/views/components/pagination/pagination_component.rb +10 -7
- data/app/views/components/panel/panel_component.html.erb +13 -6
- data/app/views/components/panel/panel_component.rb +11 -5
- data/app/views/components/resource_header/resource_header_component.html.erb +81 -0
- data/app/views/components/resource_header/resource_header_component.rb +20 -0
- data/app/views/components/resource_layout/resource_layout_component.html.erb +32 -0
- data/app/views/components/resource_layout/resource_layout_component.rb +39 -0
- data/app/views/components/sidebar/sidebar_component.html.erb +3 -33
- data/app/views/components/sidebar/sidebar_component.rb +3 -3
- data/app/views/components/sidebar_menu/sidebar_menu_component.html.erb +4 -2
- data/app/views/components/sidebar_menu/sidebar_menu_component.rb +10 -6
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.html.erb +63 -71
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.rb +27 -8
- data/app/views/components/skeleton/table/table_component.html.erb +1 -1
- data/app/views/components/skeleton/table/table_component.rb +3 -3
- data/app/views/components/table/table_component.html.erb +40 -89
- data/app/views/components/table/table_component.rb +124 -28
- data/app/views/components/table_search_input/table_search_input_component.html.erb +1 -1
- data/app/views/components/table_search_input/table_search_input_component.rb +11 -6
- data/app/views/components/table_toolbar/table_toolbar_component.html.erb +1 -1
- data/app/views/components/table_toolbar/table_toolbar_component.rb +11 -3
- data/app/views/components/toolbar/toolbar_component.html.erb +2 -2
- data/app/views/components/toolbar/toolbar_component.rb +16 -8
- data/app/views/layouts/resource.html copy.erb +2 -2
- data/app/views/layouts/resource.html.erb +21 -37
- data/app/views/layouts/rodauth.html.erb +32 -25
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/app/views/resource/_resource_details.html.erb +8 -5
- data/app/views/resource/_resource_table.html.erb +70 -1
- data/app/views/resource/interactive_resource_collection_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_record_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_recordless_action.html.erb +1 -0
- data/app/views/resource/new.html.erb +1 -0
- data/app/views/rodauth/add_recovery_codes.html.erb +8 -7
- data/app/views/rodauth/otp_auth.html.erb +1 -1
- data/app/views/rodauth/otp_setup.html.erb +10 -8
- data/config/initializers/simple_form.rb +22 -2
- data/esbuild.config.js +35 -31
- data/lib/generators/pu/core/assets/assets_generator.rb +41 -0
- data/lib/generators/pu/core/assets/templates/tailwind.config.js +18 -0
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +3 -0
- data/lib/generators/pu/core/ruby/ruby_generator.rb +30 -0
- data/lib/generators/pu/core/ruby/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/install_generator.rb +35 -0
- data/lib/generators/pu/docker/install/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.dev.tt +30 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.tt +75 -0
- data/lib/generators/pu/docker/install/templates/bin/console +3 -0
- data/lib/generators/pu/docker/install/templates/bin/restart +3 -0
- data/lib/generators/pu/docker/install/templates/bin/shell +3 -0
- data/lib/generators/pu/docker/install/templates/docker-compose.yml +29 -0
- data/lib/generators/pu/gem/dotenv/dotenv_generator.rb +32 -0
- data/lib/generators/pu/gem/dotenv/templates/.env +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local.template +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.template +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.keep +0 -0
- data/lib/generators/pu/gem/dotenv/templates/config/initializers/001_ensure_required_env.rb +21 -0
- data/lib/generators/pu/gem/redis/redis_generator.rb +22 -0
- data/lib/generators/pu/gem/redis/templates/.keep +0 -0
- data/lib/generators/pu/gen/component/component_generator.rb +13 -10
- data/lib/generators/pu/gen/component/templates/component.html.erb.tt +1 -1
- data/lib/generators/pu/gen/component/templates/component.rb.tt +10 -4
- data/lib/generators/pu/lib/plutonium_generators/concerns/actions.rb +154 -32
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +6 -6
- data/lib/generators/pu/lib/plutonium_generators/installer.rb +1 -1
- data/lib/generators/pu/pkg/app/app_generator.rb +4 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/concerns/controller.rb.tt +28 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/controller.rb.tt +5 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/dashboard_controller.rb.tt +1 -1
- data/lib/generators/pu/res/conn/conn_generator.rb +4 -4
- data/lib/generators/pu/res/conn/templates/app/controllers/resource_controller.rb.tt +1 -1
- data/lib/generators/pu/res/model/model_generator.rb +3 -3
- data/lib/generators/pu/res/scaffold/templates/policy.rb.tt +6 -0
- data/lib/generators/pu/rodauth/account_generator.rb +10 -10
- data/lib/generators/pu/rodauth/install_generator.rb +9 -2
- data/lib/generators/pu/rodauth/migration/sequel/audit_logging.erb +2 -2
- data/lib/generators/pu/rodauth/migration_generator.rb +1 -1
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/account_rodauth_plugin.rb.tt +2 -2
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_plugin.rb.tt +0 -3
- data/lib/generators/pu/rodauth/templates/db/migrate/install_rodauth.rb.tt +5 -0
- data/lib/generators/pu/service/postgres/postgres_generator.rb +61 -0
- data/lib/generators/pu/service/postgres/templates/.keep +0 -0
- data/lib/generators/pu/service/postgres/templates/bin/initdb.d/create-multiple-postgresql-databases.sh +22 -0
- data/lib/generators/pu/service/postgres/templates/database.yml.tt +93 -0
- data/lib/generators/pu/service/sidekiq/sidekiq_generator.rb +57 -0
- data/lib/generators/pu/service/sidekiq/templates/.keep +0 -0
- data/lib/generators/pu/service/sidekiq/templates/app/sidekiq/sidekiq_job.rb +3 -0
- data/lib/generators/pu/service/sidekiq/templates/config/initializers/sidekiq.rb +53 -0
- data/lib/generators/pu/service/sidekiq/templates/config/sidekiq.yml +6 -0
- data/lib/plutonium/config.rb +2 -9
- data/lib/plutonium/core/associations/renderers/basic_renderer.rb +28 -0
- data/lib/plutonium/core/associations/renderers/factory.rb +36 -0
- data/lib/plutonium/core/associations/renderers/has_many_renderer.rb +16 -0
- data/lib/plutonium/core/autodiscovery/association_renderer_discoverer.rb +31 -0
- data/lib/plutonium/core/controllers/authorizable.rb +13 -17
- data/lib/plutonium/core/controllers/base.rb +3 -7
- data/lib/plutonium/core/controllers/entity_scoping.rb +3 -3
- data/lib/plutonium/core/controllers/presentable.rb +6 -1
- data/lib/plutonium/core/definers/association_renderer_definer.rb +33 -0
- data/lib/plutonium/core/fields/inputs/checkbox_input.rb +13 -0
- data/lib/plutonium/core/fields/inputs/factory.rb +1 -0
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +1 -1
- data/lib/plutonium/core/ui/detail.rb +1 -0
- data/lib/plutonium/helpers/application_helper.rb +8 -9
- data/lib/plutonium/helpers/assets_helper.rb +33 -0
- data/lib/plutonium/helpers/display_helper.rb +13 -0
- data/lib/plutonium/helpers/form_helper.rb +1 -1
- data/lib/plutonium/helpers.rb +1 -0
- data/lib/plutonium/icons.rb +12 -5
- data/lib/plutonium/pkg/app.rb +10 -0
- data/lib/plutonium/pundit/context.rb +18 -0
- data/lib/plutonium/pundit/policy_finder.rb +25 -0
- data/lib/plutonium/railtie.rb +24 -8
- data/lib/plutonium/reloader.rb +18 -7
- data/lib/plutonium/resource/controller.rb +5 -0
- data/lib/plutonium/resource/policy.rb +69 -47
- data/lib/plutonium/resource/presenter.rb +1 -0
- data/lib/plutonium/resource/query_object.rb +139 -130
- data/lib/plutonium/rodauth/controller_methods.rb +7 -3
- data/lib/plutonium/version.rb +1 -1
- data/lib/plutonium.rb +10 -54
- data/lib/tasks/create_rodauth_admin.rake +16 -0
- data/package-lock.json +782 -17
- data/package.json +31 -8
- data/postcss.config.js +17 -7
- data/src/.npmignore +2 -0
- data/src/js/controllers/color_mode_controller.js +41 -0
- data/src/js/controllers/frame_navigator_controller.js +99 -0
- data/src/js/controllers/has_many_panel_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_item_controller.js +8 -0
- data/{app/views/components/tab_bar/tab_bar_controller.js → src/js/controllers/nav_user_controller.js} +2 -2
- data/src/js/controllers/nav_user_link_controller.js +8 -0
- data/src/js/controllers/nav_user_section_controller.js +8 -0
- data/src/js/controllers/register_controllers.js +45 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_dismiss_controller.js +2 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_drop_down_controller.js +2 -0
- data/src/js/controllers/resource_header_controller.js +8 -0
- data/src/js/controllers/resource_layout_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_item_controller.js +8 -0
- data/src/js/core.js +4 -0
- data/{app/assets/javascripts/plutonium-app.js → src/js/plutonium.js} +1 -1
- data/{app/assets/javascripts → src/js}/turbo/turbo_debug.js +2 -4
- data/tailwind.config.js +85 -84
- metadata +106 -41
- data/app/assets/build/plutonium.js +0 -5122
- data/app/assets/javascripts/controllers/index.js +0 -34
- data/app/assets/javascripts/plutonium.js +0 -1
- data/app/views/application/_color_modes.html.erb +0 -57
- data/app/views/components/tab_bar/tab_bar_component.html.erb +0 -11
- data/app/views/components/tab_bar/tab_bar_component.rb +0 -9
- data/app/views/resource/_nav_user.html.erb +0 -4
- data/app/views/resource/_tab_menu.html.erb +0 -13
- data/css.manifest +0 -3
- data/js.manifest +0 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/app_controller.rb.tt +0 -5
- data/lib/generators/pu/pkg/app/templates/app/controllers/package_controller.rb.tt +0 -26
- data/public/plutonium-assets/application.css +0 -25086
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js +0 -6
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js.map +0 -7
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js +0 -39
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js.map +0 -7
- data/public/plutonium-assets/plutonium.2d4f0c333cd000051d3b.css +0 -3424
- data/public/plutonium-assets/plutonium.50232e35b5495f5ad90d.css +0 -3415
- /data/{app/assets/build → lib/generators/pu/core/assets/templates}/.keep +0 -0
- /data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_app.rb.tt +0 -0
- /data/{app/assets/stylesheets → src/css}/plutonium.css +0 -0
- /data/{app/views/components/form → src/js/controllers}/form_controller.js +0 -0
- /data/{app/views/components/interactive_action_form → src/js/controllers}/interactive_action_form_controller.js +0 -0
- /data/{app/views/components/nested_resource_form_fields → src/js/controllers}/nested_resource_form_fields_controller.js +0 -0
- /data/{app/views/components/table → src/js/controllers}/table_controller.js +0 -0
- /data/{app/views/components/table_search_input → src/js/controllers}/table_search_input_controller.js +0 -0
- /data/{app/views/components/table_toolbar → src/js/controllers}/table_toolbar_controller.js +0 -0
- /data/{app/views/components/toolbar → src/js/controllers}/toolbar_controller.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/index.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_actions.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_frame_monkey_patch.js +0 -0
@@ -17,7 +17,7 @@ module Pu
|
|
17
17
|
source_feature = select_feature
|
18
18
|
source_module = (source_feature == "main_app") ? "ResourceRecord" : "#{source_feature.classify}::ResourceRecord"
|
19
19
|
|
20
|
-
|
20
|
+
Plutonium.eager_load_rails!
|
21
21
|
available_resources = source_module.constantize.descendants.map(&:to_s)
|
22
22
|
selected_resources = prompt.multi_select("Select resources", available_resources)
|
23
23
|
|
@@ -27,9 +27,9 @@ module Pu
|
|
27
27
|
@resource_class = resource
|
28
28
|
|
29
29
|
template "app/controllers/resource_controller.rb", "packages/#{package_namespace}/app/controllers/#{package_namespace}/#{resource.pluralize.underscore}_controller.rb"
|
30
|
-
template "app/policies/resource_policy.rb", "packages/#{package_namespace}/app/policies/#{package_namespace}/#{resource.underscore}_policy.rb"
|
31
|
-
template "app/presenters/resource_presenter.rb", "packages/#{package_namespace}/app/presenters/#{package_namespace}/#{resource.underscore}_presenter.rb"
|
32
|
-
template "app/query_objects/resource_query_object.rb", "packages/#{package_namespace}/app/query_objects/#{package_namespace}/#{resource.underscore}_query_object.rb"
|
30
|
+
# template "app/policies/resource_policy.rb", "packages/#{package_namespace}/app/policies/#{package_namespace}/#{resource.underscore}_policy.rb"
|
31
|
+
# template "app/presenters/resource_presenter.rb", "packages/#{package_namespace}/app/presenters/#{package_namespace}/#{resource.underscore}_presenter.rb"
|
32
|
+
# template "app/query_objects/resource_query_object.rb", "packages/#{package_namespace}/app/query_objects/#{package_namespace}/#{resource.underscore}_query_object.rb"
|
33
33
|
|
34
34
|
insert_into_file "packages/#{package_namespace}/lib/engine.rb",
|
35
35
|
indent("register_resource ::#{resource}\n", 6),
|
@@ -14,9 +14,9 @@ module Pu
|
|
14
14
|
def run_create_model
|
15
15
|
model_class = class_name.safe_constantize
|
16
16
|
if model_class.present? && !model_class.include?(Plutonium::Resource::Record)
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
gsub_file File.join("app/models", class_path, "#{file_name}.rb"),
|
18
|
+
"< ApplicationRecord",
|
19
|
+
"< ResourceRecord"
|
20
20
|
end
|
21
21
|
|
22
22
|
create_model_file if create_files?
|
@@ -19,5 +19,11 @@ class <%= class_name %>Policy < <%= [feature_package_name, "ResourcePolicy"].joi
|
|
19
19
|
def permitted_attributes_for_read
|
20
20
|
<%= attributes.select{ |a| !a.rich_text? && !a.password_digest? && !a.token? }.map(&:name).map(&:to_sym).inspect %>
|
21
21
|
end
|
22
|
+
|
23
|
+
# Associations
|
24
|
+
|
25
|
+
def permitted_associations
|
26
|
+
%i[]
|
27
|
+
end
|
22
28
|
end
|
23
29
|
<% end -%>
|
@@ -28,7 +28,7 @@ module Pu
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def create_rodauth_app
|
31
|
-
template "app/
|
31
|
+
template "app/rodauth/account_rodauth_plugin.rb", "app/rodauth/#{account_path}_rodauth_plugin.rb"
|
32
32
|
end
|
33
33
|
|
34
34
|
def configure_rodauth_plugin
|
@@ -36,16 +36,16 @@ module Pu
|
|
36
36
|
plugin_name = indent(
|
37
37
|
"configure ::#{account_path.classify}RodauthPlugin#{", :#{table_prefix}" unless primary?}\n", 2
|
38
38
|
)
|
39
|
-
gsub_file "app/
|
40
|
-
insert_into_file "app/
|
39
|
+
gsub_file "app/rodauth/rodauth_app.rb", /.*# configure RodauthMain\n/, ""
|
40
|
+
insert_into_file "app/rodauth/rodauth_app.rb", plugin_name, after: "# auth configuration\n"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def configure_rodauth_plugin_load_route
|
45
45
|
in_root do
|
46
46
|
route_config = indent("r.rodauth#{"(:#{table_prefix})" unless primary?}\n", 4)
|
47
|
-
gsub_file "app/
|
48
|
-
insert_into_file "app/
|
47
|
+
gsub_file "app/rodauth/rodauth_app.rb", /.*# r\.rodauth\n/, ""
|
48
|
+
insert_into_file "app/rodauth/rodauth_app.rb", route_config, after: "# auth route configuration\n"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,15 +54,15 @@ module Pu
|
|
54
54
|
plugin_config = indent(
|
55
55
|
"rodauth#{"(:#{table_prefix})" unless primary?}.load_memory # autologin remembered #{table}\n", 4
|
56
56
|
)
|
57
|
-
gsub_file "app/
|
57
|
+
gsub_file "app/rodauth/rodauth_app.rb", /.*# rodauth\.load_memory.*\n/, ""
|
58
58
|
|
59
59
|
if remember?
|
60
|
-
insert_into_file "app/
|
60
|
+
insert_into_file "app/rodauth/rodauth_app.rb", plugin_config, after: "# plugin route configuration\n"
|
61
61
|
else
|
62
|
-
gsub_file "app/
|
62
|
+
gsub_file "app/rodauth/rodauth_app.rb", plugin_config, ""
|
63
63
|
in_root do
|
64
|
-
unless File.read("app/
|
65
|
-
insert_into_file "app/
|
64
|
+
unless File.read("app/rodauth/rodauth_app.rb").match?(/.*\.load_memory # autologin/)
|
65
|
+
insert_into_file "app/rodauth/rodauth_app.rb", indent("# rodauth.load_memory # autologin remembered users\n", 4),
|
66
66
|
after: "# plugin route configuration\n"
|
67
67
|
end
|
68
68
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require "rails/generators/base"
|
2
|
+
require "rails/generators/active_record/migration"
|
2
3
|
require "securerandom"
|
3
4
|
|
4
5
|
module Pu
|
5
6
|
module Rodauth
|
6
7
|
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
include ::ActiveRecord::Generators::Migration
|
9
|
+
|
7
10
|
SEQUEL_ADAPTERS = {
|
8
11
|
"postgresql" => (RUBY_ENGINE == "jruby") ? "postgresql" : "postgres",
|
9
12
|
"mysql2" => (RUBY_ENGINE == "jruby") ? "mysql" : "mysql2",
|
@@ -31,8 +34,8 @@ module Pu
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def create_rodauth_app
|
34
|
-
template "app/
|
35
|
-
template "app/
|
37
|
+
template "app/rodauth/rodauth_app.rb"
|
38
|
+
template "app/rodauth/rodauth_plugin.rb"
|
36
39
|
end
|
37
40
|
|
38
41
|
def add_dev_config
|
@@ -41,6 +44,10 @@ module Pu
|
|
41
44
|
before: /^end/
|
42
45
|
end
|
43
46
|
|
47
|
+
def create_install_migration
|
48
|
+
migration_template "db/migrate/install_rodauth.rb", "db/migrate/install_rodauth.rb" # , File.join(db_migrate_path, "#{migration_name}.rb")
|
49
|
+
end
|
50
|
+
|
44
51
|
def show_instructions
|
45
52
|
readme "INSTRUCTIONS" if behavior == :invoke
|
46
53
|
end
|
@@ -12,6 +12,6 @@ create_table :<%= table_prefix %>_authentication_audit_logs do
|
|
12
12
|
<% else -%>
|
13
13
|
String :metadata
|
14
14
|
<% end -%>
|
15
|
-
index [:<%= table_prefix %>_id, :at], name:
|
16
|
-
index :at, name:
|
15
|
+
index [:<%= table_prefix %>_id, :at], name: :<%= table_prefix %>_audit_<%= table_prefix %>_at_idx
|
16
|
+
index :at, name: :<%= table_prefix %>_audit_at_idx
|
17
17
|
end
|
@@ -38,8 +38,8 @@ class <%= account_path.classify %>RodauthPlugin < RodauthPlugin
|
|
38
38
|
rails_account_model { <%= account_path.classify %> }
|
39
39
|
<% if verify_account? -%>
|
40
40
|
|
41
|
-
# Set password
|
42
|
-
verify_account_set_password? false
|
41
|
+
# Set password password during create account.
|
42
|
+
# verify_account_set_password? false
|
43
43
|
<% end -%>
|
44
44
|
|
45
45
|
# Change some default param keys.
|
@@ -50,9 +50,6 @@ class RodauthPlugin < Rodauth::Rails::Auth
|
|
50
50
|
# Store account status in an integer column without foreign key constraint.
|
51
51
|
account_status_column :status
|
52
52
|
|
53
|
-
# Set password when verifying account.
|
54
|
-
# verify_account_set_password? false
|
55
|
-
|
56
53
|
# Change some default param keys/labels.
|
57
54
|
login_label "Email"
|
58
55
|
login_param "email"
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Service
|
7
|
+
class PostgresGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
11
|
+
|
12
|
+
desc "Set up postgres for project"
|
13
|
+
|
14
|
+
def start
|
15
|
+
bundle "goldiloader"
|
16
|
+
template "database.yml", "config/database.yml", force: true
|
17
|
+
bin_directory
|
18
|
+
add_compose_env :POSTGRES_HOST, service
|
19
|
+
add_compose_dependency service
|
20
|
+
add_compose_service service, compose_config
|
21
|
+
add_docker_dependency docker_deps
|
22
|
+
rescue => e
|
23
|
+
exception "#{self.class} failed:", e
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def service
|
29
|
+
:postgres
|
30
|
+
end
|
31
|
+
|
32
|
+
def compose_config
|
33
|
+
<<~COMPOSE
|
34
|
+
postgres:
|
35
|
+
image: postgres:15 # postgres
|
36
|
+
# postgres properties
|
37
|
+
environment: # postgres
|
38
|
+
POSTGRES_MULTIPLE_DATABASES: #{db_prefix}_development,#{db_prefix}_test # postgres
|
39
|
+
POSTGRES_USER: postgres # postgres
|
40
|
+
POSTGRES_PASSWORD: postgres # postgres
|
41
|
+
volumes: # postgres
|
42
|
+
- "./.volumes/postgres/data:/var/lib/postgresql/data" # postgres
|
43
|
+
- "./bin/initdb.d:/docker-entrypoint-initdb.d" # postgres
|
44
|
+
COMPOSE
|
45
|
+
end
|
46
|
+
|
47
|
+
def docker_deps
|
48
|
+
<<~DEPS
|
49
|
+
# Install packages needed for postgres
|
50
|
+
RUN apt-get update -qq && \\
|
51
|
+
apt-get install --no-install-recommends -y curl postgresql-client && \\
|
52
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
53
|
+
DEPS
|
54
|
+
end
|
55
|
+
|
56
|
+
def db_prefix
|
57
|
+
Plutonium.application_name.underscore
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
set -u
|
5
|
+
|
6
|
+
function create_user_and_database() {
|
7
|
+
local database=$1
|
8
|
+
echo " Creating user and database '$database'"
|
9
|
+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
10
|
+
CREATE USER $database;
|
11
|
+
CREATE DATABASE $database;
|
12
|
+
GRANT ALL PRIVILEGES ON DATABASE $database TO $database;
|
13
|
+
EOSQL
|
14
|
+
}
|
15
|
+
|
16
|
+
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
|
17
|
+
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
|
18
|
+
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
|
19
|
+
create_user_and_database $db
|
20
|
+
done
|
21
|
+
echo "Multiple databases created"
|
22
|
+
fi
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# PostgreSQL. Versions 9.3 and up are supported.
|
2
|
+
#
|
3
|
+
# Install the pg driver:
|
4
|
+
# gem install pg
|
5
|
+
# On macOS with Homebrew:
|
6
|
+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
7
|
+
# On Windows:
|
8
|
+
# gem install pg
|
9
|
+
# Choose the win32 build.
|
10
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
11
|
+
#
|
12
|
+
# Configure Using Gemfile
|
13
|
+
# gem "pg"
|
14
|
+
#
|
15
|
+
default: &default
|
16
|
+
adapter: postgresql
|
17
|
+
encoding: unicode
|
18
|
+
# For details on connection pooling, see Rails configuration guide
|
19
|
+
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
20
|
+
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
21
|
+
# Timeouts
|
22
|
+
connect_timeout: 1
|
23
|
+
checkout_timeout: 1
|
24
|
+
variables:
|
25
|
+
statement_timeout: <%%= ENV["STATEMENT_TIMEOUT"] || "15s" %> # or ms, min, etc
|
26
|
+
|
27
|
+
local: &local
|
28
|
+
host: <%%= ENV["POSTGRES_HOST"] %>
|
29
|
+
port: 5432
|
30
|
+
username: postgres
|
31
|
+
password: postgres
|
32
|
+
|
33
|
+
development:
|
34
|
+
<<: [*default, *local]
|
35
|
+
database: <%= db_prefix %>_development
|
36
|
+
|
37
|
+
# The specified database role being used to connect to PostgreSQL.
|
38
|
+
# To create additional roles in PostgreSQL see `$ createuser --help`.
|
39
|
+
# When left blank, PostgreSQL will use the default role. This is
|
40
|
+
# the same name as the operating system user running Rails.
|
41
|
+
#username: <%= db_prefix %>
|
42
|
+
|
43
|
+
# The password associated with the PostgreSQL role (username).
|
44
|
+
#password:
|
45
|
+
|
46
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
47
|
+
# domain socket that doesn't need configuration. Windows does not have
|
48
|
+
# domain sockets, so uncomment these lines.
|
49
|
+
#host: localhost
|
50
|
+
|
51
|
+
# The TCP port the server listens on. Defaults to 5432.
|
52
|
+
# If your server runs on a different port number, change accordingly.
|
53
|
+
#port: 5432
|
54
|
+
|
55
|
+
# Schema search path. The server defaults to $user,public
|
56
|
+
#schema_search_path: myapp,sharedapp,public
|
57
|
+
|
58
|
+
# Minimum log levels, in increasing order:
|
59
|
+
# debug5, debug4, debug3, debug2, debug1,
|
60
|
+
# log, notice, warning, error, fatal, and panic
|
61
|
+
# Defaults to warning.
|
62
|
+
#min_messages: notice
|
63
|
+
|
64
|
+
# Warning: The database defined as "test" will be erased and
|
65
|
+
# re-generated from your development database when you run "rake".
|
66
|
+
# Do not set this db to the same as development or production.
|
67
|
+
test:
|
68
|
+
<<: [*default, *local]
|
69
|
+
database: <%= db_prefix %>_test
|
70
|
+
|
71
|
+
# As with config/credentials.yml, you never want to store sensitive information,
|
72
|
+
# like your database password, in your source code. If your source code is
|
73
|
+
# ever seen by anyone, they now have access to your database.
|
74
|
+
#
|
75
|
+
# Instead, provide the password or a full connection URL as an environment
|
76
|
+
# variable when you boot the app. For example:
|
77
|
+
#
|
78
|
+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
79
|
+
#
|
80
|
+
# If the connection URL is provided in the special DATABASE_URL environment
|
81
|
+
# variable, Rails will automatically merge its configuration values on top of
|
82
|
+
# the values provided in this file. Alternatively, you can specify a connection
|
83
|
+
# URL environment variable explicitly:
|
84
|
+
#
|
85
|
+
# production:
|
86
|
+
# url: <%%= ENV["MY_APP_DATABASE_URL"] %>
|
87
|
+
#
|
88
|
+
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
89
|
+
# for a full overview on how database connection configuration can be specified.
|
90
|
+
#
|
91
|
+
production:
|
92
|
+
<<: *default
|
93
|
+
database: <%= db_prefix %>_production
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Service
|
7
|
+
class SidekiqGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
11
|
+
|
12
|
+
desc "Set up sidekiq for project"
|
13
|
+
|
14
|
+
def start
|
15
|
+
bundle "sidekiq"
|
16
|
+
directory "app"
|
17
|
+
directory "config"
|
18
|
+
|
19
|
+
add_compose_env :REDIS_QUEUE_URL, "redis://redis-queue/0"
|
20
|
+
add_required_env_vars :REDIS_QUEUE_URL
|
21
|
+
add_compose_dependency redis_service
|
22
|
+
add_compose_service service, sidekiq_compose_config
|
23
|
+
add_compose_service redis_service, redis_compose_config
|
24
|
+
rescue => e
|
25
|
+
exception "#{self.class} failed:", e
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def service
|
31
|
+
:sidekiq
|
32
|
+
end
|
33
|
+
|
34
|
+
def redis_service
|
35
|
+
:"redis-queue"
|
36
|
+
end
|
37
|
+
|
38
|
+
def sidekiq_compose_config
|
39
|
+
<<~COMPOSE
|
40
|
+
sidekiq:
|
41
|
+
<<: *app # sidekiq
|
42
|
+
command: /bin/sh -c "bundle && sidekiq" # sidekiq
|
43
|
+
# sidekiq properties
|
44
|
+
COMPOSE
|
45
|
+
end
|
46
|
+
|
47
|
+
def redis_compose_config
|
48
|
+
<<~COMPOSE
|
49
|
+
redis-queue:
|
50
|
+
image: redis # redis-queue
|
51
|
+
command: bash -c "redis-server --maxmemory-policy noeviction" # redis-queue
|
52
|
+
# redis-queue properties
|
53
|
+
COMPOSE
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
redis_config = {
|
4
|
+
url: ENV.fetch("REDIS_QUEUE_URL", ""),
|
5
|
+
connect_timeout: 1, # Defaults to 1 second
|
6
|
+
read_timeout: 0.2, # Defaults to 1 second
|
7
|
+
write_timeout: 0.2, # Defaults to 1 second
|
8
|
+
# https://github.com/redis/redis-rb#reconnections
|
9
|
+
reconnect_attempts: [ # Defaults to 1
|
10
|
+
0, # retry immediately
|
11
|
+
0.25, # retry a second time after 250ms
|
12
|
+
1, # retry a third time after another 1s
|
13
|
+
5, # retry a fourth time after another 5s
|
14
|
+
10 # retry a fifth and final time after another 15s
|
15
|
+
]
|
16
|
+
}
|
17
|
+
|
18
|
+
Sidekiq.configure_client do |config|
|
19
|
+
config.redis = redis_config
|
20
|
+
|
21
|
+
# Configure sidekiq client here
|
22
|
+
end
|
23
|
+
|
24
|
+
Sidekiq.configure_server do |config|
|
25
|
+
config.redis = redis_config
|
26
|
+
config.logger = Rails.logger = Sidekiq::Logger.new($stdout)
|
27
|
+
config.death_handlers << lambda { |job, exception|
|
28
|
+
worker = job["wrapped"].safe_constantize
|
29
|
+
worker&.sidekiq_retries_exhausted_block&.call(job, exception)
|
30
|
+
}
|
31
|
+
|
32
|
+
if defined?(Prosopite)
|
33
|
+
# configure prosopite
|
34
|
+
config.server_middleware do |chain|
|
35
|
+
require "prosopite/middleware/sidekiq"
|
36
|
+
chain.add(Prosopite::Middleware::Sidekiq)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Configure sidekiq server here
|
41
|
+
end
|
42
|
+
|
43
|
+
# Use sidekiq
|
44
|
+
Rails.application.config.active_job.queue_adapter = :sidekiq
|
45
|
+
|
46
|
+
# nil will use the "default" queue
|
47
|
+
# some of these options will not work with your Rails version. add/remove as necessary
|
48
|
+
Rails.application.config.action_mailer.deliver_later_queue_name = nil if Rails.application.config.respond_to?(:action_mailbox) # defaults to "mailers"
|
49
|
+
Rails.application.config.action_mailbox.queues.routing = nil if Rails.application.config.respond_to?(:action_mailbox) # defaults to "action_mailbox_routing"
|
50
|
+
Rails.application.config.active_storage.queues.analysis = nil if Rails.application.config.respond_to?(:active_storage) # defaults to "active_storage_analysis"
|
51
|
+
Rails.application.config.active_storage.queues.purge = nil if Rails.application.config.respond_to?(:active_storage) # defaults to "active_storage_purge"
|
52
|
+
Rails.application.config.active_storage.queues.mirror = nil if Rails.application.config.respond_to?(:active_storage) # defaults to "active_storage_mirror"
|
53
|
+
Rails.application.config.active_storage.queues.purge = :low if Rails.application.config.respond_to?(:active_storage) # put purge jobs in the `low` queue
|
data/lib/plutonium/config.rb
CHANGED
@@ -3,14 +3,7 @@ require "active_model"
|
|
3
3
|
|
4
4
|
module Plutonium
|
5
5
|
module Config
|
6
|
-
mattr_accessor :
|
7
|
-
@@
|
8
|
-
"<link rel=\"stylesheet\" href=\"#{Plutonium.stylesheet_link}\" />"
|
9
|
-
}
|
10
|
-
|
11
|
-
mattr_accessor :script_tag
|
12
|
-
@@script_tag = ->(view_context) {
|
13
|
-
"<script src=\"#{Plutonium.script_link}\"></script>"
|
14
|
-
}
|
6
|
+
mattr_accessor :logo
|
7
|
+
@@logo = "plutonium-logo.png"
|
15
8
|
end
|
16
9
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Core
|
3
|
+
module Associations
|
4
|
+
module Renderers
|
5
|
+
class BasicRenderer
|
6
|
+
attr_reader :name, :label, :reflection, :user_options
|
7
|
+
|
8
|
+
def initialize(name, label:, reflection:, **user_options)
|
9
|
+
@name = name
|
10
|
+
@label = label
|
11
|
+
@reflection = reflection
|
12
|
+
@user_options = user_options
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(view_context, record)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
def options = @options ||= renderer_options.deep_merge(@user_options)
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def renderer_options = {}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "simple_form/map_type"
|
2
|
+
|
3
|
+
module Plutonium
|
4
|
+
module Core
|
5
|
+
module Associations
|
6
|
+
module Renderers
|
7
|
+
class Factory
|
8
|
+
extend ::SimpleForm::MapType
|
9
|
+
|
10
|
+
map_type :has_many, to: Plutonium::Core::Associations::Renderers::HasManyRenderer
|
11
|
+
|
12
|
+
def self.build(name, type:, **)
|
13
|
+
mapping = mappings[type]
|
14
|
+
raise ArgumentError, "Unknown association renderer type #{type}" unless mapping.present?
|
15
|
+
|
16
|
+
mapping.new(name, **)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.for_resource_association(resource_class, attr_name, **options)
|
20
|
+
options[:label] ||= resource_class.human_attribute_name(attr_name)
|
21
|
+
|
22
|
+
association = resource_class.try(:reflect_on_association, attr_name)
|
23
|
+
raise ArgumentError, "#{attr_name} is not a valid association of #{resource_class}" unless association.present?
|
24
|
+
raise ArgumentError, "#{association.klass} does is not a resource record" unless association.klass.include?(Plutonium::Resource::Record)
|
25
|
+
|
26
|
+
type = association.macro
|
27
|
+
raise NotImplementedError, "#{macro} associations are currently not supported." unless type == :has_many
|
28
|
+
|
29
|
+
options[:reflection] = association
|
30
|
+
build(attr_name, type:, **options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Core
|
3
|
+
module Associations
|
4
|
+
module Renderers
|
5
|
+
class HasManyRenderer < BasicRenderer
|
6
|
+
def render(view_context, record)
|
7
|
+
view_context.render_component :has_many_panel,
|
8
|
+
title: label,
|
9
|
+
src: view_context.resource_url_for(reflection.klass, parent: record),
|
10
|
+
**options
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Core
|
3
|
+
module Autodiscovery
|
4
|
+
module AssociationRendererDiscoverer
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include Discoverer
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
def autodiscovery_association_renderer_cache = @autodiscovery_association_renderer_cache ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# If cache_discovery is enabled, use the class level cache that persists
|
15
|
+
# between requests, otherwise use the instance one.
|
16
|
+
def autodiscovery_association_renderer_cache
|
17
|
+
if Rails.application.config.plutonium.cache_discovery
|
18
|
+
self.class.autodiscovery_association_renderer_cache
|
19
|
+
else
|
20
|
+
@autodiscovery_association_renderer_cache ||= {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def autodiscover_association_renderer(name)
|
25
|
+
autodiscovery_association_renderer_cache[name] ||=
|
26
|
+
Plutonium::Core::Associations::Renderers::Factory.for_resource_association(resource_class, name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|