From 51f6793e217ca298b0b5a4adda28b81d7f3d306c Mon Sep 17 00:00:00 2001 From: theLazyProgrammer <48143641+nanafox@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:54:38 +0000 Subject: [PATCH 1/4] chore: Remove arguments as the signature is identical This update fixes the `Style/SuperArgument` error from `standardrb` --- lib/plutonium/ui/form/interaction.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plutonium/ui/form/interaction.rb b/lib/plutonium/ui/form/interaction.rb index 90559fd..04bc073 100644 --- a/lib/plutonium/ui/form/interaction.rb +++ b/lib/plutonium/ui/form/interaction.rb @@ -25,7 +25,7 @@ def initialize_attributes end def submit_button(*, **) - super(*, **) do + super do object.label end end From 3988e08630cbc0e3c31d109def472025f9d08409 Mon Sep 17 00:00:00 2001 From: theLazyProgrammer <48143641+nanafox@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:56:35 +0000 Subject: [PATCH 2/4] feat: Add `app_name` parameter to allow custom names for titles This update allows users to now pass a custom name instead of using the default value, i.e., the application from `Rails.application.name`. --- lib/plutonium/core/controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plutonium/core/controller.rb b/lib/plutonium/core/controller.rb index ae08c96..95826e0 100644 --- a/lib/plutonium/core/controller.rb +++ b/lib/plutonium/core/controller.rb @@ -29,8 +29,8 @@ def set_page_title(page_title) @page_title = page_title end - def make_page_title(title) - [title.presence, helpers.application_name].compact.join(" | ") + def make_page_title(title, app_name: helpers.application_name) + [title.presence, app_name].compact.join(" | ") end # From df866b8b88f1a68b399b4a70167a34b18ddc1b84 Mon Sep 17 00:00:00 2001 From: theLazyProgrammer <48143641+nanafox@users.noreply.github.com> Date: Sun, 2 Feb 2025 00:05:33 +0000 Subject: [PATCH 3/4] refactor: Extra `app_name` into a separate method #13 --- lib/plutonium/core/controller.rb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/plutonium/core/controller.rb b/lib/plutonium/core/controller.rb index 95826e0..df19d9f 100644 --- a/lib/plutonium/core/controller.rb +++ b/lib/plutonium/core/controller.rb @@ -12,11 +12,12 @@ module Controller before_action do next unless defined?(ActiveStorage) - ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port} + ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port } end helper Plutonium::Helpers - helper_method :make_page_title, :resource_url_for, :resource_url_args_for, :root_path + helper_method :make_page_title, :resource_url_for, + :resource_url_args_for, :root_path, :app_name append_view_path File.expand_path("app/views", Plutonium.root) layout -> { turbo_frame_request? ? false : "resource" } @@ -29,10 +30,26 @@ def set_page_title(page_title) @page_title = page_title end - def make_page_title(title, app_name: helpers.application_name) + def make_page_title(title) [title.presence, app_name].compact.join(" | ") end + # Returns the name of the application as defined in the configuration + # + # This value can be overridden to provide a custom name for the application + # which will then be used to set the page title + # + # For example, if the application name is "Acme", the page title + # will be set to "Login | Acme" + # + # example: + # def app_name = "Acme" + # + # @return [String] the name of the application + def app_name + helpers.application_name + end + # # Returns a dynamic list of args to be used with `url_for`, which considers the route namespace and nesting. # The current entity and parent record (for nested routes) are inserted appropriately, ensuring that generated URLs @@ -61,7 +78,7 @@ def make_page_title(title, app_name: helpers.application_name) # @return [Hash] args to pass to `url_for` # def resource_url_args_for(*args, action: nil, parent: nil, **kwargs) - url_args = {**kwargs, action: action}.compact + url_args = { **kwargs, action: action }.compact controller_chain = [current_package&.to_s].compact [*args].compact.each_with_index do |element, index| From ec4491c760058e03eb758fa5cdefaf1133dea50c Mon Sep 17 00:00:00 2001 From: theLazyProgrammer <48143641+nanafox@users.noreply.github.com> Date: Sun, 2 Feb 2025 11:59:36 +0000 Subject: [PATCH 4/4] chore: Remove `app_name` docs and format with standard --- lib/plutonium/core/controller.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/plutonium/core/controller.rb b/lib/plutonium/core/controller.rb index df19d9f..0581da0 100644 --- a/lib/plutonium/core/controller.rb +++ b/lib/plutonium/core/controller.rb @@ -12,7 +12,7 @@ module Controller before_action do next unless defined?(ActiveStorage) - ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port } + ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port} end helper Plutonium::Helpers @@ -34,18 +34,6 @@ def make_page_title(title) [title.presence, app_name].compact.join(" | ") end - # Returns the name of the application as defined in the configuration - # - # This value can be overridden to provide a custom name for the application - # which will then be used to set the page title - # - # For example, if the application name is "Acme", the page title - # will be set to "Login | Acme" - # - # example: - # def app_name = "Acme" - # - # @return [String] the name of the application def app_name helpers.application_name end @@ -78,7 +66,7 @@ def app_name # @return [Hash] args to pass to `url_for` # def resource_url_args_for(*args, action: nil, parent: nil, **kwargs) - url_args = { **kwargs, action: action }.compact + url_args = {**kwargs, action: action}.compact controller_chain = [current_package&.to_s].compact [*args].compact.each_with_index do |element, index|