From 6b8a9e86106ec3d19d3058ce9de0dc8722e85fb4 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 10 Mar 2012 14:56:25 +0100 Subject: [PATCH] Profile links with tilde --- app/helpers/application_helper.rb | 3 ++- app/helpers/asciicasts_helper.rb | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1bfe30f..416ee57 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -12,7 +12,8 @@ module ApplicationHelper end def avatar_img(user) + nickname = "~#{user.nickname}" image_tag user.avatar_url || default_avatar_url, - :title => user.nickname, :alt => user.nickname, :class => "avatar" + :title => nickname, :alt => nickname, :class => "avatar" end end diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index 27a962f..b05a6eb 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -10,10 +10,15 @@ module AsciicastsHelper end end - def asciicast_author(asciicast) + def profile_link(asciicast, options = {}) if asciicast.user - link_to avatar_img(asciicast.user) + " #{asciicast.user.nickname}", - profile_path(asciicast.user) + if options[:avatar] + img = avatar_img(asciicast.user) + " " + else + img = "" + end + + link_to img + "~#{asciicast.user.nickname}", profile_path(asciicast.user) end end