From a7dbf6f5a5f3bddbc40d8b4d9067bec0a7025169 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 20 Sep 2024 08:50:51 -0400 Subject: [PATCH] Use heredoc/squish for inline css styles in oembed serializer (#31991) --- app/serializers/oembed_serializer.rb | 40 +++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/app/serializers/oembed_serializer.rb b/app/serializers/oembed_serializer.rb index a693a961f4..c87f14f26b 100644 --- a/app/serializers/oembed_serializer.rb +++ b/app/serializers/oembed_serializer.rb @@ -2,10 +2,36 @@ class OEmbedSerializer < ActiveModel::Serializer INLINE_STYLES = { - blockquote: 'max-width: 540px; min-width: 270px; background:#FCF8FF; border: 1px solid #C9C4DA; border-radius: 8px; overflow: hidden; margin: 0; padding: 0;', - a: "color: #1C1A25; text-decoration: none; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 24px; font-size: 14px; line-height: 20px; letter-spacing: 0.25px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Roboto, sans-serif;", # rubocop:disable Layout/LineLength - div0: 'margin-top: 16px; color: #787588;', - div1: 'font-weight: 500;', + blockquote: <<~CSS.squish, + background: #FCF8FF; + border-radius: 8px; + border: 1px solid #C9C4DA; + margin: 0; + max-width: 540px; + min-width: 270px; + overflow: hidden; + padding: 0; + CSS + status_link: <<~CSS.squish, + align-items: center; + color: #1C1A25; + display: flex; + flex-direction: column; + font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Roboto, sans-serif; + font-size: 14px; + justify-content: center; + letter-spacing: 0.25px; + line-height: 20px; + padding: 24px; + text-decoration: none; + CSS + div_account: <<~CSS.squish, + color: #787588; + margin-top: 16px; + CSS + div_view: <<~CSS.squish, + font-weight: 500; + CSS }.freeze DEFAULT_WIDTH = 400 @@ -48,10 +74,10 @@ class OEmbedSerializer < ActiveModel::Serializer def html <<~HTML.squish
- + -
Post by @#{object.account.pretty_acct}@#{provider_name}
-
View on Mastodon
+
Post by @#{object.account.pretty_acct}@#{provider_name}
+
View on Mastodon