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 older draft of the specification.
In the meantime an actual RFC draft has been in development, which should serve as a base for all future changes of this implementation.
Constant Summary collapse
- REL_HCARD =
hcard_url
link relation "http://microformats.org/profile/hcard".freeze
- REL_SEED =
seed_url
link relation "http://joindiaspora.com/seed_location".freeze
- REL_PROFILE =
Note:
This might just as well be an
Alias
instead of aLink
.profile_url
link relation. "http://webfinger.net/rel/profile-page".freeze
- REL_ATOM =
atom_url
link relation "http://schemas.google.com/g/2010#updates-from".freeze
- REL_SALMON =
salmon_url
link relation "salmon".freeze
- REL_SUBSCRIBE =
subscribe_url
link relation "http://ostatus.org/schema/1.0/subscribe".freeze
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.
-
.from_xml(webfinger_xml) ⇒ WebFinger
Creates a WebFinger instance from the given XML string.
Instance Method Summary collapse
-
#initialize(data, additional_data = {}) ⇒ WebFinger
constructor
Initializes a new WebFinger Entity.
- #to_json ⇒ Object
-
#to_s ⇒ String
String representation of this object.
-
#to_xml ⇒ String
Creates the XML string from the current WebFinger instance.
Methods inherited from Entity
class_name, entity_class, entity_name, #to_h
Methods included from PropertiesDSL
#class_props, #default_values, #entity, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names
Methods included from Logging
Constructor Details
#initialize(data, additional_data = {}) ⇒ WebFinger
Initializes a new WebFinger Entity
102 103 104 105 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 102 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.
35 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 35 property :acct_uri, :string |
#additional_data ⇒ Hash (readonly)
Additional WebFinger data
92 93 94 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 92 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.
58 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 58 property :atom_url, :string, optional: true |
#hcard_url ⇒ String (readonly)
Returns link to the hCard
.
39 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 39 property :hcard_url, :string |
#profile_url ⇒ String (readonly)
Returns link to the users profile.
47 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 47 property :profile_url, :string, optional: true |
#salmon_url ⇒ String (readonly)
could be nil
Returns salmon endpoint url.
65 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 65 property :salmon_url, :string, optional: true |
#seed_url ⇒ String (readonly)
Returns link to the pod.
43 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 43 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.
69 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 69 property :subscribe_url, :string, optional: true |
Class Method Details
.from_hash(data) ⇒ WebFinger
Creates a WebFinger instance from the given data
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 135 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
128 129 130 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 128 def self.from_json(webfinger_json) from_hash(XrdDocument.json_data(webfinger_json)) end |
.from_xml(webfinger_xml) ⇒ WebFinger
Creates a WebFinger instance from the given XML string
121 122 123 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 121 def self.from_xml(webfinger_xml) from_hash(parse_xml_and_validate(webfinger_xml)) end |
Instance Method Details
#to_json ⇒ Object
113 114 115 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 113 def to_json to_xrd.to_json end |
#to_s ⇒ String
Returns string representation of this object.
152 153 154 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 152 def to_s "WebFinger:#{acct_uri}" end |
#to_xml ⇒ String
Creates the XML string from the current WebFinger instance
109 110 111 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 109 def to_xml to_xrd.to_xml end |