diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-05-09 07:43:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-09 07:43:08 +0200 |
commit | 2b8dc58b7ff7fb708687c08a75c99b3fb30efc49 (patch) | |
tree | 6145e0c99b5550ad80d902b67a76278e0753ac69 /app/lib/rss/builder.rb | |
parent | f17e73da09e6c63665aee4e9731df7808094960e (diff) |
Change RSS feeds (#18356)
* Change RSS feeds - Use date and time for titles instead of ellipsized text - Use full content in body, even when there is a content warning - Use media extensions * Change feed icons and add width and height attributes to custom emojis * Fix custom emoji animate on hover breaking * Fix tests
Diffstat (limited to 'app/lib/rss/builder.rb')
-rw-r--r-- | app/lib/rss/builder.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/lib/rss/builder.rb b/app/lib/rss/builder.rb new file mode 100644 index 000000000..a9b3f08c5 --- /dev/null +++ b/app/lib/rss/builder.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class RSS::Builder + attr_reader :dsl + + def self.build + new.tap do |builder| + yield builder.dsl + end.to_xml + end + + def initialize + @dsl = RSS::Channel.new + end + + def to_xml + ('<?xml version="1.0" encoding="UTF-8"?>'.dup << Ox.dump(wrap_in_document, effort: :tolerant)).force_encoding('UTF-8') + end + + private + + def wrap_in_document + Ox::Document.new(version: '1.0').tap do |document| + document << Ox::Element.new('rss').tap do |rss| + rss['version'] = '2.0' + rss['xmlns:webfeeds'] = 'http://webfeeds.org/rss/1.0' + rss['xmlns:media'] = 'http://search.yahoo.com/mrss/' + + rss << @dsl.to_element + end + end + end +end |