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.

44 lines
1.5 KiB

  1. doc = Ox::Document.new(version: '1.0')
  2. doc << Ox::Element.new('XRD').tap do |xrd|
  3. xrd['xmlns'] = 'http://docs.oasis-open.org/ns/xri/xrd-1.0'
  4. xrd << (Ox::Element.new('Subject') << @account.to_webfinger_s)
  5. xrd << (Ox::Element.new('Alias') << short_account_url(@account))
  6. xrd << (Ox::Element.new('Alias') << account_url(@account))
  7. xrd << Ox::Element.new('Link').tap do |link|
  8. link['rel'] = 'http://webfinger.net/rel/profile-page'
  9. link['type'] = 'text/html'
  10. link['href'] = short_account_url(@account)
  11. end
  12. xrd << Ox::Element.new('Link').tap do |link|
  13. link['rel'] = 'http://schemas.google.com/g/2010#updates-from'
  14. link['type'] = 'application/atom+xml'
  15. link['href'] = account_url(@account, format: 'atom')
  16. end
  17. xrd << Ox::Element.new('Link').tap do |link|
  18. link['rel'] = 'self'
  19. link['type'] = 'application/activity+json'
  20. link['href'] = account_url(@account)
  21. end
  22. xrd << Ox::Element.new('Link').tap do |link|
  23. link['rel'] = 'salmon'
  24. link['href'] = api_salmon_url(@account.id)
  25. end
  26. xrd << Ox::Element.new('Link').tap do |link|
  27. link['rel'] = 'magic-public-key'
  28. link['href'] = "data:application/magic-public-key,#{@account.magic_key}"
  29. end
  30. xrd << Ox::Element.new('Link').tap do |link|
  31. link['rel'] = 'http://ostatus.org/schema/1.0/subscribe'
  32. link['template'] = "#{authorize_interaction_url}?acct={uri}"
  33. end
  34. end
  35. ('<?xml version="1.0" encoding="UTF-8"?>' + Ox.dump(doc, effort: :tolerant)).force_encoding('UTF-8')