This commit is contained in:
Matt Jankowski 2025-09-03 20:07:44 +00:00 committed by GitHub
commit 2337b5df84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

View File

@ -1,4 +1,4 @@
- description = status_description(activity) -# locals(description:)
%meta{ name: 'description', content: description }/ %meta{ name: 'description', content: description }/
= opengraph 'og:description', description = opengraph 'og:description', description

View File

@ -1,6 +1,7 @@
- if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media)) -# locals(status:, account:)
- player_card = false
- activity.ordered_media_attachments.each do |media| - if status.non_sensitive_with_media? || (status.with_media? && Setting.preview_sensitive_media)
- status.ordered_media_attachments.each do |media|
- if media.image? - if media.image?
= opengraph 'og:image', full_asset_url(media.file.url(:original)) = opengraph 'og:image', full_asset_url(media.file.url(:original))
= opengraph 'og:image:type', media.file_content_type = opengraph 'og:image:type', media.file_content_type
@ -10,7 +11,6 @@
- if media.description.present? - if media.description.present?
= opengraph 'og:image:alt', media.description = opengraph 'og:image:alt', media.description
- elsif media.video? || media.gifv? - elsif media.video? || media.gifv?
- player_card = true
= opengraph 'og:image', full_asset_url(media.file.url(:small)) = opengraph 'og:image', full_asset_url(media.file.url(:small))
= opengraph 'og:image:type', 'image/png' = opengraph 'og:image:type', 'image/png'
- unless media.file.meta.nil? - unless media.file.meta.nil?
@ -28,7 +28,6 @@
= opengraph 'twitter:player:width', media.file.meta.dig('original', 'width') = opengraph 'twitter:player:width', media.file.meta.dig('original', 'width')
= opengraph 'twitter:player:height', media.file.meta.dig('original', 'height') = opengraph 'twitter:player:height', media.file.meta.dig('original', 'height')
- elsif media.audio? - elsif media.audio?
- player_card = true
= opengraph 'og:image', full_asset_url(account.avatar.url(:original)) = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
= opengraph 'og:image:width', '400' = opengraph 'og:image:width', '400'
= opengraph 'og:image:height', '400' = opengraph 'og:image:height', '400'
@ -40,7 +39,7 @@
= opengraph 'twitter:player:stream:content_type', media.file_content_type = opengraph 'twitter:player:stream:content_type', media.file_content_type
= opengraph 'twitter:player:width', '670' = opengraph 'twitter:player:width', '670'
= opengraph 'twitter:player:height', '380' = opengraph 'twitter:player:height', '380'
- if player_card - if status.ordered_media_attachments.any?(&:larger_media_format?)
= opengraph 'twitter:card', 'player' = opengraph 'twitter:card', 'player'
- else - else
= opengraph 'twitter:card', 'summary_large_image' = opengraph 'twitter:card', 'summary_large_image'

View File

@ -16,7 +16,7 @@
= opengraph 'og:locale', @status.language = opengraph 'og:locale', @status.language
= opengraph 'profile:username', acct(@account)[1..] = opengraph 'profile:username', acct(@account)[1..]
= render 'og_description', activity: @status = render 'og_description', description: status_description(@status)
= render 'og_image', activity: @status, account: @account = render 'og_image', status: @status, account: @account
= render 'shared/web_app' = render 'shared/web_app'