show.rss.ruby 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. RSS::Builder.build do |doc|
  2. doc.title(display_name(@account))
  3. doc.description(I18n.t('rss.descriptions.account', acct: @account.local_username_and_domain))
  4. doc.link(params[:tag].present? ? short_account_tag_url(@account, params[:tag]) : short_account_url(@account))
  5. doc.image(full_asset_url(@account.avatar.url(:original)), display_name(@account), params[:tag].present? ? short_account_tag_url(@account, params[:tag]) : short_account_url(@account))
  6. doc.last_build_date(@statuses.first.created_at) if @statuses.any?
  7. doc.icon(full_asset_url(@account.avatar.url(:original)))
  8. doc.logo(full_pack_url('media/images/logo_transparent_white.svg'))
  9. doc.generator("Mastodon v#{Mastodon::Version.to_s}")
  10. @statuses.each do |status|
  11. doc.item do |item|
  12. item.title(l(status.created_at))
  13. item.link(ActivityPub::TagManager.instance.url_for(status))
  14. item.pub_date(status.created_at)
  15. item.description(rss_status_content_format(status))
  16. if status.ordered_media_attachments.first&.audio?
  17. media = status.ordered_media_attachments.first
  18. item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
  19. end
  20. status.ordered_media_attachments.each do |media|
  21. item.media_content(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size) do |media_content|
  22. media_content.medium(media.gifv? ? 'image' : media.type.to_s)
  23. media_content.rating(status.sensitive? ? 'adult' : 'nonadult')
  24. media_content.description(media.description) if media.description.present?
  25. media_content.thumbnail(media.thumbnail.url(:original, false)) if media.thumbnail?
  26. end
  27. end
  28. status.tags.each do |tag|
  29. item.category(tag.name)
  30. end
  31. end
  32. end
  33. end