diff --git a/app/views/answerbox/_actions.haml b/app/views/answerbox/_actions.haml index 6f04c009..9e208d9f 100644 --- a/app/views/answerbox/_actions.haml +++ b/app/views/answerbox/_actions.haml @@ -1,41 +1,41 @@ %span.d-none.d-sm-inline.text-muted - unless user_signed_in? - - if a.smile_count > 0 - %button.btn.btn-info.btn-sm{name: 'ab-smile', disabled: true} + - if a.smile_count.positive? + %button.btn.btn-info.btn-sm{ name: 'ab-smile', disabled: true } %i.fa.fa-smile-o - %span{id: "ab-smile-count-#{a.id}"}= a.smile_count + %span{ id: "ab-smile-count-#{a.id}" }= a.smile_count - if user_signed_in? - if current_user.smiled? a - %button.btn.btn-link.answerbox__action{type: :button, name: 'ab-smile', data: { a_id: a.id, action: :unsmile }} + %button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-smile', data: { a_id: a.id, action: :unsmile } } %i.fa.fa-fw.fa-frown-o - %span{id: "ab-smile-count-#{a.id}"}= a.smile_count + %span{ id: "ab-smile-count-#{a.id}" }= a.smile_count - else - %button.btn.btn-link.answerbox__action{type: :button, name: 'ab-smile', data: { a_id: a.id, action: :smile }} + %button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-smile', data: { a_id: a.id, action: :smile } } %i.fa.fa-fw.fa-smile-o - %span{id: "ab-smile-count-#{a.id}"}= a.smile_count -- unless @display_all - %button.btn.btn-link.answerbox__action{type: :button, name: 'ab-comments', data: { a_id: a.id, state: :hidden }} + %span{ id: "ab-smile-count-#{a.id}" }= a.smile_count +- unless display_all + %button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-comments', data: { a_id: a.id, state: :hidden } } %i.fa.fa-fw.fa-comments - %span{id: "ab-comment-count-#{a.id}"}= a.comment_count + %span{ id: "ab-comment-count-#{a.id}" }= a.comment_count - if user_signed_in? .btn-group - %button.btn.btn-default.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} + %button.btn.btn-default.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %span.caret - .dropdown-menu.dropdown-menu-right{role: :menu} + .dropdown-menu.dropdown-menu-right{ role: :menu } - if Subscription.is_subscribed(current_user, a) -# fun joke should subscribe? - %a.dropdown-item{href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: "no" }} + %a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: 'no' } } %i.fa.fa-anchor = t 'views.actions.unsubscribe' - else - %a.dropdown-item{href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: "yes" }} + %a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: 'yes' } } %i.fa.fa-anchor = t 'views.actions.subscribe' - if privileged? a.user - %a.dropdown-item.text-danger{href: '#', data: { a_id: a.id, action: 'ab-destroy' }} + %a.dropdown-item.text-danger{ href: '#', data: { a_id: a.id, action: 'ab-destroy' } } %i.fa.fa-trash-o = t 'views.actions.return' - unless a.user == current_user - %a.dropdown-item{href: '#', data: { a_id: a.id, action: 'ab-report' }} + %a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-report' } } %i.fa.fa-exclamation-triangle - = t 'views.actions.report' \ No newline at end of file + = t 'views.actions.report' diff --git a/app/views/answerbox/_comments.haml b/app/views/answerbox/_comments.haml index 4e635a3d..d2dbf2d3 100644 --- a/app/views/answerbox/_comments.haml +++ b/app/views/answerbox/_comments.haml @@ -1,52 +1,53 @@ -- if a.comments.all.count == 0 +- if a.comments.all.count.zero? = t 'views.answerbox.no_comment' - else %ul.comment__container - a.comments.order(:created_at).each do |comment| - %li.comment{data: { comment_id: comment.id }} - %div{class: "ab-comment-smile-list", style: "height: 0; width: 0"}= render "modal/comment_smiles", comment: comment + %li.comment{ data: { comment_id: comment.id } } + %div{ style: 'height: 0; width: 0' }= render 'modal/comment_smiles', comment: comment .media .pull-left - %img.comment__user-avatar.avatar-sm{src: comment.user.profile_picture.url(:medium)} + %img.comment__user-avatar.avatar-sm{ src: comment.user.profile_picture.url(:medium) } .media-body %h6.media-heading.comment__user = user_screen_name comment.user - %span.text-muted{title: comment.created_at, data: { toggle: :tooltip, placement: :right }} - = "#{time_ago_in_words(comment.created_at)} ago" + %span.text-muted{ title: comment.created_at, data: { toggle: :tooltip, placement: :right } } + = time_ago_in_words(comment.created_at) + ago .comment__content = markdown comment.content .pull-right %span.d-none.d-sm-inline.text-muted - unless user_signed_in? - - if comment.smile_count > 0 - %button.btn.btn-link.answerbox__action{name: 'ab-smile-comment', disabled: true} + - if comment.smile_count.positive? + %button.btn.btn-link.answerbox__action{ name: 'ab-smile-comment', disabled: true } %i.fa.fa-smile-o - %span{id: "ab-comment-smile-count-#{comment.id}"}= comment.smile_count + %span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count - if user_signed_in? - if current_user.smiled_comment? comment - %button.btn.btn-link.answerbox__action{type: :button, name: 'ab-smile-comment', data: { c_id: comment.id, action: :unsmile }} + %button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-smile-comment', data: { c_id: comment.id, action: :unsmile } } %i.fa.fa-fw.fa-frown-o - %span{id: "ab-comment-smile-count-#{comment.id}"}= comment.smile_count + %span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count - else - %button.btn.btn-link.answerbox__action{type: :button, name: 'ab-smile-comment', data: { c_id: comment.id, action: :smile }} + %button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-smile-comment', data: { c_id: comment.id, action: :smile } } %i.fa.fa-fw.fa-smile-o - %span{id: "ab-comment-smile-count-#{comment.id}"}= comment.smile_count + %span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count .btn-group - %button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} + %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %span.caret - .dropdown-menu.dropdown-menu-right{role: :menu} - %a.dropdown-item{href: '#', type: :button, data: { target: "#modal-view-comment#{comment.id}-smiles", toggle: :modal}} + .dropdown-menu.dropdown-menu-right{ role: :menu } + %a.dropdown-item{ href: '#', type: :button, data: { target: "#modal-view-comment#{comment.id}-smiles", toggle: :modal } } %i.fa.fa-smile-o = t 'views.actions.view' - - if privileged?(comment.user) or privileged?(a.user) - %a.dropdown-item.text-danger{href: '#', data: { action: 'ab-comment-destroy', c_id: comment.id }} + - if privileged?(comment.user) || privileged?(a.user) + %a.dropdown-item.text-danger{ href: '#', data: { action: 'ab-comment-destroy', c_id: comment.id } } %i.fa.fa-trash-o = t 'views.actions.delete' - unless comment.user == current_user - %a.dropdown-item{href: '#', data: { action: 'ab-comment-report', c_id: comment.id }} + %a.dropdown-item{ href: '#', data: { action: 'ab-comment-report', c_id: comment.id } } %i.fa.fa-exclamation-triangle = t 'views.acions.report' - if user_signed_in? - .form-group.has-feedback.comment__input-group{name: 'ab-comment-new-group', data: { a_id: a.id }} - %input.form-control.comment__input{type: :text, placeholder: t('views.placeholder.comment'), name: 'ab-comment-new', data: {a_id: a.id }} - %span.text-muted.form-control-feedback.comment__character-count{id: "ab-comment-charcount-#{a.id}"} 160 + .form-group.has-feedback.comment__input-group{ name: 'ab-comment-new-group', data: { a_id: a.id } } + %input.form-control.comment__input{ type: :text, placeholder: t('views.placeholder.comment'), name: 'ab-comment-new', data: { a_id: a.id } } + %span.text-muted.form-control-feedback.comment__character-count{ id: "ab-comment-charcount-#{a.id}" } 160 diff --git a/app/views/answerbox/_header.haml b/app/views/answerbox/_header.haml index d4d7c8ab..15629140 100644 --- a/app/views/answerbox/_header.haml +++ b/app/views/answerbox/_header.haml @@ -1,21 +1,21 @@ .card-header .media - unless a.question.author_is_anonymous - %a.pull-left{href: show_user_profile_path(a.question.user.screen_name)} - %img.answerbox__question-user-avatar.avatar-md{src: a.question.user.profile_picture.url(:medium)} + %a.pull-left{ href: show_user_profile_path(a.question.user.screen_name) } + %img.answerbox__question-user-avatar.avatar-md{ src: a.question.user.profile_picture.url(:medium) } .media-body - if user_signed_in? .pull-right .btn-group - %button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} + %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %span.caret - .dropdown-menu.dropdown-menu-right{role: :menu} - - if current_user.mod? or a.question.user == current_user - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: a.question.id }} + .dropdown-menu.dropdown-menu-right{ role: :menu } + - if current_user.mod? || a.question.user == current_user + %a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: a.question.id } } %i.fa.fa-trash-o = t 'views.actions.delete' - unless a.question.user == current_user - %a.dropdown-item{href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: a.question.id }} + %a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: a.question.id } } %i.fa.fa-exclamation-triangle = t 'views.actions.report' %h6.text-muted.media-heading.answerbox__question-user @@ -23,7 +23,7 @@ - unless a.question.author_is_anonymous - 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) } = pluralize(a.question.answer_count, t('views.general.answer')) .answerbox__question-text - = a.question.content \ No newline at end of file + = a.question.content diff --git a/app/views/answerbox/_smiles.haml b/app/views/answerbox/_smiles.haml index ef9a8a4f..51f5934e 100644 --- a/app/views/answerbox/_smiles.haml +++ b/app/views/answerbox/_smiles.haml @@ -2,9 +2,11 @@ .pull-left %i.fa.fa-smile-o .media-body - - if a.smiles.all.count == 0 + - if a.smiles.all.count.zero? = t 'views.answerbox.no_smile' - else - a.smiles.all.each do |smile| - %a{href: show_user_profile_path(smile.user.screen_name), title: smile.user.screen_name, data: { toggle: :tooltip, placement: :top, smile_id: smile.id }} - %img.avatar-xs{src: smile.user.profile_picture.url(:medium)} \ No newline at end of file + %a{ href: show_user_profile_path(smile.user.screen_name), + title: smile.user.screen_name, + data: { toggle: :tooltip, placement: :top, smile_id: smile.id } } + %img.avatar-xs{ src: smile.user.profile_picture.url(:medium) }