This commit is contained in:
Jonne Hass 2011-12-10 12:44:55 +01:00
parent 8666c6e209
commit 05be43e21a
2 changed files with 5 additions and 4 deletions

View file

@ -52,19 +52,20 @@ module PeopleHelper
end end
def person_href(person, opts={}) def person_href(person, opts={})
"href=\"#{local_or_remote_person_path(person, opts)}\"" "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe
end end
# Rails.application.routes.url_helpers is needed since this is indirectly called from a model # Rails.application.routes.url_helpers is needed since this is indirectly called from a model
def local_or_remote_person_path(person, opts={}) def local_or_remote_person_path(person, opts={})
opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority) opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority)
absolute = opts.delete(:absolute)
if person.local? if person.local?
username = person.diaspora_handle.split('@')[0] username = person.diaspora_handle.split('@')[0]
unless username.include?('.') unless username.include?('.')
opts.merge!(:username => username) opts.merge!(:username => username)
if opts[:absolute] if absolute
return Rails.application.routes.url_helpers.user_profile_url(opts) return Rails.application.routes.url_helpers.user_profile_url(opts)
else else
return Rails.application.routes.url_helpers.user_profile_path(opts) return Rails.application.routes.url_helpers.user_profile_path(opts)
@ -72,7 +73,7 @@ module PeopleHelper
end end
end end
if opts[:absolute] if absolute
return Rails.application.routes.url_helpers.person_url(person, opts) return Rails.application.routes.url_helpers.person_url(person, opts)
else else
return Rails.application.routes.url_helpers.person_path(person, opts) return Rails.application.routes.url_helpers.person_path(person, opts)

View file

@ -6,7 +6,7 @@
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.url%>"/> <Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.url%>"/>
<Link rel="http://joindiaspora.com/guid" type = 'text/html' href="<%=@person.guid%>"/> <Link rel="http://joindiaspora.com/guid" type = 'text/html' href="<%=@person.guid%>"/>
<Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%="#{person_href(@person, :absolute => true)}"%>/> <Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%=person_href(@person, :absolute => true)%>/>
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/> <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/>
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64s(@person.exported_key)%>"/> <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64s(@person.exported_key)%>"/>