plutonium 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.standard.yml +4 -0
- data/.vscode/extensions.json +15 -0
- data/.vscode/launch.json +7 -0
- data/.vscode/settings.json +35 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README copy.md +84 -0
- data/README.md +67 -0
- data/Rakefile +8 -0
- data/app/views/layouts/resource.html.erb +43 -0
- data/app/views/resource/_color_modes.html.erb +55 -0
- data/app/views/resource/_details.html.erb +6 -0
- data/app/views/resource/_empty_card.html.erb +12 -0
- data/app/views/resource/_flash.html.erb +9 -0
- data/app/views/resource/_form.html.erb +32 -0
- data/app/views/resource/_header.html.erb +8 -0
- data/app/views/resource/_interactive_resource_action_form.html.erb +67 -0
- data/app/views/resource/_messages.html.erb +1 -0
- data/app/views/resource/_metric_card.html.erb +16 -0
- data/app/views/resource/_nav_user.html.erb +4 -0
- data/app/views/resource/_pagination.html.erb +6 -0
- data/app/views/resource/_pagy_pagination.html.erb +15 -0
- data/app/views/resource/_resource.html.erb +1 -0
- data/app/views/resource/_resource.rabl +5 -0
- data/app/views/resource/_sidebar.html.erb +11 -0
- data/app/views/resource/_sidebar_menu.html.erb +1 -0
- data/app/views/resource/_tab_menu.html.erb +13 -0
- data/app/views/resource/_table.html.erb +78 -0
- data/app/views/resource/_table_actions.html.erb +15 -0
- data/app/views/resource/_toast.html.erb +26 -0
- data/app/views/resource/_toolbar.html.erb +22 -0
- data/app/views/resource/_toolbar_actions.html.erb +16 -0
- data/app/views/resource/_toolbar_breadcrumbs.html.erb +32 -0
- data/app/views/resource/_toolbar_search_input.erb +27 -0
- data/app/views/resource/edit.html.erb +10 -0
- data/app/views/resource/errors.rabl +3 -0
- data/app/views/resource/index.html.erb +19 -0
- data/app/views/resource/index.rabl +3 -0
- data/app/views/resource/interactive_resource_collection_action.html.erb +11 -0
- data/app/views/resource/interactive_resource_record_action.html.erb +11 -0
- data/app/views/resource/interactive_resource_recordless_action.html.erb +11 -0
- data/app/views/resource/new.html.erb +11 -0
- data/app/views/resource/readme.md +16 -0
- data/app/views/resource/show.html.erb +14 -0
- data/app/views/resource/show.rabl +3 -0
- data/brakeman.ignore +51 -0
- data/lib/active_model/validations/array_validator.rb +74 -0
- data/lib/active_model/validations/attached_validator.rb +17 -0
- data/lib/active_model/validations/url_validator.rb +51 -0
- data/lib/generators/pu/core/install/install_generator.rb +43 -0
- data/lib/generators/pu/core/install/templates/.keep +0 -0
- data/lib/generators/pu/core/install/templates/app/controllers/resource_controller.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/interactions/resource_interaction.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/models/resource_record.rb.tt +5 -0
- data/lib/generators/pu/core/install/templates/app/policies/resource_policy.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/presenters/resource_presenter.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +2 -0
- data/lib/generators/pu/core/install/templates/config/packages.rb +3 -0
- data/lib/generators/pu/gem/pagy/pagy_generator.rb +25 -0
- data/lib/generators/pu/gem/pagy/templates/.keep +0 -0
- data/lib/generators/pu/gem/pagy/templates/config/initializers/pagy.rb +4 -0
- data/lib/generators/pu/gem/rabl/rabl_generator.rb +25 -0
- data/lib/generators/pu/gem/rabl/templates/.keep +0 -0
- data/lib/generators/pu/gem/rabl/templates/config/initializers/rabl.rb +60 -0
- data/lib/generators/pu/gem/simple_form/simple_form_generator.rb +25 -0
- data/lib/generators/pu/gem/simple_form/templates/.keep +0 -0
- data/lib/generators/pu/gen/pug/pug_generator.rb +43 -0
- data/lib/generators/pu/gen/pug/templates/pug.rb.tt +23 -0
- data/lib/generators/pu/pkg/app/app_generator.rb +60 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/resource_controller.rb.tt +26 -0
- data/lib/generators/pu/pkg/app/templates/app/interactions/resource_interaction.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/app/policies/resource_policy.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/app/presenters/resource_presenter.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/config/routes.rb.tt +17 -0
- data/lib/generators/pu/pkg/app/templates/lib/engine.rb.tt +14 -0
- data/lib/generators/pu/pkg/feature/feature_generator.rb +44 -0
- data/lib/generators/pu/pkg/feature/templates/.keep +0 -0
- data/lib/generators/pu/pkg/feature/templates/app/controllers/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/pkg/feature/templates/app/interactions/resource_interaction.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/app/models/resource_record.rb.tt +5 -0
- data/lib/generators/pu/pkg/feature/templates/app/policies/resource_policy.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/app/presenters/resource_presenter.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/lib/engine.rb.tt +8 -0
- data/lib/generators/pu/resource/conn/conn_generator.rb +54 -0
- data/lib/generators/pu/resource/conn/templates/.keep +0 -0
- data/lib/generators/pu/resource/conn/templates/app/controllers/resource_controller.rb.tt +3 -0
- data/lib/generators/pu/resource/conn/templates/app/policies/resource_policy.rb.tt +3 -0
- data/lib/generators/pu/resource/conn/templates/app/presenters/resource_presenter.rb.tt +3 -0
- data/lib/generators/pu/resource/model/USAGE +113 -0
- data/lib/generators/pu/resource/model/model_generator.rb +163 -0
- data/lib/generators/pu/resource/model/templates/controller.rb.tt +5 -0
- data/lib/generators/pu/resource/model/templates/create_table_migration.rb.tt +26 -0
- data/lib/generators/pu/resource/model/templates/model.rb.tt +53 -0
- data/lib/generators/pu/resource/model/templates/module.rb.tt +7 -0
- data/lib/generators/pu/resource/model/templates/policy.rb.tt +4 -0
- data/lib/generators/pu/resource/model/templates/presenter.rb.tt +4 -0
- data/lib/generators/pu/resource/scaffold/scaffold_generator.rb +219 -0
- data/lib/generators/pu/resource/scaffold/templates/app/controllers/admin_resources/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/controllers/entity_resources/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/admin/resource_policy.rb.tt +22 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/entity/resource_policy.rb.tt +22 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/resource_policy.rb.tt +13 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/admin_presenter.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/entity_presenter.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/presenter.rb.tt +23 -0
- data/lib/generators/pu/resource/scaffold/templates/app/views/resources/resource/_resource.html.erb.tt +3 -0
- data/lib/generators/pu/resource/scaffold/templates/app/views/resources/resource/_resource.rabl +7 -0
- data/lib/generators/pu/rodauth/account_generator.rb +120 -0
- data/lib/generators/pu/rodauth/concerns/account_selector.rb +22 -0
- data/lib/generators/pu/rodauth/concerns/configuration.rb +211 -0
- data/lib/generators/pu/rodauth/concerns/feature_selector.rb +125 -0
- data/lib/generators/pu/rodauth/install_generator.rb +69 -0
- data/lib/generators/pu/rodauth/migration/active_record/account_expiration.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/active_sessions.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/audit_logging.erb +16 -0
- data/lib/generators/pu/rodauth/migration/active_record/base.erb +22 -0
- data/lib/generators/pu/rodauth/migration/active_record/disallow_password_reuse.erb +5 -0
- data/lib/generators/pu/rodauth/migration/active_record/email_auth.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/jwt_refresh.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/lockout.erb +13 -0
- data/lib/generators/pu/rodauth/migration/active_record/otp.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/password_expiration.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/recovery_codes.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/remember.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/reset_password.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/separate_passwords.erb +5 -0
- data/lib/generators/pu/rodauth/migration/active_record/single_session.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/sms_codes.erb +9 -0
- data/lib/generators/pu/rodauth/migration/active_record/verify_account.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/verify_login_change.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/webauthn.erb +13 -0
- data/lib/generators/pu/rodauth/migration/sequel/account_expiration.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/active_sessions.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/audit_logging.erb +17 -0
- data/lib/generators/pu/rodauth/migration/sequel/base.erb +25 -0
- data/lib/generators/pu/rodauth/migration/sequel/disallow_password_reuse.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/email_auth.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/jwt_refresh.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/lockout.erb +11 -0
- data/lib/generators/pu/rodauth/migration/sequel/otp.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/password_expiration.erb +5 -0
- data/lib/generators/pu/rodauth/migration/sequel/recovery_codes.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/remember.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/reset_password.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/separate_passwords.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/single_session.erb +5 -0
- data/lib/generators/pu/rodauth/migration/sequel/sms_codes.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/verify_account.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/verify_login_change.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/webauthn.erb +13 -0
- data/lib/generators/pu/rodauth/migration_generator.rb +190 -0
- data/lib/generators/pu/rodauth/templates/INSTRUCTIONS +52 -0
- data/lib/generators/pu/rodauth/templates/app/controllers/plugin_controller.rb.tt +6 -0
- data/lib/generators/pu/rodauth/templates/app/controllers/rodauth_controller.rb.tt +3 -0
- data/lib/generators/pu/rodauth/templates/app/mailers/account_mailer.rb.tt +4 -0
- data/lib/generators/pu/rodauth/templates/app/mailers/rodauth_mailer.rb.tt +62 -0
- data/lib/generators/pu/rodauth/templates/app/misc/account_rodauth_plugin.rb.tt +255 -0
- data/lib/generators/pu/rodauth/templates/app/misc/rodauth_app.rb.tt +24 -0
- data/lib/generators/pu/rodauth/templates/app/misc/rodauth_plugin.rb.tt +234 -0
- data/lib/generators/pu/rodauth/templates/app/models/account.rb.tt +40 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb +7 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_login_form.html.erb +26 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_login_form_footer.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/add_recovery_codes.html.erb +6 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/change_login.html.erb +27 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/change_password.html.erb +27 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/close_account.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/confirm_password.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/create_account.html.erb +35 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/email_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/login.html.erb +4 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/logout.html.erb +14 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/multi_phase_login.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_setup.html.erb +41 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/recovery_codes.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/remember.html.erb +22 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/reset_password.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_request.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_setup.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_email_auth_request_form.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_login_form.html.erb +24 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_login_form_footer.html.erb +7 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/add_recovery_codes.html.erb +16 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/change_login.html.erb +25 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/change_password.html.erb +25 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/close_account.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/confirm_password.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/create_account.html.erb +33 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/email_auth.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/login.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/logout.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/multi_phase_login.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_setup.html.erb +32 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/recovery_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/recovery_codes.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/remember.html.erb +18 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/reset_password.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/reset_password_request.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_confirm.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_request.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_setup.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_manage.html.erb +26 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/unlock_account.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/unlock_account_request.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_account.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_account_resend.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_login_change.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_auth.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_autofill.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_remove.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_setup.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_manage.html.erb +22 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/unlock_account.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_account.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_autofill.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/email_auth.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/password_changed.text.erb +2 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/reset_password.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/reset_password_notify.text.erb +2 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/unlock_account.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/verify_account.text.erb +4 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/verify_login_change.text.erb +10 -0
- data/lib/generators/pu/rodauth/templates/config/initializers/rodauth.rb.tt +3 -0
- data/lib/generators/pu/rodauth/templates/db/migrate/create_rodauth.rb.tt +13 -0
- data/lib/generators/pu/rodauth/views_generator.rb +125 -0
- data/lib/plutonium/auth/public_access.rb +17 -0
- data/lib/plutonium/auth/rodauth.rb +35 -0
- data/lib/plutonium/auth.rb +12 -0
- data/lib/plutonium/config.rb +11 -0
- data/lib/plutonium/core/.DS_Store +0 -0
- data/lib/plutonium/core/action.rb +46 -0
- data/lib/plutonium/core/actions/basic_action.rb +16 -0
- data/lib/plutonium/core/actions/collection.rb +33 -0
- data/lib/plutonium/core/actions/destroy_action.rb +21 -0
- data/lib/plutonium/core/actions/edit_action.rb +19 -0
- data/lib/plutonium/core/actions/interactive_action.rb +64 -0
- data/lib/plutonium/core/actions/new_action.rb +18 -0
- data/lib/plutonium/core/actions/show_action.rb +17 -0
- data/lib/plutonium/core/actions.rb +17 -0
- data/lib/plutonium/core/app_controller.rb +121 -0
- data/lib/plutonium/core/autodiscovery/discoverer.rb +15 -0
- data/lib/plutonium/core/autodiscovery/input_discoverer.rb +33 -0
- data/lib/plutonium/core/autodiscovery/renderer_discoverer.rb +33 -0
- data/lib/plutonium/core/autodiscovery.rb +13 -0
- data/lib/plutonium/core/controllers/authorizable.rb +56 -0
- data/lib/plutonium/core/controllers/bootable.rb +44 -0
- data/lib/plutonium/core/controllers/crud_actions.rb +128 -0
- data/lib/plutonium/core/controllers/entity_scoping.rb +69 -0
- data/lib/plutonium/core/controllers/interactive_actions.rb +210 -0
- data/lib/plutonium/core/controllers/presentable.rb +59 -0
- data/lib/plutonium/core/controllers.rb +16 -0
- data/lib/plutonium/core/definers/action_definer.rb +25 -0
- data/lib/plutonium/core/definers/field_definer.rb +19 -0
- data/lib/plutonium/core/definers/input_definer.rb +37 -0
- data/lib/plutonium/core/definers/renderer_definer.rb +35 -0
- data/lib/plutonium/core/definers.rb +14 -0
- data/lib/plutonium/core/fields/inputs/association_input.rb +26 -0
- data/lib/plutonium/core/fields/inputs/basic_input.rb +42 -0
- data/lib/plutonium/core/fields/inputs/belongs_to_input.rb +15 -0
- data/lib/plutonium/core/fields/inputs/factory.rb +58 -0
- data/lib/plutonium/core/fields/inputs/has_many_input.rb +15 -0
- data/lib/plutonium/core/fields/inputs/noop_input.rb +19 -0
- data/lib/plutonium/core/fields/inputs.rb +18 -0
- data/lib/plutonium/core/fields/renderers/association_renderer.rb +25 -0
- data/lib/plutonium/core/fields/renderers/basic_renderer.rb +27 -0
- data/lib/plutonium/core/fields/renderers/factory.rb +52 -0
- data/lib/plutonium/core/fields/renderers.rb +15 -0
- data/lib/plutonium/core/fields.rb +12 -0
- data/lib/plutonium/core/ui/collection.rb +14 -0
- data/lib/plutonium/core/ui/detail.rb +11 -0
- data/lib/plutonium/core/ui/form.rb +11 -0
- data/lib/plutonium/core/ui.rb +13 -0
- data/lib/plutonium/core.rb +16 -0
- data/lib/plutonium/helpers/action_buttons_helper.rb +32 -0
- data/lib/plutonium/helpers/application_helper.rb +22 -0
- data/lib/plutonium/helpers/attachment_helper.rb +62 -0
- data/lib/plutonium/helpers/content_helper.rb +66 -0
- data/lib/plutonium/helpers/display_helper.rb +83 -0
- data/lib/plutonium/helpers/form_helper.rb +24 -0
- data/lib/plutonium/helpers/menu_helper.rb +69 -0
- data/lib/plutonium/helpers/pagination_helper.rb +9 -0
- data/lib/plutonium/helpers/turbo_helper.rb +13 -0
- data/lib/plutonium/helpers/turbo_stream_actions_helper.rb +9 -0
- data/lib/plutonium/helpers.rb +31 -0
- data/lib/plutonium/initializers/TODO +2 -0
- data/lib/plutonium/initializers/pagy.rb +5 -0
- data/lib/plutonium/initializers/patches.rb +2 -0
- data/lib/plutonium/initializers/rabl.rb +60 -0
- data/lib/plutonium/initializers/simple_form.rb +405 -0
- data/lib/plutonium/lib/after_commit.rb +34 -0
- data/lib/plutonium/lib/bit_flags.rb +36 -0
- data/lib/plutonium/packaging/app.rb +125 -0
- data/lib/plutonium/packaging/feature.rb +18 -0
- data/lib/plutonium/packaging/package.rb +22 -0
- data/lib/plutonium/packaging.rb +9 -0
- data/lib/plutonium/policy/initializer.rb +22 -0
- data/lib/plutonium/policy/scope.rb +19 -0
- data/lib/plutonium/policy.rb +8 -0
- data/lib/plutonium/preserved__/field.rb +65 -0
- data/lib/plutonium/preserved__/input.rb +93 -0
- data/lib/plutonium/reactor/core.rb +61 -0
- data/lib/plutonium/reactor/resource_context.rb +15 -0
- data/lib/plutonium/reactor/resource_controller.rb +108 -0
- data/lib/plutonium/reactor/resource_interaction.rb +8 -0
- data/lib/plutonium/reactor/resource_policy.rb +105 -0
- data/lib/plutonium/reactor/resource_presenter.rb +42 -0
- data/lib/plutonium/reactor/resource_record.rb +123 -0
- data/lib/plutonium/reactor.rb +13 -0
- data/lib/plutonium/refinements/parameter_refinements.rb +26 -0
- data/lib/plutonium/simple_form_components/attachment_component.rb +77 -0
- data/lib/plutonium/simple_form_components/input_group_component.rb +14 -0
- data/lib/plutonium/version.rb +3 -0
- data/lib/plutonium.rb +31 -0
- data/plutonium.gemspec +47 -0
- data/public/.keep +0 -0
- data/public/plutonium-assets/application.css +24280 -0
- data/public/plutonium-assets/application.js +31420 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff +0 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff2 +0 -0
- data/public/plutonium-assets/logo.png +0 -0
- data/sig/plutonium.rbs +4 -0
- metadata +519 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Helpers
|
3
|
+
module ContentHelper
|
4
|
+
def timeago(date, format: :long)
|
5
|
+
return if date.blank?
|
6
|
+
|
7
|
+
content = I18n.l(date, format:)
|
8
|
+
tag.time(
|
9
|
+
content,
|
10
|
+
title: content,
|
11
|
+
data: {
|
12
|
+
controller: "timeago",
|
13
|
+
timeago_refresh_interval_value: 1000,
|
14
|
+
timeago_include_seconds_value: true,
|
15
|
+
timeago_add_suffix_value: true,
|
16
|
+
timeago_datetime_value: date.iso8601
|
17
|
+
}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def read_more(content, clamp = 4)
|
22
|
+
return if content.blank?
|
23
|
+
|
24
|
+
# Stimulus Read More (https://www.stimulus-components.com/docs/stimulus-read-more/)
|
25
|
+
style = "overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; " \
|
26
|
+
"-webkit-line-clamp: var(--read-more-line-clamp, #{clamp});"
|
27
|
+
|
28
|
+
tag.div(
|
29
|
+
data: {
|
30
|
+
controller: "read-more",
|
31
|
+
read_more_more_text_value: "Read more",
|
32
|
+
read_more_less_text_value: "Read less"
|
33
|
+
}
|
34
|
+
) do
|
35
|
+
concat tag.div(content,
|
36
|
+
style:,
|
37
|
+
data: {read_more_target: "content"})
|
38
|
+
|
39
|
+
next unless content.lines.size > clamp
|
40
|
+
|
41
|
+
concat tag.button("Read more",
|
42
|
+
class: "btn btn-sm btn-link text-decoration-none ps-0",
|
43
|
+
data: {action: "read-more#toggle"})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def quill(content)
|
48
|
+
return if content.blank?
|
49
|
+
|
50
|
+
tag.div(
|
51
|
+
content,
|
52
|
+
class: "ql-viewer",
|
53
|
+
data: {
|
54
|
+
controller: "quill-viewer"
|
55
|
+
}
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
def clamp_content(content)
|
60
|
+
return if content.blank?
|
61
|
+
|
62
|
+
tag.div content, class: "clamped-content"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Helpers
|
3
|
+
module DisplayHelper
|
4
|
+
def display_field(value:, helper: nil, **options)
|
5
|
+
return "-" unless value.present?
|
6
|
+
|
7
|
+
stack_multiple = options.key?(:stack_multiple) ? options.delete(:stack_multiple) : helper != :display_name_of
|
8
|
+
|
9
|
+
# clean options list
|
10
|
+
options.select! { |k, _v| !k.starts_with? "pu_" }
|
11
|
+
|
12
|
+
if value.respond_to?(:each) && stack_multiple
|
13
|
+
tag.ul class: "list-unstyled m-0" do
|
14
|
+
value.each do |val|
|
15
|
+
rendered = display_field_value(value: val, helper:, **options)
|
16
|
+
concat tag.li(rendered)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
else
|
20
|
+
rendered = display_field_value(value:, helper:, **options)
|
21
|
+
tag.span rendered
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def display_datetime_value(value)
|
26
|
+
timeago value
|
27
|
+
end
|
28
|
+
|
29
|
+
def display_field_value(value:, helper: nil, title: nil, **)
|
30
|
+
title = (title != false) ? title || value : nil
|
31
|
+
rendered = helper.present? ? send(helper, value, **) : value
|
32
|
+
tag.span rendered, title:
|
33
|
+
end
|
34
|
+
|
35
|
+
def display_association_value(association)
|
36
|
+
display_name = display_name_of(association)
|
37
|
+
link_to display_name, adapt_route_args(association, use_parent: false),
|
38
|
+
class: "text-decoration-none"
|
39
|
+
rescue NoMethodError
|
40
|
+
display_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def display_numeric_value(value)
|
44
|
+
number_with_delimiter value
|
45
|
+
end
|
46
|
+
|
47
|
+
def display_boolean_value(value)
|
48
|
+
tag.input type: :checkbox, class: "form-check-input", checked: value, disabled: true
|
49
|
+
end
|
50
|
+
|
51
|
+
def display_url_value(value)
|
52
|
+
link_to nil, value, class: "text-decoration-none", target: :blank
|
53
|
+
end
|
54
|
+
|
55
|
+
def display_name_of(obj, separator: ", ")
|
56
|
+
return unless obj.present?
|
57
|
+
|
58
|
+
# If this is an array, display for each
|
59
|
+
return obj.map { |i| display_name_of i, separator: }.join(separator) if obj.is_a? Array
|
60
|
+
|
61
|
+
# Fallback to retrieving the value from a predefined list
|
62
|
+
%i[to_label name title].each do |method|
|
63
|
+
name = obj.send(method) if obj.respond_to?(method)
|
64
|
+
return name if name.present?
|
65
|
+
end
|
66
|
+
|
67
|
+
# Maybe this is a record?
|
68
|
+
return "#{resource_name(obj.class)} ##{obj.id}" if obj.respond_to?(:id)
|
69
|
+
|
70
|
+
# Oh well. Just convert it to a string.
|
71
|
+
obj.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def display_clamped_quill(value)
|
75
|
+
clamp_content quill(value)
|
76
|
+
end
|
77
|
+
|
78
|
+
def display_attachment_value(value, **, &block)
|
79
|
+
attachment_preview(value, **, &block)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Helpers
|
3
|
+
module FormHelper
|
4
|
+
include ActionView::Helpers::FormHelper
|
5
|
+
|
6
|
+
#
|
7
|
+
# Override the original form_for helper to disable turbo forms by default if not
|
8
|
+
# explicitly opted into
|
9
|
+
#
|
10
|
+
def resource_form_for(record, options = {}, &block)
|
11
|
+
turbo_frame = options.key?(:turbo_frame) ? options[:turbo_frame] : "_top"
|
12
|
+
options = {
|
13
|
+
html: {
|
14
|
+
data: {
|
15
|
+
turbo_frame:
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}.deep_merge! options
|
19
|
+
|
20
|
+
simple_form_for(record, options, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Helpers
|
3
|
+
module MenuHelper
|
4
|
+
# <ul class="list-unstyled ps-0">
|
5
|
+
# <li class="mb-1">
|
6
|
+
# <button class="btn btn-toggle d-inline-flex align-items-center rounded border-0 collapsed" data-bs-toggle="collapse" data-bs-target="#resources-collapse" aria-expanded="true">Resources</button>
|
7
|
+
# <div class="collapse show" id="resources-collapse">
|
8
|
+
# <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
|
9
|
+
# <li class="mb-1">
|
10
|
+
# <a class="link-body-emphasis d-inline-flex text-decoration-none rounded" data-turbo-frame="content" href="http://127.0.0.1:3000/admin/organisations">Organisations</a>
|
11
|
+
# </li>
|
12
|
+
# <li class="mb-1" style="margin-left: 1.25em">
|
13
|
+
# <button class="btn btn-toggle d-inline-flex align-items-center rounded border-0 collapsed" data-bs-toggle="collapse" data-bs-target="#nested-collapse" aria-expanded="true">Nested</button>
|
14
|
+
# <div class="collapse show" id="nested-collapse">
|
15
|
+
# <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
|
16
|
+
# <li class="mb-1">
|
17
|
+
# <a class="link-body-emphasis d-inline-flex text-decoration-none rounded" data-turbo-frame="content" href="http://127.0.0.1:3000/admin/organisations">Nested Organisations</a>
|
18
|
+
# </li>
|
19
|
+
# </ul>
|
20
|
+
# </div>
|
21
|
+
# </li>
|
22
|
+
# </ul>
|
23
|
+
# </div>
|
24
|
+
# </li>
|
25
|
+
# </ul>
|
26
|
+
|
27
|
+
def build_sidebar_menu(menu, turbo_frame: "content")
|
28
|
+
tag.ul class: "list-unstyled ps-0" do
|
29
|
+
menu.each do |name, definition|
|
30
|
+
concat build_sidebar_menu_item(name, definition, 0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def build_sidebar_menu_item(name, definition, depth)
|
38
|
+
if definition.is_a? String
|
39
|
+
tag.li class: "mb-1" do
|
40
|
+
tag.a name,
|
41
|
+
class: "link-body-emphasis d-inline-flex text-decoration-none rounded ps-0",
|
42
|
+
data: {turbo_frame: "content"},
|
43
|
+
href: definition
|
44
|
+
end
|
45
|
+
else
|
46
|
+
style = "margin-left: #{depth * 1.25}em"
|
47
|
+
tag.li(class: "mb-1", style:) do
|
48
|
+
concat tag.button(
|
49
|
+
name,
|
50
|
+
class: "btn btn-toggle d-inline-flex align-items-center rounded border-0 collapsed ps-0",
|
51
|
+
data: {bs_toggle: "collapse", bs_target: "##{name.parameterize}-collapse"},
|
52
|
+
aria: {expanded: "false"}
|
53
|
+
)
|
54
|
+
|
55
|
+
concat begin
|
56
|
+
tag.div(class: "collapse", id: "#{name.parameterize}-collapse") do
|
57
|
+
tag.ul(class: "btn-toggle-nav list-unstyled fw-normal pb-1 small") do
|
58
|
+
definition.each do |name, sub_definition|
|
59
|
+
concat build_sidebar_menu_item(name, sub_definition, depth + 1)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Plutonium
|
2
|
+
module Helpers
|
3
|
+
extend ActiveSupport::Autoload
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
include Plutonium::Helpers::ApplicationHelper
|
8
|
+
include Plutonium::Helpers::ActionButtonsHelper
|
9
|
+
include Plutonium::Helpers::ContentHelper
|
10
|
+
include Plutonium::Helpers::FormHelper
|
11
|
+
include Plutonium::Helpers::MenuHelper
|
12
|
+
include Plutonium::Helpers::PaginationHelper
|
13
|
+
include Plutonium::Helpers::DisplayHelper
|
14
|
+
include Plutonium::Helpers::TurboHelper
|
15
|
+
include Plutonium::Helpers::AttachmentHelper
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
eager_autoload do
|
20
|
+
autoload :ApplicationHelper
|
21
|
+
autoload :ActionButtonsHelper
|
22
|
+
autoload :ContentHelper
|
23
|
+
autoload :FormHelper
|
24
|
+
autoload :MenuHelper
|
25
|
+
autoload :PaginationHelper
|
26
|
+
autoload :DisplayHelper
|
27
|
+
autoload :TurboHelper
|
28
|
+
autoload :AttachmentHelper
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "rabl"
|
2
|
+
|
3
|
+
# https://github.com/nesquena/rabl#configuration
|
4
|
+
|
5
|
+
Rabl.configure do |config|
|
6
|
+
config.cache_sources = !Rails.env.development? # Defaults to false
|
7
|
+
config.raise_on_missing_attribute = !Rails.env.production? # Defaults to false
|
8
|
+
|
9
|
+
# config.cache_all_output = false
|
10
|
+
# config.cache_engine = Rabl::CacheEngine.new # Defaults to Rails cache
|
11
|
+
# config.perform_caching = false
|
12
|
+
# config.escape_all_output = false
|
13
|
+
# config.json_engine = nil # Class with #dump class method (defaults JSON)
|
14
|
+
# config.msgpack_engine = nil # Defaults to ::MessagePack
|
15
|
+
# config.bson_engine = nil # Defaults to ::BSON
|
16
|
+
# config.plist_engine = nil # Defaults to ::Plist::Emit
|
17
|
+
# config.include_json_root = true
|
18
|
+
# config.include_msgpack_root = true
|
19
|
+
# config.include_bson_root = true
|
20
|
+
# config.include_plist_root = true
|
21
|
+
# config.include_xml_root = false
|
22
|
+
# config.include_child_root = true
|
23
|
+
# config.enable_json_callbacks = false
|
24
|
+
# config.xml_options = { :dasherize => true, :skip_types => false }
|
25
|
+
# config.view_paths = []
|
26
|
+
# config.replace_nil_values_with_empty_strings = true # Defaults to false
|
27
|
+
# config.replace_empty_string_values_with_nil_values = true # Defaults to false
|
28
|
+
# config.exclude_nil_values = true # Defaults to false
|
29
|
+
# config.exclude_empty_values_in_collections = true # Defaults to false
|
30
|
+
# config.camelize_keys = :upper # Defaults to false
|
31
|
+
end
|
32
|
+
|
33
|
+
# Monkey Patch Rabl source lookup to make it compatible with Rails view lookup
|
34
|
+
module Rabl
|
35
|
+
module Sources
|
36
|
+
private
|
37
|
+
|
38
|
+
# Returns the rabl template path for Rails
|
39
|
+
def fetch_rails_source(file, _options = {})
|
40
|
+
# use Rails template resolution mechanism if possible (find_template)
|
41
|
+
source_format = request_format if defined?(request_format)
|
42
|
+
|
43
|
+
lookup_proc = lambda do |partial|
|
44
|
+
context_scope.lookup_context.find(file, context_scope.lookup_context.prefixes, partial, [],
|
45
|
+
{formats: [source_format]})
|
46
|
+
end
|
47
|
+
template = begin
|
48
|
+
lookup_proc.call(false)
|
49
|
+
rescue
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
template ||= begin
|
53
|
+
lookup_proc.call(true)
|
54
|
+
rescue
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
template&.identifier
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|