Skip to content
Extraits de code Groupes Projets
Valider d407be03 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

i am not a number! include username in the main url of a local user!

parent 540a3e68
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -61,7 +61,7 @@ class PeopleController < ApplicationController
end
def show
@person = Person.where(:id => params[:id]).first
@person = find_person_from_id_or_username
if @person && @person.remote? && !user_signed_in?
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
return
......@@ -156,4 +156,13 @@ class PeopleController < ApplicationController
Resque.enqueue(Job::SocketWebfinger, current_user.id, account, opts)
end
def find_person_from_id_or_username
if params[:id].present?
Person.where(:id => params[:id]).first
elsif params[:username].present?
User.find_by_username(params[:username]).person
else
nil
end
end
end
......@@ -3,6 +3,9 @@
# the COPYRIGHT file.
module ApplicationHelper
def how_long_ago(obj)
timeago(obj.created_at)
end
......@@ -48,9 +51,15 @@ module ApplicationHelper
def person_link(person, opts={})
opts[:class] ||= ""
opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person
"<a href='/people/#{person.id}' class='#{opts[:class]}'>
#{h(person.name)}
</a>".html_safe
if person.local?
"<a href='#{person.diaspora_handle.split('@')[0]}' class='#{opts[:class]}'>
#{h(person.name)}
</a>".html_safe
else
"<a href='/people/#{person.id}'>
#{h(person.name)}
</a>".html_safe
end
end
def hard_link(string, path)
......@@ -62,9 +71,15 @@ module ApplicationHelper
if opts[:to] == :photos
link_to person_image_tag(person, opts[:size]), person_photos_path(person)
else
"<a href='/people/#{person.id}'>
#{person_image_tag(person)}
</a>".html_safe
if person.local?
"<a href='#{person.diaspora_handle.split('@')[0]}' class='#{opts[:class]}'>
#{person_image_tag(person)}
</a>".html_safe
else
"<a href='/people/#{person.id}'>
#{person_image_tag(person)}
</a>".html_safe
end
end
end
......
......@@ -154,7 +154,7 @@ Diaspora::Application.routes.draw do
get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
get ':username' => 'people#show', :as => 'user_profile'
# Startpage
root :to => 'home#show'
......
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