changing some webfinger resources

This commit is contained in:
maxwell 2010-08-10 12:36:00 -07:00
parent 95c4de5d6c
commit 71612ba33d
9 changed files with 39 additions and 25 deletions

View file

@ -3,8 +3,11 @@ class PublicsController < ApplicationController
include Diaspora::Parser
def hcard
@user = User.owner
render 'hcard'
@person = Person.first(:_id => params[:id])
unless @person.nil? || @person.owner.nil?
render 'hcard'
end
end
def host_meta
@ -13,8 +16,10 @@ class PublicsController < ApplicationController
end
def webfinger
@user = Person.first(:email => params[:q].gsub('acct:', ''))
render 'webfinger', :layout => false, :content_type => 'application/xrd+xml'
@person = Person.first(:email => params[:q].gsub('acct:', ''))
unless @person.nil? || @person.owner.nil?
render 'webfinger', :layout => false, :content_type => 'application/xrd+xml'
end
end
def receive

View file

@ -14,4 +14,11 @@ module PublicsHelper
400
end
end
def terse_url(full_url)
terse = full_url.gsub(/https?:\/\//, '')
terse.gsub!(/www\./, '')
terse = terse.chop! if terse[-1, 1] == '/'
terse
end
end

View file

@ -109,6 +109,9 @@ class Person
self.id == post.person.id
end
def recieve_url
"#{self.url}user/#{self.owner.id}"
end
protected
def clean_url

View file

@ -77,14 +77,11 @@ class User
def receive_friend_request(friend_request)
Rails.logger.debug("receiving friend request #{friend_request.to_json}")
#u am originator
if Request.where(:callback_url => person.url, :destination_url => person.url).first
puts "NOOO!!"
activate_friend friend_request.person
Rails.logger.debug("#{self.real_name}'s friend request has been accepted")
friend_request.destroy
else
puts "423423"
friend_request.person.save
pending_requests << friend_request
save

View file

@ -1,24 +1,24 @@
<div id="content">
<h1><%=@user.real_name%></h1>
<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="<%=@user.url%>" rel="me" class="nickname url uid"><%= @user.real_name%></a>
<a href="<%=@person.url%>" rel="me" class="nickname url uid"><%= @person.real_name%></a>
</dd>
</dl>
<dl class="entity_fn">
<dt>Full name</dt>
<dd>
<span class="fn"><%= @user.real_name %></span>
<span class="fn"><%= @person.real_name %></span>
</dd>
</dl>
<dl class="entity_url">
<dt>URL</dt>
<dd>
<a href="<%= @user.url%>" rel="me" class="url"><%= @user.url%></a>
<a href="<%= @person.url%>" rel="me" class="url"><%= @person.url%></a>
</dd>
</dl>
<dl class="entity_note">

View file

@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/xrd/1.0'>
<hm:Host><%= @user.terse_url %></hm:Host>
<hm:Host><%= terse_url(root_url) %></hm:Host>
<Link rel='lrdd'
template='<%=@user.url%>webfinger?q={uri}'>
template='<%= root_url %>webfinger?q={uri}'>
<Title>Resource Descriptor</Title>
</Link>
</XRD>

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:<%=@user.email%></Subject>
<Alias>"<%=@user.url%>hcard"</Alias>
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@user.url%>hcard"/>
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@user.url%>status_messages.atom"/>
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@user.url%>"/>
<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"/>
<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%>"/>
</XRD>

View file

@ -24,13 +24,13 @@ Diaspora::Application.routes.draw do |map|
#match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration"
resources :users
#public routes
match 'receive/users/:id', :to => 'publics#receive'
match '.well-known/host-meta',:to => 'publics#host_meta'
match 'webfinger', :to => 'publics#webfinger'
match 'hcard', :to => 'publics#hcard'
#
match 'webfinger', :to => 'publics#webfinger'
match 'users/:id/hcard', :to => 'publics#hcard'
match '.well-known/host-meta',:to => 'publics#host_meta'
match 'receive/users/:id', :to => 'publics#receive'
#root
root :to => 'dashboards#index'
end

View file

@ -4,6 +4,8 @@ describe Person do
before do
@person = Factory.create(:person)
end
it 'should not allow two people with the same email' do
person_two = Factory.build(:person, :url => @person.email)
person_two.valid?.should == false