Show anon identifier in tooltip when unmasking
This commit is contained in:
parent
03a4ea512a
commit
e5b8ea017c
|
@ -42,10 +42,6 @@ module ApplicationHelper
|
|||
false
|
||||
end
|
||||
|
||||
def moderation_view?
|
||||
current_user.mod? && session[:moderation_view] == true
|
||||
end
|
||||
|
||||
def rails_admin_path_for_resource(resource)
|
||||
[rails_admin_path, resource.model_name.param_key, resource.id].join("/")
|
||||
end
|
||||
|
|
|
@ -27,17 +27,17 @@ module ApplicationHelper::TitleMethods
|
|||
|
||||
def question_title(question)
|
||||
context_user = question.answers&.first&.user if question.direct
|
||||
name = user_screen_name question.user, context_user: context_user, anonymous: question.author_is_anonymous, url: false
|
||||
name = user_screen_name question.user, context_user: context_user, author_identifier: question.author_identifier, url: false
|
||||
generate_title name, "asked", question.content
|
||||
end
|
||||
|
||||
def answer_title(answer)
|
||||
name = user_screen_name answer.user, anonymous: false, url: false
|
||||
name = user_screen_name answer.user, url: false
|
||||
generate_title name, "answered", answer.question.content
|
||||
end
|
||||
|
||||
def user_title(user, junction = nil)
|
||||
name = user_screen_name user, anonymous: false, url: false
|
||||
name = user_screen_name user, url: false
|
||||
generate_title name, junction, nil, !junction.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
module UserHelper
|
||||
# Decides what user name to show.
|
||||
# @param context_user [User] the user whose the profile preferences should be applied
|
||||
# @param author_identifier [nil, String] the author identifier of the question (questions only)
|
||||
# @return [String] The user name
|
||||
def user_screen_name(user, context_user: nil, anonymous: false, url: true, link_only: false)
|
||||
return profile_link(user) if should_unmask?(user, anonymous)
|
||||
return anonymous_name(context_user) if anonymous?(user, anonymous)
|
||||
def user_screen_name(user, context_user: nil, author_identifier: nil, url: true, link_only: false)
|
||||
return unmask(user, context_user, author_identifier) if should_unmask?(author_identifier)
|
||||
return anonymous_name(context_user) if anonymous?(user, author_identifier.present?)
|
||||
|
||||
if url
|
||||
return show_user_profile_path(user.screen_name) if link_only
|
||||
|
@ -16,14 +17,24 @@ module UserHelper
|
|||
user.profile.safe_name.strip
|
||||
end
|
||||
|
||||
def moderation_view?
|
||||
current_user.mod? && session[:moderation_view] == true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def profile_link(user)
|
||||
link_to(user.profile.safe_name, show_user_profile_path(user.screen_name), class: ("user--banned" if user.banned?).to_s)
|
||||
end
|
||||
|
||||
def should_unmask?(user, anonymous)
|
||||
user.present? && moderation_view? && anonymous
|
||||
def should_unmask?(anonymous_identifier)
|
||||
moderation_view? && anonymous_identifier.present?
|
||||
end
|
||||
|
||||
def unmask(user, context_user, anonymous_identifier)
|
||||
return profile_link(user) if user.present?
|
||||
|
||||
"<abbr title='#{anonymous_identifier}'>#{anonymous_name(context_user)}</abbr>"
|
||||
end
|
||||
|
||||
def anonymous_name(context_user)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
%h6.text-muted.media-heading.answerbox__question-user
|
||||
- if a.question.author_is_anonymous
|
||||
%i.fa.fa-user-secret{ title: t('.anon_hint') }
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, context_user: a.user, anonymous: a.question.author_is_anonymous), time: time_tooltip(a.question))
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, context_user: a.user, author_identifier: a.question.author_identifier), time: time_tooltip(a.question))
|
||||
- if !a.question.author_is_anonymous && !a.question.direct
|
||||
·
|
||||
%a{ href: show_user_question_path(a.question.user.screen_name, a.question.id) }
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
- else
|
||||
- a.smiles.all.each do |smile|
|
||||
%a{ href: show_user_profile_path(smile.user.screen_name),
|
||||
title: user_screen_name(smile.user, anonymous: false, url: false),
|
||||
title: user_screen_name(smile.user, url: false),
|
||||
data: { toggle: :tooltip, placement: :top, smile_id: smile.id } }
|
||||
%img.avatar-xs{ src: smile.user.profile_picture.url(:medium) }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
%h6.text-muted.media-heading.answerbox__question-user
|
||||
- if i.question.author_is_anonymous
|
||||
%i.fa.fa-user-secret{ title: t('.anon_hint') }
|
||||
= t(".asked_html", user: user_screen_name(i.question.user, context_user: i.user, anonymous: i.question.author_is_anonymous), time: time_tooltip(i.question))
|
||||
= t(".asked_html", user: user_screen_name(i.question.user, context_user: i.user, author_identifier: i.question.author_identifier), time: time_tooltip(i.question))
|
||||
- if !i.question.author_is_anonymous && i.question.answer_count.positive?
|
||||
·
|
||||
%a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) }
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
- if hidden
|
||||
= user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
|
||||
- else
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(question.user, anonymous: question.author_is_anonymous), time: time_tooltip(question))
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(question.user, author_identifier: question.author_identifier), time: time_tooltip(question))
|
||||
.answerbox__question-text= question_markdown question.content
|
||||
|
|
Loading…
Reference in New Issue