Skip to content
Extraits de code Groupes Projets
Valider c6aff4a5 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

making the hcard work

parent 6645d209
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,6 +29,7 @@ gem 'json' ...@@ -29,6 +29,7 @@ gem 'json'
#Standards #Standards
gem 'pubsubhubbub' gem 'pubsubhubbub'
gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git' gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
gem 'prism'
#EventMachine #EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http' gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
......
...@@ -152,6 +152,8 @@ GEM ...@@ -152,6 +152,8 @@ GEM
plucky (0.3.5) plucky (0.3.5)
mongo (~> 1.0.8) mongo (~> 1.0.8)
polyglot (0.3.1) polyglot (0.3.1)
prism (0.1.0)
nokogiri
pubsubhubbub (0.1.1) pubsubhubbub (0.1.1)
em-http-request (>= 0.1.5) em-http-request (>= 0.1.5)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
...@@ -242,6 +244,7 @@ DEPENDENCIES ...@@ -242,6 +244,7 @@ DEPENDENCIES
mongo_ext mongo_ext
mongo_mapper (= 0.8.4)! mongo_mapper (= 0.8.4)!
nifty-generators nifty-generators
prism
pubsubhubbub pubsubhubbub
rails (= 3.0.0) rails (= 3.0.0)
redfinger! redfinger!
......
...@@ -88,17 +88,24 @@ class Person ...@@ -88,17 +88,24 @@ class Person
end end
def self.from_webfinger_profile( identifier, profile) def self.from_webfinger_profile( identifier, profile)
public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href
new_person = Person.new new_person = Person.new
public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href
new_person.exported_key = Base64.decode64 public_key new_person.exported_key = Base64.decode64 public_key
new_person.email = identifier new_person.email = identifier
puts profile.hcard.first[:href]
hcard = Prism.find profile.hcard.first[:href]
puts hcard.inspect
receive_url = profile.links.select{ |l| l.rel == 'http://joindiaspora.com/seed_location'}.first.href receive_url = profile.links.select{ |l| l.rel == 'http://joindiaspora.com/seed_location'}.first.href
new_person.url = receive_url.split('receive').first new_person.url = receive_url.split('receive').first
new_person.profile = Profile.new(:first_name => "Anon", :last_name => "ymous") new_person.profile = Profile.new(:first_name => "Anon", :last_name => "ymous")
if new_person.save! if new_person.save
new_person new_person
else else
cry nil
end end
end end
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>acct:<%=@person.email%></Subject> <Subject>acct:<%=@person.email%></Subject>
<Alias>"<%= @person.url %>users/#{@user.id}/hcard"</Alias> <Alias>"<%= @person.url %>"</Alias>
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>hcard"/> <Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>/hcard/users/<%=@person.id%>"/>
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.url%>status_messages.atom"/> <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.url%>status_messages.atom"/>
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.receive_url%>"/> <Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.receive_url%>"/>
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/> <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/>
......
...@@ -27,7 +27,7 @@ Diaspora::Application.routes.draw do ...@@ -27,7 +27,7 @@ Diaspora::Application.routes.draw do
#public routes #public routes
# #
match 'webfinger', :to => 'publics#webfinger' match 'webfinger', :to => 'publics#webfinger'
match 'users/:id/hcard', :to => 'publics#hcard' match 'hcard/users/:id', :to => 'publics#hcard'
match '.well-known/host-meta',:to => 'publics#host_meta' match '.well-known/host-meta',:to => 'publics#host_meta'
match 'receive/users/:id', :to => 'publics#receive' match 'receive/users/:id', :to => 'publics#receive'
......
...@@ -144,6 +144,12 @@ describe Person do ...@@ -144,6 +144,12 @@ describe Person do
it 'should search by email exactly' do it 'should search by email exactly' do
Person.by_webfinger(@friend_one.email).should == @friend_one Person.by_webfinger(@friend_one.email).should == @friend_one
end end
it 'should create a stub for a remote user' do
tom = Person.by_webfinger('tom@tom.joindiaspora.com')
puts tom.real_name
tom.real_name.include?("Hamiltom").should be true
end
describe 'wall posting' do describe 'wall posting' do
it 'should be able to post on another persons wall' do it 'should be able to post on another persons wall' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter