hcard has searchable field, and is taken in to account when building Person from webfinger

This commit is contained in:
danielvincent 2010-11-02 16:12:12 -07:00
parent fff43bf650
commit da8124f8a7
9 changed files with 57 additions and 64 deletions

View file

@ -55,15 +55,6 @@ GIT
carrierwave (0.5.0)
activesupport (~> 3.0)
GIT
remote: git://github.com/rsofaer/redfinger.git
revision: 07721f46d02b9d3aa04880788fecb0b4c1b284d7
specs:
redfinger (0.0.6)
hashie
nokogiri (>= 1.4.0)
rest-client (>= 1.5.0)
GIT
remote: git://github.com/rsofaer/sprinkle.git
revision: 7c744ed158dda1f99a015e6a29d086e80bd8c635
@ -409,7 +400,6 @@ DEPENDENCIES
omniauth
pubsubhubbub
rails (>= 3.0.0)
redfinger!
roxml!
rspec (>= 2.0.0)
rspec-rails (>= 2.0.0)

View file

@ -55,10 +55,6 @@ class PeopleController < ApplicationController
params[:person][:profile][:birthday] ||= Date.parse("#{birthday[:year]}-#{birthday[:month]}-#{birthday[:day]}")
end
search_flag = params[:person][:searchable]
search_flag.to_s.match(/(true)/) ? search_flag = true : search_flag = false
params[:person][:searchable] = search_flag
# upload and set new profile photo
if params[:person][:profile][:image].present?
raw_image = params[:person][:profile].delete(:image)

View file

@ -11,7 +11,7 @@ class PublicsController < ApplicationController
def hcard
@person = Person.find_by_id params[:id]
unless @person.nil? || @person.owner.nil?
render 'hcard'
render 'publics/hcard'
else
render :nothing => true, :status => 404
end

View file

@ -122,7 +122,10 @@ class Person
#hcard_profile = HCard.find profile.hcard.first[:href]
Rails.logger.info("hcard: #{ hcard.inspect}")
new_person.url = hcard[:url]
new_person.profile = Profile.new(:first_name => hcard[:given_name], :last_name => hcard[:family_name], :image_url => hcard[:photo])
new_person.profile = Profile.new( :first_name => hcard[:given_name],
:last_name => hcard[:family_name],
:image_url => hcard[:photo],
:searchable => hcard[:searchable])
new_person.save! ? new_person : nil
end

View file

@ -1,44 +0,0 @@
<div id="content">
<h1><%=@person.real_name%></h1>
<div id="content_inner">
<div id="i" class="entity_profile vcard author">
<h2>User profile</h2>
<dl class="entity_nickname">
<dt>Nickname</dt>
<dd>
<a href="<%=@person.url%>" rel="me" class="nickname url uid"><%= @person.real_name%></a>
</dd>
</dl>
<dl class="entity_given_name">
<dt>First name</dt>
<dd>
<span class="given_name" ><%= @person.profile.first_name %></span>
</dd>
</dl>
<dl class="entity_family_name">
<dt>Family name</dt>
<dd>
<span class="family_name" ><%= @person.profile.last_name %></span>
</dd>
</dl>
<dl class="entity_fn">
<dt>Full name</dt>
<dd>
<span class="fn" ><%= @person.real_name %></span>
</dd>
</dl>
<dl class="entity_url">
<dt>URL</dt>
<dd>
<a href="<%= @person.url%>" rel="me" id="pod_location" class="url"><%= @person.url%></a>
</dd>
</dl>
<dl class="entity_photo">
<dt>Photo</dt>
<dd>
<img class="photo avatar" src="<%= image_or_default(@person)%>" width="100" height="100"/>
</dd>
</dl>
</div>
</div>
</div>

View file

@ -0,0 +1,40 @@
#content
%h1= @person.real_name
#content_inner
#i.entity_profile.vcard.author
%h2 User profile
%dl.entity_nickname
%dt Nickname
%dd
%a.nickname.url.uid{:href=>@person.url, :rel=>'me'}= @person.real_name
%dl.entity_given_name
%dt First name
%dd
%span.given_name= @person.profile.first_name
%dl.entity_family_name
%dt Family name
%dd
%span.family_name= @person.profile.last_name
%dl.entity_fn
%dt Full name
%dd
%span.fn= @person.real_name
%dl.entity_url
%dt URL
%dd
%a#pod_location.url{:href=>@person.url, :rel=>'me'}= @person.url
%dl.entity_photo
%dt Photo
%dd
%img.photo.avatar{:src=>image_or_default(@person), :width=>'100px', :height=>'100px'}
%dl.entity_searchable
%dt Searchable
%dd
%span.searchable= @person.profile.searchable

View file

@ -5,10 +5,11 @@
module HCard
def self.parse doc
{
:given_name => doc.css(".given_name").text,
:given_name => doc.css(".given_name").text,
:family_name => doc.css(".family_name").text,
:url => doc.css("#pod_location").text,
:photo => doc.css(".photo[src]").attribute('src').text
:url => doc.css("#pod_location").text,
:photo => doc.css(".photo[src]").attribute('src').text,
:searchable => doc.css(".searchable").text
}
end

View file

@ -43,6 +43,12 @@
<dt>Note</dt>
<dd class="note">Diaspora is awesome! vi is better than emacs!</dd>
</dl>
<dl class='entity_searchable'>
<dt>Searchable</dt>
<dd>
<span class='searchable'>false</span>
</dd>
</dl>
</div>
</div>
</div>

View file

@ -12,6 +12,7 @@ describe HCard do
hcard[:family_name].include?("Hamiltom").should be true
hcard[:given_name].include?("Alex").should be true
hcard[:photo].include?("tom.jpg").should be true
hcard[:url].should == "http://tom.joindiaspora.com/"
hcard[:url].should == "http://tom.joindiaspora.com/"
hcard[:searchable].should == "false"
end
end