diff --git a/.github/workflows/retrospring.yml b/.github/workflows/retrospring.yml index f6f1e23f..90d33f11 100644 --- a/.github/workflows/retrospring.yml +++ b/.github/workflows/retrospring.yml @@ -67,6 +67,8 @@ jobs: env: POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} REDIS_URL: "redis://localhost:${{ job.services.redis.ports[6379] }}" + - name: Lint HAML templates + run: bundle exec haml-lint app/views - uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.haml-lint.yml b/.haml-lint.yml new file mode 100644 index 00000000..42b1d2eb --- /dev/null +++ b/.haml-lint.yml @@ -0,0 +1,130 @@ +skip_frontmatter: false + +linters: + AlignmentTabs: + enabled: true + + AltText: + enabled: false + + ClassAttributeWithStaticValue: + enabled: true + + ClassesBeforeIds: + enabled: true + + ConsecutiveComments: + enabled: true + max_consecutive: 1 + + ConsecutiveSilentScripts: + enabled: true + max_consecutive: 2 + + EmptyObjectReference: + enabled: true + + EmptyScript: + enabled: true + + FinalNewline: + enabled: true + present: true + + HtmlAttributes: + enabled: true + + IdNames: + enabled: true + style: lisp_case + + ImplicitDiv: + enabled: true + + Indentation: + enabled: true + character: space # or tab + width: 2 # ignored if character == tab + + InlineStyles: + enabled: false + + InstanceVariables: + enabled: true + file_types: partials + matchers: + all: .* + partials: \A_.*\.haml\z + + LeadingCommentSpace: + enabled: true + + LineLength: + enabled: true + max: 160 + + MultilinePipe: + enabled: true + + MultilineScript: + enabled: true + + ObjectReferenceAttributes: + enabled: true + + RepeatedId: + enabled: true + severity: error + + RuboCop: + enabled: true + # These cops are incredibly noisy when it comes to HAML templates, so we + # ignore them. + ignored_cops: + - Lint/BlockAlignment + - Lint/EndAlignment + - Lint/Void + - Layout/AlignParameters + - Layout/EmptyLineAfterGuardClause + - Layout/IndentationWidth + - Layout/TrailingEmptyLines + - Layout/TrailingWhitespace + - Metrics/BlockLength + - Metrics/BlockNesting + - Metrics/LineLength + - Style/BlockNesting + - Style/ElseAlignment + - Style/EndOfLine + - Style/FileName + - Style/FinalNewline + - Style/FrozenStringLiteralComment + - Style/IdenticalConditionalBranches + - Style/IfUnlessModifier + - Style/Next + - Style/WhileUntilModifier + + RubyComments: + enabled: true + + SpaceBeforeScript: + enabled: true + + SpaceInsideHashAttributes: + enabled: true + style: space + + TagName: + enabled: true + + TrailingWhitespace: + enabled: true + + UnnecessaryInterpolation: + enabled: true + + UnnecessaryStringOutput: + enabled: true + + ViewLength: + enabled: true + max: 200 diff --git a/.rubocop.yml b/.rubocop.yml index 47316f61..8d3dc4dd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,5 @@ AllCops: - Rails: - Enabled: true + NewCops: enable Exclude: - 'vendor/**/*' - 'db/schema.rb' diff --git a/Gemfile b/Gemfile index 470ffa08..0fb8001e 100644 --- a/Gemfile +++ b/Gemfile @@ -106,4 +106,5 @@ group :development, :test do gem 'guard-brakeman' gem 'timecop' gem 'rails-controller-testing' + gem 'haml_lint', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index fb1728a5..2f64072f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) + ast (2.4.0) autoprefixer-rails (9.7.6) execjs bcrypt (3.1.13) @@ -197,6 +198,11 @@ GEM haml (5.1.2) temple (>= 0.8.0) tilt + haml_lint (0.35.0) + haml (>= 4.0, < 5.2) + rainbow + rubocop (>= 0.50.0) + sysexits (~> 1.1) hashie (4.1.0) http (4.4.1) addressable (~> 2.3) @@ -217,6 +223,7 @@ GEM i18n-js (3.0.0.rc10) i18n (~> 0.6) ipaddress (0.8.3) + jaro_winkler (1.5.4) jbuilder (2.10.0) activesupport (>= 5.0.0) jquery-minicolors-rails (2.2.6.2) @@ -310,6 +317,9 @@ GEM mime-types mimemagic (~> 0.3.0) terrapin (~> 0.6.0) + parallel (1.19.1) + parser (2.7.1.2) + ast (~> 2.4.0) pg (1.2.3) pghero (2.4.2) activerecord (>= 5) @@ -378,6 +388,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) raindrops (0.19.1) rake (13.0.1) rb-fsevent (0.10.3) @@ -390,6 +401,7 @@ GEM responders (3.0.0) actionpack (>= 5.0) railties (>= 5.0) + rexml (3.2.4) rolify (5.2.0) rspec-core (3.9.1) rspec-support (~> 3.9.1) @@ -414,6 +426,14 @@ GEM rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.9.2) + rubocop (0.82.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.7.0.1) + rainbow (>= 2.2.2, < 4.0) + rexml + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) ruby-progressbar (1.10.1) sanitize (5.1.0) crass (~> 1.0.2) @@ -464,6 +484,7 @@ GEM sprockets (>= 3.0.0) sweetalert-rails (1.1.3) railties (>= 3.1.0) + sysexits (1.2.0) temple (0.8.2) terrapin (0.6.0) climate_control (>= 0.0.3, < 1.0) @@ -493,6 +514,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.7) + unicode-display_width (1.7.0) unicorn (5.5.4) kgio (~> 2.6) raindrops (~> 0.7) @@ -539,6 +561,7 @@ DEPENDENCIES foreman guard-brakeman haml (~> 5.0) + haml_lint httparty i18n-js (= 3.0.0.rc10) jbuilder (~> 2.10) diff --git a/app/assets/javascripts/inbox.coffee b/app/assets/javascripts/inbox.coffee index f35361d8..bdff685c 100644 --- a/app/assets/javascripts/inbox.coffee +++ b/app/assets/javascripts/inbox.coffee @@ -22,7 +22,7 @@ btn.button "reset" ($ document).on "click", "button#ib-author", -> - $('#author_form').submit -> + $('#author-form').submit -> query = $('#author').val() window.location.href = '/inbox/' + query false diff --git a/app/assets/javascripts/question.coffee b/app/assets/javascripts/question.coffee index d07cb337..49b5f57d 100644 --- a/app/assets/javascripts/question.coffee +++ b/app/assets/javascripts/question.coffee @@ -1,15 +1,15 @@ -$(document).on "keydown", "textarea#q-answer", (evt) -> +$(document).on "keydown", "textarea#q-answer-text", (evt) -> qid = $(this)[0].dataset.id if evt.keyCode == 13 and evt.ctrlKey # trigger warning: - $("button#q-answer").trigger 'click' + $("button#q-answer-btn").trigger 'click' -$(document).on "click", "button#q-answer", -> +$(document).on "click", "button#q-answer-btn", -> btn = $(this) btn.button "loading" qid = btn[0].dataset.qId - $("textarea#q-answer").attr "readonly", "readonly" + $("textarea#q-answer-text").attr "readonly", "readonly" shareTo = [] ($ "input[type=checkbox][name=share][data-q-id=#{qid}]:checked").each (i, share) -> @@ -21,7 +21,7 @@ $(document).on "click", "button#q-answer", -> dataType: 'json' data: id: qid - answer: $("textarea#q-answer[data-id=#{qid}]").val() + answer: $("textarea#q-answer-text[data-id=#{qid}]").val() share: JSON.stringify shareTo inbox: false success: (data, status, jqxhr) -> @@ -34,4 +34,4 @@ $(document).on "click", "button#q-answer", -> showNotification translate('frontend.error.message'), false complete: (jqxhr, status) -> btn.button "reset" - $("textarea#q-answer").removeAttr "readonly" + $("textarea#q-answer-text").removeAttr "readonly" diff --git a/app/views/announcement/edit.haml b/app/views/announcement/edit.haml new file mode 100644 index 00000000..e0a4c43b --- /dev/null +++ b/app/views/announcement/edit.haml @@ -0,0 +1,37 @@ +- provide(:title, generate_title('Edit announcement')) +.container.container--main + .card + .card-body + = bootstrap_form_for(@announcement, url: { action: 'update' }, method: 'PATCH') do |f| + - if @announcement.errors.any? + .row + .col-md-12 + .alert.alert-danger + %strong + = pluralize(@announcement.errors.count, 'error') + prohibited this announcement from being saved: + %ul + - @announcement.errors.full_messages.each do |err| + %li= err + .row + .col-md-12 + = f.text_area :content, label: 'Content' + .row + .col-md-6 + = f.url_field :link_href, label: 'Link URL' + .col-md-6 + = f.text_field :link_text, label: 'Link text' + .row + .col-md-6 + = f.datetime_field :starts_at, + label: 'Start time', + class: 'datetimepicker-input', + data: { toggle: 'datetimepicker', target: '#announcement_starts_at', 'date-format': 'YYYY-MM-DD hh:mm A' } + .col-md-6 + = f.datetime_field :ends_at, + label: 'End time', + class: 'datetimepicker-input', + data: { toggle: 'datetimepicker', target: '#announcement_ends_at', 'date-format': 'YYYY-MM-DD hh:mm A' } + .row + .col-md-12.text-right + = f.submit class: 'btn btn-primary' diff --git a/app/views/announcement/edit.html.haml b/app/views/announcement/edit.html.haml deleted file mode 100644 index 45f54008..00000000 --- a/app/views/announcement/edit.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -- provide(:title, generate_title("Edit announcement")) -.container.container--main - .card - .card-body - = bootstrap_form_for(@announcement, url: {action: "update"}, method: "PATCH") do |f| - - if @announcement.errors.any? - .row - .col-md-12 - .alert.alert-danger - %strong - = pluralize(@announcement.errors.count, "error") - prohibited this announcement from being saved: - %ul - - @announcement.errors.full_messages.each do |err| - %li= err - .row - .col-md-12 - = f.text_area :content, label: "Content" - .row - .col-md-6 - = f.url_field :link_href, label: "Link URL" - .col-md-6 - = f.text_field :link_text, label: "Link text" - .row - .col-md-6 - = f.datetime_field :starts_at, label: "Start time", class: "datetimepicker-input", data: { toggle: "datetimepicker", target: "#announcement_starts_at", "date-format": "YYYY-MM-DD hh:mm A" } - .col-md-6 - = f.datetime_field :ends_at, label: "End time", class: "datetimepicker-input", data: { toggle: "datetimepicker", target: "#announcement_ends_at", "date-format": "YYYY-MM-DD hh:mm A" } - .row - .col-md-12.text-right - = f.submit class: "btn btn-primary" diff --git a/app/views/announcement/index.haml b/app/views/announcement/index.haml new file mode 100644 index 00000000..1cf04dda --- /dev/null +++ b/app/views/announcement/index.haml @@ -0,0 +1,20 @@ +- provide(:title, generate_title('Announcements')) +.container.container--main + - @announcements.each do |announcement| + .card + .card-body + .d-flex.w-100.justify-content-between + %p.mb-3= announcement.content + %small.text-muted= announcement.starts_at + + .d-flex.w-100 + = link_to 'Edit', announcement_edit_path(id: announcement.id), class: 'btn btn-link text-primary' + = button_to 'Delete', + announcement_destroy_path(id: announcement.id), + method: :delete, + class: 'btn btn-link text-danger', + confirm: 'Are you sure you want to delete this announcement?' + + .row + .col-md-12 + = link_to 'Add new', :announcement_new, class: 'btn btn-primary' diff --git a/app/views/announcement/index.html.haml b/app/views/announcement/index.html.haml deleted file mode 100644 index bb8c3616..00000000 --- a/app/views/announcement/index.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- provide(:title, generate_title("Announcements")) -.container.container--main - - @announcements.each do |announcement| - .card - .card-body - .d-flex.w-100.justify-content-between - %p.mb-3= announcement.content - %small.text-muted= announcement.starts_at - - .d-flex.w-100 - = link_to "Edit", announcement_edit_path(id: announcement.id), class: 'btn btn-link text-primary' - = button_to "Delete", announcement_destroy_path(id: announcement.id), method: :delete, class: 'btn btn-link text-danger', confirm: 'Are you sure you want to delete this announcement?' - - .row - .col-md-12 - = link_to "Add new", :announcement_new, class: "btn btn-primary" \ No newline at end of file diff --git a/app/views/announcement/new.haml b/app/views/announcement/new.haml new file mode 100644 index 00000000..a4495bc7 --- /dev/null +++ b/app/views/announcement/new.haml @@ -0,0 +1,37 @@ +- provide(:title, generate_title('Add new announcement')) +.container.container--main + .card + .card-body + = bootstrap_form_for(@announcement, url: { action: 'create' }) do |f| + - if @announcement.errors.any? + .row + .col-md-12 + .alert.alert-danger + %strong + = pluralize(@announcement.errors.count, 'error') + prohibited this announcement from being saved: + %ul + - @announcement.errors.full_messages.each do |err| + %li= err + .row + .col-md-12 + = f.text_area :content, label: 'Content' + .row + .col-md-6 + = f.url_field :link_href, label: 'Link URL' + .col-md-6 + = f.text_field :link_text, label: 'Link text' + .row + .col-md-6 + = f.datetime_field :starts_at, + label: 'Start time', + class: 'datetimepicker-input', + data: { toggle: 'datetimepicker', target: '#announcement_starts_at', 'date-format': 'YYYY-MM-DD hh:mm A' } + .col-md-6 + = f.datetime_field :ends_at, + label: 'End time', + class: 'datetimepicker-input', + data: { toggle: 'datetimepicker', target: '#announcement_ends_at', 'date-format': 'YYYY-MM-DD hh:mm A' } + .row + .col-md-12.text-right + = f.submit class: 'btn btn-primary' diff --git a/app/views/announcement/new.html.haml b/app/views/announcement/new.html.haml deleted file mode 100644 index 69e61d2c..00000000 --- a/app/views/announcement/new.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -- provide(:title, generate_title("Add new announcement")) -.container.container--main - .card - .card-body - = bootstrap_form_for(@announcement, url: {action: "create"}) do |f| - - if @announcement.errors.any? - .row - .col-md-12 - .alert.alert-danger - %strong - = pluralize(@announcement.errors.count, "error") - prohibited this announcement from being saved: - %ul - - @announcement.errors.full_messages.each do |err| - %li= err - .row - .col-md-12 - = f.text_area :content, label: "Content" - .row - .col-md-6 - = f.url_field :link_href, label: "Link URL" - .col-md-6 - = f.text_field :link_text, label: "Link text" - .row - .col-md-6 - = f.datetime_field :starts_at, label: "Start time", class: "datetimepicker-input", data: { toggle: "datetimepicker", target: "#announcement_starts_at", "date-format": "YYYY-MM-DD hh:mm A" } - .col-md-6 - = f.datetime_field :ends_at, label: "End time", class: "datetimepicker-input", data: { toggle: "datetimepicker", target: "#announcement_ends_at", "date-format": "YYYY-MM-DD hh:mm A" } - .row - .col-md-12.text-right - = f.submit class: "btn btn-primary" diff --git a/app/views/answer/show.haml b/app/views/answer/show.haml index f1096f09..c3e0453b 100644 --- a/app/views/answer/show.haml +++ b/app/views/answer/show.haml @@ -1,3 +1,3 @@ - provide(:title, answer_title(@answer)) .container.container--main - = render 'answerbox', a: @answer \ No newline at end of file + = render 'answerbox', a: @answer, display_all: @display_all 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) } diff --git a/app/views/application/_answerbox.haml b/app/views/application/_answerbox.haml index ed8a260d..1639c5da 100644 --- a/app/views/application/_answerbox.haml +++ b/app/views/application/_answerbox.haml @@ -1,14 +1,15 @@ -.card.answerbox{data: { id: a.id, q_id: a.question.id }} +- display_all ||= nil +.card.answerbox{ data: { id: a.id, q_id: a.question.id } } - if @question.nil? - = render "answerbox/header", a: a + = render 'answerbox/header', a: a .card-body - - if @display_all.nil? + - if display_all.nil? .answerbox__answer-text = markdown a.content[0..255] - if a.content.length > 255 [...] %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) } = t 'views.answerbox.read' - else .answerbox__answer-text @@ -18,15 +19,15 @@ .col.col-sm-4.col-md-6.text-left.text-muted .media .pull-left - %a{href: show_user_profile_path(a.user.screen_name)} - %img.answerbox__answer-user-avatar.avatar-sm{src: a.user.profile_picture.url(:medium)} + %a{ href: show_user_profile_path(a.user.screen_name) } + %img.answerbox__answer-user-avatar.avatar-sm{ src: a.user.profile_picture.url(:medium) } .media-body %h6.media-heading.answerbox__answer-user - = raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), "d-none d-sm-inline"), user: user_screen_name(a.user)) + = raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), 'd-none d-sm-inline'), user: user_screen_name(a.user)) .answerbox__answer-date = link_to(raw(t('views.answerbox.time', time: time_tooltip(a))), show_user_answer_path(a.user.screen_name, a.id)) .col.col-sm-8.col-md-6.text-right - = render 'answerbox/actions', a: a + = render 'answerbox/actions', a: a, display_all: display_all - else .row .col-4.col-sm-4.col-md-6.text-left.text-muted @@ -34,6 +35,6 @@ = link_to(raw(t('views.answerbox.time', time: time_tooltip(a))), show_user_answer_path(a.user.screen_name, a.id)) .col-8.col-sm-8.col-md-6.text-right = render 'answerbox/actions', a: a - .card-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil } - %div{id: "ab-smiles-#{a.id}"}= render 'answerbox/smiles', a: a - %div{id: "ab-comments-#{a.id}"}= render 'answerbox/comments', a: a \ No newline at end of file + .card-footer{ id: "ab-comments-section-#{a.id}", style: display_all.nil? ? 'display: none' : nil } + %div{ id: "ab-smiles-#{a.id}" }= render 'answerbox/smiles', a: a + %div{ id: "ab-comments-#{a.id}" }= render 'answerbox/comments', a: a diff --git a/app/views/application/_questionbox.haml b/app/views/application/_questionbox.haml index 78f0cd2d..23af423e 100644 --- a/app/views/application/_questionbox.haml +++ b/app/views/application/_questionbox.haml @@ -1,43 +1,46 @@ .card .card-header - - if @user.motivation_header.blank? + - if user.motivation_header.blank? = t 'views.questionbox.title' - else - = @user.motivation_header + = user.motivation_header .card-body - - if @user.banned? + - if user.banned? .text-center %strong= t 'views.questionbox.banned' - else - - if user_signed_in? or @user.privacy_allow_anonymous_questions? + - if user_signed_in? || user.privacy_allow_anonymous_questions? #question-box - %textarea.form-control{:name => "qb-question", :placeholder => t('views.placeholder.question')} - .row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"} + %textarea.form-control{ name: 'qb-question', placeholder: t('views.placeholder.question') } + .row{ style: 'padding-top: 5px; padding-left: 5px; padding-right: 5px;' } .col-6 - if user_signed_in? - - if @user.privacy_allow_anonymous_questions? - %input{:name => "qb-anonymous", :type => "checkbox"}/ + - if user.privacy_allow_anonymous_questions? + %input{ name: 'qb-anonymous', type: :checkbox }/ = t 'views.actions.anonymous' %br/ - else - %input{:name => "qb-anonymous", :type => "hidden", :value => "false"}/ + %input{ name: 'qb-anonymous', type: :hidden, value: false }/ .col-6 %p.pull-right - %input{name: 'qb-to', type: 'hidden', :value => @user.id}/ - %button.btn.btn-primary{name: 'qb-ask', :type => "button", data: {loading_text: t('views.questionbox.load'), promote: user_signed_in? ? "false" : "true" }} Ask + %input{ name: 'qb-to', type: 'hidden', value: user.id }/ + %button.btn.btn-primary{ name: 'qb-ask', + type: :button, + data: { loading_text: t('views.questionbox.load'), promote: user_signed_in? ? 'false' : 'true' } } + Ask - unless user_signed_in? - - if @user.privacy_allow_anonymous_questions? - #question-box-promote{:style => "display: none;"} + - if user.privacy_allow_anonymous_questions? + #question-box-promote{ style: 'display: none;' } .row .col-12.text-center %strong= t 'views.questionbox.promote.message' .row .col-sm-5.offset-sm-1 - %button#create-account.btn.btn-block.btn-primary= t 'views.questionbox.promote.create' + %button.btn.btn-block.btn-primary#create-account= t 'views.questionbox.promote.create' .col-sm-5 - %button#new-question.btn.btn-block.btn-default= t 'views.questionbox.promote.another' + %button.btn.btn-block.btn-default#new-question= t 'views.questionbox.promote.another' .row .col-xs-12.col-sm-10.offset-sm-1.text-center %small= t('views.questionbox.promote.join', app_title: APP_CONFIG['site_name']) - else - %p= raw t 'views.questionbox.required', signup: link_to(t('views.sessions.new'),new_user_registration_path) + %p= raw t 'views.questionbox.required', signup: link_to(t('views.sessions.new'), new_user_registration_path) diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.haml similarity index 60% rename from app/views/devise/confirmations/new.html.haml rename to app/views/devise/confirmations/new.haml index da395950..ba3a40fa 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.haml @@ -1,4 +1,4 @@ -- provide(:title, generate_title("Resend confirmation instructions")) +- provide(:title, generate_title('Resend confirmation instructions')) .container .row .col-sm-8.offset-sm-2 @@ -8,8 +8,8 @@ = bootstrap_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| = devise_error_messages! - = f.text_field :screen_name, autofocus: true, label: "User name" - = f.submit "Resend confirmation instructions", class: "btn btn-primary mb-3" + = f.text_field :screen_name, autofocus: true, label: 'User name' + = f.submit 'Resend confirmation instructions', class: 'btn btn-primary mb-3' - = render "devise/shared/links" -= render "shared/links" + = render 'devise/shared/links' += render 'shared/links' diff --git a/app/views/devise/mailer/confirmation_instructions.haml b/app/views/devise/mailer/confirmation_instructions.haml new file mode 100644 index 00000000..466209dc --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.haml @@ -0,0 +1,10 @@ +%p{ style: 'margin:0px;padding:0px' } + Welcome to + = succeed ',' do + = APP_CONFIG['site_name'] + = succeed '!' do + = @resource.screen_name +%p   +%p{ style: 'margin:0px;padding:0px' } You can confirm your account email through the link below: +%p{ style: 'margin:0px;padding:0px' } + = link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml deleted file mode 100644 index ae56f4eb..00000000 --- a/app/views/devise/mailer/confirmation_instructions.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%p{style: "margin:0px;padding:0px"} - Welcome to - = succeed ',' do - = APP_CONFIG['site_name'] - = succeed '!' do - = @resource.screen_name -%p   -%p{style: "margin:0px;padding:0px"} You can confirm your account email through the link below: -%p{style: "margin:0px;padding:0px"}= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) diff --git a/app/views/devise/mailer/reset_password_instructions.haml b/app/views/devise/mailer/reset_password_instructions.haml new file mode 100644 index 00000000..b6b23a0f --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.haml @@ -0,0 +1,11 @@ +%p{ style: 'margin:0px;padding:0px' } + Hello + = succeed '!' do + = @resource.screen_name +%p   +%p{ style: 'margin:0px;padding:0px' } Someone (hopefully you) has requested a link to change your password. You can do this through the link below. +%p{ style: 'margin:0px;padding:0px' } + = link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) +%p   +%p{ style: 'margin:0px;padding:0px' } If you didn't request this, please ignore this email. +%p{ style: 'margin:0px;padding:0px' } Your password won't change until you access the link above and create a new one. diff --git a/app/views/devise/mailer/reset_password_instructions.html.haml b/app/views/devise/mailer/reset_password_instructions.html.haml deleted file mode 100644 index 00c50a44..00000000 --- a/app/views/devise/mailer/reset_password_instructions.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%p{style: "margin:0px;padding:0px"} - Hello - = succeed '!' do - = @resource.screen_name -%p   -%p{style: "margin:0px;padding:0px"} Someone (hopefully you) has requested a link to change your password. You can do this through the link below. -%p{style: "margin:0px;padding:0px"}= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) -%p   -%p{style: "margin:0px;padding:0px"} If you didn't request this, please ignore this email. -%p{style: "margin:0px;padding:0px"} Your password won't change until you access the link above and create a new one. diff --git a/app/views/devise/mailer/unlock_instructions.haml b/app/views/devise/mailer/unlock_instructions.haml new file mode 100644 index 00000000..45541a3e --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.haml @@ -0,0 +1,9 @@ +%p{ style: 'margin:0px;padding:0px' } + Hello + = succeed '!' do + = @resource.screen_name +%p   +%p{ style: 'margin:0px;padding:0px' } Your account has been locked due to an excessive number of unsuccessful sign in attempts. +%p{ style: 'margin:0px;padding:0px' } Click the link below to unlock your account: +%p{ style: 'margin:0px;padding:0px' } + = link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) diff --git a/app/views/devise/mailer/unlock_instructions.html.haml b/app/views/devise/mailer/unlock_instructions.html.haml deleted file mode 100644 index eb427845..00000000 --- a/app/views/devise/mailer/unlock_instructions.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -%p{style: "margin:0px;padding:0px"} - Hello - = succeed '!' do - = @resource.screen_name -%p   -%p{style: "margin:0px;padding:0px"} Your account has been locked due to an excessive number of unsuccessful sign in attempts. -%p{style: "margin:0px;padding:0px"} Click the link below to unlock your account: -%p{style: "margin:0px;padding:0px"}= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token, protocol: (APP_CONFIG['https'] ? :https : :http)) diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.haml similarity index 65% rename from app/views/devise/passwords/edit.html.haml rename to app/views/devise/passwords/edit.haml index 7c052384..1ad2365f 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.haml @@ -1,4 +1,4 @@ -- provide(:title, generate_title("Reset Password")) +- provide(:title, generate_title('Reset Password')) .container .row .col-sm-4.offset-sm-4 @@ -10,10 +10,10 @@ = f.hidden_field :reset_password_token - = f.password_field :password, autofocus: true, autocomplete: "off", label: "New password" - = f.password_field :password_confirmation, autocomplete: "off", label: "Confirm new password" + = f.password_field :password, autofocus: true, autocomplete: :off, label: 'New password' + = f.password_field :password_confirmation, autocomplete: :off, label: 'Confirm new password' - = f.submit "Change my password" + = f.submit 'Change my password' - = render "devise/shared/links" -= render "shared/links" + = render 'devise/shared/links' += render 'shared/links' diff --git a/app/views/devise/passwords/new.haml b/app/views/devise/passwords/new.haml new file mode 100644 index 00000000..16d44834 --- /dev/null +++ b/app/views/devise/passwords/new.haml @@ -0,0 +1,15 @@ +- provide(:title, generate_title('Forgot your Password?')) +.container + .row + .col-sm-8.offset-sm-2 + .card.mt-3 + .card-body + %h1 Forgot your password? + = bootstrap_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| + = devise_error_messages! + + = f.email_field :email, autofocus: true, label: 'Email address' + = f.submit 'Send me password reset instructions', class: 'btn btn-primary mb-3' + + = render 'devise/shared/links' += render 'shared/links' diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml deleted file mode 100644 index b3578cfe..00000000 --- a/app/views/devise/passwords/new.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- provide(:title, generate_title("Forgot your Password?")) -.container - .row - .col-sm-8.offset-sm-2 - .card.mt-3 - .card-body - %h1 Forgot your password? - = bootstrap_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| - = devise_error_messages! - - = f.email_field :email, autofocus: true, label: "Email address" - = f.submit "Send me password reset instructions", class: "btn btn-primary mb-3" - - = render "devise/shared/links" -= render "shared/links" diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml new file mode 100644 index 00000000..2435e936 --- /dev/null +++ b/app/views/devise/registrations/edit.haml @@ -0,0 +1,4 @@ += render 'settings/account' + +- provide(:title, generate_title('Account Settings')) +- parent_layout 'user/settings' diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml deleted file mode 100644 index 77d692f8..00000000 --- a/app/views/devise/registrations/edit.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render "settings/account" - -- provide(:title, generate_title("Account Settings")) -- parent_layout "user/settings" diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.haml similarity index 66% rename from app/views/devise/registrations/new.html.haml rename to app/views/devise/registrations/new.haml index 7ed1f434..cbbafe39 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.haml @@ -1,4 +1,4 @@ -- provide(:title, generate_title("Sign Up")) +- provide(:title, generate_title('Sign Up')) .container .row .col-sm-8.offset-sm-2 @@ -11,11 +11,11 @@ = f.text_field :screen_name, autofocus: true, label: t('views.settings.account.username') = f.email_field :email, autofocus: false, label: t('views.settings.account.email') - = f.password_field :password, autocomplete: "off", label: t('views.settings.account.password') - = f.password_field :password_confirmation, autocomplete: "off", label: t('views.settings.account.password_confirm') + = f.password_field :password, autocomplete: :off, label: t('views.settings.account.password') + = f.password_field :password_confirmation, autocomplete: :off, label: t('views.settings.account.password_confirm') %p= raw t('views.sessions.info', terms: link_to(t('views.general.terms'), terms_path)) - = f.submit "Sign up", class: "btn btn-primary mb-3" + = f.submit 'Sign up', class: 'btn btn-primary mb-3' - = render "devise/shared/links" + = render 'devise/shared/links' = render 'shared/links' diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.haml similarity index 59% rename from app/views/devise/sessions/new.html.haml rename to app/views/devise/sessions/new.haml index c6d12ce8..144a5323 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.haml @@ -1,4 +1,4 @@ -- provide(:title, generate_title("Sign In")) +- provide(:title, generate_title('Sign In')) .container .row .col-sm-4.offset-sm-4 @@ -9,12 +9,12 @@ = bootstrap_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| = f.text_field :login, autofocus: true, label: t('views.settings.account.username') - = f.password_field :password, autocomplete: "off", label: t('views.settings.account.password') + = f.password_field :password, autocomplete: :off, label: t('views.settings.account.password') - if devise_mapping.rememberable? = f.check_box :remember_me - = f.submit t('views.sessions.create'), class: "btn btn-primary mt-3 mb-3" + = f.submit t('views.sessions.create'), class: 'btn btn-primary mt-3 mb-3' - = render "devise/shared/links" -= render "shared/links" + = render 'devise/shared/links' += render 'shared/links' diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.haml similarity index 81% rename from app/views/devise/shared/_links.html.haml rename to app/views/devise/shared/_links.haml index d4cafbf5..18ff87cc 100644 --- a/app/views/devise/shared/_links.html.haml +++ b/app/views/devise/shared/_links.haml @@ -1,13 +1,13 @@ - if controller_name != 'sessions' - = link_to "Sign in", new_session_path(resource_name) + = link_to 'Sign in', new_session_path(resource_name) %br/ - if devise_mapping.registerable? && controller_name != 'registrations' - = link_to "Sign up", new_registration_path(resource_name) + = link_to 'Sign up', new_registration_path(resource_name) %br/ - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' - = link_to "Forgot your password?", new_password_path(resource_name) + = link_to 'Forgot your password?', new_password_path(resource_name) %br/ - if devise_mapping.confirmable? && controller_name != 'confirmations' @@ -21,4 +21,4 @@ - if devise_mapping.omniauthable? - resource_class.omniauth_providers.each do |provider| = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) - %br/ \ No newline at end of file + %br/ diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.haml similarity index 51% rename from app/views/devise/unlocks/new.html.haml rename to app/views/devise/unlocks/new.haml index f35c61e4..a099864e 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.haml @@ -1,4 +1,4 @@ -- provide(:title, generate_title("Unlock")) +- provide(:title, generate_title('Unlock')) .container %h1 Resend unlock instructions = render 'layouts/messages' @@ -6,9 +6,9 @@ = bootstrap_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| = devise_error_messages! - = f.email_field :email, autofocus: true, label: "Email address" + = f.email_field :email, autofocus: true, label: 'Email address' - = f.submit "Resend unlock instructions" + = f.submit 'Resend unlock instructions' - = render "devise/shared/links" -= render "shared/links" + = render 'devise/shared/links' += render 'shared/links' diff --git a/app/views/discover/_tab_answers.haml b/app/views/discover/_tab_answers.haml new file mode 100644 index 00000000..5037483c --- /dev/null +++ b/app/views/discover/_tab_answers.haml @@ -0,0 +1,3 @@ +.tab-pane.active.fade.show{ role: :tabpanel, id: 'answers' } + - answers.each do |a| + = render 'answerbox', a: a diff --git a/app/views/discover/_tab_answers.html.haml b/app/views/discover/_tab_answers.html.haml deleted file mode 100644 index 0738798d..00000000 --- a/app/views/discover/_tab_answers.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.tab-pane.active.fade.show{role: "tabpanel", id: "answers"} - - answers.each do |a| - = render 'answerbox', a: a diff --git a/app/views/discover/_tab_asked.haml b/app/views/discover/_tab_asked.haml new file mode 100644 index 00000000..0927fd85 --- /dev/null +++ b/app/views/discover/_tab_asked.haml @@ -0,0 +1,3 @@ +.tab-pane.fade{ role: :tabpanel, id: 'asked' } + - asked.each do |user| + = render 'discover/userbox', u: user.user, type: 'asked', q: user.question_count diff --git a/app/views/discover/_tab_asked.html.haml b/app/views/discover/_tab_asked.html.haml deleted file mode 100644 index 95136d6c..00000000 --- a/app/views/discover/_tab_asked.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.tab-pane.fade{role: "tabpanel", id: "asked"} - - asked.each do |user| - = render 'discover/userbox', u: user.user, type: "asked", q: user.question_count diff --git a/app/views/discover/_tab_discussed.html.haml b/app/views/discover/_tab_discussed.haml similarity index 52% rename from app/views/discover/_tab_discussed.html.haml rename to app/views/discover/_tab_discussed.haml index 1dafe7ce..7b853232 100644 --- a/app/views/discover/_tab_discussed.html.haml +++ b/app/views/discover/_tab_discussed.haml @@ -1,3 +1,3 @@ -.tab-pane.fade{role: "tabpanel", id: "comments"} +.tab-pane.fade{ role: :tabpanel, id: 'comments' } - comments.each do |a| = render 'answerbox', a: a diff --git a/app/views/discover/_tab_most.haml b/app/views/discover/_tab_most.haml new file mode 100644 index 00000000..31d4a356 --- /dev/null +++ b/app/views/discover/_tab_most.haml @@ -0,0 +1,3 @@ +.tab-pane.fade{ role: :tabpanel, id: 'answered' } + - answered.each do |user| + = render 'discover/userbox', u: user.user, type: 'most', a: user.answer_count diff --git a/app/views/discover/_tab_most.html.haml b/app/views/discover/_tab_most.html.haml deleted file mode 100644 index 3b9a1645..00000000 --- a/app/views/discover/_tab_most.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.tab-pane.fade{role: "tabpanel", id: "answered"} - - answered.each do |user| - = render 'discover/userbox', u: user.user, type: "most", a: user.answer_count diff --git a/app/views/discover/_tab_new.haml b/app/views/discover/_tab_new.haml new file mode 100644 index 00000000..99ceb4e2 --- /dev/null +++ b/app/views/discover/_tab_new.haml @@ -0,0 +1,3 @@ +.tab-pane.active.fade.show{ role: :tabpanel, id: 'new' } + - new.each do |user| + = render 'discover/userbox', u: user, type: 'new' diff --git a/app/views/discover/_tab_new.html.haml b/app/views/discover/_tab_new.html.haml deleted file mode 100644 index 016a9612..00000000 --- a/app/views/discover/_tab_new.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.tab-pane.active.fade.show{role: "tabpanel", id: "new"} - - new.each do |user| - = render 'discover/userbox', u: user, type: "new" diff --git a/app/views/discover/_tab_questions.haml b/app/views/discover/_tab_questions.haml new file mode 100644 index 00000000..4841eb45 --- /dev/null +++ b/app/views/discover/_tab_questions.haml @@ -0,0 +1,3 @@ +.tab-pane.fade{ role: :tabpanel, id: 'questions' } + - questions.each do |q| + = render 'shared/question', q: q, type: 'discover' diff --git a/app/views/discover/_tab_questions.html.haml b/app/views/discover/_tab_questions.html.haml deleted file mode 100644 index cd14a840..00000000 --- a/app/views/discover/_tab_questions.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.tab-pane.fade{role: "tabpanel", id: "questions"} - - questions.each do |q| - = render 'shared/question', q: q, type: "discover" diff --git a/app/views/discover/_userbox.html.haml b/app/views/discover/_userbox.haml similarity index 52% rename from app/views/discover/_userbox.html.haml rename to app/views/discover/_userbox.haml index c1d5cf9b..b087ca2f 100644 --- a/app/views/discover/_userbox.html.haml +++ b/app/views/discover/_userbox.haml @@ -1,22 +1,22 @@ -.card{data: { id: u.id }} +.card{ data: { id: u.id } } .card-body .media .pull-left - %a{href: show_user_profile_path(u.screen_name)} - %img.avatar-md.mr-2{src: u.profile_picture.url(:medium)} + %a{ href: show_user_profile_path(u.screen_name) } + %img.avatar-md.mr-2{ src: u.profile_picture.url(:medium) } .media-body %h6.media-heading.answerbox__question-user - if u.display_name.blank? - %a{href: show_user_profile_path(u.screen_name)} - %span= "@#{u.screen_name}" + %a{ href: show_user_profile_path(u.screen_name) } + = u.screen_name - else - %a{href: show_user_profile_path(u.screen_name)} - %span= u.display_name - %span.text-muted= "@#{u.screen_name}" + %a{ href: show_user_profile_path(u.screen_name) } + = u.display_name + %span.text-muted= u.screen_name %p.answerbox__question-text - - if type == "new" + - if type == 'new' = t('views.discover.userbox.new', time: time_ago_in_words(u.created_at)) - - elsif type == "most" + - elsif type == 'most' = t('views.discover.userbox.answers', questions: pluralize(a, t('views.general.question'))) - else = t('views.discover.userbox.questions', questions: pluralize(q, t('views.general.question'))) diff --git a/app/views/discover/index.haml b/app/views/discover/index.haml new file mode 100644 index 00000000..52322fc5 --- /dev/null +++ b/app/views/discover/index.haml @@ -0,0 +1,40 @@ +- provide(:title, generate_title('Discover')) + +.jumbotron.jumbotron--particles + .jumbotron__particles#particles + .jumbotron__content + %h1= t 'views.discover.title' + %p= t('views.discover.subtitle', app_title: APP_CONFIG['site_name']) +.container + .row + .col-md-7.col-sm-6 + %h2= t 'views.discover.content.title' + %p= t 'views.discover.content.desc' + %div{ role: :tabpanel } + %ul.nav.nav-tabs{ role: :tablist } + %li.nav-item{ role: 'presentation' } + %a.nav-link.active{ href: '#answers', role: :tab, aria: { controls: 'answers' }, data: { toggle: :tab } }= t 'views.discover.content.tab.answers' + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#questions', role: :tab, aria: { controls: 'questions' }, data: { toggle: :tab } }= t 'views.discover.content.tab.questions' + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#comments', role: :tab, aria: { controls: 'comments' }, data: { toggle: :tab } }= t 'views.discover.content.tab.comments' + .tab-content.mt-3 + = render 'discover/tab_answers', answers: @popular_answers + = render 'discover/tab_questions', questions: @popular_questions + = render 'discover/tab_discussed', comments: @most_discussed + .col-md-5.col-sm-6 + %h2= t 'views.discover.people.title' + %p= t 'views.discover.people.desc' + %div{ role: :tabpanel } + %ul.nav.nav-tabs{ role: :tablist } + %li.nav-item{ role: 'presentation' } + %a.nav-link.active{ href: '#new', role: :tab, aria: { controls: 'new' }, data: { toggle: :tab } }= t 'views.discover.people.tab.new' + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#asked', role: :tab, aria: { controls: 'asked' }, data: { toggle: :tab } }= t 'views.discover.people.tab.questions' + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#answered', role: :tab, aria: { controls: 'answered' }, data: { toggle: :tab } }= t 'views.discover.people.tab.answers' + .tab-content.mt-3 + = render 'discover/tab_new', new: @new_users + = render 'discover/tab_asked', asked: @users_with_most_questions + = render 'discover/tab_most', answered: @users_with_most_answers + = render 'shared/links' diff --git a/app/views/discover/index.html.haml b/app/views/discover/index.html.haml deleted file mode 100644 index b20a58b3..00000000 --- a/app/views/discover/index.html.haml +++ /dev/null @@ -1,39 +0,0 @@ -- provide(:title, generate_title("Discover")) -.jumbotron.jumbotron--particles - #particles.jumbotron__particles - .jumbotron__content - %h1= t 'views.discover.title' - %p= t('views.discover.subtitle', app_title: APP_CONFIG['site_name']) -.container - .row - .col-md-7.col-sm-6 - %h2= t 'views.discover.content.title' - %p= t 'views.discover.content.desc' - %div{role: "tabpanel"} - %ul.nav.nav-tabs{role: "tablist"} - %li.nav-item{role: "presentation"} - %a.nav-link.active{href: "#answers", role: "tab", aria: {controls: "answers"}, data: {toggle: "tab"}}= t 'views.discover.content.tab.answers' - %li.nav-item{role: "presentation"} - %a.nav-link{href: "#questions", role: "tab", aria: {controls: "questions"}, data: {toggle: "tab"}}= t 'views.discover.content.tab.questions' - %li.nav-item{role: "presentation"} - %a.nav-link{href: "#comments", role: "tab", aria: {controls: "comments"}, data: {toggle: "tab"}}= t 'views.discover.content.tab.comments' - .tab-content.mt-3 - = render 'discover/tab_answers', answers: @popular_answers - = render 'discover/tab_questions', questions: @popular_questions - = render 'discover/tab_discussed', comments: @most_discussed - .col-md-5.col-sm-6 - %h2= t 'views.discover.people.title' - %p= t 'views.discover.people.desc' - %div{role: "tabpanel"} - %ul.nav.nav-tabs{role: "tablist"} - %li.nav-item{role: "presentation"} - %a.nav-link.active{href: "#new", role: "tab", aria: {controls: "new"}, data: {toggle: "tab"}}= t 'views.discover.people.tab.new' - %li.nav-item{role: "presentation"} - %a.nav-link{href: "#asked", role: "tab", aria: {controls: "asked"}, data: {toggle: "tab"}}= t 'views.discover.people.tab.questions' - %li.nav-item{role: "presentation"} - %a.nav-link{href: "#answered", role: "tab", aria: {controls: "answered"}, data: {toggle: "tab"}}= t 'views.discover.people.tab.answers' - .tab-content.mt-3 - = render 'discover/tab_new', new: @new_users - = render 'discover/tab_asked', asked: @users_with_most_questions - = render 'discover/tab_most', answered: @users_with_most_answers - = render 'shared/links' diff --git a/app/views/group/index.haml b/app/views/group/index.haml index 73d45b12..e45235a4 100644 --- a/app/views/group/index.haml +++ b/app/views/group/index.haml @@ -5,8 +5,8 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @timeline_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @timeline_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @timeline_last_id } } = t 'views.actions.load' - provide(:title, group_title(@group)) -- parent_layout "feed" +- parent_layout 'feed' diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.haml similarity index 51% rename from app/views/inbox/_entry.html.haml rename to app/views/inbox/_entry.haml index 307a43c6..9e7066b4 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.haml @@ -1,36 +1,36 @@ -.card.inbox-entry{class: i.new? ? 'inbox-entry--new' : '', data: { id: i.id }} +.card.inbox-entry{ class: i.new? ? 'inbox-entry--new' : '', data: { id: i.id } } .card-header .media - unless i.question.author_is_anonymous - %a.pull-left{href: show_user_profile_path(i.question.user.screen_name)} - %img.answerbox__question-user-avatar.avatar-md{src: i.question.user.profile_picture.url(:medium)} + %a.pull-left{ href: show_user_profile_path(i.question.user.screen_name) } + %img.answerbox__question-user-avatar.avatar-md{ src: i.question.user.profile_picture.url(:medium) } .media-body %h6.text-muted.media-heading.answerbox__question-user = 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 + - if i.question.answer_count.positive? · - %a{href: show_user_question_path(i.question.user.screen_name, i.question.id)} + %a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) } = pluralize(i.question.answer_count, t('views.inbox.entry.response')) %p.answerbox__question-text= i.question.content .card-body - %textarea.form-control{name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id }} + %textarea.form-control{ name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id } } %br/ - %button.btn.btn-success{name: 'ib-answer', data: { ib_id: i.id }} + %button.btn.btn-success{ name: 'ib-answer', data: { ib_id: i.id } } = t 'views.actions.answer' - %button.btn.btn-danger{name: 'ib-destroy', data: { ib_id: i.id }} + %button.btn.btn-danger{ name: 'ib-destroy', data: { ib_id: i.id } } = t 'views.actions.delete' - %button.btn.btn-default{name: 'ib-options', data: { ib_id: i.id, state: :hidden }} + %button.btn.btn-default{ name: 'ib-options', data: { ib_id: i.id, state: :hidden } } %i.fa.fa-cog %span.sr-only= t 'views.actions.options' - .card-footer{id: "ib-options-#{i.id}", style: 'display: none'} + .card-footer{ id: "ib-options-#{i.id}", style: 'display: none' } %h4= t 'views.inbox.entry.sharing.title' - - if current_user.services.count > 0 + - if current_user.services.count.positive? .row - current_user.services.each do |service| .col-md-3.col-sm-4.col-xs-6 %label - %input{type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider }} + %input{ type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider } } = raw t('views.inbox.entry.sharing.post', service: service.provider.capitalize) - else %p= raw t('views.inbox.entry.sharing.none', settings: link_to(t('views.inbox.entry.sharing.settings'), services_path)) diff --git a/app/views/inbox/_sidebar.haml b/app/views/inbox/_sidebar.haml new file mode 100644 index 00000000..c14f2272 --- /dev/null +++ b/app/views/inbox/_sidebar.haml @@ -0,0 +1,27 @@ +.card + .card-header= t 'views.inbox.sidebar.questions.title' + .card-body + %button.btn.btn-block.btn-info{ type: :button, id: 'ib-generate-question' }= t 'views.inbox.sidebar.questions.button' +.card + .card-header= t 'views.inbox.sidebar.share.title' + .card-body + %a.btn.btn-block.btn-primary{ target: '_blank', + href: "https://twitter.com/intent/tweet?text=Ask%20me%20anything%21&url=#{show_user_profile_url(current_user.screen_name)}" } + %i.fa.fa-fw.fa-twitter + = raw t('views.inbox.sidebar.share.button', service: 'Twitter') + %a.btn.btn-block.btn-primary{ target: '_blank', + href: "https://www.tumblr.com/share/link?url=#{show_user_profile_url(current_user.screen_name)}&name=Ask%20me%20anything%21" } + %i.fa.fa-fw.fa-tumblr + = raw t('views.inbox.sidebar.share.button', service: 'Tumblr') +.card + .card-header Show author + .card-body + %form#author-form + = bootstrap_form_tag url: inbox_path, method: :get do |f| + = f.text_field :author, value: params[:author], placeholder: 'username', prepend: '@', hide_label: true + = f.button 'Show', name: nil, class: 'btn btn-light btn-block btn-sm', id: 'ib-author' +.card + .card-header= t 'views.inbox.sidebar.actions.title' + .card-body + %button.btn.btn-block.btn-danger{ type: :button, id: delete_id, disabled: (disabled ? :disabled : nil), data: { ib_count: inbox_count } } + = t 'views.inbox.sidebar.actions.button' diff --git a/app/views/inbox/_sidebar.html.haml b/app/views/inbox/_sidebar.html.haml deleted file mode 100644 index 4cda09a0..00000000 --- a/app/views/inbox/_sidebar.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -.card.inbox--panel - .card-header= t 'views.inbox.sidebar.questions.title' - .card-body - %button.btn.btn-block.btn-info{type: :button, id: 'ib-generate-question'}= t 'views.inbox.sidebar.questions.button' -.card.inbox--panel - .card-header= t 'views.inbox.sidebar.share.title' - .card-body - %a.btn.btn-block.btn-primary{target: '_blank', href: "https://twitter.com/intent/tweet?text=Ask%20me%20anything%21&url=#{show_user_profile_url(current_user.screen_name)}"} - %i.fa.fa-fw.fa-twitter - = raw t('views.inbox.sidebar.share.button', service: "Twitter") - %a.btn.btn-block.btn-primary{target: '_blank', href: "https://www.tumblr.com/share/link?url=#{show_user_profile_url(current_user.screen_name)}&name=Ask%20me%20anything%21"} - %i.fa.fa-fw.fa-tumblr - = raw t('views.inbox.sidebar.share.button', service: "Tumblr") -.card.inbox--panel - .card-header Show author - .card-body - %form#author_form - = bootstrap_form_tag url: inbox_path, method: :get do |f| - = f.text_field :author, value: params[:author], placeholder: "username", prepend: "@" , hide_label: true - = f.button "Show", name: nil, class: "btn btn-light btn-block btn-sm", id: "ib-author" -.card.warning--panel - .card-header= t 'views.inbox.sidebar.actions.title' - .card-body - %button.btn.btn-block.btn-danger{type: :button, id: @delete_id , disabled: (@disabled ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button' - diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.haml similarity index 75% rename from app/views/inbox/show.html.haml rename to app/views/inbox/show.haml index 89e14824..86b9e4c6 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.haml @@ -8,5 +8,5 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @inbox_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @inbox_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @inbox_last_id } } = t 'views.actions.load' diff --git a/app/views/layouts/_messages.haml b/app/views/layouts/_messages.haml new file mode 100644 index 00000000..759449c1 --- /dev/null +++ b/app/views/layouts/_messages.haml @@ -0,0 +1,10 @@ +%noscript + .alert.alert-danger + = t 'messages.noscript' + +- flash.each do |key, value| + .alert.alert-dismissible{ class: "alert-#{bootstrap_color key}", role: :alert } + %button.close{ type: :button, data: { dismiss: :alert } } + %span{ aria: { hidden: true } } × + %span.sr-only= t 'views.actions.close' + = value diff --git a/app/views/layouts/_messages.html.haml b/app/views/layouts/_messages.html.haml deleted file mode 100644 index 73ba513d..00000000 --- a/app/views/layouts/_messages.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%noscript - .alert.alert-danger - = t 'messages.noscript' - -- flash.each do |key, value| - .alert.alert-dismissible{class: "alert-#{bootstrap_color key}", role: "alert"} - %button.close{type: "button", "data-dismiss" => "alert"} - %span{"aria-hidden" => "true"} × - %span.sr-only= t 'views.actions.close' - = value diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 001462ad..3263dc07 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -1,3 +1,3 @@ = yield -- parent_layout "base" +- parent_layout 'base' diff --git a/app/views/layouts/base.haml b/app/views/layouts/base.haml index 7e466fe6..6910315d 100644 --- a/app/views/layouts/base.haml +++ b/app/views/layouts/base.haml @@ -1,21 +1,21 @@ !!! 5 -%html{lang: 'en'} +%html{ lang: 'en' } %head - %meta{charset: 'utf-8'} - %meta{'http-equiv' => 'X-UA-Compatible' ,content: 'IE=edge'} - %meta{name: 'viewport', content: 'width=device-width, initial-scale=1, user-scalable=no'} - %meta{name: 'theme-color', content: '#5e35b1'} - %link{rel: 'apple-touch-icon', href: '/apple-touch-icon-precomposed.png'} - %link{rel: 'icon', href: '/images/favicon/favicon-16.png', sizes: '16x16'} - %link{rel: 'icon', href: '/icon-152.png', sizes: '152x152'} - %link{rel: 'icon', href: '/images/favicon/favicon-32.png', sizes: '32x32'} + %meta{ charset: 'utf-8' } + %meta{ 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' } + %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1, user-scalable=no' } + %meta{ name: 'theme-color', content: '#5e35b1' } + %link{ rel: 'apple-touch-icon', href: '/apple-touch-icon-precomposed.png' } + %link{ rel: 'icon', href: '/images/favicon/favicon-16.png', sizes: '16x16' } + %link{ rel: 'icon', href: '/icon-152.png', sizes: '152x152' } + %link{ rel: 'icon', href: '/images/favicon/favicon-32.png', sizes: '32x32' } %title= yield(:title) - = javascript_include_tag 'i18n', 'data-turbolinks-track' => true - = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true - = javascript_include_tag 'application', 'data-turbolinks-track' => true + = javascript_include_tag 'i18n', data: { 'turbolinks-track': true } + = stylesheet_link_tag 'application', media: 'all', data: { 'turbolinks-track': true } + = javascript_include_tag 'application', data: { 'turbolinks-track': true } - if user_signed_in? - if current_user.mod? - = javascript_include_tag 'moderation', 'data-turbolinks-track' => true + = javascript_include_tag 'moderation', data: { 'turbolinks-track': true } = csrf_meta_tags %body - if user_signed_in? diff --git a/app/views/layouts/feed.haml b/app/views/layouts/feed.haml index dff4d4f9..615fd51d 100644 --- a/app/views/layouts/feed.haml +++ b/app/views/layouts/feed.haml @@ -4,6 +4,6 @@ = render 'shared/sidebar' .col-md-9.col-xs-12.col-sm-8 = render 'layouts/messages' - = render 'tabs/feed' + = render 'tabs/feed', group: @group = yield - .d-block.d-sm-none= render 'shared/links' \ No newline at end of file + .d-block.d-sm-none= render 'shared/links' diff --git a/app/views/layouts/inbox.haml b/app/views/layouts/inbox.haml index 625bdfcd..8dcff72c 100644 --- a/app/views/layouts/inbox.haml +++ b/app/views/layouts/inbox.haml @@ -1,13 +1,14 @@ .container.container--main .row .col-md-3.col-xs-12.col-sm-4.order-2.order-sm-1 - = render 'inbox/sidebar' + = render 'inbox/sidebar', delete_id: @delete_id, disabled: @disabled, inbox_count: @inbox_count .col-md-9.col-xs-12.col-sm-8.order-1.order-sm-2 = render 'layouts/messages' = yield -= render "shared/links" += render 'shared/links' -- Inbox.where(id: @inbox.ids).update_all(new: false) -- provide(:title, generate_title("Inbox")) -- parent_layout "base" \ No newline at end of file +:ruby + Inbox.where(id: @inbox.ids).update_all(new: false) + provide(:title, generate_title('Inbox')) + parent_layout 'base' diff --git a/app/views/layouts/mail.haml b/app/views/layouts/mail.haml new file mode 100644 index 00000000..fac5c9c5 --- /dev/null +++ b/app/views/layouts/mail.haml @@ -0,0 +1,28 @@ +%html + %head + :css + body { + font-size: 16px; + margin-top: 0px; + margin-bottom: 0px; + font-family: Arial, sans-serif; + } + p { + margin: 0px; + padding: 0px; + } + %body + %table{ cellpadding: 0, cellspacing: 0, border: 5, bordercolor: '#5e35b1', bgcolor: '#5e35b1', style: 'font-size:0px;', align: 'center', width: '630' } + %tbody + %tr + %td{ style: 'padding:5px 10px;', align: 'center' } + %p{ style: 'margin:0px;padding:0px' } + %font{ color: '#ffffff', size: 6, face: 'Arial, sans-serif' }= APP_CONFIG['site_name'] + %tr + %td{ bgcolor: '#ffffff', style: 'padding:10px' } + %font{ color: '#000000', size: 4, face: 'Arial, sans-serif' }= yield + %p{ style: 'margin:0px;padding:5px;', align: 'center' } + %font{ size: 2, color: '#797979', face: 'Arial, sans-serif' } + © + = Time.zone.now.year + = APP_CONFIG['site_name'] diff --git a/app/views/layouts/mail.html.haml b/app/views/layouts/mail.html.haml deleted file mode 100644 index 3b06a584..00000000 --- a/app/views/layouts/mail.html.haml +++ /dev/null @@ -1,28 +0,0 @@ -%html - %head - :css - body { - font-size: 16px; - margin-top: 0px; - margin-bottom: 0px; - font-family: Arial, sans-serif; - } - p { - margin: 0px; - padding: 0px; - } - %body - %table{cellpadding: 0, cellspacing: 0, border: 5, bordercolor: "#5e35b1", bgcolor: "#5e35b1", style: "font-size:0px;", align: "center", width: "630"} - %tbody - %tr - %td{style: "padding:5px 10px;", align: "center"} - %p{style: "margin:0px;padding:0px"} - %font{color: "#ffffff", size: 6, face: "Arial, sans-serif"}= APP_CONFIG['site_name'] - %tr - %td{bgcolor: "#ffffff", style: "padding:10px"} - %font{color: "#000000", size: 4, face: "Arial, sans-serif"}= yield - %p{style:"margin:0px;padding:5px;", align: "center"} - %font{size: 2, color: "#797979", face: "Arial, sans-serif"} - © - = Time.zone.now.year - = APP_CONFIG['site_name'] diff --git a/app/views/layouts/moderation.haml b/app/views/layouts/moderation.haml index 18fb60a6..46954223 100644 --- a/app/views/layouts/moderation.haml +++ b/app/views/layouts/moderation.haml @@ -6,5 +6,5 @@ .col-md-9.col-sm-8.col-xs-12 = yield -- provide(:title, generate_title("Moderation")) -- parent_layout "base" \ No newline at end of file +- provide(:title, generate_title('Moderation')) +- parent_layout 'base' diff --git a/app/views/layouts/notifications.haml b/app/views/layouts/notifications.haml index 83d74825..f495ae8e 100644 --- a/app/views/layouts/notifications.haml +++ b/app/views/layouts/notifications.haml @@ -6,6 +6,7 @@ .col-md-9.col-xs-12.col-sm-8 = yield -- Notification.for(current_user).update_all(new: false) -- provide(:title, generate_title("Notifications")) -- parent_layout "base" \ No newline at end of file +:ruby + Notification.for(current_user).update_all(new: false) + provide(:title, generate_title('Notifications')) + parent_layout 'base' diff --git a/app/views/layouts/user/profile.haml b/app/views/layouts/user/profile.haml index c551a4c3..f33dfa8f 100644 --- a/app/views/layouts/user/profile.haml +++ b/app/views/layouts/user/profile.haml @@ -1,16 +1,16 @@ .profile__header-container - %img.profile__header-image{src: @user.profile_header.url(:web)} + %img.profile__header-image{ src: @user.profile_header.url(:web) } .container .row .col-md-3.col-xs-12.col-sm-4 - = render 'user/profile' + = render 'user/profile', user: @user .d-none.d-sm-block= render 'shared/links' .col-md-9.col-xs-12.col-sm-8 - = render "questionbox" - = render "tabs/profile" + = render 'questionbox', user: @user + = render 'tabs/profile', user: @user = yield - if user_signed_in? - = render 'modal/group' - - if current_user.mod? and @user != current_user - = render 'modal/privileges' - = render 'modal/ban' \ No newline at end of file + = render 'modal/group', user: @user + - if current_user.mod? && @user != current_user + = render 'modal/privileges', user: @user + = render 'modal/ban', user: @user diff --git a/app/views/layouts/user/settings.haml b/app/views/layouts/user/settings.haml index e63f29ba..77e5a5f6 100644 --- a/app/views/layouts/user/settings.haml +++ b/app/views/layouts/user/settings.haml @@ -4,4 +4,4 @@ = render 'tabs/settings' .col-md-9.col-xs-12.col-sm-8 = render 'layouts/messages' - = yield \ No newline at end of file + = yield diff --git a/app/views/modal/_ask.haml b/app/views/modal/_ask.haml index 43d295d5..c99b4a6b 100644 --- a/app/views/modal/_ask.haml +++ b/app/views/modal/_ask.haml @@ -1,21 +1,21 @@ -#modal-ask-followers.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-ask-followers-label", :role => "dialog", :tabindex => "-1"} +.modal.fade#modal-ask-followers{ aria: { hidden: true, labelledby: 'modal-ask-followers-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-ask-followers-label.modal-title= t 'views.modal.ask.title' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %h5.modal-title#modal-ask-followers-label= t 'views.modal.ask.title' + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only= t 'views.actions.close' .modal-body - %textarea.form-control{:name => "qb-all-question", :placeholder => t('views.placeholder.question')} + %textarea.form-control{ name: 'qb-all-question', placeholder: t('views.placeholder.question') } .modal-footer - - if current_user.groups.count > 0 + - if current_user.groups.count.positive? %label = t 'views.modal.ask.choose' - %select{name: 'qb-all-rcpt', class: 'form-control', autocomplete: 'off'} - %option{value: 'followers', selected: true}= t('views.general.follower').pluralize(2) - %optgroup{label: t('views.group.title').pluralize(2)} + %select.form-control{ name: 'qb-all-rcpt', autocomplete: :off } + %option{ value: 'followers', selected: true }= t('views.general.follower').pluralize(2) + %optgroup{ label: t('views.group.title').pluralize(2) } - current_user.groups.each do |group| - %option{value: "grp:#{group.name}"}= group.display_name - %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"}= t 'views.actions.cancel' - %button.btn.btn-primary{name: 'qb-all-ask', :type => "button", data: {loading_text: t('views.modal.ask.loading') }}= t 'views.actions.ask' + %option{ value: "grp:#{group.name}" }= group.display_name + %button.btn.btn-default{ type: :button, data: { dismiss: :modal } }= t 'views.actions.cancel' + %button.btn.btn-primary{ name: 'qb-all-ask', type: :button, data: { loading_text: t('views.modal.ask.loading') } }= t 'views.actions.ask' diff --git a/app/views/modal/_ban.haml b/app/views/modal/_ban.haml index 0e1d5752..8720d03b 100644 --- a/app/views/modal/_ban.haml +++ b/app/views/modal/_ban.haml @@ -1,21 +1,21 @@ -#modal-ban.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-ban-label", :role => "dialog", :tabindex => "-1"} +.modal.fade#modal-ban{ aria: { hidden: true, labelledby: 'modal-ban-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-ban-label.modal-title + %h5.modal-title#modal-ban-label = t 'views.modal.bancontrol.title' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only Close - = bootstrap_form_tag(url: '/mod/ban', html: { method: :post, novalidate: "novalidate" }) do |f| - = f.hidden_field :user, value: @user.screen_name - #ban-control-super.modal-body - = f.check_box :ban, label: t('views.modal.bancontrol.ban'), checked: @user.banned? - #ban-controls{style: "#{"display: none" unless @user.banned?}"} - = f.check_box :permaban, label: t('views.modal.bancontrol.permanent'), checked: @user.permanently_banned? - #ban-controls-time{style: "#{"display: none" unless not @user.permanently_banned?}"} - = f.text_field :until, label: "", required: true, value: (@user.banned_until || DateTime.current).strftime("%m/%d/%Y %I:%M %p") - = f.text_field :reason, placeholder: t('views.modal.bancontrol.reason'), value: @user.ban_reason + = bootstrap_form_tag(url: '/mod/ban', html: { method: :post, novalidate: :novalidate }) do |f| + = f.hidden_field :user, value: user.screen_name + .modal-body#ban-control-super + = f.check_box :ban, label: t('views.modal.bancontrol.ban'), checked: user.banned? + #ban-controls{ style: !user.banned? ? 'display: none' : '' } + = f.check_box :permaban, label: t('views.modal.bancontrol.permanent'), checked: user.permanently_banned? + #ban-controls-time{ style: user.permanently_banned? ? 'display: none' : '' } + = f.text_field :until, label: '', required: true, value: (user.banned_until || DateTime.current).strftime('%m/%d/%Y %I:%M %p') + = f.text_field :reason, placeholder: t('views.modal.bancontrol.reason'), value: user.ban_reason .modal-footer - %button.btn.btn-default{name: 'stop-time', type: :button, data: { dismiss: :modal }}= t 'views.actions.close' - = f.submit t('views.modal.bancontrol.hammertime'), class: "btn btn-primary", name: 'hammer-time' + %button.btn.btn-default{ name: 'stop-time', type: :button, data: { dismiss: :modal } }= t 'views.actions.close' + = f.submit t('views.modal.bancontrol.hammertime'), class: 'btn btn-primary', name: 'hammer-time' diff --git a/app/views/modal/_comment_smiles.haml b/app/views/modal/_comment_smiles.haml index 0e15e327..c48b6b48 100644 --- a/app/views/modal/_comment_smiles.haml +++ b/app/views/modal/_comment_smiles.haml @@ -1,18 +1,18 @@ -.modal.fade{"id" => "modal-view-comment#{comment.id}-smiles","aria-hidden" => "true", "aria-labelledby" => "modal-view-comment#{comment.id}-smiles-label", :role => "dialog", :tabindex => "-1"} +.modal.fade{ id: "modal-view-comment#{comment.id}-smiles", aria: { hidden: true, labelledby: 'modal-commentsmile-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-ask-followers-label.modal-title= t 'views.answerbox.commentsmile' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %h5.modal-title#modal-commentsmile-label= t 'views.answerbox.commentsmile' + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only Close .modal-body - - if comment.smiles.all.count == 0 + - if comment.smiles.all.count.zero? = t 'views.answerbox.no_smile' - else %ul.smiles__user-list - comment.smiles.all.each do |smile| %li.smiles__user-list-entry - %a{href: show_user_profile_path(smile.user.screen_name)} - %img{src: smile.user.profile_picture.url(:medium), alt: user_screen_name(smile.user, url: false)} + %a{ href: show_user_profile_path(smile.user.screen_name) } + %img{ src: smile.user.profile_picture.url(:medium), alt: user_screen_name(smile.user, url: false) } %span= user_screen_name(smile.user, url: false) diff --git a/app/views/modal/_group.haml b/app/views/modal/_group.haml index 4b7b45c4..6ad41b08 100644 --- a/app/views/modal/_group.haml +++ b/app/views/modal/_group.haml @@ -1,28 +1,28 @@ -#modal-group-memberships.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-group-memberships-label", :role => "dialog", :tabindex => "-1"} +.modal.fade#modal-group-memberships{ aria: { hidden: true, labelledby: 'modal-group-memberships-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-group-memberships-label.modal-title= t 'views.modal.group.title' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %h5.modal-title#modal-group-memberships-label= t 'views.modal.group.title' + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only= t 'views.actions.close' - %div{role: "tabpanel"} - %ul.nav.nav-tabs.mt-1{role: "tablist"} - %li.nav-item{role: "presentation"} - %a.nav-link.active{href: "#grouplist", aria: {controls: "grouplist"}, data: {toggle: "tab"}, role: "tab"} + %div{ role: :tabpanel } + %ul.nav.nav-tabs.mt-1{ role: :tablist } + %li.nav-item{ role: 'presentation' } + %a.nav-link.active{ href: '#grouplist', aria: { controls: 'grouplist' }, data: { toggle: :tab }, role: :tab } = t 'views.modal.group.tabs.main' - %li.nav-item{role: "presentation"} - %a.nav-link{href: "#create", aria: {controls: "create"}, data: {toggle: "tab"}, role: "tab"} + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#create', aria: { controls: 'create' }, data: { toggle: :tab }, role: :tab } = t 'views.modal.group.tabs.create' .tab-content - .tab-pane.active{role:"tabpanel", id: "grouplist"} + .tab-pane.active{ role: :tabpanel, id: 'grouplist' } %ul.list-group - current_user.groups.each do |group| - = render 'modal/group/item', group: group, user: @user - .tab-pane{role:"tabpanel", id: "create"} + = render 'modal/group/item', group: group, user: user + .tab-pane{ role: :tabpanel, id: 'create' } .modal-body - %input#new-group-name.form-control{type: :text, placeholder: t('views.modal.group.name')} - %button#create-group.btn.btn-primary{type: :button, data: { user: @user.screen_name }}= t('views.modal.group.create') + %input.form-control#new-group-name{ type: :text, placeholder: t('views.modal.group.name') } + %button.btn.btn-primary#create-group{ type: :button, data: { user: user.screen_name } }= t('views.modal.group.create') .modal-footer - %button.btn.btn-primary{name: 'gm-save', type: :button, data: { dismiss: :modal }}= t 'views.actions.done' + %button.btn.btn-primary{ name: 'gm-save', type: :button, data: { dismiss: :modal } }= t 'views.actions.done' diff --git a/app/views/modal/_password.haml b/app/views/modal/_password.haml index 7d411fb8..e6fc37c4 100644 --- a/app/views/modal/_password.haml +++ b/app/views/modal/_password.haml @@ -1,13 +1,16 @@ -#modal-passwd.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-passwd-label", :role => "dialog", :tabindex => "-1"} +.modal.fade#modal-passwd{ aria: { hidden: true, labelledby: 'modal-passwd-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-passwd-label.modal-title= t 'views.settings.account.modal.title' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %h5.modal-title#modal-passwd-label= t 'views.settings.account.modal.title' + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only= t 'views.actions.close' .modal-body - = f.password_field :current_password, autocomplete: "off", label: t('views.settings.account.password_current'), help: t('views.settings.account.password_current_help') + = f.password_field :current_password, + autocomplete: :off, + label: t('views.settings.account.password_current'), + help: t('views.settings.account.password_current_help') .modal-footer - %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"}= t 'views.actions.cancel' - %button.btn.btn-primary{:type => "submit"}= t 'views.actions.save' \ No newline at end of file + %button.btn.btn-default{ data: { dismiss: :modal }, type: :button }= t 'views.actions.cancel' + %button.btn.btn-primary{ type: :submit }= t 'views.actions.save' diff --git a/app/views/modal/_privileges.haml b/app/views/modal/_privileges.haml index 3fda929e..139845a0 100644 --- a/app/views/modal/_privileges.haml +++ b/app/views/modal/_privileges.haml @@ -1,15 +1,15 @@ -#modal-privileges.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-privileges-label", :role => "dialog", :tabindex => "-1"} +.modal.fade#modal-privileges{ aria: { hidden: true, labelledby: 'modal-privileges-label' }, role: :dialog, tabindex: -1 } .modal-dialog .modal-content .modal-header - %h5#modal-privileges-label.modal-title - = raw t('views.actions.privilege', user: @user.screen_name) - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × + %h5.modal-title#modal-privileges-label + = raw t('views.actions.privilege', user: user.screen_name) + %button.close{ data: { dismiss: :modal }, type: :button } + %span{ aria: { hidden: true } } × %span.sr-only= t 'views.actions.close' %ul.list-group.groups--list - if current_user.has_role?(:administrator) - = render 'modal/privileges/item', privilege: 'moderator', description: t('views.modal.privilege.moderator'),user: @user - = render 'modal/privileges/item', privilege: 'admin', description: t('views.modal.privilege.admin'), user: @user + = render 'modal/privileges/item', privilege: 'moderator', description: t('views.modal.privilege.moderator'), user: user + = render 'modal/privileges/item', privilege: 'admin', description: t('views.modal.privilege.admin'), user: user .modal-footer - %button.btn.btn-primary{name: 'checked-privileges', type: :button, data: { dismiss: :modal }}= t 'views.actions.done' + %button.btn.btn-primary{ name: 'checked-privileges', type: :button, data: { dismiss: :modal } }= t 'views.actions.done' diff --git a/app/views/modal/group/_item.haml b/app/views/modal/group/_item.haml index c060abc8..fd525549 100644 --- a/app/views/modal/group/_item.haml +++ b/app/views/modal/group/_item.haml @@ -1,15 +1,18 @@ -%li.list-group-item{id: "group-#{group.name}"} +%li.list-group-item{ id: "group-#{group.name}" } .media .pull-left .custom-control.custom-checkbox - %input.custom-control-input{type: :checkbox, id: "groupCheck#{group.id}", name: 'gm-group-check', data: { group: group.name, user: user.screen_name }, checked: user.member_of?(group), autocomplete: 'off'} - %label.custom-control-label{for: "groupCheck#{group.id}"} + %input.custom-control-input{ type: :checkbox, + id: "groupCheck#{group.id}", + name: 'gm-group-check', + data: { group: group.name, user: user.screen_name }, checked: user.member_of?(group), autocomplete: :off } + %label.custom-control-label{ for: "groupCheck#{group.id}" } .media-body .list-group-item-heading= group.display_name .list-group-item-text.text-muted - %span{id: "#{group.name}-members"}= group.members.count + %span{ id: "#{group.name}-members" }= group.members.count = t 'views.modal.group.members' · - %a.text-danger#delete-group{href: "#", data: { group: group.name }} + %a.text-danger#delete-group{ href: '#', data: { group: group.name } } %i.fa.fa-close = t 'views.actions.delete' diff --git a/app/views/modal/privileges/_item.haml b/app/views/modal/privileges/_item.haml index 47c6380e..dde51929 100644 --- a/app/views/modal/privileges/_item.haml +++ b/app/views/modal/privileges/_item.haml @@ -1,11 +1,12 @@ -- description ||= '' -- role_mapping = {"admin" => "administrator"} -- requires_role = %w[admin moderator].include?(privilege) -- checked = requires_role ? user.has_role?(role_mapping.fetch(privilege, privilege).to_sym) : user.public_send("#{privilege}?") -%li.list-group-item{id: "privilege-#{privilege}"} +:ruby + description ||= '' + role_mapping = { admin: 'administrator' } + requires_role = %w[admin moderator].include?(privilege) + checked = requires_role ? user.has_role?(role_mapping.fetch(privilege, privilege).to_sym) : user.public_send("#{privilege}?") +%li.list-group-item{ id: "privilege-#{privilege}" } .media .pull-left - %input{type: :checkbox, name: 'check-your-privileges', data: { type: privilege, user: user.screen_name }, checked: checked, autocomplete: 'off'} + %input{ type: :checkbox, name: 'check-your-privileges', data: { type: privilege, user: user.screen_name }, checked: checked, autocomplete: :off } .media-body .list-group-item-heading= privilege.capitalize - unless description.blank? diff --git a/app/views/moderation/_actions.haml b/app/views/moderation/_actions.haml new file mode 100644 index 00000000..9bfeecb4 --- /dev/null +++ b/app/views/moderation/_actions.haml @@ -0,0 +1,4 @@ +%a.btn.btn-default.btn-block{ href: moderation_priority_path(user.id) } + View reports relating to user +%a.btn.btn-default.btn-block{ href: moderation_ip_path(user.id) } + View users with same IP diff --git a/app/views/moderation/_actions.html.haml b/app/views/moderation/_actions.html.haml deleted file mode 100644 index 20c21cd9..00000000 --- a/app/views/moderation/_actions.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%a.btn.btn-default.btn-block{href: moderation_priority_path(user.id)} - View reports relating to user -%a.btn.btn-default.btn-block{href: moderation_ip_path(user.id)} - View users with same IP diff --git a/app/views/moderation/_discussion.haml b/app/views/moderation/_discussion.haml new file mode 100644 index 00000000..86ebc108 --- /dev/null +++ b/app/views/moderation/_discussion.haml @@ -0,0 +1,29 @@ +- if report.moderation_comments.all.count.zero? + = t 'views.answerbox.no_comment' +- else + %ul.comment__container + - report.moderation_comments.order(:created_at).each do |comment| + %li.comment{ data: { comment_id: comment.id } } + .media + .pull-left + %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 + - if comment.user == current_user + .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 } + %a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'mod-comment-destroy', id: comment.id } } + %i.fa.fa-trash-o + = t 'views.actions.delete' + .comment__content + = comment.content +.form-group.has-feedback{ name: 'mod-comment-new-group', data: { id: report.id } } + %input.form-control.comments--box{ type: :text, placeholder: t('views.placeholder.comment'), name: 'mod-comment-new', data: { id: report.id } } + %span.text-muted.form-control-feedback.comments--count{ id: "mod-comment-charcount-#{report.id}" } 160 diff --git a/app/views/moderation/_discussion.html.haml b/app/views/moderation/_discussion.html.haml deleted file mode 100644 index 4be392f0..00000000 --- a/app/views/moderation/_discussion.html.haml +++ /dev/null @@ -1,28 +0,0 @@ -- if report.moderation_comments.all.count == 0 - = t 'views.answerbox.no_comment' -- else - %ul.comment__container - - report.moderation_comments.order(:created_at).each do |comment| - %li.comment{data: { comment_id: comment.id }} - .media - .pull-left - %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" - - if comment.user == current_user - .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} - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'mod-comment-destroy', id: comment.id }} - %i.fa.fa-trash-o - = t 'views.actions.delete' - .comment__content - = comment.content -.form-group.has-feedback{name: 'mod-comment-new-group', data: { id: report.id }} - %input.form-control.comments--box{type: :text, placeholder: t('views.placeholder.comment'), name: 'mod-comment-new', data: { id: report.id }} - %span.text-muted.form-control-feedback.comments--count{id: "mod-comment-charcount-#{report.id}"} 160 diff --git a/app/views/moderation/_moderationbox.haml b/app/views/moderation/_moderationbox.haml new file mode 100644 index 00000000..b7c623af --- /dev/null +++ b/app/views/moderation/_moderationbox.haml @@ -0,0 +1,55 @@ +- unless report.nil? || report.target.nil? || report.user.nil? || report.type.nil? + .card.moderationbox{ data: { id: report.id } } + .card-header + %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } + = raw t('views.moderation.moderationbox.reported', + user: user_screen_name(report.user), + content: report.type.sub('Reports::', ''), + time: time_tooltip(report)) + .card-body + %p + - if report.type == 'Reports::User' + = user_screen_name report.target + - else + = report.target.content + %p + %b= t 'views.moderation.moderationbox.reason' + %br + - if report.reason.nil? || report.reason.strip.blank? + No reason provided + - else + - report.reason.lines.each do |reason| + - next if reason.strip.blank? + = reason.strip + .row + .col-md-8.col-sm-8.col-xs-8.text-left + %a.btn.btn-primary{ href: content_url(report) } + = t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', '')) + - if report.target.respond_to?(:user) && report.target.user + %a.btn.btn-primary{ href: show_user_profile_path(report.target.user.screen_name) } + = t('views.moderation.moderationbox.view', content: t('views.general.user')) + %a.btn.btn-primary{ href: moderation_priority_path(report.target.user.id) } + Reports + %a.btn.btn-primary{ href: moderation_ip_path(report.target.user.id) } + IP + .col-md-4.col-sm-4.col-xs-4.text-right + %span.mod-count{ id: "mod-count-#{report.id}" } + = report.votes + .btn-group + %button.btn.btn-success.btn-sm{ type: :button, + name: 'mod-vote', + disabled: current_user.report_x_voted?(report, true) ? :disabled : nil, + data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' } } + %i.fa.fa-thumbs-up + %button.btn.btn-danger.btn-sm{ type: :button, + name: 'mod-vote', + disabled: current_user.report_x_voted?(report, false) ? :disabled : nil, + data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' } } + %i.fa.fa-thumbs-down + %button.btn.btn-primary.btn-sm{ type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden } } + %i.fa.fa-comments + %span{ id: "mod-comment-count-#{report.id}" }= report.moderation_comments.all.count + %button.btn.btn-default.btn-sm{ type: :button, name: 'mod-delete-report', data: { id: report.id } } + %i.fa.fa-trash-o + .card-footer{ id: "mod-comments-section-#{report.id}", style: 'display: none' } + %div{ id: "mod-comments-#{report.id}" }= render 'moderation/discussion', report: report diff --git a/app/views/moderation/_moderationbox.html.haml b/app/views/moderation/_moderationbox.html.haml deleted file mode 100644 index 122582cb..00000000 --- a/app/views/moderation/_moderationbox.html.haml +++ /dev/null @@ -1,46 +0,0 @@ -- unless report.nil? or report.target.nil? or report.user.nil? or report.type.nil? - .card.moderationbox{data: { id: report.id }} - .card-header - %img.avatar-sm{src: report.user.profile_picture.url(:medium)} - = raw t('views.moderation.moderationbox.reported', user: user_screen_name(report.user), content: report.type.sub('Reports::', ''), time: time_tooltip(report)) - .card-body - %p - - if report.type == 'Reports::User' - = user_screen_name report.target - - else - = report.target.content - %p - %b= t 'views.moderation.moderationbox.reason' - %br - - if report.reason.nil? or report.reason.strip.blank? - No reason provided - - else - - report.reason.lines.each do |reason| - - next if reason.strip.blank? - = reason.strip - .row - .col-md-8.col-sm-8.col-xs-8.text-left - %a.btn.btn-primary{href: content_url(report)} - = t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', '')) - - if report.target.respond_to? :user and not report.target.user.nil? - %a.btn.btn-primary{href: show_user_profile_path(report.target.user.screen_name)} - = t('views.moderation.moderationbox.view', content: t('views.general.user')) - %a.btn.btn-primary{href: moderation_priority_path(report.target.user.id)} - Reports - %a.btn.btn-primary{href: moderation_ip_path(report.target.user.id)} - IP - .col-md-4.col-sm-4.col-xs-4.text-right - %span.mod-count{id: "mod-count-#{report.id}"} - = report.votes - .btn-group - %button.btn.btn-success.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, true) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' }} - %i.fa.fa-thumbs-up - %button.btn.btn-danger.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, false) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' }} - %i.fa.fa-thumbs-down - %button.btn.btn-primary.btn-sm{type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden }} - %i.fa.fa-comments - %span{id: "mod-comment-count-#{report.id}"}= report.moderation_comments.all.count - %button.btn.btn-default.btn-sm{type: :button, name: "mod-delete-report", data: { id: report.id }} - %i.fa.fa-trash-o - .card-footer{id: "mod-comments-section-#{report.id}", style: 'display: none'} - %div{id: "mod-comments-#{report.id}"}= render 'moderation/discussion', report: report diff --git a/app/views/moderation/_userbox.html.haml b/app/views/moderation/_userbox.haml similarity index 57% rename from app/views/moderation/_userbox.html.haml rename to app/views/moderation/_userbox.haml index ad59b82e..0b604f6d 100644 --- a/app/views/moderation/_userbox.html.haml +++ b/app/views/moderation/_userbox.haml @@ -1,14 +1,16 @@ .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 + .profile__screen-name + = user.screen_name .row .col-md-12.col-sm-12.col-xs-12 - - unless count.nil? + - if count.positive? %h4.entry-text.text-center#asked-count = count = 'Report'.pluralize(count) diff --git a/app/views/moderation/index.html.haml b/app/views/moderation/index.haml similarity index 100% rename from app/views/moderation/index.html.haml rename to app/views/moderation/index.haml diff --git a/app/views/moderation/priority.html.haml b/app/views/moderation/priority.haml similarity index 100% rename from app/views/moderation/priority.html.haml rename to app/views/moderation/priority.haml diff --git a/app/views/navigation/_feed.haml b/app/views/navigation/_feed.haml deleted file mode 100644 index acbfaeec..00000000 --- a/app/views/navigation/_feed.haml +++ /dev/null @@ -1,10 +0,0 @@ -%nav.navbar.navbar-light.navbar-static-top.j2-navbar.d-flex.d-sm-none.bg-white{role: "navigation"} - %a.navbar-brand{href: "/"} Timelines - %button.navbar-toggler{"data-target" => "#j2-tl-navbar-collapse", "data-toggle" => "collapse", type: "button"} - %span.sr-only Toggle navigation - %span.navbar-toggler-icon - #j2-tl-navbar-collapse.collapse.navbar-collapse - %ul.nav.navbar-nav - = nav_entry "Public", public_timeline_path - - current_user.groups.each do |group| - = nav_entry group.display_name, group_timeline_path(group.name) \ No newline at end of file diff --git a/app/views/navigation/_guest.haml b/app/views/navigation/_guest.haml index d06d91c8..2c9cd80d 100644 --- a/app/views/navigation/_guest.haml +++ b/app/views/navigation/_guest.haml @@ -1,10 +1,10 @@ -%nav.navbar.navbar-dark.navbar-expand-lg.bg-primary.fixed-top{role: "navigation"} - .container{class: ios_web_app? ? "ios-web-app" : ''} - %a.navbar-brand{href: "/"}= APP_CONFIG['site_name'] - %button.navbar-toggler{"data-target" => "#j2-main-navbar-collapse", "data-toggle" => "collapse", type: "button"} +%nav.navbar.navbar-dark.navbar-expand-lg.bg-primary.fixed-top{ role: :navigation } + .container{ class: ios_web_app? ? 'ios-web-app' : '' } + %a.navbar-brand{ href: '/' }= APP_CONFIG['site_name'] + %button.navbar-toggler{ data: { target: '#j2-main-navbar-collapse', toggle: :collapse }, type: :button } %span.sr-only Toggle navigation %span.navbar-toggler-icon - #j2-main-navbar-collapse.collapse.navbar-collapse + .collapse.navbar-collapse#j2-main-navbar-collapse %ul.nav.navbar-nav.ml-auto = nav_entry t('views.sessions.create'), new_user_session_path - = nav_entry t('views.sessions.new'), new_user_registration_path \ No newline at end of file + = nav_entry t('views.sessions.new'), new_user_registration_path diff --git a/app/views/navigation/_main.haml b/app/views/navigation/_main.haml index 8e0aea46..04c93eab 100644 --- a/app/views/navigation/_main.haml +++ b/app/views/navigation/_main.haml @@ -1,28 +1,28 @@ -%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top{role: "navigation"} - .container{class: ios_web_app? ? "ios-web-app" : ''} - %a.navbar-brand{href: "/"}= APP_CONFIG['site_name'] - %button.navbar-toggler{"data-target" => "#j2-main-navbar-collapse", "data-toggle" => "collapse", type: "button"} +%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top{ role: :navigation } + .container{ class: ios_web_app? ? 'ios-web-app' : '' } + %a.navbar-brand{ href: '/' }= APP_CONFIG['site_name'] + %button.navbar-toggler{ data: { target: '#j2-main-navbar-collapse', toggle: :collapse }, type: :button } %span.sr-only Toggle navigation %span.navbar-toggler-icon - #j2-main-navbar-collapse.collapse.navbar-collapse + .collapse.navbar-collapse#j2-main-navbar-collapse %ul.nav.navbar-nav.mr-auto = nav_entry t('views.navigation.timeline'), root_path - = nav_entry t('views.navigation.inbox'), "/inbox", badge: inbox_count + = nav_entry t('views.navigation.inbox'), '/inbox', badge: inbox_count - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t('views.navigation.discover'), discover_path %ul.nav.navbar-nav - unless @user.nil? - unless @user == current_user - %li.nav-item.d-none.d-sm-block{"data-toggle" => "tooltip", "data-placement" => "bottom", title: t('views.actions.group')} - %a.nav-link{href: '#', data: { target: "#modal-group-memberships", toggle: :modal }} + %li.nav-item.d-none.d-sm-block{ data: { toggle: 'tooltip', placement: 'bottom' }, title: t('views.actions.group') } + %a.nav-link{ href: '#', data: { target: '#modal-group-memberships', toggle: :modal } } %i.fa.fa-users.hidden-xs %span.d-none.d-sm-inline.d-md-none= t('views.actions.group') - = render "navigation/main/notifications" - %li.nav-item.d-none.d-sm-block{"data-toggle" => "tooltip", "data-placement" => "bottom", title: t('views.actions.ask_question')} - %a.nav-link{href: "#", name: "toggle-all-ask", "data-target" => "#modal-ask-followers", "data-toggle" => "modal"} + = render 'navigation/main/notifications' + %li.nav-item.d-none.d-sm-block{ data: { toggle: 'tooltip', placement: 'bottom' }, title: t('views.actions.ask_question') } + %a.nav-link{ href: '#', name: 'toggle-all-ask', data: { target: '#modal-ask-followers', toggle: :modal } } %i.fa.fa-pencil-square-o - = render "navigation/main/profile" + = render 'navigation/main/profile' = render 'modal/ask' -%button.btn.btn-primary.btn-fab.d-block.d-sm-none{"data-target" => "#modal-ask-followers", "data-toggle" => "modal", :type => "button"} - %i.fa.fa-pencil-square-o \ No newline at end of file +%button.btn.btn-primary.btn-fab.d-block.d-sm-none{ data: { target: '#modal-ask-followers', toggle: :modal }, type: 'button' } + %i.fa.fa-pencil-square-o diff --git a/app/views/navigation/_moderation.haml b/app/views/navigation/_moderation.haml index e97f466d..8a70ef05 100644 --- a/app/views/navigation/_moderation.haml +++ b/app/views/navigation/_moderation.haml @@ -1,13 +1,13 @@ -%nav.navbar.navbar-light.bg-light.navbar-static-top.j2-navbar.d-flex.d-sm-none{role: "navigation"} - %a.navbar-brand{href: moderation_path} Moderation - %button.navbar-toggler{"data-target" => "#j2-tl-navbar-collapse", "data-toggle" => "collapse", type: "button"} +%nav.navbar.navbar-light.bg-light.navbar-static-top.j2-navbar.d-flex.d-sm-none{ role: :navigation } + %a.navbar-brand{ href: moderation_path } Moderation + %button.navbar-toggler{ data: { target: '#j2-tl-navbar-collapse', toggle: :collapse }, type: :button } %span.sr-only Toggle navigation %span.navbar-toggler-icon - #j2-tl-navbar-collapse.collapse.navbar-collapse + .collapse.navbar-collapse#j2-tl-navbar-collapse %ul.nav.navbar-nav = nav_entry t('views.moderation.tabs.all'), moderation_path - = nav_entry t('views.general.answer').pluralize(2) , moderation_path('answer') - = nav_entry t('views.general.comment').pluralize(2), moderation_path('comment') - = nav_entry t('views.general.user').pluralize(2) , moderation_path('user') - = nav_entry t('views.general.question').pluralize(2), moderation_path('question') - = nav_entry 'Priority', moderation_priority_path + = nav_entry t('views.general.answer').pluralize(2), moderation_path('answer') + = nav_entry t('views.general.comment').pluralize(2), moderation_path('comment') + = nav_entry t('views.general.user').pluralize(2), moderation_path('user') + = nav_entry t('views.general.question').pluralize(2), moderation_path('question') + = nav_entry 'Priority', moderation_priority_path diff --git a/app/views/navigation/_notification.haml b/app/views/navigation/_notification.haml index c2be678a..a7456422 100644 --- a/app/views/navigation/_notification.haml +++ b/app/views/navigation/_notification.haml @@ -1,12 +1,12 @@ -%nav.navbar.navbar-light.bg-white.navbar-static-top.j2-navbar.d-flex.d-sm-none{role: "navigation"} - %a.navbar-brand{href: notifications_path} Notifications - %button.navbar-toggler{"data-target" => "#j2-tl-navbar-collapse", "data-toggle" => "collapse", type: "button"} +%nav.navbar.navbar-light.bg-white.navbar-static-top.d-flex.d-sm-none{ role: :navigation } + %a.navbar-brand{ href: notifications_path } Notifications + %button.navbar-toggler{ data: { target: '#j2-tl-navbar-collapse', toggle: :collapse }, type: :button } %span.sr-only Toggle navigation %span.navbar-toggler-icon - #j2-tl-navbar-collapse.collapse.navbar-collapse + .collapse.navbar-collapse#j2-tl-navbar-collapse %ul.nav.navbar-nav - = nav_entry "New Notifications", notifications_path - = nav_entry "All Notifications", notifications_path('all') + = nav_entry 'New Notifications', notifications_path + = nav_entry 'All Notifications', notifications_path('all') = nav_entry t('views.notifications.tabs.answer'), notifications_path('answer') = nav_entry t('views.notifications.tabs.smile'), notifications_path('smile') = nav_entry t('views.notifications.tabs.comment'), notifications_path('comment') diff --git a/app/views/navigation/main/_notifications.haml b/app/views/navigation/main/_notifications.haml index a8b5988a..80f43d9c 100644 --- a/app/views/navigation/main/_notifications.haml +++ b/app/views/navigation/main/_notifications.haml @@ -1,7 +1,7 @@ = nav_entry t('views.navigation.notifications'), notifications_path, badge: notification_count, class: 'd-block d-sm-none' - notifications = Notification.for(current_user).where(new: true).limit(4) %li.nav-item.dropdown.d-none.d-sm-block - %a.nav-link.dropdown-toggle{href: "#", "data-toggle" => "dropdown"} + %a.nav-link.dropdown-toggle{ href: '#', data: { toggle: :dropdown } } - if notification_count.nil? %i.fa.fa-bell-o - else @@ -9,11 +9,11 @@ %span.sr-only Notifications %span.badge= notification_count .dropdown-menu.dropdown-menu-right.notification-dropdown - - if notifications.count == 0 + - if notifications.count.zero? .dropdown-item.text-center.p-2 %i.fa.fa-bell-o.notification__bell-icon %p No new notifications. - %a.dropdown-item.text-center{href: notifications_path('all')} + %a.dropdown-item.text-center{ href: notifications_path('all') } %i.fa.fa-fw.fa-chevron-right Show all notifications - else @@ -21,6 +21,6 @@ .dropdown-item = render "notifications/type/#{notification.target_type.downcase}", notification: notification - %a.dropdown-item.text-center{href: notifications_path} + %a.dropdown-item.text-center{ href: notifications_path } %i.fa.fa-fw.fa-chevron-right Show all new notifications diff --git a/app/views/navigation/main/_profile.haml b/app/views/navigation/main/_profile.haml index 2aef7ad5..ae054665 100644 --- a/app/views/navigation/main/_profile.haml +++ b/app/views/navigation/main/_profile.haml @@ -1,37 +1,37 @@ %li.nav-item.dropdown.profile--image-dropdown - %a.nav-link.dropdown-toggle.p-sm-0{href: "#", "data-toggle" => "dropdown"} - %img.avatar-md.d-none.d-sm-inline{src: current_user.profile_picture.url(:small)} + %a.nav-link.dropdown-toggle.p-sm-0{ href: '#', data: { toggle: :dropdown } } + %img.avatar-md.d-none.d-sm-inline{ src: current_user.profile_picture.url(:small) } %span.d-inline.d-sm-none = current_user.screen_name %b.caret .dropdown-menu %h6.dropdown-header.d-none.d-sm-block= current_user.screen_name - %a.dropdown-item{href: show_user_profile_path(current_user.screen_name)} + %a.dropdown-item{ href: show_user_profile_path(current_user.screen_name) } %i.fa.fa-fw.fa-user = t('views.navigation.show') - %a.dropdown-item{href: edit_user_registration_path} + %a.dropdown-item{ href: edit_user_registration_path } %i.fa.fa-fw.fa-cog = t('views.navigation.settings') .dropdown-divider - if current_user.has_role?(:administrator) - %a.dropdown-item{href: rails_admin_path} + %a.dropdown-item{ href: rails_admin_path } %i.fa.fa-fw.fa-cogs = t('views.navigation.admin') - %a.dropdown-item{href: sidekiq_web_path} + %a.dropdown-item{ href: sidekiq_web_path } %i.fa.fa-fw.fa-bar-chart = t('views.navigation.sidekiq') - %a.dropdown-item{href: pghero_path} + %a.dropdown-item{ href: pghero_path } %i.fa.fa-fw.fa-database Database Monitor - %a.dropdown-item{href: announcement_index_path} + %a.dropdown-item{ href: announcement_index_path } %i.fa.fa-fw.fa-info Announcements .dropdown-divider - if current_user.mod? - %a.dropdown-item{href: moderation_path} + %a.dropdown-item{ href: moderation_path } %i.fa.fa-fw.fa-gavel = t('views.navigation.moderation') .dropdown-divider - %a.dropdown-item{href: destroy_user_session_path, data: {method: :delete} } + %a.dropdown-item{ href: destroy_user_session_path, data: { method: :delete } } %i.fa.fa-fw.fa-sign-out = t 'views.sessions.destroy' diff --git a/app/views/notifications/index.haml b/app/views/notifications/index.haml index 86a66d4c..4a004ce0 100644 --- a/app/views/notifications/index.haml +++ b/app/views/notifications/index.haml @@ -1,11 +1,11 @@ .card - %ul#notifications.list-group - - if @notifications.count == 0 + %ul.list-group#notifications + - if @notifications.count.zero? %li.list-group-item.text-center .notifications--none %i.fa.fa-bell-o.notification__bell-icon %p - - if params[:type] != "all" + - if params[:type] != 'all' No new notifications. - else No notifications. @@ -19,5 +19,5 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type] - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @notifications_last_id } } Load more diff --git a/app/views/notifications/type/_answer.haml b/app/views/notifications/type/_answer.haml index f8d8539e..0c3d781d 100644 --- a/app/views/notifications/type/_answer.haml +++ b/app/views/notifications/type/_answer.haml @@ -3,10 +3,10 @@ %i.fa.fa-2x.fa-fw.fa-exclamation .media-body .notification__heading - %img.avatar-xs{src: notification.target.user.profile_picture.url(:small)} + %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } = user_screen_name notification.target.user answered - = link_to "your question", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id) + = link_to 'your question', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id) = time_tooltip(notification.target) ago .list-group @@ -14,9 +14,9 @@ .media.question-media .media-body %h6.notification__list-heading question - = markdown notification.target.question.content[0..60] + "#{notification.target.question.content.length > 60 ? '[...]' : ''}" + = markdown notification.target.question.content[0..60] + (notification.target.question.content.length > 60 ? '[...]' : '') .list-group-item .media.question-media .media-body %h6.notification__list-heading answer - = markdown notification.target.content[0..60] + "#{notification.target.content.length > 60 ? '[...]' : ''}" \ No newline at end of file + = markdown notification.target.content[0..60] + (notification.target.content.length > 60 ? '[...]' : '') diff --git a/app/views/notifications/type/_comment.haml b/app/views/notifications/type/_comment.haml index 91f58666..02ee271a 100644 --- a/app/views/notifications/type/_comment.haml +++ b/app/views/notifications/type/_comment.haml @@ -3,15 +3,16 @@ %i.fa.fa-2x.fa-fw.fa-comments .media-body .notification__heading - %img.avatar-xs{src: notification.target.user.profile_picture.url(:small)} + %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } = user_screen_name notification.target.user commented on - if notification.target.answer.user == current_user - = link_to "your answer", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = link_to 'your answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) - elsif notification.target.user == notification.target.answer.user - = link_to "their answer", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = link_to 'their answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) - else - = link_to "#{notification.target.answer.user.screen_name}'s answer", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = link_to "#{notification.target.answer.user.screen_name}'s answer", + show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) = time_tooltip(notification.target) ago .list-group @@ -19,9 +20,9 @@ .media.question-media .media-body %h6.notification__list-heading answer - = markdown notification.target.answer.content[0..60] + "#{notification.target.answer.content.length > 60 ? '[...]' : ''}" + = markdown notification.target.answer.content[0..60] + (notification.target.answer.content.length > 60 ? '[...]' : '') .list-group-item .media.question-media .media-body %h6.notification__list-heading comment - = markdown notification.target.content[0..60] + "#{notification.target.content.length > 60 ? '[...]' : ''}" \ No newline at end of file + = markdown notification.target.content[0..60] + (notification.target.content.length > 60 ? '[...]' : '') diff --git a/app/views/notifications/type/_commentsmile.haml b/app/views/notifications/type/_commentsmile.haml index 09833486..b5567eb8 100644 --- a/app/views/notifications/type/_commentsmile.haml +++ b/app/views/notifications/type/_commentsmile.haml @@ -3,10 +3,10 @@ %i.fa.fa-2x.fa-fw.fa-smile-o .media-body .notification__heading - %img.avatar-xs{src: notification.target.user.profile_picture.url(:small)} + %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } = user_screen_name notification.target.user smiled - = link_to "your comment", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.comment.answer.id) + = link_to 'your comment', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.comment.answer.id) = time_tooltip(notification.target) ago .list-group @@ -14,4 +14,4 @@ .media.question-media .media-body %h6.notification__list-heading comment - = markdown notification.target.comment.content[0..60] + "#{notification.target.comment.content.length > 60 ? '[...]' : ''}" \ No newline at end of file + = markdown notification.target.comment.content[0..60] + (notification.target.comment.content.length > 60 ? '[...]' : '') diff --git a/app/views/notifications/type/_relationship.haml b/app/views/notifications/type/_relationship.haml index c5654ae5..8e0cf3cf 100644 --- a/app/views/notifications/type/_relationship.haml +++ b/app/views/notifications/type/_relationship.haml @@ -1,8 +1,8 @@ .media.notification .notification__icon - %img.avatar-sm{src: notification.target.source.profile_picture.url(:small)} + %img.avatar-sm{ src: notification.target.source.profile_picture.url(:small) } .media-body %h6.media-heading.notification__user = user_screen_name notification.target.source .notification__text - = raw t('views.notifications.relationship.body', time: time_ago_in_words(notification.target.created_at)) \ No newline at end of file + = raw t('views.notifications.relationship.body', time: time_ago_in_words(notification.target.created_at)) diff --git a/app/views/notifications/type/_smile.haml b/app/views/notifications/type/_smile.haml index eabe35c1..9a94d92b 100644 --- a/app/views/notifications/type/_smile.haml +++ b/app/views/notifications/type/_smile.haml @@ -3,10 +3,10 @@ %i.fa.fa-2x.fa-fw.fa-smile-o .media-body .notification__heading - %img.avatar-xs{src: notification.target.user.profile_picture.url(:small)} + %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } = user_screen_name notification.target.user smiled - = link_to "your answer", show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = link_to 'your answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) = time_tooltip(notification.target) ago .list-group @@ -14,4 +14,4 @@ .media.question-media .media-body %h6.notification__list-heading answer - = markdown notification.target.answer.content[0..60] + "#{notification.target.answer.content.length > 60 ? '[...]' : ''}" \ No newline at end of file + = markdown notification.target.answer.content[0..60] + (notification.target.answer.content.length > 60 ? '[...]' : '') diff --git a/app/views/public/index.haml b/app/views/public/index.haml index c73a0c30..22647940 100644 --- a/app/views/public/index.haml +++ b/app/views/public/index.haml @@ -5,8 +5,8 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @timeline_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @timeline_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @timeline_last_id } } Load more -- provide(:title, generate_title("Public Timeline")) -- parent_layout "feed" +- provide(:title, generate_title('Public Timeline')) +- parent_layout 'feed' diff --git a/app/views/question/_question.haml b/app/views/question/_question.haml index 045ef6d2..c7844a16 100644 --- a/app/views/question/_question.haml +++ b/app/views/question/_question.haml @@ -1,24 +1,28 @@ -.card.question--fixed{class: if hidden then 'question--hidden' end, tabindex: if hidden then '-1' end, aria: { hidden: if hidden then :true end }} +.card.question--fixed{ class: hidden ? 'question--hidden' : '', tabindex: hidden ? -1 : '', aria: { hidden: hidden } } .container .card-body .media - unless question.author_is_anonymous - %a.pull-left{href: unless hidden then show_user_profile_path(question.user.screen_name) end} - %img.answerbox__question-user-avatar.avatar-md{src: question.user.profile_picture.url(:medium)} + %a.pull-left{ href: unless hidden then show_user_profile_path(question.user.screen_name) end } + %img.answerbox__question-user-avatar.avatar-md{ src: 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 - unless hidden - .dropdown-menu.dropdown-menu-right{role: :menu} - - if current_user.mod? or question.user == current_user - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: question.id, redirect: if question.author_is_anonymous? then "/" else show_user_questions_path(question.user.screen_name) end }} + .dropdown-menu.dropdown-menu-right{ role: :menu } + - if current_user.mod? || question.user == current_user + %a.dropdown-item.text-danger{ href: '#', + tabindex: -1, + data: { action: 'ab-question-destroy', + q_id: question.id, + redirect: question.author_is_anonymous? ? '/' : show_user_questions_path(question.user.screen_name) } } %i.fa.fa-trash-o = t 'views.actions.delete' - unless question.user == current_user - %a.dropdown-item{href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id }} + %a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id } } %i.fa.fa-exclamation-triangle = t 'views.actions.report' %h6.text-muted.media-heading.answerbox__question-user diff --git a/app/views/question/show.haml b/app/views/question/show.haml index bb460154..329f50a2 100644 --- a/app/views/question/show.haml +++ b/app/views/question/show.haml @@ -9,18 +9,18 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @answers_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @answers_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @answers_last_id } } Load more - if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers .card#q-answer-box .card-header= t('views.question.title') .card-body - %textarea#q-answer.form-control{placeholder: t('views.placeholder.inbox'), data: { id: @question.id }} + %textarea.form-control#q-answer-text{ placeholder: t('views.placeholder.inbox'), data: { id: @question.id } } %br/ - %button#q-answer.btn.btn-success{data: { q_id: @question.id }} + %button.btn.btn-success#q-answer-btn{ data: { q_id: @question.id } } = t('views.actions.answer') - current_user.services.each do |service| %label - %input{type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider }} + %input{ type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider } } = t('views.inbox.entry.sharing.post', service: service.provider.capitalize) diff --git a/app/views/services/index.haml b/app/views/services/index.haml index 691d5076..e10a1a56 100644 --- a/app/views/services/index.haml +++ b/app/views/services/index.haml @@ -1,4 +1,4 @@ -= render "settings/services" += render 'settings/services' -- provide(:title, generate_title("Service Settings")) -- parent_layout "user/settings" +- provide(:title, generate_title('Service Settings')) +- parent_layout 'user/settings' diff --git a/app/views/settings/_account.haml b/app/views/settings/_account.haml index bc34b0a9..e1fea70f 100644 --- a/app/views/settings/_account.haml +++ b/app/views/settings/_account.haml @@ -11,19 +11,19 @@ - if devise_mapping.confirmable? && resource.pending_reconfirmation? %div= raw t('views.settings.account.email_confirm', resource: resource.unconfirmed_email) - = f.password_field :password, autocomplete: "off", label: t('views.settings.account.password'), help: t('views.settings.account.password_help') - = f.password_field :password_confirmation, autocomplete: "off", label: t('views.settings.account.password_confirm') + = f.password_field :password, autocomplete: :off, label: t('views.settings.account.password'), help: t('views.settings.account.password_help') + = f.password_field :password_confirmation, autocomplete: :off, label: t('views.settings.account.password_confirm') - %button.btn.btn-primary{"data-target" => "#modal-passwd", "data-toggle" => "modal", :type => "button"} + %button.btn.btn-primary{ data: { target: '#modal-passwd', toggle: :modal, type: :button } } = t 'views.actions.save' %hr/ %p = t 'views.settings.account.unsatisfied' - =button_to t('views.settings.account.delete'), '/settings/account', data: { confirm: "Are you sure?" }, method: :delete, class: "btn btn-danger btn-xs" + = button_to t('views.settings.account.delete'), '/settings/account', data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-danger btn-xs' = link_to t('views.settings.account.back'), :back -.visible-xs= render "shared/links" +.visible-xs= render 'shared/links' diff --git a/app/views/settings/_data.haml b/app/views/settings/_data.haml index fd6b4829..98b80195 100644 --- a/app/views/settings/_data.haml +++ b/app/views/settings/_data.haml @@ -43,28 +43,28 @@ %p.font-weight-bold.mb-0 Profile picture .media .pull-left - %img.profile--img{src: current_user.profile_picture.url(:medium)} + %img.profile--img{ src: current_user.profile_picture.url(:medium) } .media-body %ul %li - %a{href: current_user.profile_picture.url(:small)} Small + %a{ href: current_user.profile_picture.url(:small) } Small %li - %a{href: current_user.profile_picture.url(:medium)} Medium + %a{ href: current_user.profile_picture.url(:medium) } Medium %li - %a{href: current_user.profile_picture.url(:large)} Large + %a{ href: current_user.profile_picture.url(:large) } Large %li - %a{href: current_user.profile_picture.url(:original)} Original image + %a{ href: current_user.profile_picture.url(:original) } Original image %p.font-weight-bold.mb-0 Header picture - %img{src: current_user.profile_header.url(:mobile), style: 'width: 100%'} + %img{ src: current_user.profile_header.url(:mobile), style: 'width: 100%' } %p - %a{href: current_user.profile_header.url(:mobile)} Mobile + %a{ href: current_user.profile_header.url(:mobile) } Mobile | - %a{href: current_user.profile_header.url(:web)} Web + %a{ href: current_user.profile_header.url(:web) } Web | - %a{href: current_user.profile_header.url(:retina)} Retina + %a{ href: current_user.profile_header.url(:retina) } Retina | - %a{href: current_user.profile_header.url(:original)} Original image + %a{ href: current_user.profile_header.url(:original) } Original image .row .col-md-6.col-sm-6.col-xs-12 %h4 Statistics @@ -132,13 +132,13 @@ %h4 Sign In %p.font-weight-bold.mb-0 Current Sign In - %p.text-muted= current_user.current_sign_in_at ? localize(current_user.current_sign_in_at) : "Not set" + %p.text-muted= current_user.current_sign_in_at ? localize(current_user.current_sign_in_at) : 'Not set' %p.font-weight-bold.mb-0 Last Sign In - %p.text-muted= current_user.last_sign_in_at ? localize(current_user.last_sign_in_at) : "Not set" + %p.text-muted= current_user.last_sign_in_at ? localize(current_user.last_sign_in_at) : 'Not set' %p.font-weight-bold.mb-0 Remember me set at - %p.text-muted= current_user.remember_created_at ? localize(current_user.remember_created_at) : "Not set" + %p.text-muted= current_user.remember_created_at ? localize(current_user.remember_created_at) : 'Not set' .col-md-6.col-sm-6.col-xs-12 %h4 Create/Update diff --git a/app/views/settings/_export.haml b/app/views/settings/_export.haml index 91634d2c..85704a9d 100644 --- a/app/views/settings/_export.haml +++ b/app/views/settings/_export.haml @@ -3,7 +3,7 @@ %h2 Export your data %p The data is inside a - %code= ".tar.gz" + %code= '.tar.gz' archive and available in three formats: YAML, JSON, and XML. The archive also contains a copy of your profile picture and header picture in all sizes. %p @@ -11,13 +11,13 @@ will take a while, so please be patient. You will receive a question once exporting is done. - if current_user.can_export? - %form{action: begin_user_export_path, method: 'POST'} + %form{ action: begin_user_export_path, method: :post } %p.text-center - %button#export-btn.btn.btn-lg.btn-primary{type: :submit} Export + %button.btn.btn-lg.btn-primary#export-btn{ type: :submit } Export = hidden_field_tag :authenticity_token, form_authenticity_token - else %p.text-center - %button.btn.btn-lg.btn-primary.disabled{disabled: :disabled} Export + %button.btn.btn-lg.btn-primary.disabled{ disabled: :disabled } Export %p - if current_user.export_url.nil? Once exporting your account is done, a download link will appear here. @@ -25,5 +25,5 @@ Here is your export from = succeed ':' do = current_user.export_created_at - %a{href: current_user.export_url} - = File.basename current_user.export_url \ No newline at end of file + %a{ href: current_user.export_url } + = File.basename current_user.export_url diff --git a/app/views/settings/_privacy.haml b/app/views/settings/_privacy.haml index e3edd407..7e660c66 100644 --- a/app/views/settings/_privacy.haml +++ b/app/views/settings/_privacy.haml @@ -1,9 +1,9 @@ .card .card-body - = bootstrap_form_for(current_user, url: {action: "edit_privacy"}, method: "patch") do |f| + = bootstrap_form_for(current_user, url: { action: 'edit_privacy' }, method: :patch) do |f| = f.check_box :privacy_allow_anonymous_questions, label: t('views.settings.privacy.anonymous') = f.check_box :privacy_allow_public_timeline, label: t('views.settings.privacy.public') = f.check_box :privacy_allow_stranger_answers, label: t('views.settings.privacy.stranger') - = f.submit t('views.actions.save'), class: 'btn btn-primary' \ No newline at end of file + = f.submit t('views.actions.save'), class: 'btn btn-primary' diff --git a/app/views/settings/_profile.haml b/app/views/settings/_profile.haml index 1dcd3cda..f62a7f0c 100644 --- a/app/views/settings/_profile.haml +++ b/app/views/settings/_profile.haml @@ -1,41 +1,41 @@ .card .card-body - = bootstrap_form_for(current_user, url: {action: "edit"}, :html => { :multipart => true }, method: "patch") do |f| + = bootstrap_form_for(current_user, url: { action: :edit }, html: { multipart: true }, method: :patch) do |f| = f.text_field :display_name, label: t('views.settings.profile.displayname') .media#profile-picture-media .pull-left - %img.avatar-lg.mr-3{src: current_user.profile_picture.url(:medium)} + %img.avatar-lg.mr-3{ src: current_user.profile_picture.url(:medium) } .media-body = f.file_field :profile_picture, label: t('views.settings.profile.avatar') - .row#profile-picture-crop-controls{style: 'display: none;'} + .row#profile-picture-crop-controls{ style: 'display: none;' } .col-sm-10.col-md-8 %strong= t('views.settings.profile.avatar_adjust') - %img#profile-picture-cropper{src: current_user.profile_picture.url(:medium)} + %img#profile-picture-cropper{ src: current_user.profile_picture.url(:medium) } .col-sm-2.col-md-4 .btn-group - %button#cropper-zoom-out.btn.btn-inverse{type: :button} + %button.btn.btn-inverse#cropper-zoom-out{ type: :button } %i.fa.fa-search-minus - %button#cropper-zoom-in.btn.btn-inverse{type: :button} + %button.btn.btn-inverse#cropper-zoom-in{ type: :button } %i.fa.fa-search-plus .row.mb-2#profile-header-media .col - %img.mw-100.mr-3{src: current_user.profile_header.url(:mobile)} + %img.mw-100.mr-3{ src: current_user.profile_header.url(:mobile) } .col-xs-12.mt-3.mt-sm-0.pl-3.pr-3 = f.file_field :profile_header, label: t('views.settings.profile.header') - .row#profile-header-crop-controls{style: 'display: none;'} + .row#profile-header-crop-controls{ style: 'display: none;' } .col-sm-10.col-md-8 %strong= t('views.settings.profile.header_adjust') - %img#profile-header-cropper{src: current_user.profile_header.url(:web)} + %img#profile-header-cropper{ src: current_user.profile_header.url(:web) } .col-sm-2.col-md-4 .btn-group - %button#cropper-header-zoom-out.btn.btn-inverse{type: :button} + %button.btn.btn-inverse#cropper-header-zoom-out{ type: :button } %i.fa.fa-search-minus - %button#cropper-header-zoom-in.btn.btn-inverse{type: :button} + %button.btn.btn-inverse#cropper-header-zoom-in{ type: :button } %i.fa.fa-search-plus = f.text_field :motivation_header, label: t('views.settings.profile.motivation'), placeholder: t('views.settings.profile.placeholder.motivation') @@ -48,10 +48,10 @@ = f.check_box :show_foreign_themes, label: 'Render other user themes when visiting their profile' - - for attrib in %i(crop_x crop_y crop_w crop_h) + - %i[crop_x crop_y crop_w crop_h].each do |attrib| = f.hidden_field attrib, id: attrib - - for attrib in %i(crop_h_x crop_h_y crop_h_w crop_h_h) + - %i[crop_h_x crop_h_y crop_h_w crop_h_h].each do |attrib| = f.hidden_field attrib, id: attrib - = f.submit t('views.actions.save'), class: 'btn btn-primary' \ No newline at end of file + = f.submit t('views.actions.save'), class: 'btn btn-primary' diff --git a/app/views/settings/_services.haml b/app/views/settings/_services.haml index 6967f0fc..be9c7493 100644 --- a/app/views/settings/_services.haml +++ b/app/views/settings/_services.haml @@ -1,19 +1,22 @@ .card .card-body - - if @services.count > 0 + - if @services.count.positive? = t 'views.settings.service.enabled' - else = t 'views.settings.service.none' - APP_CONFIG['sharing'].each do |service, service_options| - - if service_options['enabled'] and !@services.any? { |x| x.provider == service.to_s } - %p=link_to t('views.settings.service.connect', service: service.capitalize), "/auth/#{service}" + - if service_options['enabled'] && @services.none? { |x| x.provider == service.to_s } + %p= link_to t('views.settings.service.connect', service: service.capitalize), "/auth/#{service}" - - if @services.count > 0 + - if @services.count.positive? %ul.list-group - @services.each do |service| %li.list-group-item - %i{class: "fa fa-#{service.provider}"} + %i{ class: "fa fa-#{service.provider}" } %strong= service.provider.capitalize (#{service.nickname}) - = link_to t('views.settings.service.disconnect'), service_path(service), data: { confirm: t('views.settings.service.confirm', service: service.provider.capitalize) }, method: :delete \ No newline at end of file + = link_to t('views.settings.service.disconnect'), + service_path(service), + data: { confirm: t('views.settings.service.confirm', service: service.provider.capitalize) }, + method: :delete diff --git a/app/views/settings/_theme.haml b/app/views/settings/_theme.haml index 53f4ba6f..50ea4918 100644 --- a/app/views/settings/_theme.haml +++ b/app/views/settings/_theme.haml @@ -2,19 +2,19 @@ .card-body %h1 Theming %p.lead Welcome to the Theme Editor! - %p - Here you'll be able to modify your Retrospring experience by adjusting all available colors. - To further help you with adjusting needs, there are a few example elements using the specified colors, and sections will include + %p + Here you'll be able to modify your Retrospring experience by adjusting all available colors. + To further help you with adjusting needs, there are a few example elements using the specified colors, and sections will include descriptions on their general use on the site! - %p + %p And with that: %b Happy Theming! - + - if current_user.theme .pull-right - = button_to 'Delete Theme', delete_user_theme_path, data: { confirm: "Are you sure?" }, tabindex: -1, method: :delete, class: "btn btn-danger" -= bootstrap_form_for(current_user.theme || Theme.new, url: {action: "update_theme"}, html: {id: 'update_theme'}, method: "patch") do |f| + = button_to 'Delete Theme', delete_user_theme_path, data: { confirm: 'Are you sure?' }, tabindex: -1, method: :delete, class: 'btn btn-danger' += bootstrap_form_for(current_user.theme || Theme.new, url: { action: 'update_theme' }, html: { id: 'update_theme' }, method: :patch) do |f| .card .card-body %h2 General @@ -22,9 +22,9 @@ Here you'll find general page values that are basically visible all across the page. .row .col-sm-6 - = f.text_field :background_color, class: 'color', data: {default: 0xF0EDF4} + = f.text_field :background_color, class: 'color', data: { default: 0xF0EDF4 } .col-sm-6 - = f.text_field :body_text, class: 'color', data: {default: 0x000000} + = f.text_field :body_text, class: 'color', data: { default: 0x000000 } .card .card-body %h2 Colors @@ -50,61 +50,61 @@ Color used for messages if something went through successfully. .row .col-sm-6 - = f.text_field :primary_color, class: 'color', data: {default: 0x5E35B1} + = f.text_field :primary_color, class: 'color', data: { default: 0x5E35B1 } .col-sm-6 - = f.text_field :primary_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :primary_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 .alert.alert-primary A simple primary alert—check it out! .row .col-sm-6 - = f.text_field :danger_color, class: 'color', data: {default: 0xDC3545} + = f.text_field :danger_color, class: 'color', data: { default: 0xDC3545 } .col-sm-6 - = f.text_field :danger_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :danger_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 .alert.alert-danger A simple danger alert—check it out! .row .col-sm-6 - = f.text_field :warning_color, class: 'color', data: {default: 0xFFC107} + = f.text_field :warning_color, class: 'color', data: { default: 0xFFC107 } .col-sm-6 - = f.text_field :warning_text, class: 'color', data: {default: 0x292929} + = f.text_field :warning_text, class: 'color', data: { default: 0x292929 } .col-sm-12 .alert.alert-warning A simple warning alert—check it out! .row .col-sm-6 - = f.text_field :info_color, class: 'color', data: {default: 0x17A2B8} + = f.text_field :info_color, class: 'color', data: { default: 0x17A2B8 } .col-sm-6 - = f.text_field :info_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :info_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 .alert.alert-info A simple info alert—check it out! .row .col-sm-6 - = f.text_field :success_color, class: 'color', data: {default: 0x28A745} + = f.text_field :success_color, class: 'color', data: { default: 0x28A745 } .col-sm-6 - = f.text_field :success_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :success_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 .alert.alert-success A simple success alert—check it out! .row .col-sm-6 - = f.text_field :dark_color, class: 'color', data: {default: 0x343A40} + = f.text_field :dark_color, class: 'color', data: { default: 0x343A40 } .col-sm-6 - = f.text_field :dark_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :dark_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 %a.btn.btn-dark.mb-3{ href: '#' } A dark button .row .col-sm-6 - = f.text_field :light_color, class: 'color', data: {default: 0xF8F9FA} + = f.text_field :light_color, class: 'color', data: { default: 0xF8F9FA } .col-sm-6 - = f.text_field :light_text, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :light_text, class: 'color', data: { default: 0xFFFFFF } .col-sm-12 %a.btn.btn-light.mb-3{ href: '#' } A light button .row .col-sm-6 - = f.text_field :muted_text, class: 'color', data: {default: 0x6C757D} + = f.text_field :muted_text, class: 'color', data: { default: 0x6C757D } .col-sm-6 %p.pt-4.text-muted Some muted text .card @@ -114,9 +114,9 @@ Styles for form inputs, like textfields. .row .col-sm-6 - = f.text_field :input_color, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :input_color, class: 'color', data: { default: 0xFFFFFF } .col-sm-6 - = f.text_field :input_text, class: 'color', data: {default: 0x000000} + = f.text_field :input_text, class: 'color', data: { default: 0x000000 } .card .card-body %h2 Raised Content @@ -124,9 +124,9 @@ Raised content basically describes all the different boxes and panels you can see across the site. .row .col-sm-6 - = f.text_field :raised_background, class: 'color', data: {default: 0xFFFFFF} + = f.text_field :raised_background, class: 'color', data: { default: 0xFFFFFF } .col-sm-6 - = f.text_field :raised_accent, class: 'color', data: {default: 0xF7F7F7} + = f.text_field :raised_accent, class: 'color', data: { default: 0xF7F7F7 } .card-footer %p Some text on top of a accented area on a raised element! .card diff --git a/app/views/shared/_announcements.haml b/app/views/shared/_announcements.haml index 3f4bab7b..96fcca85 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..5f0571e8 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/static/about.haml b/app/views/static/about.haml index dddc544c..f6ad2c21 100644 --- a/app/views/static/about.haml +++ b/app/views/static/about.haml @@ -1,6 +1,6 @@ -- provide(:title, generate_title("About")) +- provide(:title, generate_title('About')) .jumbotron.jumbotron--particles - #particles.jumbotron__particles + .jumbotron__particles#particles .jumbotron__content %h1= APP_CONFIG['site_name'] %p= t 'views.about.subtitle' @@ -12,13 +12,13 @@ %h3= t 'views.about.links.title' %p= t('views.about.links.desc', app_title: APP_CONFIG['site_name']) .col-md-4.col-sm-6 - %a{href: "https://twitter.com/retrospring"} + %a{ href: 'https://twitter.com/retrospring' } .icon--showcase %i.fa.fa-twitter %h4.heading-about.text-center Twitter .col-md-4.col-sm-6 - %a{href: help_faq_path} + %a{ href: help_faq_path } .icon--showcase %i.fa.fa-question %h4.heading-about.text-center @@ -29,9 +29,12 @@ .col-md-4 %h3= t 'views.about.opensource.title' %p= t('views.about.opensource.warning', app_title: APP_CONFIG['site_name']) - %p= raw t('views.about.opensource.desc', app_title: APP_CONFIG['site_name'], github: link_to(t('views.about.opensource.github'), "https://github.com/Retrospring/retrospring"), bugtracker: link_to(t('views.about.opensource.bugtracker'), "https://github.com/Retrospring/retrospring/issues")) + %p= raw t('views.about.opensource.desc', + app_title: APP_CONFIG['site_name'], + github: link_to(t('views.about.opensource.github'), 'https://github.com/Retrospring/retrospring'), + bugtracker: link_to(t('views.about.opensource.bugtracker'), 'https://github.com/Retrospring/retrospring/issues')) .col-md-4 - %a{href: "https://github.com/Retrospring/retrospring"} + %a{ href: 'https://github.com/Retrospring/retrospring' } .icon--showcase %i.fa.fa-github %h4.heading-about.text-center= t 'views.about.repository.title' @@ -62,4 +65,4 @@ .entry__value#follower-count= User.count %h4.entry__description= t('views.general.user').pluralize(User.count) -= render "shared/links" += render 'shared/links' diff --git a/app/views/static/faq.html.haml b/app/views/static/faq.haml similarity index 59% rename from app/views/static/faq.html.haml rename to app/views/static/faq.haml index 0b126b30..e027a0f7 100644 --- a/app/views/static/faq.html.haml +++ b/app/views/static/faq.haml @@ -1,6 +1,6 @@ -- provide(:title, generate_title("Frequently Asked Questions")) +- provide(:title, generate_title('Frequently Asked Questions')) .jumbotron.jumbotron--particles - #particles.jumbotron__particles + .jumbotron__particles#particles .jumbotron__content %h1 Frequently Asked Questions %p @@ -10,4 +10,4 @@ .container .card .card-body - = raw_markdown_io "service-docs/en/help/faq.md" + = raw_markdown_io 'service-docs/en/help/faq.md' diff --git a/app/views/static/front.html.haml b/app/views/static/front.haml similarity index 59% rename from app/views/static/front.html.haml rename to app/views/static/front.haml index c3dcb866..d56aa3ff 100644 --- a/app/views/static/front.html.haml +++ b/app/views/static/front.haml @@ -1,34 +1,40 @@ -- provide(:title, "#{APP_CONFIG['site_name']}") +- provide(:title, APP_CONFIG['site_name']) .jumbotron.jumbotron--particles.jumbotron--frontpage .jumbotron__scroller - %a.arctic_scroll{href: "#content", data: {offset: "-80"} } + %a{ href: '#content' } %i.fa.fa-chevron-down - #particles.jumbotron__particles + .jumbotron__particles#particles .jumbotron__content .container = render 'layouts/messages' %h1= APP_CONFIG['site_name'] %p= t 'views.front.subtitle' %p - %a.btn.btn-outline-light.btn-lg{href: url_for(new_user_registration_path)} + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } Register now %small Already a member? = link_to 'Sign in', new_user_session_path -#content.container.text-center - %h1= "What is #{APP_CONFIG['site_name']}?" +.container.text-center#content + %h1 + What is #{APP_CONFIG['site_name']}? %p.lead A - %abbr{title: "Question and Answer"} Q/A + %abbr{ title: 'Question and Answer' } Q/A based social network - %p Most of the people already know how these sorts of networks already work. You have a profile and other users (or even anonymous people without accounts) can ask you any question to find out more about you, so can you do the same with others. Finding friends with the same interests, people that share your opinion (and people that probably don't), you can find everything here! + %p + Most of the people already know how these sorts of networks already work. + You have a profile and other users (or even anonymous people without accounts) can ask you any question to find out more about + you, so can you do the same with others. Finding friends with the same interests, people that share your opinion (and people that probably don't), + you can find everything here! %p.lead But what makes = APP_CONFIG['site_name'] special? %p = APP_CONFIG['site_name'] - tries to take aspects from other popular or now gone platforms and combine them to get the best result possible. Also, we take in the ideas and feedback of our community so we can build a service that's even closer to being exactly the service people want to use! + tries to take aspects from other popular or now gone platforms and combine them to get the best result possible. + Also, we take in the ideas and feedback of our community so we can build a service that's even closer to being exactly the service people want to use! %h2 Awesome Features @@ -37,32 +43,40 @@ %h3 %i.fa.fa-fw.fa-comments.text-primary Discussion - %p= "With #{APP_CONFIG['site_name']}, you can ask and answer questions from other users as well as receive anonymous questions. Want to know something? Keep the conversation alive with interactive comments." + %p + With + = APP_CONFIG['site_name'] + you can ask and answer questions from other users as well as receive anonymous questions. + Want to know something? Keep the conversation alive with interactive comments." .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-user-plus.text-primary Following %p - Following users allows you to get a personalized feed of all people you want to know more about. You can also send a question to all your followers at once! + Following users allows you to get a personalized feed of all people you want to know more about. + You can also send a question to all your followers at once! .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-share-square-o.text-primary Sharing %p - Want to share your answer to a question so that more people read it? With a simple click on the answer button, your answer is shared wherever you want! + Want to share your answer to a question so that more people read it? + With a simple click on the answer button, your answer is shared wherever you want! .row .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-users.text-primary Groups %p - Want to ask a question to a specific set of people? No problem! Set up unique groups of users and send them questions apart from everyone else. + Want to ask a question to a specific set of people? No problem! + Set up unique groups of users and send them questions apart from everyone else. .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-image.text-primary Images %p - Express yourself with images and upload an avatar and a header of your liking. And soon you'll be able to attach images to answers and questions as well! + Express yourself with images and upload an avatar and a header of your liking. + And soon you'll be able to attach images to answers and questions as well! .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-paint-brush.text-primary @@ -79,7 +93,8 @@ %p You heard it right! = APP_CONFIG['site_name'] - and all of it's core components are open source! Everyone can help and improve the service! + and all of it's core components are open source! + Everyone can help and improve the service! .col-md-4.col-sm-4.col-xs-12 %h3 %i.fa.fa-fw.fa-eye-slash.text-primary @@ -88,7 +103,7 @@ We don't like them ourselves, really. = APP_CONFIG['site_name'] just runs with community funding over - %a{href: "https://patreon.com/retrospring"} Patreon + %a{ href: 'https://patreon.com/retrospring' } Patreon which is way better than displaying annoying stuff. .col-md-4.col-sm-4.col-xs-12 %h3 @@ -98,18 +113,19 @@ Today the most precious things on the internet is your data. = APP_CONFIG['site_name'] doesn't sell any data that is collected. It remains encrypted on our servers! - + .card .card-body %p Any questions? Ask us on - %a{href: "https://twitter.com/retrospring"} Twitter - + %a{ href: 'https://twitter.com/retrospring' } Twitter + %h2 What are you waiting for? %p Registering takes less than 5 minutes! %p - %a.btn.btn-primary.btn-lg{href: url_for(new_user_registration_path)} + %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } Register now -= render "shared/links" += render 'shared/links' + diff --git a/app/views/static/index.haml b/app/views/static/index.haml index 30b7be95..644c8cfd 100644 --- a/app/views/static/index.haml +++ b/app/views/static/index.haml @@ -5,8 +5,8 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @timeline_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @timeline_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @timeline_last_id } } Load more -- provide(:title, "#{APP_CONFIG['site_name']}") -- parent_layout "feed" +- provide(:title, APP_CONFIG['site_name']) +- parent_layout 'feed' diff --git a/app/views/static/privacy_policy.haml b/app/views/static/privacy_policy.haml new file mode 100644 index 00000000..5e99850c --- /dev/null +++ b/app/views/static/privacy_policy.haml @@ -0,0 +1,6 @@ +- provide(:title, generate_title('Privacy Policy')) +.container.container--main + .card + .card-body + = raw_markdown_io 'service-docs/en/policy/privacy.md' + diff --git a/app/views/static/privacy_policy.html.haml b/app/views/static/privacy_policy.html.haml deleted file mode 100644 index 15c9f8aa..00000000 --- a/app/views/static/privacy_policy.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- provide(:title, generate_title("Privacy Policy")) -.container.container--main - .card - .card-body - = raw_markdown_io "service-docs/en/policy/privacy.md" diff --git a/app/views/static/terms.haml b/app/views/static/terms.haml new file mode 100644 index 00000000..6650c250 --- /dev/null +++ b/app/views/static/terms.haml @@ -0,0 +1,6 @@ +- provide(:title, generate_title('Terms of Service')) +.container.container--main + .card + .card-body + = raw_markdown_io 'service-docs/en/policy/terms.md' + diff --git a/app/views/static/terms.html.haml b/app/views/static/terms.html.haml deleted file mode 100644 index 792ede73..00000000 --- a/app/views/static/terms.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- provide(:title, generate_title("Terms of Service")) -.container.container--main - .card - .card-body - = raw_markdown_io "service-docs/en/policy/terms.md" diff --git a/app/views/tabs/_feed.haml b/app/views/tabs/_feed.haml index 8ee4fc1c..cf5a4a7e 100644 --- a/app/views/tabs/_feed.haml +++ b/app/views/tabs/_feed.haml @@ -3,10 +3,10 @@ = list_group_item t('views.general.timeline'), root_path - if APP_CONFIG.dig(:features, :public, :enabled) = list_group_item t('views.general.public'), public_timeline_path - .list-group-item.list-group-item-action.dropdown{class: "#{'active' if @group}"} - %a.dropdown-toggle{ type: 'button', data: { toggle: 'dropdown' }, aria: { haspopup: true, expanded: false }} - - if @group - = @group.display_name + .list-group-item.list-group-item-action.dropdown{ class: group ? 'active' : '' } + %a.dropdown-toggle{ type: :button, data: { toggle: :dropdown }, aria: { haspopup: true, expanded: false } } + - if group + = group.display_name - else Groups .dropdown-menu @@ -22,4 +22,4 @@ when selected, you'll get a timeline view of all users from that group. - current_user.groups.each do |group| - %a.dropdown-item{ href: group_timeline_path(group.name) }= group.display_name \ No newline at end of file + %a.dropdown-item{ href: group_timeline_path(group.name) }= group.display_name diff --git a/app/views/tabs/_moderation.haml b/app/views/tabs/_moderation.haml index 180922c7..9e2670ae 100644 --- a/app/views/tabs/_moderation.haml +++ b/app/views/tabs/_moderation.haml @@ -1,10 +1,10 @@ .card.d-none.d-sm-block .list-group = list_group_item t('views.moderation.tabs.all'), moderation_path - = list_group_item t('views.general.answer').pluralize(2), moderation_path('answer') - = list_group_item t('views.general.comment').pluralize(2), moderation_path('comment') - = list_group_item t('views.general.user').pluralize(2), moderation_path('user') - = list_group_item t('views.general.question').pluralize(2), moderation_path('question') - = list_group_item 'Priority', moderation_priority_path + = list_group_item t('views.general.answer').pluralize(2), moderation_path('answer') + = list_group_item t('views.general.comment').pluralize(2), moderation_path('comment') + = list_group_item t('views.general.user').pluralize(2), moderation_path('user') + = list_group_item t('views.general.question').pluralize(2), moderation_path('question') + = list_group_item 'Priority', moderation_priority_path -.d-none.d-sm-block= render "shared/links" \ No newline at end of file +.d-none.d-sm-block= render 'shared/links' diff --git a/app/views/tabs/_notifications.haml b/app/views/tabs/_notifications.haml index d282b911..74289536 100644 --- a/app/views/tabs/_notifications.haml +++ b/app/views/tabs/_notifications.haml @@ -1,16 +1,26 @@ .card.d-none.d-sm-block .list-group - = list_group_item "New Notifications", notifications_path, badge: Notification.for(current_user).where(new: true).count - = list_group_item "All Notifications", notifications_path('all') + = list_group_item 'New Notifications', notifications_path, badge: Notification.for(current_user).where(new: true).count + = list_group_item 'All Notifications', notifications_path('all') .card.d-none.d-sm-block .card-header Filter by Type .list-group - = list_group_item t('views.notifications.tabs.answer'), notifications_path('answer'), badge: Notification.for(current_user).where(target_type: "Answer", new: true).count - = list_group_item t('views.notifications.tabs.smile'), notifications_path('smile'), badge: Notification.for(current_user).where(target_type: "Smile", new: true).count - = list_group_item t('views.notifications.tabs.comment'), notifications_path('comment'), badge: Notification.for(current_user).where(target_type: "Comment", new: true).count - = list_group_item t('views.notifications.tabs.commentsmile'), notifications_path('commentsmile'), badge: Notification.for(current_user).where(target_type: "CommentSmile", new: true).count - = list_group_item t('views.notifications.tabs.relationship'), notifications_path('relationship'), badge: Notification.for(current_user).where(target_type: "Relationship", new: true).count + = list_group_item t('views.notifications.tabs.answer'), + notifications_path('answer'), + badge: Notification.for(current_user).where(target_type: 'Answer', new: true).count + = list_group_item t('views.notifications.tabs.smile'), + notifications_path('smile'), + badge: Notification.for(current_user).where(target_type: 'Smile', new: true).count + = list_group_item t('views.notifications.tabs.comment'), + notifications_path('comment'), + badge: Notification.for(current_user).where(target_type: 'Comment', new: true).count + = list_group_item t('views.notifications.tabs.commentsmile'), + notifications_path('commentsmile'), + badge: Notification.for(current_user).where(target_type: 'CommentSmile', new: true).count + = list_group_item t('views.notifications.tabs.relationship'), + notifications_path('relationship'), + badge: Notification.for(current_user).where(target_type: 'Relationship', new: true).count -.d-none.d-sm-block= render "shared/links" \ No newline at end of file +.d-none.d-sm-block= render 'shared/links' diff --git a/app/views/tabs/_profile.haml b/app/views/tabs/_profile.haml index f49f17dd..82e3d9f2 100644 --- a/app/views/tabs/_profile.haml +++ b/app/views/tabs/_profile.haml @@ -1,6 +1,6 @@ .card .list-group.list-group-horizontal-sm.text-center - = list_group_item "Answers", show_user_profile_path(@user.screen_name), badge: @user.answered_count - = list_group_item "Questions", show_user_questions_path(@user.screen_name), badge: @user.asked_count - = list_group_item "Followers", show_user_followers_path(@user.screen_name), badge: @user.follower_count - = list_group_item "Following", show_user_friends_path(@user.screen_name), badge: @user.friend_count \ No newline at end of file + = list_group_item 'Answers', show_user_profile_path(user.screen_name), badge: user.answered_count + = list_group_item 'Questions', show_user_questions_path(user.screen_name), badge: user.asked_count + = list_group_item 'Followers', show_user_followers_path(user.screen_name), badge: user.follower_count + = list_group_item 'Following', show_user_friends_path(user.screen_name), badge: user.friend_count diff --git a/app/views/tabs/_settings.haml b/app/views/tabs/_settings.haml index a3b91589..13d4a420 100644 --- a/app/views/tabs/_settings.haml +++ b/app/views/tabs/_settings.haml @@ -5,7 +5,7 @@ = list_group_item t('views.settings.tabs.privacy'), edit_user_privacy_path = list_group_item t('views.settings.tabs.sharing'), services_path = list_group_item 'Theme', edit_user_theme_path - = list_group_item "Your Data", user_data_path + = list_group_item 'Your Data', user_data_path = list_group_item 'Export', user_export_path -.d-none.d-sm-block= render "shared/links" \ No newline at end of file +.d-none.d-sm-block= render 'shared/links' diff --git a/app/views/user/_actions.haml b/app/views/user/_actions.haml index f257fb09..f03e1db4 100644 --- a/app/views/user/_actions.haml +++ b/app/views/user/_actions.haml @@ -1,32 +1,30 @@ .profile__actions - - if user_signed_in? - - type ||= :nil - - if user == current_user - %a.btn.btn-dark.btn-block{href: edit_user_profile_path} Edit profile + - type ||= :nil + - if user_signed_in? && user == current_user + %a.btn.btn-dark.btn-block{ href: edit_user_profile_path } Edit profile + - elsif user_signed_in? + - if current_user.following? user + %button.btn.btn-primary.btn-block{ type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name } } + = t 'views.actions.unfollow' - else - - if current_user.following? user - %button#editprofile.btn.btn-primary.btn-block{type: :button, name: 'user-action', data: { action: :unfollow, type: type, target: user.screen_name }} - = t 'views.actions.unfollow' - - else - %button#editprofile.btn.btn-primary.btn-block{type: :button, name: 'user-action', data: { action: :follow, type: type, target: user.screen_name }} - = t 'views.actions.follow' - - unless user == current_user - .btn-group.btn-block - %button.btn.btn-light.btn-block.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} - = t 'views.actions.title' - %span.caret - .dropdown-menu - %a.dropdown-item.d-block.d-sm-none{href: '#', data: { target: "#modal-group-memberships", toggle: :modal }} - %i.fa.fa-users - = t 'views.actions.group' - %a.dropdown-item{href: '#', data: { action: 'report-user', target: user.screen_name }} - %i.fa.fa-exclamation-triangle - = t 'views.actions.report' - - if current_user.mod? - %a.dropdown-item{href: '#', data: { target: "#modal-privileges", toggle: :modal }} - %i.fa.fa-wrench - = raw t('views.actions.privilege', user: user.screen_name) - - unless user.has_role?(:administrator) - %a.dropdown-item{href: '#', data: { target: "#modal-ban", toggle: :modal }} - %i.fa.fa-ban - = t 'views.actions.ban' + %button.btn.btn-primary.btn-block{ type: :button, name: 'user-action', data: { action: :follow, type: type, target: user.screen_name } } + = t 'views.actions.follow' + .btn-group.btn-block + %button.btn.btn-light.btn-block.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } + = t 'views.actions.title' + %span.caret + .dropdown-menu + %a.dropdown-item.d-block.d-sm-none{ href: '#', data: { target: '#modal-group-memberships', toggle: :modal } } + %i.fa.fa-users + = t 'views.actions.group' + %a.dropdown-item{ href: '#', data: { action: 'report-user', target: user.screen_name } } + %i.fa.fa-exclamation-triangle + = t 'views.actions.report' + - if current_user.mod? + %a.dropdown-item{ href: '#', data: { target: '#modal-privileges', toggle: :modal } } + %i.fa.fa-wrench + = raw t('views.actions.privilege', user: user.screen_name) + - unless user.has_role?(:administrator) + %a.dropdown-item{ href: '#', data: { target: '#modal-ban', toggle: :modal } } + %i.fa.fa-ban + = t 'views.actions.ban' diff --git a/app/views/user/_profile.haml b/app/views/user/_profile.haml index 55783cd2..235fe788 100644 --- a/app/views/user/_profile.haml +++ b/app/views/user/_profile.haml @@ -1,38 +1,38 @@ .card#profile - %img.profile__avatar{src: @user.profile_picture.url(:large)} + %img.profile__avatar{ src: user.profile_picture.url(:large) } .card-body .profile__name - - unless @user.display_name.blank? + - unless user.display_name.blank? .profile__display-name - = @user.display_name + = user.display_name .profile__screen-name - = @user.screen_name + = user.screen_name .profile__badge-container - - if @user.banned? + - if user.banned? %span.badge.badge-dark %i.fa.fa-fw.fa-ban = t 'views.user.title.banned' - - if @user.following? current_user + - if user.following? current_user .badge.badge-light = t 'views.user.follows_you' - if user_signed_in? && current_user.has_role?(:administrator) - - if @user.has_role?(:administrator) + - if user.has_role?(:administrator) %span.badge.badge-danger %i.fa.fa-fw.fa-flask = t 'views.user.title.admin' - - if @user.has_role?(:moderator) + - if user.has_role?(:moderator) %span.badge.badge-success %i.fa.fa-fw.fa-users = t 'views.user.title.moderator' - - unless @user.bio.blank? + - unless user.bio.blank? .profile__biography - = markdown @user.bio - - unless @user.website.blank? + = markdown user.bio + - unless user.website.blank? .profile__website %i.fa.fa-fw.fa-globe - %a{href: @user.website}= @user.display_website - - unless @user.location.blank? + %a{ href: user.website }= user.display_website + - unless user.location.blank? .profile__location %i.fa.fa-fw.fa-location-arrow - = @user.location - = render 'user/actions', user: @user, type: :follower + = user.location + = render 'user/actions', user: user, type: :follower diff --git a/app/views/user/data.haml b/app/views/user/data.haml index f2093748..8672ac12 100644 --- a/app/views/user/data.haml +++ b/app/views/user/data.haml @@ -1,4 +1,4 @@ -= render "settings/data" += render 'settings/data' -- provide(:title, generate_title("Your Data")) -- parent_layout "user/settings" +- provide(:title, generate_title('Your Data')) +- parent_layout 'user/settings' diff --git a/app/views/user/edit.haml b/app/views/user/edit.haml index 43a76cb4..fd160c64 100644 --- a/app/views/user/edit.haml +++ b/app/views/user/edit.haml @@ -1,4 +1,4 @@ -= render "settings/profile" += render 'settings/profile' -- provide(:title, generate_title("Profile Settings")) -- parent_layout "user/settings" \ No newline at end of file +- provide(:title, generate_title('Profile Settings')) +- parent_layout 'user/settings' diff --git a/app/views/user/edit_privacy.haml b/app/views/user/edit_privacy.haml index c422fb37..d806ff57 100644 --- a/app/views/user/edit_privacy.haml +++ b/app/views/user/edit_privacy.haml @@ -1,4 +1,4 @@ -= render "settings/privacy" += render 'settings/privacy' -- provide(:title, generate_title("Privacy Settings")) -- parent_layout "user/settings" +- provide(:title, generate_title('Privacy Settings')) +- parent_layout 'user/settings' diff --git a/app/views/user/edit_theme.haml b/app/views/user/edit_theme.haml index 38fec528..e4060ce2 100644 --- a/app/views/user/edit_theme.haml +++ b/app/views/user/edit_theme.haml @@ -1,4 +1,4 @@ -= render "settings/theme" += render 'settings/theme' -- provide(:title, generate_title("Theme Settings")) -- parent_layout "user/settings" \ No newline at end of file +- provide(:title, generate_title('Theme Settings')) +- parent_layout 'user/settings' diff --git a/app/views/user/export.haml b/app/views/user/export.haml index bc025d90..7e3acde2 100644 --- a/app/views/user/export.haml +++ b/app/views/user/export.haml @@ -1,4 +1,4 @@ -= render "settings/export" += render 'settings/export' -- provide(:title, generate_title("Export")) -- parent_layout "user/settings" +- provide(:title, generate_title('Export')) +- parent_layout 'user/settings' diff --git a/app/views/user/groups.haml b/app/views/user/groups.haml index 0f08b0cf..41a8547d 100644 --- a/app/views/user/groups.haml +++ b/app/views/user/groups.haml @@ -5,5 +5,5 @@ %i.fa.fa-lock = group.display_name -- provide(:title, user_title(@user, "groups")) -- parent_layout "user/profile" +- provide(:title, user_title(@user, 'groups')) +- parent_layout 'user/profile' diff --git a/app/views/user/questions.haml b/app/views/user/questions.haml index f606d663..1be1b614 100644 --- a/app/views/user/questions.haml +++ b/app/views/user/questions.haml @@ -5,8 +5,8 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @questions_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @questions_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @questions_last_id } } = t 'views.actions.load' - provide(:title, questions_title(@user)) -- parent_layout "user/profile" \ No newline at end of file +- parent_layout 'user/profile' diff --git a/app/views/user/show.haml b/app/views/user/show.haml index 486b25e7..8acf7d31 100644 --- a/app/views/user/show.haml +++ b/app/views/user/show.haml @@ -1,4 +1,3 @@ -.profile--panel-push-inner.hidden-xs - unless @user.banned? #answers - @answers.each do |a| @@ -7,8 +6,8 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @answers_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @answers_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @answers_last_id } } = t 'views.actions.load' - provide(:title, user_title(@user)) -- parent_layout "user/profile" +- parent_layout 'user/profile' diff --git a/app/views/user/show_follow.haml b/app/views/user/show_follow.haml index 15cf82e6..22801fcb 100644 --- a/app/views/user/show_follow.haml +++ b/app/views/user/show_follow.haml @@ -1,13 +1,13 @@ -#users.row.row-cols-1.row-cols-sm-2.row-cols-md-3 +.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 - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @users_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @users_last_id } } = t 'views.actions.load' -- provide(:title, user_title(@user, "friends and followers")) -- parent_layout "user/profile" +- provide(:title, user_title(@user, 'friends and followers')) +- parent_layout 'user/profile' 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 %>');