1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-23 14:46:18 +09:00

Remove remnants of embed views (#32419)

This commit is contained in:
Matt Jankowski 2024-11-16 15:48:10 -05:00 committed by GitHub
parent 44d92fa4f6
commit a1ac2a73ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 70 deletions

View File

@ -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

View File

@ -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?

View File

@ -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?
·

View File

@ -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

View File

@ -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