Verified Commit 7ac9c595 authored by Haelwenn's avatar Haelwenn
Browse files

Revert "Enable custom emojis in profiles (notes, field values, display names) (#7374)"

This reverts commit 61a90186.
parent a69b492b
......@@ -5,11 +5,7 @@ module StreamEntriesHelper
EMBEDDED_ACTION = 'embed'
def display_name(account, **options)
if options[:custom_emojify]
Formatter.instance.format_display_name(account, options)
else
account.display_name.presence || account.username
end
account.display_name.presence || account.username
end
def account_description(account)
......
......@@ -4,25 +4,18 @@ import { unescapeHTML } from '../../utils/html';
const domParser = new DOMParser();
const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => {
obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});
export function normalizeAccount(account) {
account = { ...account };
const emojiMap = makeEmojiMap(account);
const displayName = account.display_name.length === 0 ? account.username : account.display_name;
account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap);
account.note_emojified = emojify(account.note, emojiMap);
account.display_name_html = emojify(escapeTextContentForBrowser(displayName));
account.note_emojified = emojify(account.note);
if (account.fields) {
account.fields = account.fields.map(pair => ({
...pair,
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
value_emojified: emojify(pair.value, emojiMap),
value_emojified: emojify(pair.value),
value_plain: unescapeHTML(pair.value),
}));
}
......@@ -51,7 +44,11 @@ export function normalizeStatus(status, normalOldStatus) {
normalStatus.hidden = normalOldStatus.get('hidden');
} else {
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
const emojiMap = makeEmojiMap(normalStatus);
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});
normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
......
......@@ -67,17 +67,9 @@ class Formatter
html.html_safe # rubocop:disable Rails/OutputSafety
end
def format_display_name(account, **options)
html = encode(account.display_name.presence || account.username)
html = encode_custom_emojis(html, account.emojis) if options[:custom_emojify]
html.html_safe # rubocop:disable Rails/OutputSafety
end
def format_field(account, str, **options)
def format_field(account, str)
return reformat(str).html_safe unless account.local? # rubocop:disable Rails/OutputSafety
html = encode_and_link_urls(str, me: true)
html = encode_custom_emojis(html, account.emojis) if options[:custom_emojify]
html.html_safe # rubocop:disable Rails/OutputSafety
encode_and_link_urls(str, me: true).html_safe # rubocop:disable Rails/OutputSafety
end
def linkify(text)
......
......@@ -413,7 +413,7 @@ class Account < ApplicationRecord
end
def emojis
@emojis ||= CustomEmoji.from_text(emojifiable_text, domain)
@emojis ||= CustomEmoji.from_text(note, domain)
end
before_create :generate_keys
......@@ -456,8 +456,4 @@ class Account < ApplicationRecord
self.domain = TagManager.instance.normalize_domain(domain)
end
def emojifiable_text
[note, display_name, fields.map(&:value)].join(' ')
end
end
......@@ -8,7 +8,6 @@ class REST::AccountSerializer < ActiveModel::Serializer
:followers_count, :following_count, :statuses_count
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
has_many :emojis, serializer: REST::CustomEmojiSerializer
class FieldSerializer < ActiveModel::Serializer
attributes :name, :value
......
......@@ -6,7 +6,7 @@
.account__avatar{ style: "background-image: url(#{@instance_presenter.contact_account.avatar.url})" }
%span.display-name
%bdi
%strong.display-name__html.emojify= display_name(@instance_presenter.contact_account, custom_emojify: true)
%strong.display-name__html.emojify= display_name(@instance_presenter.contact_account)
%span.display-name__account @#{@instance_presenter.contact_account.acct}
- else
.account__display-name
......
......@@ -12,7 +12,7 @@
.avatar= image_tag contact.contact_account.avatar.url
.name
= link_to TagManager.instance.url_for(contact.contact_account) do
%span.display_name.emojify= display_name(contact.contact_account, custom_emojify: true)
%span.display_name.emojify= display_name(contact.contact_account)
%span.username @#{contact.contact_account.acct}
- else
.owner
......
......@@ -5,7 +5,7 @@
.avatar= image_tag account.avatar.url(:original)
.name
= link_to TagManager.instance.url_for(account) do
%span.display_name.emojify= display_name(account, custom_emojify: true)
%span.display_name.emojify= display_name(account)
%span.username
@#{account.local? ? account.local_username_and_domain : account.acct}
= fa_icon('lock') if account.locked?
......
......@@ -6,7 +6,7 @@
.card__bio
%h1.name
%span.p-name.emojify= display_name(account, custom_emojify: true)
%span.p-name.emojify= display_name(account)
%small<
%span>< @#{account.local_username_and_domain}
= fa_icon('lock') if account.locked?
......
......@@ -3,7 +3,7 @@
.moved-strip
.moved-strip__message
= fa_icon 'suitcase'
= t('accounts.moved_html', name: content_tag(:strong, display_name(account, custom_emojify: true), class: :emojify), new_profile_link: link_to(content_tag(:strong, safe_join(['@', content_tag(:span, moved_to_account.acct)])), TagManager.instance.url_for(moved_to_account), class: 'mention'))
= t('accounts.moved_html', name: content_tag(:strong, display_name(account), class: :emojify), new_profile_link: link_to(content_tag(:strong, safe_join(['@', content_tag(:span, moved_to_account.acct)])), TagManager.instance.url_for(moved_to_account), class: 'mention'))
.moved-strip__card
= link_to TagManager.instance.url_for(moved_to_account), class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'noopener' do
......@@ -13,5 +13,5 @@
.account__avatar-overlay-overlay{ style: "background-image: url('#{account.avatar.url(:original)}')" }
%span.display-name
%strong.emojify= display_name(moved_to_account, custom_emojify: true)
%strong.emojify= display_name(moved_to_account)
%span @#{moved_to_account.acct}
......@@ -15,5 +15,5 @@
.account__avatar{ style: "background-image: url(#{account.avatar.url}); width: #{size}px; height: #{size}px; background-size: #{size}px #{size}px" }
%span.display-name
%bdi
%strong.display-name__html.emojify= display_name(account, custom_emojify: true)
%strong.display-name__html.emojify= display_name(account)
%span.display-name__account @#{account.acct}
......@@ -6,7 +6,7 @@
%span.display-name
- account_url = local_assigns[:admin] ? admin_account_path(account.id) : TagManager.instance.url_for(account)
= link_to account_url, class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'noopener' do
%strong.emojify= display_name(account, custom_emojify: true)
%strong.emojify= display_name(account)
%span @#{account.acct}
- if account.note?
......
......@@ -6,7 +6,7 @@
%span.display-name
- account_url = local_assigns[:admin] ? admin_account_path(account.id) : TagManager.instance.url_for(account)
= link_to account_url, class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'noopener' do
%strong.emojify= display_name(account, custom_emojify: true)
%strong.emojify= display_name(account)
%span @#{account.acct}
- if account.note?
......
......@@ -2,7 +2,7 @@
= image_tag asset_pack_path('logo.svg'), class: 'logo'
%div
= t('landing_strip_html', name: content_tag(:span, display_name(account, custom_emojify: true), class: :emojify), link_to_root_path: link_to(content_tag(:strong, site_hostname), root_path))
= t('landing_strip_html', name: content_tag(:span, display_name(account), class: :emojify), link_to_root_path: link_to(content_tag(:strong, site_hostname), root_path))
- if open_registrations?
= t('landing_strip_signup_html', sign_up_path: new_user_registration_path)
......@@ -4,7 +4,7 @@
.avatar
= image_tag status.account.avatar.url(:original), width: 48, height: 48, alt: '', class: 'u-photo'
%span.display-name
%strong.p-name.emojify= display_name(status.account, custom_emojify: true)
%strong.p-name.emojify= display_name(status.account)
%span= acct(status.account)
- if embedded_view?
......
......@@ -10,7 +10,7 @@
%div
= image_tag status.account.avatar(:original), width: 48, height: 48, alt: '', class: 'u-photo'
%span.display-name
%strong.p-name.emojify= display_name(status.account, custom_emojify: true)
%strong.p-name.emojify= display_name(status.account)
%span= acct(status.account)
.status__content.p-name.emojify<
......
......@@ -28,7 +28,7 @@
= fa_icon('retweet fw')
%span
= link_to TagManager.instance.url_for(status.account), class: 'status__display-name muted' do
%strong.emojify= display_name(status.account, custom_emojify: true)
%strong.emojify= display_name(status.account)
= t('stream_entries.reblogged')
- elsif pinned
.pre-header
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment