From a1ac2a73fffa2a8e1b3aa71041fd01c1587e0d5f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 16 Nov 2024 15:48:10 -0500 Subject: [PATCH] Remove remnants of embed views (#32419) --- app/helpers/statuses_helper.rb | 11 ------ app/views/admin/reports/_status.html.haml | 2 +- .../filters/statuses/_status_filter.html.haml | 2 +- spec/helpers/accounts_helper_spec.rb | 35 ++----------------- spec/helpers/statuses_helper_spec.rb | 24 ------------- 5 files changed, 4 insertions(+), 70 deletions(-) diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb index 9bbb03fd82..16b9d3fb53 100644 --- a/app/helpers/statuses_helper.rb +++ b/app/helpers/statuses_helper.rb @@ -1,9 +1,6 @@ # frozen_string_literal: true module StatusesHelper - EMBEDDED_CONTROLLER = 'statuses' - EMBEDDED_ACTION = 'embed' - VISIBLITY_ICONS = { public: 'globe', unlisted: 'lock_open', @@ -60,18 +57,10 @@ module StatusesHelper components.compact_blank.join("\n\n") end - def stream_link_target - embedded_view? ? '_blank' : nil - end - def visibility_icon(status) VISIBLITY_ICONS[status.visibility.to_sym] end - def embedded_view? - params[:controller] == EMBEDDED_CONTROLLER && params[:action] == EMBEDDED_ACTION - end - def prefers_autoplay? ActiveModel::Type::Boolean.new.cast(params[:autoplay]) || current_user&.setting_auto_play_gif end diff --git a/app/views/admin/reports/_status.html.haml b/app/views/admin/reports/_status.html.haml index 3a35fdd272..bd688a1a5d 100644 --- a/app/views/admin/reports/_status.html.haml +++ b/app/views/admin/reports/_status.html.haml @@ -44,7 +44,7 @@ = t("statuses.visibilities.#{status.visibility}") · - = link_to ActivityPub::TagManager.instance.url_for(status.proper), class: 'detailed-status__link', target: stream_link_target, rel: 'noopener noreferrer' do + = link_to ActivityPub::TagManager.instance.url_for(status.proper), class: 'detailed-status__link', rel: 'noopener noreferrer' do = t('admin.statuses.view_publicly') - if status.proper.sensitive? diff --git a/app/views/filters/statuses/_status_filter.html.haml b/app/views/filters/statuses/_status_filter.html.haml index d0d04638d2..3476869e60 100644 --- a/app/views/filters/statuses/_status_filter.html.haml +++ b/app/views/filters/statuses/_status_filter.html.haml @@ -23,7 +23,7 @@ = image_tag(status.account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar') .username= status.account.acct · - = link_to ActivityPub::TagManager.instance.url_for(status), class: 'detailed-status__datetime', target: stream_link_target, rel: 'noopener noreferrer' do + = link_to ActivityPub::TagManager.instance.url_for(status), class: 'detailed-status__datetime', rel: 'noopener noreferrer' do %time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at) - if status.edited? · diff --git a/spec/helpers/accounts_helper_spec.rb b/spec/helpers/accounts_helper_spec.rb index 2c949cde69..8526482362 100644 --- a/spec/helpers/accounts_helper_spec.rb +++ b/spec/helpers/accounts_helper_spec.rb @@ -3,16 +3,6 @@ require 'rails_helper' RSpec.describe AccountsHelper do - def set_not_embedded_view - params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}" - params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}" - end - - def set_embedded_view - params[:controller] = StatusesHelper::EMBEDDED_CONTROLLER - params[:action] = StatusesHelper::EMBEDDED_ACTION - end - describe '#display_name' do it 'uses the display name when it exists' do account = Account.new(display_name: 'Display', username: 'Username') @@ -28,9 +18,8 @@ RSpec.describe AccountsHelper do end describe '#acct' do - it 'is fully qualified for embedded local accounts' do + it 'is fully qualified for local accounts' do allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain') - set_embedded_view account = Account.new(domain: nil, username: 'user') acct = helper.acct(account) @@ -38,32 +27,12 @@ RSpec.describe AccountsHelper do expect(acct).to eq '@user@local_domain' end - it 'is fully qualified for embedded foreign accounts' do - set_embedded_view + it 'is fully qualified for remote accounts' do account = Account.new(domain: 'foreign_server.com', username: 'user') acct = helper.acct(account) expect(acct).to eq '@user@foreign_server.com' end - - it 'is fully qualified for non embedded foreign accounts' do - set_not_embedded_view - account = Account.new(domain: 'foreign_server.com', username: 'user') - - acct = helper.acct(account) - - expect(acct).to eq '@user@foreign_server.com' - end - - it 'is fully qualified for non embedded local accounts' do - allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain') - set_not_embedded_view - account = Account.new(domain: nil, username: 'user') - - acct = helper.acct(account) - - expect(acct).to eq '@user@local_domain' - end end end diff --git a/spec/helpers/statuses_helper_spec.rb b/spec/helpers/statuses_helper_spec.rb index edd3e8f2f7..07ad72eda9 100644 --- a/spec/helpers/statuses_helper_spec.rb +++ b/spec/helpers/statuses_helper_spec.rb @@ -77,28 +77,4 @@ RSpec.describe StatusesHelper do end end end - - describe '#stream_link_target' do - it 'returns nil if it is not an embedded view' do - set_not_embedded_view - - expect(helper.stream_link_target).to be_nil - end - - it 'returns _blank if it is an embedded view' do - set_embedded_view - - expect(helper.stream_link_target).to eq '_blank' - end - end - - def set_not_embedded_view - params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}" - params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}" - end - - def set_embedded_view - params[:controller] = StatusesHelper::EMBEDDED_CONTROLLER - params[:action] = StatusesHelper::EMBEDDED_ACTION - end end