From 0b805abec2ef24ef6f493b730729c1de60103661 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 13 Jul 2025 19:38:11 +0100 Subject: [PATCH] Use a minimal layout for turbo frame renders --- app/controllers/accounts/deletions_controller.rb | 2 +- app/controllers/accounts/pd_declarations_controller.rb | 2 +- app/controllers/accounts/terms_controller.rb | 2 +- app/controllers/accounts_controller.rb | 2 +- app/controllers/application_controller.rb | 4 ++++ app/controllers/changeset_subscriptions_controller.rb | 2 +- app/controllers/changesets_controller.rb | 2 +- app/controllers/confirmations_controller.rb | 2 +- app/controllers/dashboards_controller.rb | 2 +- app/controllers/diary_comments_controller.rb | 2 +- app/controllers/diary_entries_controller.rb | 2 +- app/controllers/follows_controller.rb | 2 +- app/controllers/issue_comments_controller.rb | 2 +- app/controllers/issues/reporters_controller.rb | 2 +- app/controllers/issues_controller.rb | 2 +- app/controllers/messages/mailboxes_controller.rb | 2 +- app/controllers/messages/mutes_controller.rb | 2 +- app/controllers/messages/read_marks_controller.rb | 2 +- app/controllers/messages/replies_controller.rb | 2 +- app/controllers/messages_controller.rb | 2 +- app/controllers/oauth2_applications_controller.rb | 2 +- app/controllers/oauth2_authorizations_controller.rb | 2 +- .../oauth2_authorized_applications_controller.rb | 2 +- app/controllers/passwords_controller.rb | 2 +- app/controllers/preferences/preferences_controller.rb | 2 +- app/controllers/profiles/profile_sections_controller.rb | 2 +- app/controllers/redactions_controller.rb | 2 +- app/controllers/reports_controller.rb | 2 +- app/controllers/sessions_controller.rb | 2 +- app/controllers/site_controller.rb | 2 +- app/controllers/traces/data_controller.rb | 2 +- app/controllers/traces_controller.rb | 2 +- app/controllers/user_blocks_controller.rb | 2 +- app/controllers/user_mutes_controller.rb | 2 +- app/controllers/user_roles_controller.rb | 2 +- app/controllers/users/comments_controller.rb | 2 +- app/controllers/users/issued_blocks_controller.rb | 2 +- app/controllers/users/lists_controller.rb | 2 +- app/controllers/users/received_blocks_controller.rb | 2 +- app/controllers/users/statuses_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/views/layouts/turbo_frame.html.erb | 6 ++++++ 42 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 app/views/layouts/turbo_frame.html.erb diff --git a/app/controllers/accounts/deletions_controller.rb b/app/controllers/accounts/deletions_controller.rb index 303da6cfb..4d579d399 100644 --- a/app/controllers/accounts/deletions_controller.rb +++ b/app/controllers/accounts/deletions_controller.rb @@ -1,6 +1,6 @@ module Accounts class DeletionsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/accounts/pd_declarations_controller.rb b/app/controllers/accounts/pd_declarations_controller.rb index 4a636a888..52ec4241e 100644 --- a/app/controllers/accounts/pd_declarations_controller.rb +++ b/app/controllers/accounts/pd_declarations_controller.rb @@ -1,6 +1,6 @@ module Accounts class PdDeclarationsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/accounts/terms_controller.rb b/app/controllers/accounts/terms_controller.rb index de8b8dbe7..e123daf71 100644 --- a/app/controllers/accounts/terms_controller.rb +++ b/app/controllers/accounts/terms_controller.rb @@ -2,7 +2,7 @@ module Accounts class TermsController < ApplicationController include SessionMethods - layout "site" + layout :site_layout before_action -> { authorize_web(:skip_terms => true) } before_action :set_locale diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index e1855b028..cdf102ff8 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -2,7 +2,7 @@ class AccountsController < ApplicationController include SessionMethods include UserMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 03ea6bedb..9f49f6faa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,6 +39,10 @@ class ApplicationController < ActionController::Base private + def site_layout + turbo_frame_request? ? "turbo_frame" : "site" + end + def authorize_web(skip_terms: false) if session[:user] self.current_user = User.find_by(:id => session[:user], :status => %w[active confirmed suspended]) diff --git a/app/controllers/changeset_subscriptions_controller.rb b/app/controllers/changeset_subscriptions_controller.rb index 00f5f4d20..8a496168f 100644 --- a/app/controllers/changeset_subscriptions_controller.rb +++ b/app/controllers/changeset_subscriptions_controller.rb @@ -1,5 +1,5 @@ class ChangesetSubscriptionsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/changesets_controller.rb b/app/controllers/changesets_controller.rb index 07e7a365f..e7e0c244a 100644 --- a/app/controllers/changesets_controller.rb +++ b/app/controllers/changesets_controller.rb @@ -4,7 +4,7 @@ class ChangesetsController < ApplicationController include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 73c007dd2..1cdfe058d 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -2,7 +2,7 @@ class ConfirmationsController < ApplicationController include SessionMethods include UserMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index cb73cc38f..39b156735 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -1,5 +1,5 @@ class DashboardsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/diary_comments_controller.rb b/app/controllers/diary_comments_controller.rb index d5672c928..324bfb43e 100644 --- a/app/controllers/diary_comments_controller.rb +++ b/app/controllers/diary_comments_controller.rb @@ -1,5 +1,5 @@ class DiaryCommentsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index ffb52d2d5..a24f4a30f 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -2,7 +2,7 @@ class DiaryEntriesController < ApplicationController include UserMethods include PaginationMethods - layout "site", :except => :rss + layout :site_layout, :except => :rss before_action :authorize_web before_action :set_locale diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index c1ba11346..a89ee4fd1 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,7 +1,7 @@ class FollowsController < ApplicationController include UserMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/issue_comments_controller.rb b/app/controllers/issue_comments_controller.rb index cb504ad04..57e186490 100644 --- a/app/controllers/issue_comments_controller.rb +++ b/app/controllers/issue_comments_controller.rb @@ -1,5 +1,5 @@ class IssueCommentsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/issues/reporters_controller.rb b/app/controllers/issues/reporters_controller.rb index 9e195df78..c99d2e56b 100644 --- a/app/controllers/issues/reporters_controller.rb +++ b/app/controllers/issues/reporters_controller.rb @@ -1,6 +1,6 @@ module Issues class ReportersController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 56c0bbdf0..07d8eef34 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,7 +1,7 @@ class IssuesController < ApplicationController include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/messages/mailboxes_controller.rb b/app/controllers/messages/mailboxes_controller.rb index a0da9f52b..a519f6bd3 100644 --- a/app/controllers/messages/mailboxes_controller.rb +++ b/app/controllers/messages/mailboxes_controller.rb @@ -1,6 +1,6 @@ module Messages class MailboxesController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/messages/mutes_controller.rb b/app/controllers/messages/mutes_controller.rb index 0d0ef7d40..2b0739a4a 100644 --- a/app/controllers/messages/mutes_controller.rb +++ b/app/controllers/messages/mutes_controller.rb @@ -1,6 +1,6 @@ module Messages class MutesController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/messages/read_marks_controller.rb b/app/controllers/messages/read_marks_controller.rb index 2db0b89e3..ae8b1e4ae 100644 --- a/app/controllers/messages/read_marks_controller.rb +++ b/app/controllers/messages/read_marks_controller.rb @@ -1,6 +1,6 @@ module Messages class ReadMarksController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/messages/replies_controller.rb b/app/controllers/messages/replies_controller.rb index b1e7b8d19..eb6ac0b7f 100644 --- a/app/controllers/messages/replies_controller.rb +++ b/app/controllers/messages/replies_controller.rb @@ -1,6 +1,6 @@ module Messages class RepliesController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index ae3c6eb8e..bcefc6bb1 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -1,7 +1,7 @@ class MessagesController < ApplicationController include UserMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/oauth2_applications_controller.rb b/app/controllers/oauth2_applications_controller.rb index fcb9afc3b..2d1f13af9 100644 --- a/app/controllers/oauth2_applications_controller.rb +++ b/app/controllers/oauth2_applications_controller.rb @@ -1,5 +1,5 @@ class Oauth2ApplicationsController < Doorkeeper::ApplicationsController - layout "site" + layout :site_layout prepend_before_action :authorize_web before_action :set_locale diff --git a/app/controllers/oauth2_authorizations_controller.rb b/app/controllers/oauth2_authorizations_controller.rb index 9f86e8b18..e4b61b9ce 100644 --- a/app/controllers/oauth2_authorizations_controller.rb +++ b/app/controllers/oauth2_authorizations_controller.rb @@ -1,5 +1,5 @@ class Oauth2AuthorizationsController < Doorkeeper::AuthorizationsController - layout "site" + layout :site_layout prepend_before_action :authorize_web before_action :set_locale diff --git a/app/controllers/oauth2_authorized_applications_controller.rb b/app/controllers/oauth2_authorized_applications_controller.rb index 369908b87..3d07cd089 100644 --- a/app/controllers/oauth2_authorized_applications_controller.rb +++ b/app/controllers/oauth2_authorized_applications_controller.rb @@ -1,5 +1,5 @@ class Oauth2AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController - layout "site" + layout :site_layout prepend_before_action :authorize_web before_action :set_locale diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 1b1a60aa1..de9985389 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -1,7 +1,7 @@ class PasswordsController < ApplicationController include SessionMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/preferences/preferences_controller.rb b/app/controllers/preferences/preferences_controller.rb index f74107fa8..93add68bb 100644 --- a/app/controllers/preferences/preferences_controller.rb +++ b/app/controllers/preferences/preferences_controller.rb @@ -1,6 +1,6 @@ module Preferences class PreferencesController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/profiles/profile_sections_controller.rb b/app/controllers/profiles/profile_sections_controller.rb index 3ab17616d..a85d5c8af 100644 --- a/app/controllers/profiles/profile_sections_controller.rb +++ b/app/controllers/profiles/profile_sections_controller.rb @@ -1,6 +1,6 @@ module Profiles class ProfileSectionsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/redactions_controller.rb b/app/controllers/redactions_controller.rb index 6e28f3625..e10dd03fa 100644 --- a/app/controllers/redactions_controller.rb +++ b/app/controllers/redactions_controller.rb @@ -1,5 +1,5 @@ class RedactionsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 49eb8f95a..f299c4cb1 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,5 +1,5 @@ class ReportsController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 090a9ea5c..d89ff0d5b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,7 +1,7 @@ class SessionsController < ApplicationController include SessionMethods - layout "site" + layout :site_layout before_action :authorize_web, :except => [:destroy] before_action -> { authorize_web(:skip_terms => true) }, :only => [:destroy] diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 6fa4db5e9..b475ee8ce 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -1,5 +1,5 @@ class SiteController < ApplicationController - layout "site" + layout :site_layout layout :map_layout, :only => [:index, :export] before_action :authorize_web diff --git a/app/controllers/traces/data_controller.rb b/app/controllers/traces/data_controller.rb index 84119f2da..12225c1f1 100644 --- a/app/controllers/traces/data_controller.rb +++ b/app/controllers/traces/data_controller.rb @@ -1,6 +1,6 @@ module Traces class DataController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index 2bf34f593..fcd4f7938 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -2,7 +2,7 @@ class TracesController < ApplicationController include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index ec85aef38..91273eb07 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -2,7 +2,7 @@ class UserBlocksController < ApplicationController include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/user_mutes_controller.rb b/app/controllers/user_mutes_controller.rb index dfd89083e..30561080d 100644 --- a/app/controllers/user_mutes_controller.rb +++ b/app/controllers/user_mutes_controller.rb @@ -1,7 +1,7 @@ class UserMutesController < ApplicationController include UserMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/user_roles_controller.rb b/app/controllers/user_roles_controller.rb index 912453be8..683427d3a 100644 --- a/app/controllers/user_roles_controller.rb +++ b/app/controllers/user_roles_controller.rb @@ -1,7 +1,7 @@ class UserRolesController < ApplicationController include UserMethods - layout "site" + layout :site_layout before_action :authorize_web diff --git a/app/controllers/users/comments_controller.rb b/app/controllers/users/comments_controller.rb index 06d2d7f4d..0a0499a32 100644 --- a/app/controllers/users/comments_controller.rb +++ b/app/controllers/users/comments_controller.rb @@ -3,7 +3,7 @@ module Users include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/users/issued_blocks_controller.rb b/app/controllers/users/issued_blocks_controller.rb index b533b5f6d..0832fd08f 100644 --- a/app/controllers/users/issued_blocks_controller.rb +++ b/app/controllers/users/issued_blocks_controller.rb @@ -3,7 +3,7 @@ module Users include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index 5a0ff205b..c3c3c61bb 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -2,7 +2,7 @@ module Users class ListsController < ApplicationController include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/users/received_blocks_controller.rb b/app/controllers/users/received_blocks_controller.rb index 6f6cabd26..4b7f58e20 100644 --- a/app/controllers/users/received_blocks_controller.rb +++ b/app/controllers/users/received_blocks_controller.rb @@ -3,7 +3,7 @@ module Users include UserMethods include PaginationMethods - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/users/statuses_controller.rb b/app/controllers/users/statuses_controller.rb index a66782edf..393acb355 100644 --- a/app/controllers/users/statuses_controller.rb +++ b/app/controllers/users/statuses_controller.rb @@ -1,6 +1,6 @@ module Users class StatusesController < ApplicationController - layout "site" + layout :site_layout before_action :authorize_web before_action :set_locale diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c38a79987..a427d2bec 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,7 @@ class UsersController < ApplicationController include SessionMethods include UserMethods - layout "site" + layout :site_layout skip_before_action :verify_authenticity_token, :only => [:auth_success] before_action :authorize_web diff --git a/app/views/layouts/turbo_frame.html.erb b/app/views/layouts/turbo_frame.html.erb new file mode 100644 index 000000000..04ead2014 --- /dev/null +++ b/app/views/layouts/turbo_frame.html.erb @@ -0,0 +1,6 @@ + + <%= render :partial => "layouts/head" %> + + <%= yield %> + + -- 2.39.5