localized answerbox (trigger warning: horrible code)
This commit is contained in:
parent
ac2d50398b
commit
9c83972105
|
@ -39,6 +39,14 @@ module ApplicationHelper
|
||||||
content_tag(:a, body.html_safe, href: path, class: ("list-group-item #{'active ' if current_page? path}#{options[:class]}"))
|
content_tag(:a, body.html_safe, href: path, class: ("list-group-item #{'active ' if current_page? path}#{options[:class]}"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tooltip(body, tooltip_content, placement)
|
||||||
|
content_tag(:span, body, {title: tooltip_content, "data-toggle" => "tooltip", "data-placement" => placement} )
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidespan(body, hide)
|
||||||
|
content_tag(:span, body, class: "hidden-#{hide}")
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
def bootstrap_color c
|
def bootstrap_color c
|
||||||
|
|
|
@ -23,21 +23,12 @@
|
||||||
%i.fa.fa-exclamation-triangle
|
%i.fa.fa-exclamation-triangle
|
||||||
Report
|
Report
|
||||||
%h6.text-muted.media-heading.answerbox--question-user
|
%h6.text-muted.media-heading.answerbox--question-user
|
||||||
= user_screen_name a.question.user, a.question.author_is_anonymous
|
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, a.question.author_is_anonymous), time: (@user.nil? or a.question.author_is_anonymous) ? tooltip(time_ago_in_words(a.question.created_at), a.question.created_at, "bottom") : link_to(tooltip(time_ago_in_words(a.question.created_at), a.question.created_at, "bottom"),show_user_question_path(a.question.user.screen_name, a.question.id)))
|
||||||
asked
|
|
||||||
- if @user.nil? or a.question.author_is_anonymous
|
|
||||||
%span{title: a.question.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
|
||||||
= time_ago_in_words(a.question.created_at)
|
|
||||||
- else
|
|
||||||
%a{href: show_user_question_path(a.question.user.screen_name, a.question.id)}
|
|
||||||
%span{title: a.question.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
|
||||||
= time_ago_in_words(a.question.created_at)
|
|
||||||
ago
|
|
||||||
- unless a.question.author_is_anonymous
|
- unless a.question.author_is_anonymous
|
||||||
- if a.question.answer_count > 1
|
- if a.question.answer_count > 1
|
||||||
·
|
·
|
||||||
%a{href: show_user_question_path(a.question.user.screen_name, a.question.id)}
|
%a{href: show_user_question_path(a.question.user.screen_name, a.question.id)}
|
||||||
#{a.question.answer_count} answers
|
= pluralize(a.question.answer_count, t('views.general.answer'))
|
||||||
.answerbox--question-text
|
.answerbox--question-text
|
||||||
= a.question.content
|
= a.question.content
|
||||||
.panel-body
|
.panel-body
|
||||||
|
@ -48,7 +39,7 @@
|
||||||
[...]
|
[...]
|
||||||
%p
|
%p
|
||||||
%a.btn.btn-primary{href: show_user_answer_path(a.user.screen_name, a.id)}
|
%a.btn.btn-primary{href: show_user_answer_path(a.user.screen_name, a.id)}
|
||||||
Read the entire answer
|
= t 'views.answerbox.read'
|
||||||
- else
|
- else
|
||||||
.answerbox--answer-text
|
.answerbox--answer-text
|
||||||
= markdown a.content
|
= markdown a.content
|
||||||
|
@ -61,24 +52,16 @@
|
||||||
%img.img-rounded.answerbox--img{src: gravatar_url(a.user)}
|
%img.img-rounded.answerbox--img{src: gravatar_url(a.user)}
|
||||||
.media-body
|
.media-body
|
||||||
%h6.media-heading.answerbox--answer-user
|
%h6.media-heading.answerbox--answer-user
|
||||||
%span.hidden-xs
|
= raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), "xs"), user: user_screen_name(a.user))
|
||||||
Answered by
|
|
||||||
= user_screen_name a.user
|
|
||||||
.answerbox--answer-date
|
.answerbox--answer-date
|
||||||
%a{href: show_user_answer_path(a.user.screen_name, a.id)}
|
= link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id))
|
||||||
%span{title: a.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
|
||||||
= time_ago_in_words(a.created_at)
|
|
||||||
ago
|
|
||||||
.col-md-6.col-sm-8.col-xs-6.text-right
|
.col-md-6.col-sm-8.col-xs-6.text-right
|
||||||
= render 'shared/answerbox_buttons', a: a
|
= render 'shared/answerbox_buttons', a: a
|
||||||
- else
|
- else
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-sm-4.col-xs-6.text-left.text-muted
|
.col-md-6.col-sm-4.col-xs-6.text-left.text-muted
|
||||||
%i.fa.fa-clock-o
|
%i.fa.fa-clock-o
|
||||||
%a{href: show_user_answer_path(a.user.screen_name, a.id)}
|
= link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id))
|
||||||
%span{title: a.created_at, data: { toggle: :tooltip, placement: :bottom }}
|
|
||||||
= time_ago_in_words(a.created_at)
|
|
||||||
ago
|
|
||||||
.col-md-6.col-sm-8.col-xs-6.text-right
|
.col-md-6.col-sm-8.col-xs-6.text-right
|
||||||
= render 'shared/answerbox_buttons', a: a
|
= render 'shared/answerbox_buttons', a: a
|
||||||
.panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil }
|
.panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil }
|
||||||
|
|
|
@ -105,4 +105,10 @@ en:
|
||||||
new: "registered %{time} ago"
|
new: "registered %{time} ago"
|
||||||
answers: "answered %{questions}"
|
answers: "answered %{questions}"
|
||||||
questions: "asked %{questions}"
|
questions: "asked %{questions}"
|
||||||
|
answerbox:
|
||||||
|
asked: "%{user} asked %{time} ago"
|
||||||
|
read: "Read the entire answer"
|
||||||
|
answered: "%{hide} %{user}"
|
||||||
|
hide: "Answered by"
|
||||||
|
time: "%{time} ago"
|
||||||
hello: "Hello world"
|
hello: "Hello world"
|
||||||
|
|
Loading…
Reference in New Issue