The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. class RSS::TagSerializer
  3. include ActionView::Helpers::NumberHelper
  4. include ActionView::Helpers::SanitizeHelper
  5. include RoutingHelper
  6. def render(tag, statuses)
  7. builder = RSSBuilder.new
  8. builder.title("##{tag.name}")
  9. .description(strip_tags(I18n.t('about.about_hashtag_html', hashtag: tag.name)))
  10. .link(tag_url(tag))
  11. .logo(full_pack_url('media/images/logo.svg'))
  12. .accent_color('2b90d9')
  13. statuses.each do |status|
  14. builder.item do |item|
  15. item.title(status.title)
  16. .link(ActivityPub::TagManager.instance.url_for(status))
  17. .pub_date(status.created_at)
  18. .description(status.spoiler_text.presence || Formatter.instance.format(status).to_str)
  19. status.media_attachments.each do |media|
  20. item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
  21. end
  22. end
  23. end
  24. builder.to_xml
  25. end
  26. def self.render(tag, statuses)
  27. new.render(tag, statuses)
  28. end
  29. end