diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 509aa83e2..5407404fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -264,9 +264,18 @@ module ApplicationHelper render "table_builder/table", table: table end - def body_attributes(current_user, params, current_item = nil) - controller_param = params[:controller].parameterize.dasherize - action_param = params[:action].parameterize.dasherize + def body_attributes(current_user, params, current_item, exception) + if exception + controller_param = "static" + action_param = "error" + layout = nil + extra_attributes = {} + else + controller_param = params[:controller].parameterize.dasherize + action_param = params[:action].parameterize.dasherize + layout = controller.class.send(:_layout) + extra_attributes = current_item_data_attributes(current_item) + end { lang: "en", @@ -275,12 +284,12 @@ module ApplicationHelper data: { controller: controller_param, action: action_param, - layout: controller.class.send(:_layout), + layout: layout, "current-user-ip-addr": request.remote_ip, "current-user-save-data": CurrentUser.save_data, **current_user_data_attributes(current_user), **cookie_data_attributes, - **current_item_data_attributes(current_item), + **extra_attributes, } } end diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index d09cc2193..6b9e08b43 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -57,7 +57,7 @@ <%= yield :html_header %> <%= raw Danbooru.config.custom_html_header_content %> -<%= tag.body **body_attributes(CurrentUser.user, params, @current_item) do %> +<%= tag.body **body_attributes(CurrentUser.user, params, @current_item, @exception) do %> <%= render "news_updates/listing" %>