parent
0393a64a90
commit
42bcbd36b7
@ -0,0 +1,26 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class WebfingerSerializer < ActiveModel::Serializer
|
||||||
|
include RoutingHelper
|
||||||
|
|
||||||
|
attributes :subject, :aliases, :links
|
||||||
|
|
||||||
|
def subject
|
||||||
|
object.to_webfinger_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def aliases
|
||||||
|
[short_account_url(object), account_url(object)]
|
||||||
|
end
|
||||||
|
|
||||||
|
def links
|
||||||
|
[
|
||||||
|
{ rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(object) },
|
||||||
|
{ rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(object, format: 'atom') },
|
||||||
|
{ rel: 'self', type: 'application/activity+json', href: account_url(object) },
|
||||||
|
{ rel: 'salmon', href: api_salmon_url(object.id) },
|
||||||
|
{ rel: 'magic-public-key', href: "data:application/magic-public-key,#{object.magic_key}" },
|
||||||
|
{ rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" },
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
@ -1,18 +0,0 @@
|
|||||||
object @account
|
|
||||||
|
|
||||||
node(:subject) { @canonical_account_uri }
|
|
||||||
|
|
||||||
node(:aliases) do
|
|
||||||
[short_account_url(@account), account_url(@account)]
|
|
||||||
end
|
|
||||||
|
|
||||||
node(:links) do
|
|
||||||
[
|
|
||||||
{ rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(@account) },
|
|
||||||
{ rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom') },
|
|
||||||
{ rel: 'self', type: 'application/activity+json', href: account_url(@account) },
|
|
||||||
{ rel: 'salmon', href: api_salmon_url(@account.id) },
|
|
||||||
{ rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}" },
|
|
||||||
{ rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" },
|
|
||||||
]
|
|
||||||
end
|
|
@ -1,13 +1,13 @@
|
|||||||
Nokogiri::XML::Builder.new do |xml|
|
Nokogiri::XML::Builder.new do |xml|
|
||||||
xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do
|
xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do
|
||||||
xml.Subject @canonical_account_uri
|
xml.Subject @account.to_webfinger_s
|
||||||
xml.Alias short_account_url(@account)
|
xml.Alias short_account_url(@account)
|
||||||
xml.Alias account_url(@account)
|
xml.Alias account_url(@account)
|
||||||
xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(@account))
|
xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: short_account_url(@account))
|
||||||
xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom'))
|
xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom'))
|
||||||
xml.Link(rel: 'self', type: 'application/activity+json', href: account_url(@account))
|
xml.Link(rel: 'self', type: 'application/activity+json', href: account_url(@account))
|
||||||
xml.Link(rel: 'salmon', href: api_salmon_url(@account.id))
|
xml.Link(rel: 'salmon', href: api_salmon_url(@account.id))
|
||||||
xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}")
|
xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@account.magic_key}")
|
||||||
xml.Link(rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}")
|
xml.Link(rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}")
|
||||||
end
|
end
|
||||||
end.to_xml
|
end.to_xml
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Oj.default_options = { mode: :compat, time_format: :ruby, use_to_json: true }
|
@ -1,7 +0,0 @@
|
|||||||
Rabl.configure do |config|
|
|
||||||
config.json_engine = Oj
|
|
||||||
config.cache_all_output = false
|
|
||||||
config.cache_sources = Rails.env.production?
|
|
||||||
config.include_json_root = false
|
|
||||||
config.view_paths = [Rails.root.join('app/views')]
|
|
||||||
end
|
|
Loading…
Reference in new issue