Omit empty tags in Atom feed

This commit is contained in:
Eugen Rochko 2016-03-22 20:20:37 +01:00
parent 12d1d9dd80
commit 921f40c187

View file

@ -36,7 +36,7 @@ module AtomBuilderHelper
end end
def content(xml, content) def content(xml, content)
xml.content({ type: 'html' }, content) xml.content({ type: 'html' }, content) unless content.blank?
end end
def title(xml, title) def title(xml, title)
@ -64,11 +64,11 @@ module AtomBuilderHelper
end end
def summary(xml, summary) def summary(xml, summary)
xml.summary summary xml.summary(summary) unless summary.blank?
end end
def subtitle(xml, subtitle) def subtitle(xml, subtitle)
xml.subtitle subtitle xml.subtitle(subtitle) unless subtitle.blank?
end end
def link_alternate(xml, url) def link_alternate(xml, url)
@ -89,8 +89,8 @@ module AtomBuilderHelper
def portable_contact(xml, account) def portable_contact(xml, account)
xml['poco'].preferredUsername account.username xml['poco'].preferredUsername account.username
xml['poco'].displayName account.display_name xml['poco'].displayName(account.display_name) unless account.display_name.blank?
xml['poco'].note account.note xml['poco'].note(account.note) unless account.note.blank?
end end
def in_reply_to(xml, uri, url) def in_reply_to(xml, uri, url)
@ -145,7 +145,7 @@ module AtomBuilderHelper
activity.content activity.content
end end
elsif activity.nil? elsif activity.nil?
'' nil
else else
activity.content activity.content
end end
@ -169,7 +169,6 @@ module AtomBuilderHelper
content xml, conditionally_formatted(stream_entry.activity) content xml, conditionally_formatted(stream_entry.activity)
verb xml, stream_entry.verb verb xml, stream_entry.verb
link_self xml, account_stream_entry_url(stream_entry.account, stream_entry, format: 'atom') link_self xml, account_stream_entry_url(stream_entry.account, stream_entry, format: 'atom')
object_type xml, stream_entry.object_type
# Comments need thread element # Comments need thread element
if stream_entry.threaded? if stream_entry.threaded?
@ -202,6 +201,8 @@ module AtomBuilderHelper
end end
end end
end end
else
object_type xml, stream_entry.object_type
end end
stream_entry.mentions.each do |mentioned| stream_entry.mentions.each do |mentioned|