From fe7071751083122553e13a25425ec2eb169a8fd0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 10 May 2020 10:02:04 +0200 Subject: [PATCH] Fix lints in app/views/shared --- app/views/shared/_announcements.haml | 4 +-- .../shared/_cursored_pagination_dummy.haml | 6 ++-- .../shared/{_links.html.haml => _links.haml} | 2 +- app/views/shared/_locales.haml | 8 ++--- app/views/shared/_question.haml | 31 +++++++++++++++++++ app/views/shared/_question.html.haml | 31 ------------------- app/views/shared/_sidebar.haml | 8 ++--- app/views/shared/_userbox.haml | 8 ++--- app/views/user/show_follow.haml | 2 +- app/views/user/show_follow.js.erb | 2 +- 10 files changed, 51 insertions(+), 51 deletions(-) rename app/views/shared/{_links.html.haml => _links.haml} (80%) create mode 100644 app/views/shared/_question.haml delete mode 100644 app/views/shared/_question.html.haml diff --git a/app/views/shared/_announcements.haml b/app/views/shared/_announcements.haml index 3f4bab7b..0088f830 100644 --- a/app/views/shared/_announcements.haml +++ b/app/views/shared/_announcements.haml @@ -2,8 +2,8 @@ - @active_announcements.each do |announcement| .alert.announcement.alert-info.alert-dismissable.d-none{ data: { 'announcement-id': announcement.id } } .container - %button.close{ type: "button", "data-dismiss" => "alert" } - %span{ "aria-hidden" => "true" } × + %button.close{ type: 'button', 'data-dismiss' => 'alert' } + %span{ 'aria-hidden' => 'true' } × %p = announcement.content - if announcement.link_present? diff --git a/app/views/shared/_cursored_pagination_dummy.haml b/app/views/shared/_cursored_pagination_dummy.haml index 84436d34..d9949ea8 100644 --- a/app/views/shared/_cursored_pagination_dummy.haml +++ b/app/views/shared/_cursored_pagination_dummy.haml @@ -1,11 +1,11 @@ -# this renders a pagination html to keep compatibility with the current pagination js --# it _should_ be replaced with something else entirely later on. + it _should_ be replaced with something else entirely later on. - permitted_params ||= [] #pagination %ul.pagination - %li.next{class: more_data_available ? nil : "disabled"} + %li.next{ class: more_data_available ? nil : 'disabled' } - if more_data_available - %a{rel: :next, href: url_for(params.permit(*permitted_params).merge(last_id: last_id))} + %a{ rel: :next, href: url_for(params.permit(*permitted_params).merge(last_id: last_id)) } Next page - else Next page diff --git a/app/views/shared/_links.html.haml b/app/views/shared/_links.haml similarity index 80% rename from app/views/shared/_links.html.haml rename to app/views/shared/_links.haml index 2c85b582..e12b91d8 100644 --- a/app/views/shared/_links.html.haml +++ b/app/views/shared/_links.haml @@ -5,7 +5,7 @@ · = link_to t('views.general.about'), about_path · - = link_to "GitHub", 'https://github.com/Retrospring/retrospring' + = link_to 'GitHub', 'https://github.com/Retrospring/retrospring' · = link_to t('views.general.terms'), terms_path · diff --git a/app/views/shared/_locales.haml b/app/views/shared/_locales.haml index 36b3e4cc..52e687d7 100644 --- a/app/views/shared/_locales.haml +++ b/app/views/shared/_locales.haml @@ -1,12 +1,12 @@ .container .locales %span - %a{href: '#', id: 'locale-switch'} + %a{ href: '#', id: 'locale-switch' } %i.fa.fa-globe = t('views.locale.languages') - #locales-panel.locales__panel + .locales__panel#locales-panel %ul - APP_LOCALES.each do |key, value| %li - .flag{class: "flag-#{value[1]}"} - %a{href: "?hl=#{key}"}= value[0] + .flag{ class: "flag-#{value[1]}" } + %a{ href: "?hl=#{key}" }= value[0] diff --git a/app/views/shared/_question.haml b/app/views/shared/_question.haml new file mode 100644 index 00000000..6e99bf30 --- /dev/null +++ b/app/views/shared/_question.haml @@ -0,0 +1,31 @@ +- type ||= nil +.card{ data: { id: q.id } } + .card-body + .media + - if type == 'discover' + .pull-left + %a{ href: user_screen_name(q.user, link_only: true) } + %img.avatar-md.mr-2{ src: q.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 } } + %span.caret + .dropdown-menu.dropdown-menu-right{ role: :menu } + - if current_user.mod? || q.user == current_user + %a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: q.id } } + %i.fa.fa-trash-o + = t 'views.actions.delete' + - unless q.user == current_user + %a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: q.id } } + %i.fa.fa-exclamation-triangle + = t 'views.actions.report' + %h6.media-heading.text-muted.answerbox__question-user + = raw t('views.answerbox.asked', user: user_screen_name(q.user), time: time_tooltip(q)) + - if q.answer_count > 1 + · + %a{ href: show_user_question_path(q.user.screen_name, q.id) } + = pluralize(q.answer_count, t('views.general.answer')) + %p.answerbox__question-text + = q.content diff --git a/app/views/shared/_question.html.haml b/app/views/shared/_question.html.haml deleted file mode 100644 index bf53049f..00000000 --- a/app/views/shared/_question.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -- type ||= nil -.card{data: { id: q.id }} - .card-body - .media - - if type == "discover" - .pull-left - %a{href: user_screen_name(q.user, link_only: true)} - %img.avatar-md.mr-2{src: q.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 }} - %span.caret - .dropdown-menu.dropdown-menu-right{role: :menu} - - if current_user.mod? or q.user == current_user - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: q.id }} - %i.fa.fa-trash-o - = t 'views.actions.delete' - - unless q.user == current_user - %a.dropdown-item{href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: q.id }} - %i.fa.fa-exclamation-triangle - = t 'views.actions.report' - %h6.media-heading.text-muted.answerbox__question-user - = raw t('views.answerbox.asked', user: user_screen_name(q.user), time: time_tooltip(q)) - - if q.answer_count > 1 - · - %a{href: show_user_question_path(q.user.screen_name, q.id)} - = pluralize(q.answer_count, t('views.general.answer')) - %p.answerbox__question-text - = q.content diff --git a/app/views/shared/_sidebar.haml b/app/views/shared/_sidebar.haml index 205d49ad..c8d8b09b 100644 --- a/app/views/shared/_sidebar.haml +++ b/app/views/shared/_sidebar.haml @@ -1,7 +1,7 @@ .card.userbox - %img.userbox__header{src: current_user.profile_header.url(:mobile)} + %img.userbox__header{ src: current_user.profile_header.url(:mobile) } .card-body - %img.userbox__avatar{src: current_user.profile_picture.url(:small)} + %img.userbox__avatar{ src: current_user.profile_picture.url(:small) } .profile__name - unless current_user.display_name.blank? .profile__display-name @@ -15,7 +15,7 @@ - if @group.members.empty? %p.text-muted No members yet! - @group.members.each do |member| - %a{href: show_user_profile_path(member.user.screen_name), title: member.user.screen_name, data: { toggle: :tooltip, placement: :top }} - %img.avatar-xs{src: member.user.profile_picture.url(:medium)} + %a{ href: show_user_profile_path(member.user.screen_name), title: member.user.screen_name, data: { toggle: :tooltip, placement: :top } } + %img.avatar-xs{ src: member.user.profile_picture.url(:medium) } = render 'shared/links' diff --git a/app/views/shared/_userbox.haml b/app/views/shared/_userbox.haml index 67a4472e..a7325486 100644 --- a/app/views/shared/_userbox.haml +++ b/app/views/shared/_userbox.haml @@ -1,9 +1,9 @@ -- type ||= @type || :nil +- type ||= :nil .card.h-100.userbox - %img.userbox__header{src: user.profile_header.url(:mobile)} + %img.userbox__header{ src: user.profile_header.url(:mobile) } .card-body - %img.userbox__avatar{src: user.profile_picture.url(:small)} - %a.profile__name{href: show_user_profile_path(user.screen_name)} + %img.userbox__avatar{ src: user.profile_picture.url(:small) } + %a.profile__name{ href: show_user_profile_path(user.screen_name) } - unless user.display_name.blank? .profile__display-name = user.display_name diff --git a/app/views/user/show_follow.haml b/app/views/user/show_follow.haml index a0817101..22801fcb 100644 --- a/app/views/user/show_follow.haml +++ b/app/views/user/show_follow.haml @@ -1,7 +1,7 @@ .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - @users.each do |user| .col - = render 'shared/userbox', user: user + = render 'shared/userbox', user: user, type: @type = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @users_last_id diff --git a/app/views/user/show_follow.js.erb b/app/views/user/show_follow.js.erb index 213d55f3..7ccf8cd2 100644 --- a/app/views/user/show_follow.js.erb +++ b/app/views/user/show_follow.js.erb @@ -1,5 +1,5 @@ $('#users').append('<% @users.each do |user| - %>
<%= j render 'shared/userbox', user: user + %>
<%= j render 'shared/userbox', user: user, type: @type %>
<% end %>'); <% if @more_data_available %> $('#pagination').html('<%= j render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @users_last_id %>');