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

Add hcard, add id for pod_location

parent 59006e65
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
require 'lib/hcard'
class Person class Person
include MongoMapper::Document include MongoMapper::Document
include ROXML include ROXML
...@@ -97,13 +99,13 @@ class Person ...@@ -97,13 +99,13 @@ class Person
puts profile.hcard.first[:href] puts profile.hcard.first[:href]
hcard = Prism.find profile.hcard.first[:href], :hcard hcard = HCard.find profile.hcard.first[:href]
pp hcard.class
debugger
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 = hcard[:url]
new_person.profile = Profile.new(:first_name => "Anon", :last_name => "ymous") puts new_person.url
if new_person.save new_person.profile = Profile.new(:first_name => hcard[:given_name], :last_name => hcard[:family_name])
if new_person.save!
new_person new_person
else else
nil nil
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
<dd> <dd>
<span class="family_name" ><%= @person.profile.last_name %></span> <span class="family_name" ><%= @person.profile.last_name %></span>
</dd> </dd>
</dl> <dl class="entity_fn"> </dl>
<dl class="entity_fn">
<dt>Full name</dt> <dt>Full name</dt>
<dd> <dd>
<span class="fn" ><%= @person.real_name %></span> <span class="fn" ><%= @person.real_name %></span>
...@@ -29,7 +30,7 @@ ...@@ -29,7 +30,7 @@
<dl class="entity_url"> <dl class="entity_url">
<dt>URL</dt> <dt>URL</dt>
<dd> <dd>
<a href="<%= @person.url%>" rel="me" class="url"><%= @person.url%></a> <a href="<%= @person.url%>" rel="me" id="pod_location" class="url"><%= @person.url%></a>
</dd> </dd>
</dl> </dl>
<dl class="entity_note"> <dl class="entity_note">
......
module HCard
def self.find url
doc = Nokogiri::HTML(Net::HTTP.get URI.parse(url))
{:given_name => doc.css(".given_name").text,
:family_name => doc.css(".family_name").text,
:url => doc.css("#pod_location").text}
end
end
require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/../../lib/hcard'
describe HCard do
it 'should retreive and parse an hcard' do
f = Redfinger.finger('tom@tom.joindiaspora.com')
hcard = HCard.find f.hcard.first[:href]
hcard[:family_name].include?("Hamiltom").should be true
hcard[:given_name].include?("Alex").should be true
pp hcard
(hcard[:url] == "http://tom.joindiaspora.com").should be true
end
end
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