about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-22 20:20:37 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-22 20:20:37 +0100
commit921f40c1873883e8ce476e04de1f3f1bd5ccbf91 (patch)
tree8bb1579ac2d52af20131f206e74f4d1b7aa2ac02 /app/helpers
parent12d1d9dd808b26b3257d93f61c8e1f2f45605ebb (diff)
Omit empty tags in Atom feed
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/atom_builder_helper.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb
index da34f1854..d5180f0f5 100644
--- a/app/helpers/atom_builder_helper.rb
+++ b/app/helpers/atom_builder_helper.rb
@@ -36,7 +36,7 @@ module AtomBuilderHelper
   end
 
   def content(xml, content)
-    xml.content({ type: 'html' }, content)
+    xml.content({ type: 'html' }, content) unless content.blank?
   end
 
   def title(xml, title)
@@ -64,11 +64,11 @@ module AtomBuilderHelper
   end
 
   def summary(xml, summary)
-    xml.summary summary
+    xml.summary(summary) unless summary.blank?
   end
 
   def subtitle(xml, subtitle)
-    xml.subtitle subtitle
+    xml.subtitle(subtitle) unless subtitle.blank?
   end
 
   def link_alternate(xml, url)
@@ -89,8 +89,8 @@ module AtomBuilderHelper
 
   def portable_contact(xml, account)
     xml['poco'].preferredUsername account.username
-    xml['poco'].displayName account.display_name
-    xml['poco'].note account.note
+    xml['poco'].displayName(account.display_name) unless account.display_name.blank?
+    xml['poco'].note(account.note) unless account.note.blank?
   end
 
   def in_reply_to(xml, uri, url)
@@ -145,7 +145,7 @@ module AtomBuilderHelper
         activity.content
       end
     elsif activity.nil?
-      ''
+      nil
     else
       activity.content
     end
@@ -169,7 +169,6 @@ module AtomBuilderHelper
     content      xml, conditionally_formatted(stream_entry.activity)
     verb         xml, stream_entry.verb
     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
     if stream_entry.threaded?
@@ -202,6 +201,8 @@ module AtomBuilderHelper
           end
         end
       end
+    else
+      object_type xml, stream_entry.object_type
     end
 
     stream_entry.mentions.each do |mentioned|