plutonium 0.10.2 → 0.10.3
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/README.md +1 -0
- data/app/views/application/_flash_alerts.html.erb +3 -0
- data/app/views/application/_flash_toasts.html.erb +2 -0
- data/app/views/components/base.rb +1 -1
- data/app/views/layouts/resource.html copy.erb +2 -2
- data/app/views/layouts/resource.html.erb +3 -3
- data/app/views/layouts/rodauth.html.erb +9 -4
- 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/css.manifest +1 -1
- 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 +15 -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/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/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 +62 -0
- data/lib/generators/pu/service/sidekiq/templates/.keep +0 -0
- data/lib/generators/pu/service/sidekiq/templates/app/sidekiq/sidekiq_job.rb +5 -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 +7 -2
- data/lib/plutonium/core/controllers/base.rb +1 -1
- data/lib/plutonium/core/controllers/entity_scoping.rb +3 -3
- data/lib/plutonium/icons.rb +1 -1
- data/lib/plutonium/railtie.rb +4 -0
- data/lib/plutonium/resource/controller.rb +1 -0
- data/lib/plutonium/rodauth/controller_methods.rb +1 -1
- data/lib/plutonium/version.rb +1 -1
- data/lib/plutonium.rb +4 -0
- data/lib/tasks/create_rodauth_admin.rake +16 -0
- data/public/plutonium-assets/plutonium.8bee7a8482988b0360e3.css +3420 -0
- metadata +36 -5
- /data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_app.rb.tt +0 -0
@@ -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
@@ -5,12 +5,17 @@ module Plutonium
|
|
5
5
|
module Config
|
6
6
|
mattr_accessor :stylesheet_tag
|
7
7
|
@@stylesheet_tag = ->(view_context) {
|
8
|
-
"<link rel=\"stylesheet\" href=\"#{Plutonium.stylesheet_link}\" />"
|
8
|
+
"<link rel=\"stylesheet\" href=\"#{Plutonium.stylesheet_link}\" data-turbo-track=\"reload\" />".html_safe
|
9
9
|
}
|
10
10
|
|
11
11
|
mattr_accessor :script_tag
|
12
12
|
@@script_tag = ->(view_context) {
|
13
|
-
"<script src=\"#{Plutonium.script_link}\"></script>"
|
13
|
+
"<script src=\"#{Plutonium.script_link}\" data-turbo-track=\"reload\"></script>".html_safe
|
14
|
+
}
|
15
|
+
|
16
|
+
mattr_accessor :favicon_tag
|
17
|
+
@@favicon_tag = ->(view_context) {
|
18
|
+
"<link rel=\"icon\" type=\"image/x-icon\" href=\"#{Plutonium.favicon_link}\">".html_safe
|
14
19
|
}
|
15
20
|
end
|
16
21
|
end
|
@@ -43,15 +43,15 @@ module Plutonium
|
|
43
43
|
return unless current_user.present?
|
44
44
|
|
45
45
|
@current_scoped_entity ||= case scoped_entity_strategy
|
46
|
-
when :current_user
|
47
|
-
current_user
|
48
46
|
when :path
|
49
47
|
scoped_entity_class
|
50
48
|
.associated_with(current_user)
|
51
49
|
.from_path_param(request.path_parameters[scoped_entity_param_key])
|
52
50
|
.first! # Raise NotFound if user does not have access to the entity or it does not exist
|
51
|
+
when Symbol
|
52
|
+
send scoped_entity_strategy
|
53
53
|
else
|
54
|
-
raise NotImplementedError, "unknown scoped entity strategy: #{scoped_entity_strategy}"
|
54
|
+
raise NotImplementedError, "unknown scoped entity strategy: #{scoped_entity_strategy.inspect}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/lib/plutonium/icons.rb
CHANGED
@@ -17,7 +17,7 @@ module Plutonium
|
|
17
17
|
path = Plutonium.root.join "app/assets/icons/#{name}.svg"
|
18
18
|
raise "Invalid icon: #{name}" unless File.exist?(path)
|
19
19
|
|
20
|
-
File.read(path).sub("<svg ", "<svg class=\"#{ICON_SIZES[size]}\" ")
|
20
|
+
File.read(path).sub("<svg ", "<svg class=\"#{ICON_SIZES[size]}\" ").html_safe
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/plutonium/railtie.rb
CHANGED
@@ -39,6 +39,10 @@ module Plutonium
|
|
39
39
|
config.view_component.capture_compatibility_patch_enabled = true
|
40
40
|
end
|
41
41
|
|
42
|
+
rake_tasks do
|
43
|
+
load "tasks/create_rodauth_admin.rake"
|
44
|
+
end
|
45
|
+
|
42
46
|
config.after_initialize do
|
43
47
|
Plutonium::Reloader.start! if Rails.application.config.plutonium.enable_hotreload
|
44
48
|
Plutonium::ZEITWERK_LOADER.eager_load if Rails.env.production?
|
@@ -49,6 +49,7 @@ module Plutonium
|
|
49
49
|
# @return [ActiveRecord::Base, nil] The resource record
|
50
50
|
def resource_record
|
51
51
|
@resource_record ||= policy_scope(resource_class).from_path_param(params[:id]).first! if params[:id].present?
|
52
|
+
@resource_record
|
52
53
|
end
|
53
54
|
|
54
55
|
# Returns the submitted resource parameters
|
data/lib/plutonium/version.rb
CHANGED
data/lib/plutonium.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace :rodauth do
|
2
|
+
desc "Create a Rodauth admin account"
|
3
|
+
task admin: :environment do
|
4
|
+
# require "rodauth"
|
5
|
+
# require "active_record"
|
6
|
+
require "tty-prompt"
|
7
|
+
|
8
|
+
prompt = TTY::Prompt.new
|
9
|
+
email = ENV["EMAIL"] || prompt.ask("email:", required: true)
|
10
|
+
# password = SecureRandom.hex
|
11
|
+
# password = ENV["PASSWORD"] || prompt.mask("password:", required: true)
|
12
|
+
# password_confirm = ENV["PASSWORD"] || prompt.mask("password:", required: true)
|
13
|
+
|
14
|
+
RodauthApp.rodauth(:admin).create_account(login: email)
|
15
|
+
end
|
16
|
+
end
|