The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

54 line
2.3 KiB

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