Make user_screen_name helper use kwargs, add link_only arg
This commit is contained in:
parent
f7d06135ef
commit
b8701e7626
|
@ -132,17 +132,17 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def question_title(question)
|
||||
name = user_screen_name question.user, question.author_is_anonymous, false
|
||||
name = user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
|
||||
generate_title name, "asked", question.content
|
||||
end
|
||||
|
||||
def answer_title(answer)
|
||||
name = user_screen_name answer.user, false, false
|
||||
name = user_screen_name answer.user, anonymous: false, url: false
|
||||
generate_title name, "answered", answer.question.content
|
||||
end
|
||||
|
||||
def user_title(user, junction = nil)
|
||||
name = user_screen_name user, false, false
|
||||
name = user_screen_name user, anonymous: false, url: false
|
||||
generate_title name, junction, nil, !junction.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
module UserHelper
|
||||
# Decides what user name to show.
|
||||
# @return [String] The user name
|
||||
def user_screen_name(user, anonymous=false, url=true)
|
||||
def user_screen_name(user, anonymous: false, url: true, link_only: false)
|
||||
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
||||
name = user.display_name.blank? ? user.screen_name : user.display_name
|
||||
return link_to(name, show_user_profile_path(user.screen_name), class: "#{"user--banned" if user.banned?}") if url
|
||||
if url
|
||||
link = show_user_profile_path(user.screen_name)
|
||||
return link if link_only
|
||||
return link_to(name, link, class: "#{"user--banned" if user.banned?}")
|
||||
end
|
||||
name.strip
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
%img.img-rounded.answerbox--img{src: gravatar_url(i.question.user)}
|
||||
.media-body
|
||||
%h6.text-muted.media-heading.answerbox--question-user
|
||||
= raw t('views.inbox.entry.asked', user: user_screen_name(i.question.user, i.question.author_is_anonymous), time: time_tooltip(i.question))
|
||||
= raw t('views.inbox.entry.asked', user: user_screen_name(i.question.user, anonymous: i.question.author_is_anonymous), time: time_tooltip(i.question))
|
||||
- unless i.question.author_is_anonymous
|
||||
- if i.question.answer_count > 0
|
||||
·
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
%i.fa.fa-exclamation-triangle
|
||||
= t 'views.actions.report'
|
||||
%h6.text-muted.media-heading.answerbox--question-user
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, a.question.author_is_anonymous), time: time_tooltip(a.question))
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, anonymous: a.question.author_is_anonymous), time: time_tooltip(a.question))
|
||||
- unless a.question.author_is_anonymous
|
||||
- if a.question.answer_count > 1
|
||||
·
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
- comment.smiles.all.each do |smile|
|
||||
%li.user-list-entry.user-list-entry-smiles
|
||||
%a{href: show_user_profile_path(smile.user.screen_name)}
|
||||
%img.img-rounded{src: gravatar_url(smile.user), alt: user_screen_name(smile.user, false, false)}
|
||||
%span= user_screen_name(smile.user, false, false)
|
||||
%img.img-rounded{src: gravatar_url(smile.user), alt: user_screen_name(smile.user, url: false)}
|
||||
%span= user_screen_name(smile.user, url: false)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.media
|
||||
- if type == "discover"
|
||||
.pull-left
|
||||
%a{href: show_user_profile_path(q.user.screen_name)}
|
||||
%a{href: user_screen_name(q.user.screen_name, link_only: true)}
|
||||
%img.answerbox--img{src: q.user.profile_picture.url(:medium)}
|
||||
.media-body
|
||||
- if user_signed_in?
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
= t 'views.actions.report'
|
||||
%h6.text-muted.media-heading.answerbox--question-user
|
||||
- if hidden
|
||||
= user_screen_name question.user, question.author_is_anonymous, false
|
||||
= user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
|
||||
- else
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(question.user, question.author_is_anonymous), time: time_tooltip(question))
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(question.user, anonymous: question.author_is_anonymous), time: time_tooltip(question))
|
||||
%p.answerbox--question-text= question.content
|
||||
|
|
Loading…
Reference in New Issue