diff --git a/app/components/layout/common_html_attributes_component.html.erb b/app/components/layout/common_html_attributes_component.html.erb new file mode 100644 index 000000000..fce00b5b2 --- /dev/null +++ b/app/components/layout/common_html_attributes_component.html.erb @@ -0,0 +1 @@ +<%= attributes -%> diff --git a/app/components/layout/common_html_attributes_component.rb b/app/components/layout/common_html_attributes_component.rb new file mode 100644 index 000000000..41cb8323b --- /dev/null +++ b/app/components/layout/common_html_attributes_component.rb @@ -0,0 +1,17 @@ +class Layout::CommonHTMLAttributesComponent < ApplicationComponent + delegate :rtl?, to: :helpers + + private + + def attributes + sanitize([dir, lang].compact.join(" ")) + end + + def dir + 'dir="rtl"' if rtl? + end + + def lang + "lang=\"#{I18n.locale}\"" + end +end diff --git a/app/helpers/layouts_helper.rb b/app/helpers/layouts_helper.rb index e97727b34..32ddde240 100644 --- a/app/helpers/layouts_helper.rb +++ b/app/helpers/layouts_helper.rb @@ -9,4 +9,8 @@ module LayoutsHelper link_to(text, path, options.merge(title: title)) end end + + def common_html_attributes + render Layout::CommonHTMLAttributesComponent.new + end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 757bc32ff..4451e348e 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,7 +1,5 @@ class ApplicationMailer < ActionMailer::Base - helper :settings - helper :application - helper :mailer + helper :application, :layouts, :mailer, :settings default from: proc { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" } layout "mailer" before_action :set_asset_host diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 47cba9f90..48ad4426d 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,6 +1,5 @@ - lang="<%= I18n.locale %>"> - +>
<%= render "layouts/common_head", default_title: "Admin" %> <%= content_for :head %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 04fa2920a..495a18838 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,5 @@ - lang="<%= I18n.locale %>" data-current-user-id="<%= current_user&.id %>"> + data-current-user-id="<%= current_user&.id %>"> <%= render "layouts/common_head", default_title: setting["org_name"] %> <%= render "layouts/meta_tags" %> diff --git a/app/views/layouts/dashboard.html.erb b/app/views/layouts/dashboard.html.erb index cf33f6f4f..ffdfc9439 100644 --- a/app/views/layouts/dashboard.html.erb +++ b/app/views/layouts/dashboard.html.erb @@ -1,5 +1,5 @@ - + data-current-user-id="<%= current_user&.id %>"> <%= render "layouts/common_head", default_title: setting["org_name"] %> <%= render "layouts/meta_tags" %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb index e9ebac423..cc4db0fca 100644 --- a/app/views/layouts/devise.html.erb +++ b/app/views/layouts/devise.html.erb @@ -1,5 +1,5 @@ - lang="<%= I18n.locale %>"> +> <%= render "layouts/common_head", default_title: setting["org_name"] %> <%= render "layouts/meta_tags" %> diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index 6691fe4fb..c5dcf1fd6 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -1,5 +1,5 @@ - +>