Decorate User#nickname

openid
Marcin Kulik 12 years ago
parent 80619928a8
commit a1fad7ccb7

@ -144,16 +144,13 @@ class AsciicastDecorator < ApplicationDecorator
end
def author
name =
if asciicast.user
asciicast.user.nickname
elsif asciicast.username
asciicast.username
else
'anonymous'
end
"~#{name}"
if user
user.nickname
elsif asciicast.username
"~#{asciicast.username}"
else
'anonymous'
end
end
private

@ -1,13 +1,17 @@
class UserDecorator < ApplicationDecorator
decorates :user
def nickname
"~#{user.nickname}"
end
def asciicasts_count
model && model.asciicasts.count
end
def avatar_img(options = {})
klass = options[:class] || "avatar"
title = options[:title] || user && "~#{user.nickname}"
title = options[:title] || user && nickname
h.image_tag user && user.avatar_url || default_avatar_url,
:title => title, :alt => title, :class => klass

@ -2,7 +2,7 @@
<% if current_user %>
<li class="username">
<%= current_user.avatar_profile_link(:title => '') %>
<%= link_to "~#{current_user.nickname}", profile_path(current_user) %>
<%= link_to current_user.nickname, profile_path(current_user) %>
<ul class="menu">
<li>

@ -1,6 +1,6 @@
Howdy!
~<%= @author.nickname %> (<%= profile_url(@author) %>) commented on your asciicast "<%= @asciicast.title %>":
<%= @author.nickname %> (<%= profile_url(@author) %>) commented on your asciicast "<%= @asciicast.title %>":
<%= indented_text @comment.body, 4 %>

@ -1,7 +1,7 @@
<section class="supplimental">
<div class="wrapper">
<div class="main">
<h1>Asciicasts by ~<%= @user.nickname %></h1>
<h1>Asciicasts by <%= @user.nickname %></h1>
<%= render :partial => 'asciicasts/previews',
:locals => { :asciicasts => @asciicasts } %>

Loading…
Cancel
Save