mastodon/app/views/atom/user_stream.xml.ruby

54 lines
2.3 KiB
Plaintext
Raw Normal View History

2016-02-22 16:00:20 +01:00
Nokogiri::XML::Builder.new do |xml|
2016-02-22 19:11:07 +01:00
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
2016-02-22 16:00:20 +01:00
xml.id_ atom_user_stream_url(id: @account.id)
xml.title @account.display_name
xml.subtitle @account.note
xml.updated stream_updated_at
xml.author do
xml['activity'].send('object-type', 'http://activitystrea.ms/schema/1.0/person')
xml.uri profile_url(name: @account.username)
xml.name @account.username
xml.summary @account.note
xml.link(rel: 'alternate', type: 'text/html', href: profile_url(name: @account.username))
2016-02-22 19:11:07 +01:00
xml['poco'].preferredUsername @account.username
xml['poco'].displayName @account.display_name
xml['poco'].note @account.note
2016-02-22 16:00:20 +01:00
end
xml.link(rel: 'alternate', type: 'text/html', href: profile_url(name: @account.username))
2016-02-22 18:10:30 +01:00
xml.link(rel: 'hub', href: HUB_URL)
2016-02-22 16:00:20 +01:00
xml.link(rel: 'salmon', href: salmon_url(@account))
xml.link(rel: 'self', type: 'application/atom+xml', href: atom_user_stream_url(id: @account.id))
2016-02-22 19:11:07 +01:00
@account.stream_entries.order('id desc').each do |stream_entry|
2016-02-22 16:00:20 +01:00
xml.entry do
xml.id_ unique_tag(stream_entry.created_at, stream_entry.activity_id, stream_entry.activity_type)
2016-02-22 18:10:30 +01:00
2016-02-22 16:00:20 +01:00
xml.published stream_entry.activity.created_at.iso8601
xml.updated stream_entry.activity.updated_at.iso8601
2016-02-22 18:10:30 +01:00
xml.title stream_entry.title
xml.content({ type: 'html' }, stream_entry.content)
2016-02-22 16:00:20 +01:00
xml['activity'].send('verb', "http://activitystrea.ms/schema/1.0/#{stream_entry.verb}")
2016-02-22 18:10:30 +01:00
if stream_entry.targeted?
xml['activity'].send('object') do
xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{stream_entry.target.object_type}")
xml.id_ stream_entry.target.uri
2016-02-22 19:11:07 +01:00
xml.title stream_entry.target.title
xml.summary stream_entry.target.summary
xml.link(rel: 'alternate', type: 'text/html', href: stream_entry.target.uri)
2016-02-22 18:10:30 +01:00
end
else
xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{stream_entry.object_type}")
end
2016-02-22 19:11:07 +01:00
xml.link(rel: 'self', type: 'application/atom+xml', href: atom_entry_url(id: stream_entry.id))
2016-02-22 16:00:20 +01:00
end
end
end
end.to_xml