1
0
mirror of https://github.com/whippyshou/mastodon synced 2025-01-22 17:54:07 +09:00
whippy-edition/app/helpers/statuses_helper.rb
whippyshou 06bc5b8851 Squashed commit of the following:
commit c9327633a352e39e75166dc0fcf88ad13e5658a3
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 01:25:41 2023 +0900

    tset

commit 40925b9adddef9c0fd50557e322a9ecab79eea15
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 01:13:54 2023 +0900

    d

commit 63a76af1acfc1442dd270aa6280597cdd39a6c56
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 01:07:21 2023 +0900

    test

commit a6024a83d779efb6fa1be20cdfa31af5e679dec5
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 00:46:16 2023 +0900

    sdf

commit 2fa4c4d4a7933a729c32f666c5dba7359f6e5eb6
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 00:33:38 2023 +0900

    ㅅㄷㄴㅅ

commit 9bb8fe3e95263f32f65dc5d884ea8789a8d4b323
Author: whippyshou <whippyshou@gmail.com>
Date:   Fri Nov 3 00:08:12 2023 +0900

    test

commit 909b622f7eef6f91c6ed24b5b5e439d853ccbf04
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 23:56:44 2023 +0900

    tes

commit e0cd24b7a8f0b69fff17f0eda260a03220e5fd9f
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 23:46:21 2023 +0900

    test

commit 623977653a3033cc104b094e7e4176efa5e820a1
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 23:41:24 2023 +0900

    icon change

commit b5d0b03dc0fe30531ecf476c7c9f2fbe7c1024ce
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 23:31:46 2023 +0900

    public

commit 1e408b723a9610dd3395ea7b2006e9dfd7f1bfe5
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 23:00:19 2023 +0900

    test

commit 5d93d266b8df636586ac37186a036beb63208e6d
Author: whippyshou <whippyshou@gmail.com>
Date:   Thu Nov 2 22:52:57 2023 +0900

    test
2023-11-03 01:26:39 +09:00

89 lines
2.1 KiB
Ruby

# frozen_string_literal: true
module StatusesHelper
EMBEDDED_CONTROLLER = 'statuses'
EMBEDDED_ACTION = 'embed'
def link_to_newer(url)
link_to t('statuses.show_newer'), url, class: 'load-more load-gap'
end
def link_to_older(url)
link_to t('statuses.show_older'), url, class: 'load-more load-gap'
end
def nothing_here(extra_classes = '')
content_tag(:div, class: "nothing-here #{extra_classes}") do
t('accounts.nothing_here')
end
end
def media_summary(status)
attachments = { image: 0, video: 0, audio: 0 }
status.ordered_media_attachments.each do |media|
if media.video?
attachments[:video] += 1
elsif media.audio?
attachments[:audio] += 1
else
attachments[:image] += 1
end
end
text = attachments.to_a.reject { |_, value| value.zero? }.map { |key, value| I18n.t("statuses.attached.#{key}", count: value) }.join(' · ')
return if text.blank?
I18n.t('statuses.attached.description', attached: text)
end
def status_text_summary(status)
return if status.spoiler_text.blank?
I18n.t('statuses.content_warning', warning: status.spoiler_text)
end
def poll_summary(status)
return unless status.preloadable_poll
status.preloadable_poll.options.map { |o| "[ ] #{o}" }.join("\n")
end
def status_description(status)
components = [[media_summary(status), status_text_summary(status)].compact_blank.join(' · ')]
if status.spoiler_text.blank?
components << status.text
components << poll_summary(status)
end
components.compact_blank.join("\n\n")
end
def stream_link_target
embedded_view? ? '_blank' : nil
end
def fa_visibility_icon(status)
case status.visibility
when 'public'
fa_icon 'globe fw'
when 'unlisted'
fa_icon 'cloud fw'
when 'private'
fa_icon 'lock fw'
when 'direct'
fa_icon 'envelope fw'
end
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
end