making the hcard work

This commit is contained in:
Raphael 2010-09-09 13:02:59 -07:00
parent 6645d2090e
commit c6aff4a562
6 changed files with 23 additions and 6 deletions

View file

@ -29,6 +29,7 @@ gem 'json'
#Standards
gem 'pubsubhubbub'
gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
gem 'prism'
#EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'

View file

@ -152,6 +152,8 @@ GEM
plucky (0.3.5)
mongo (~> 1.0.8)
polyglot (0.3.1)
prism (0.1.0)
nokogiri
pubsubhubbub (0.1.1)
em-http-request (>= 0.1.5)
eventmachine (>= 0.12.9)
@ -242,6 +244,7 @@ DEPENDENCIES
mongo_ext
mongo_mapper (= 0.8.4)!
nifty-generators
prism
pubsubhubbub
rails (= 3.0.0)
redfinger!

View file

@ -88,17 +88,24 @@ class Person
end
def self.from_webfinger_profile( identifier, profile)
public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href
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.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
new_person.url = receive_url.split('receive').first
new_person.profile = Profile.new(:first_name => "Anon", :last_name => "ymous")
if new_person.save!
if new_person.save
new_person
else
cry
nil
end
end

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>acct:<%=@person.email%></Subject>
<Alias>"<%= @person.url %>users/#{@user.id}/hcard"</Alias>
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>hcard"/>
<Alias>"<%= @person.url %>"</Alias>
<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://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.receive_url%>"/>
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/>

View file

@ -27,7 +27,7 @@ Diaspora::Application.routes.draw do
#public routes
#
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 'receive/users/:id', :to => 'publics#receive'

View file

@ -144,6 +144,12 @@ describe Person do
it 'should search by email exactly' do
Person.by_webfinger(@friend_one.email).should == @friend_one
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
it 'should be able to post on another persons wall' do