about summary refs log tree commit diff
path: root/app/views/atom/entry.xml.ruby
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/atom/entry.xml.ruby')
-rw-r--r--app/views/atom/entry.xml.ruby56
1 files changed, 27 insertions, 29 deletions
diff --git a/app/views/atom/entry.xml.ruby b/app/views/atom/entry.xml.ruby
index b66a720b3..2a26e624a 100644
--- a/app/views/atom/entry.xml.ruby
+++ b/app/views/atom/entry.xml.ruby
@@ -1,39 +1,37 @@
 Nokogiri::XML::Builder.new do |xml|
-  xml.entry(xmlns: 'http://www.w3.org/2005/Atom', 'xmlns:thr': 'http://purl.org/syndication/thread/1.0', 'xmlns:activity': 'http://activitystrea.ms/spec/1.0/', 'xmlns:poco': 'http://portablecontacts.net/spec/1.0') do
-    xml.id_ unique_tag(@entry.created_at, @entry.activity_id, @entry.activity_type)
+  entry(xml, true) do
+    unique_id    xml, @entry.created_at, @entry.activity_id, @entry.activity_type
+    published_at xml, @entry.activity.created_at
+    updated_at   xml, @entry.activity.updated_at
+    title        xml, @entry.title
+    content      xml, @entry.content
+    verb         xml, @entry.verb
 
-    xml.published @entry.activity.created_at.iso8601
-    xml.updated   @entry.activity.updated_at.iso8601
-
-    xml.title @entry.title
-    xml.content({ type: 'html' }, @entry.content)
-    xml['activity'].send('verb', "http://activitystrea.ms/schema/1.0/#{@entry.verb}")
-
-    xml.author do
-      xml['activity'].send('object-type', 'http://activitystrea.ms/schema/1.0/person')
-      xml.uri profile_url(name: @entry.account.username)
-      xml.name @entry.account.username
-      xml.summary @entry.account.note
-
-      xml.link(rel: 'alternate', type: 'text/html', href: profile_url(name: @entry.account.username))
-
-      xml['poco'].preferredUsername @entry.account.username
-      xml['poco'].displayName @entry.account.display_name
-      xml['poco'].note @entry.account.note
+    author(xml) do
+      object_type      xml, :person
+      uri              xml, profile_url(name: @entry.account.username)
+      name             xml, @entry.account.username
+      summary          xml, @entry.account.note
+      link_alternate   xml, profile_url(name: @entry.account.username)
+      portable_contact xml, @entry.account
     end
 
     if @entry.targeted?
-      xml['activity'].send('object') do
-        xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{@entry.target.object_type}")
-        xml.id_ @entry.target.uri
-        xml.title @entry.target.title
-        xml.summary @entry.target.summary
-        xml.link(rel: 'alternate', type: 'text/html', href: @entry.target.uri)
+      target(xml) do
+        object_type    xml, @entry.target.object_type
+        simple_id      xml, @entry.target.uri
+        title          xml, @entry.target.title
+        summary        xml, @entry.target.summary
+        link_alternate xml, @entry.target.uri
+
+        if @entry.target.object_type == :person
+          portable_contact xml, @entry.target
+        end
       end
     else
-      xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{@entry.object_type}")
+      object_type xml, @entry.object_type
     end
 
-    xml.link(rel: 'self', type: 'application/atom+xml', href: atom_entry_url(id: @entry.id))
+    link_self xml, atom_entry_url(id: @entry.id)
   end
-end.to_xml
+end