Class: DiasporaFederation::Discovery::WebFinger
- Defined in:
- lib/diaspora_federation/discovery/web_finger.rb
Overview
The WebFinger document used for diaspora* user discovery is based on an RFC 7033.
Constant Summary collapse
- REL_HCARD =
hcard_url
link relation "http://microformats.org/profile/hcard"
- REL_SEED =
seed_url
link relation "http://joindiaspora.com/seed_location"
- REL_PROFILE =
Note:
This might just as well be an
Alias
instead of aLink
.profile_url
link relation. "http://webfinger.net/rel/profile-page"
- REL_ATOM =
atom_url
link relation "http://schemas.google.com/g/2010#updates-from"
- REL_SALMON =
salmon_url
link relation "salmon"
- REL_SUBSCRIBE =
subscribe_url
link relation "http://ostatus.org/schema/1.0/subscribe"
Constants inherited from Entity
Entity::ENTITY_NAME_REGEX, Entity::INVALID_XML_REGEX
Instance Attribute Summary collapse
-
#acct_uri ⇒ String
readonly
The Subject element should contain the WebFinger address that was asked for.
-
#additional_data ⇒ Hash
readonly
Additional WebFinger data.
-
#atom_url ⇒ String
readonly
This atom feed is an Activity Stream of the user’s public posts.
-
#hcard_url ⇒ String
readonly
Link to the
hCard
. -
#profile_url ⇒ String
readonly
Link to the users profile.
-
#salmon_url ⇒ String
readonly
Salmon endpoint url.
-
#seed_url ⇒ String
readonly
Link to the pod.
-
#subscribe_url ⇒ Object
readonly
This url is used to find another user on the home-pod of the user in the WebFinger.
Class Method Summary collapse
-
.from_hash(data) ⇒ WebFinger
Creates a WebFinger instance from the given data.
-
.from_json(webfinger_json) ⇒ WebFinger
Creates a WebFinger instance from the given JSON string.
Instance Method Summary collapse
-
#initialize(data, additional_data = {}) ⇒ WebFinger
constructor
Initializes a new WebFinger Entity.
-
#to_json(*_args) ⇒ String
Creates the JSON string from the current WebFinger instance.
-
#to_s ⇒ String
String representation of this object.
Methods inherited from Entity
class_name, entity_class, entity_name, #to_h
Methods included from PropertiesDSL
#class_props, #default_values, #entity, #missing_props, #optional_props, #property, #resolv_aliases
Methods included from Logging
Constructor Details
#initialize(data, additional_data = {}) ⇒ WebFinger
Initializes a new WebFinger Entity
99 100 101 102 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 99 def initialize(data, additional_data={}) @additional_data = additional_data super(data) end |
Instance Attribute Details
#acct_uri ⇒ String (readonly)
The Subject element should contain the WebFinger address that was asked for. If it does not, then this WebFinger profile MUST be ignored.
32 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 32 property :acct_uri, :string |
#additional_data ⇒ Hash (readonly)
Additional WebFinger data
89 90 91 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 89 def additional_data @additional_data end |
#atom_url ⇒ String (readonly)
This atom feed is an Activity Stream of the user’s public posts. diaspora* pods SHOULD publish an Activity Stream of public posts, but there is currently no requirement to be able to read Activity Streams. Note that this feed MAY also be made available through the PubSubHubbub mechanism by supplying a <link rel=“hub”> in the atom feed itself.
55 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 55 property :atom_url, :string, optional: true |
#hcard_url ⇒ String (readonly)
Returns link to the hCard
.
36 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 36 property :hcard_url, :string |
#profile_url ⇒ String (readonly)
Returns link to the users profile.
44 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 44 property :profile_url, :string, optional: true |
#salmon_url ⇒ String (readonly)
could be nil
Returns salmon endpoint url.
62 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 62 property :salmon_url, :string, optional: true |
#seed_url ⇒ String (readonly)
Returns link to the pod.
40 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 40 property :seed_url, :string |
#subscribe_url ⇒ Object (readonly)
This url is used to find another user on the home-pod of the user in the WebFinger.
66 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 66 property :subscribe_url, :string, optional: true |
Class Method Details
.from_hash(data) ⇒ WebFinger
Creates a WebFinger instance from the given data
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 132 def self.from_hash(data) links = data[:links] new( acct_uri: data[:subject], hcard_url: parse_link(links, REL_HCARD), seed_url: parse_link(links, REL_SEED), profile_url: parse_link(links, REL_PROFILE), atom_url: parse_link(links, REL_ATOM), salmon_url: parse_link(links, REL_SALMON), subscribe_url: parse_link_template(links, REL_SUBSCRIBE) ) end |
.from_json(webfinger_json) ⇒ WebFinger
Creates a WebFinger instance from the given JSON string
125 126 127 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 125 def self.from_json(webfinger_json) from_hash(parse_json_and_validate(webfinger_json)) end |
Instance Method Details
#to_json(*_args) ⇒ String
Creates the JSON string from the current WebFinger instance
112 113 114 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 112 def to_json(*_args) to_xrd.to_json end |
#to_s ⇒ String
Returns string representation of this object.
149 150 151 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 149 def to_s "WebFinger:#{acct_uri}" end |