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.

39 lines
1.7 KiB

  1. Nokogiri::XML::Builder.new do |xml|
  2. 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
  3. xml.id_ unique_tag(@entry.created_at, @entry.activity_id, @entry.activity_type)
  4. xml.published @entry.activity.created_at.iso8601
  5. xml.updated @entry.activity.updated_at.iso8601
  6. xml.title @entry.title
  7. xml.content({ type: 'html' }, @entry.content)
  8. xml['activity'].send('verb', "http://activitystrea.ms/schema/1.0/#{@entry.verb}")
  9. xml.author do
  10. xml['activity'].send('object-type', 'http://activitystrea.ms/schema/1.0/person')
  11. xml.uri profile_url(name: @entry.account.username)
  12. xml.name @entry.account.username
  13. xml.summary @entry.account.note
  14. xml.link(rel: 'alternate', type: 'text/html', href: profile_url(name: @entry.account.username))
  15. xml['poco'].preferredUsername @entry.account.username
  16. xml['poco'].displayName @entry.account.display_name
  17. xml['poco'].note @entry.account.note
  18. end
  19. if @entry.targeted?
  20. xml['activity'].send('object') do
  21. xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{@entry.target.object_type}")
  22. xml.id_ @entry.target.uri
  23. xml.title @entry.target.title
  24. xml.summary @entry.target.summary
  25. xml.link(rel: 'alternate', type: 'text/html', href: @entry.target.uri)
  26. end
  27. else
  28. xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{@entry.object_type}")
  29. end
  30. xml.link(rel: 'self', type: 'application/atom+xml', href: atom_entry_url(id: @entry.id))
  31. end
  32. end.to_xml