Browse Source

Added haml-lint and fix warnings (#2773)

* add haml_lint to Gemfile

* add .haml-lint.yml

* fix warnings of haml_lint
yhirano 6 years ago
parent
commit
48594b18e6
39 changed files with 207 additions and 90 deletions
  1. 108 0
      .haml-lint.yml
  2. 1 0
      Gemfile
  3. 9 0
      Gemfile.lock
  4. 1 1
      app/views/about/_contact.html.haml
  5. 2 2
      app/views/about/_registration.html.haml
  6. 2 2
      app/views/about/more.html.haml
  7. 3 3
      app/views/about/show.html.haml
  8. 1 1
      app/views/accounts/_grid_card.html.haml
  9. 2 2
      app/views/accounts/_header.html.haml
  10. 1 1
      app/views/admin/accounts/_card.html.haml
  11. 3 3
      app/views/admin/reports/_report.html.haml
  12. 1 1
      app/views/admin/settings/edit.html.haml
  13. 1 1
      app/views/application/_flashes.html.haml
  14. 1 1
      app/views/auth/confirmations/new.html.haml
  15. 3 3
      app/views/auth/passwords/edit.html.haml
  16. 1 1
      app/views/auth/passwords/new.html.haml
  17. 3 3
      app/views/auth/registrations/edit.html.haml
  18. 3 3
      app/views/auth/registrations/new.html.haml
  19. 1 1
      app/views/auth/sessions/new.html.haml
  20. 1 1
      app/views/auth/sessions/two_factor.html.haml
  21. 1 1
      app/views/authorize_follows/_card.html.haml
  22. 1 1
      app/views/errors/403.html.haml
  23. 1 1
      app/views/errors/404.html.haml
  24. 2 2
      app/views/home/index.html.haml
  25. 1 1
      app/views/layouts/admin.html.haml
  26. 11 12
      app/views/layouts/application.html.haml
  27. 1 1
      app/views/layouts/auth.html.haml
  28. 2 2
      app/views/layouts/embedded.html.haml
  29. 6 6
      app/views/layouts/error.html.haml
  30. 3 3
      app/views/layouts/public.html.haml
  31. 1 1
      app/views/oauth/authorizations/new.html.haml
  32. 1 1
      app/views/oauth/authorized_applications/index.html.haml
  33. 2 2
      app/views/settings/profiles/show.html.haml
  34. 1 1
      app/views/settings/two_factor_authentication/confirmations/new.html.haml
  35. 5 5
      app/views/stream_entries/_detailed_status.html.haml
  36. 1 1
      app/views/stream_entries/_media.html.haml
  37. 2 2
      app/views/stream_entries/_simple_status.html.haml
  38. 16 16
      app/views/stream_entries/_status.html.haml
  39. 1 1
      app/views/tags/show.html.haml

+ 108 - 0
.haml-lint.yml

@@ -0,0 +1,108 @@
+# Whether to ignore frontmatter at the beginning of HAML documents for
+# frameworks such as Jekyll/Middleman
+skip_frontmatter: false
+
+exclude:
+  - 'vendor/**/*'
+  - 'spec/**/*'
+  - 'lib/templates/**/*'
+  - 'app/views/kaminari/**/*'
+
+linters:
+  AltText:
+    enabled: false
+
+  ClassAttributeWithStaticValue:
+    enabled: true
+
+  ClassesBeforeIds:
+    enabled: true
+
+  ConsecutiveComments:
+    enabled: true
+
+  ConsecutiveSilentScripts:
+    enabled: true
+    max_consecutive: 2
+
+  EmptyObjectReference:
+    enabled: true
+
+  EmptyScript:
+    enabled: true
+
+  FinalNewline:
+    enabled: true
+    present: true
+
+  HtmlAttributes:
+    enabled: true
+
+  ImplicitDiv:
+    enabled: true
+
+  LeadingCommentSpace:
+    enabled: true
+
+  LineLength:
+    enabled: false
+    max: 80
+
+  MultilinePipe:
+    enabled: true
+
+  MultilineScript:
+    enabled: true
+
+  ObjectReferenceAttributes:
+    enabled: true
+
+  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
+      - Metrics/BlockLength
+      - Metrics/LineLength
+      - Style/AlignParameters
+      - Style/BlockNesting
+      - Style/ElseAlignment
+      - Style/EndOfLine
+      - Style/FileName
+      - Style/FinalNewline
+      - Style/FrozenStringLiteralComment
+      - Style/IfUnlessModifier
+      - Style/IndentationWidth
+      - Style/Next
+      - Style/TrailingBlankLines
+      - Style/TrailingWhitespace
+      - Style/WhileUntilModifier
+
+  RubyComments:
+    enabled: true
+
+  SpaceBeforeScript:
+    enabled: true
+
+  SpaceInsideHashAttributes:
+    enabled: true
+    style: space
+
+  Indentation:
+    enabled: true
+    character: space # or tab
+
+  TagName:
+    enabled: true
+
+  TrailingWhitespace:
+    enabled: true
+
+  UnnecessaryInterpolation:
+    enabled: true
+
+  UnnecessaryStringOutput:
+    enabled: true

+ 1 - 0
Gemfile

@@ -89,6 +89,7 @@ group :development do
   gem 'brakeman', '~> 3.6.0', require: false
   gem 'bundler-audit', '~> 0.4.0', require: false
   gem 'scss_lint', '0.42.2', require: false
+  gem 'haml_lint', '~> 0.19.0', require: false
 
   gem 'capistrano', '3.8.0'
   gem 'capistrano-rails'

+ 9 - 0
Gemfile.lock

@@ -157,6 +157,13 @@ GEM
       addressable (~> 2.4)
       http (~> 2.0)
       nokogiri (~> 1.6)
+    haml (4.0.7)
+      tilt
+    haml_lint (0.19.0)
+      haml (~> 4.0)
+      rake (>= 10, < 13)
+      rubocop (>= 0.36.0)
+      sysexits (~> 1.1)
     hamlit (2.8.1)
       temple (>= 0.8.0)
       thor
@@ -431,6 +438,7 @@ GEM
       net-scp (>= 1.1.2)
       net-ssh (>= 2.8.0)
     statsd-instrument (2.1.2)
+    sysexits (1.2.0)
     temple (0.8.0)
     terminal-table (1.7.3)
       unicode-display_width (~> 1.1.1)
@@ -495,6 +503,7 @@ DEPENDENCIES
   fast_blank
   fuubar
   goldfinger
+  haml_lint (~> 0.19.0)
   hamlit-rails
   hiredis
   htmlentities

+ 1 - 1
app/views/about/_contact.html.haml

@@ -7,7 +7,7 @@
         .name
           = link_to TagManager.instance.url_for(contact.contact_account) do
             %span.display_name.emojify= display_name(contact.contact_account)
-            %span.username= "@#{contact.contact_account.acct}"
+            %span.username @#{contact.contact_account.acct}
 
     - if contact.site_contact_email
       .contact-email

+ 2 - 2
app/views/about/_registration.html.haml

@@ -11,12 +11,12 @@
     required: true,
     input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }
   = f.input :password,
-    autocomplete: "off",
+    autocomplete: 'off',
     placeholder: t('simple_form.labels.defaults.password'),
     required: true,
     input_html: { 'aria-label' => t('simple_form.labels.defaults.password') }
   = f.input :password_confirmation,
-    autocomplete: "off",
+    autocomplete: 'off',
     placeholder: t('simple_form.labels.defaults.confirm_password'),
     required: true,
     input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password') }

+ 2 - 2
app/views/about/more.html.haml

@@ -8,7 +8,7 @@
         %h2= site_hostname
 
         - unless @instance_presenter.site_description.blank?
-          %p= @instance_presenter.site_description.html_safe
+          %p!= @instance_presenter.site_description
 
       .information-board
         .section
@@ -25,7 +25,7 @@
           %span= t 'about.domain_count_after'
 
       - unless @instance_presenter.site_extended_description.blank?
-        .panel= @instance_presenter.site_extended_description.html_safe
+        .panel!= @instance_presenter.site_extended_description
 
     .sidebar
       = render 'contact', contact: @instance_presenter

+ 3 - 3
app/views/about/show.html.haml

@@ -20,7 +20,7 @@
     = image_tag asset_pack_path('logo.png')
     = Setting.site_title
 
-  %p= t('about.about_mastodon').html_safe
+  %p!= t('about.about_mastodon')
 
   .screenshot-with-signup
     .mascot= image_tag asset_pack_path('fluffy-elephant-friend.png')
@@ -32,7 +32,7 @@
         - if @instance_presenter.closed_registrations_message.blank?
           %p= t('about.closed_registrations')
         - else
-          = @instance_presenter.closed_registrations_message.html_safe
+          != @instance_presenter.closed_registrations_message
         .info
           = link_to t('auth.login'), new_user_session_path, class: 'webapp-btn'
           ·
@@ -74,7 +74,7 @@
 
   - unless @instance_presenter.site_description.blank?
     %h3= t('about.description_headline', domain: site_hostname)
-    %p= @instance_presenter.site_description.html_safe
+    %p!= @instance_presenter.site_description
 
   .actions
     .info

+ 1 - 1
app/views/accounts/_grid_card.html.haml

@@ -4,5 +4,5 @@
     .name
       = link_to TagManager.instance.url_for(account) do
         %span.display_name.emojify= display_name(account)
-        %span.username= "@#{account.acct}"
+        %span.username @#{account.acct}
   %p.note.emojify= truncate(strip_tags(account.note), length: 150)

+ 2 - 2
app/views/accounts/_header.html.haml

@@ -1,4 +1,4 @@
-.card.h-card.p-author{ style: "background-image: url(#{account.header.url( :original)})" }
+.card.h-card.p-author{ style: "background-image: url(#{account.header.url(:original)})" }
   - if user_signed_in? && current_account.id != account.id && !current_account.requested?(account)
     .controls
       - if current_account.following?(account)
@@ -13,7 +13,7 @@
   %h1.name
     %span.p-name.emojify= display_name(account)
     %small
-      %span= "@#{account.username}"
+      %span @#{account.username}
       = fa_icon('lock') if account.locked?
   .details
     .bio

+ 1 - 1
app/views/admin/accounts/_card.html.haml

@@ -6,7 +6,7 @@
     %tr
       %td= t('admin.accounts.show.targeted_reports')
       %td= link_to pluralize(account.targeted_reports.count, t('admin.accounts.show.report')), admin_reports_path(target_account_id: account.id)
-    - if account.silenced? or account.suspended?
+    - if account.silenced? || account.suspended?
       %tr
         %td= t('admin.accounts.moderation.title')
         %td

+ 3 - 3
app/views/admin/reports/_report.html.haml

@@ -6,15 +6,15 @@
   %td.reporter
     = link_to report.account.acct, admin_account_path(report.account.id)
   %td.comment
-    %span{title: report.comment}
+    %span{ title: report.comment }
       = truncate(report.comment, length: 30, separator: ' ')
   %td.stats
     - unless report.statuses.empty?
-      %span{title: t('admin.accounts.statuses')}
+      %span{ title: t('admin.accounts.statuses') }
         = fa_icon('comment')
         = report.statuses.count
     - unless report.media_attachments.empty?
-      %span{title: t('admin.accounts.media_attachments')}
+      %span{ title: t('admin.accounts.media_attachments') }
         = fa_icon('camera')
         = report.media_attachments.count
   %td

+ 1 - 1
app/views/admin/settings/edit.html.haml

@@ -5,7 +5,7 @@
   %table.table
     %thead
       %tr
-        %th{width: '40%'}
+        %th{ width: '40%' }
           = t('admin.settings.setting')
         %th
     %tbody

+ 1 - 1
app/views/application/_flashes.html.haml

@@ -1,3 +1,3 @@
 - user_facing_flashes.each do |key, value|
-  .flash-message{class: key}
+  .flash-message{ class: key }
     %strong= value

+ 1 - 1
app/views/auth/confirmations/new.html.haml

@@ -9,4 +9,4 @@
   .actions
     = f.button :button, t('auth.resend_confirmation'), type: :submit
 
-.form-footer= render "auth/shared/links"
+.form-footer= render 'auth/shared/links'

+ 3 - 3
app/views/auth/passwords/edit.html.haml

@@ -5,10 +5,10 @@
   = render 'shared/error_messages', object: resource
   = f.input :reset_password_token, as: :hidden
 
-  = f.input :password, autofocus: true, autocomplete: "off", placeholder: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password') }
-  = f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password') }
+  = f.input :password, autofocus: true, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password') }
+  = f.input :password_confirmation, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password') }
 
   .actions
     = f.button :button, t('auth.set_new_password'), type: :submit
 
-.form-footer= render "devise/shared/links"
+.form-footer= render 'devise/shared/links'

+ 1 - 1
app/views/auth/passwords/new.html.haml

@@ -9,4 +9,4 @@
   .actions
     = f.button :button, t('auth.reset_password'), type: :submit
 
-.form-footer= render "auth/shared/links"
+.form-footer= render 'auth/shared/links'

+ 3 - 3
app/views/auth/registrations/edit.html.haml

@@ -5,9 +5,9 @@
   = render 'shared/error_messages', object: resource
 
   = f.input :email, placeholder: t('simple_form.labels.defaults.email'), input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }
-  = f.input :password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password') }
-  = f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password') }
-  = f.input :current_password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.current_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.current_password') }
+  = f.input :password, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password') }
+  = f.input :password_confirmation, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password') }
+  = f.input :current_password, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.current_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.current_password') }
 
   .actions
     = f.button :button, t('generic.save_changes'), type: :submit

+ 3 - 3
app/views/auth/registrations/new.html.haml

@@ -8,10 +8,10 @@
     = ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username') }
 
   = f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }
-  = f.input :password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password') }
-  = f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password') }
+  = f.input :password, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password') }
+  = f.input :password_confirmation, autocomplete: 'off', placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password') }
 
   .actions
     = f.button :button, t('auth.register'), type: :submit
 
-.form-footer= render "auth/shared/links"
+.form-footer= render 'auth/shared/links'

+ 1 - 1
app/views/auth/sessions/new.html.haml

@@ -8,4 +8,4 @@
   .actions
     = f.button :button, t('auth.login'), type: :submit
 
-.form-footer= render "auth/shared/links"
+.form-footer= render 'auth/shared/links'

+ 1 - 1
app/views/auth/sessions/two_factor.html.haml

@@ -9,4 +9,4 @@
   .actions
     = f.button :button, t('auth.login'), type: :submit
 
-.form-footer= render "auth/shared/links"
+.form-footer= render 'auth/shared/links'

+ 1 - 1
app/views/authorize_follows/_card.html.haml

@@ -6,7 +6,7 @@
     %span.display-name
       = link_to TagManager.instance.url_for(account), class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'noopener' do
         %strong.emojify= display_name(account)
-        %span= "@#{account.acct}"
+        %span @#{account.acct}
 
   - if account.note?
     .account__header__content.emojify= Formatter.instance.simplified_format(account)

+ 1 - 1
app/views/errors/403.html.haml

@@ -2,4 +2,4 @@
   = t('errors.403')
 
 - content_for :content do
-  = t('errors.403')
+  = t('errors.403')

+ 1 - 1
app/views/errors/404.html.haml

@@ -2,4 +2,4 @@
   = t('errors.404')
 
 - content_for :content do
-  = t('errors.404')
+  = t('errors.404')

+ 2 - 2
app/views/home/index.html.haml

@@ -1,6 +1,6 @@
 - content_for :header_tags do
-  %script#initial-state{:type => 'application/json'}!= json_escape(render(file: 'home/initial_state', formats: :json))
+  %script#initial-state{ type: 'application/json' }!= json_escape(render(file: 'home/initial_state', formats: :json))
 
   = javascript_pack_tag 'application', integrity: true, crossorigin: 'anonymous'
 
-.app-holder#mastodon{ data: { props: Oj.dump(default_props) }}
+.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }

+ 1 - 1
app/views/layouts/admin.html.haml

@@ -17,4 +17,4 @@
 
         = yield
 
-= render template: "layouts/application", locals: { body_classes: 'admin' }
+= render template: 'layouts/application', locals: { body_classes: 'admin' }

+ 11 - 12
app/views/layouts/application.html.haml

@@ -1,17 +1,16 @@
 !!! 5
-%html{:lang => I18n.locale}
+%html{ lang: I18n.locale }
   %head
-    %meta{:charset => 'utf-8'}/
-    %meta{:name => 'viewport', :content => 'width=device-width, initial-scale=1'}/
-    %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge'}/
-
-    %link{:rel => "icon", :href => favicon_path, :type => "image/x-icon"}/
-    %link{:rel => "apple-touch-icon", :sizes => "180x180", :href => "/apple-touch-icon.png"}/
-    %link{:rel => "mask-icon", :href => "/mask-icon.svg", :color => "#2B90D9"}/
-    %link{:rel => "manifest", :href => "/manifest.json"}/
-    %meta{:name => "msapplication-config", :content => "/browserconfig.xml"}/
-    %meta{:name => "theme-color", :content => "#282c37"}/
-    %meta{:name => "apple-mobile-web-app-capable", :content => "yes"}/
+    %meta{ charset: 'utf-8' }/
+    %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/
+    %meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge' }/
+    %link{ rel: 'icon', href: favicon_path, type: 'image/x-icon' }/
+    %link{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/
+    %link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/
+    %link{ rel: 'manifest', href: '/manifest.json' }/
+    %meta{ name: 'msapplication-config', content: '/browserconfig.xml' }/
+    %meta{ name: 'theme-color', content: '#282c37' }/
+    %meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/
 
     %title<
       - if content_for?(:page_title)

+ 1 - 1
app/views/layouts/auth.html.haml

@@ -13,4 +13,4 @@
 
       = yield
 
-= render template: "layouts/application"
+= render template: 'layouts/application'

+ 2 - 2
app/views/layouts/embedded.html.haml

@@ -1,7 +1,7 @@
 !!! 5
-%html{:lang => I18n.locale}
+%html{ lang: I18n.locale }
   %head
-    %meta{:charset => 'utf-8'}/
+    %meta{ charset: 'utf-8' }/
     = stylesheet_link_tag 'application', media: 'all'
     = javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous'
   %body.embed

+ 6 - 6
app/views/layouts/error.html.haml

@@ -1,11 +1,11 @@
 !!!
-%html{:lang => I18n.locale}
+%html{ lang: I18n.locale }
   %head
-    %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
-    %meta{:charset => "utf-8"}/
+    %meta{ content: 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' }/
+    %meta{ charset: 'utf-8' }/
     %title= yield :page_title
-    %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/
-    %link{:href => "https://fonts.googleapis.com/css?family=Roboto:400", :rel => "stylesheet"}/
+    %meta{ content: 'width=device-width,initial-scale=1', name: 'viewport' }/
+    %link{ href: 'https://fonts.googleapis.com/css?family=Roboto:400', rel: 'stylesheet' }/
     :css
       body {
         font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
@@ -31,6 +31,6 @@
       }
   %body
     .dialog
-      %img{:alt => "Mastodon", :src => "/oops.png"}/
+      %img{ alt: 'Mastodon', src: '/oops.png' }/
       %div
         %h1= yield :content

+ 3 - 3
app/views/layouts/public.html.haml

@@ -7,9 +7,9 @@
     - if !user_signed_in? && single_user_mode?
       %span.single-user-login
         = link_to t('auth.login'), new_user_session_path
-        = "\u2014"
+        \u2014
     %span.domain= link_to site_hostname, root_path
     %span.powered-by
-      = t('generic.powered_by', link: link_to('Mastodon', 'https://github.com/tootsuite/mastodon')).html_safe
+      != t('generic.powered_by', link: link_to('Mastodon', 'https://github.com/tootsuite/mastodon'))
 
-= render template: "layouts/application"
+= render template: 'layouts/application'

+ 1 - 1
app/views/oauth/authorizations/new.html.haml

@@ -7,7 +7,7 @@
 
     %p
       = t('doorkeeper.authorizations.new.able_to')
-      = @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe
+      != @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>" }.to_sentence
 
   = form_tag oauth_authorization_path, method: :post, class: 'simple_form' do
     = hidden_field_tag :client_id, @pre_auth.client.uid

+ 1 - 1
app/views/oauth/authorized_applications/index.html.haml

@@ -16,7 +16,7 @@
             = application.name
           - else
             = link_to application.name, application.website, target: '_blank', rel: 'noopener'
-        %th= application.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.join('<br />').html_safe
+        %th!= application.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.join('<br />')
         %td= l application.created_at
         %td
           - unless application.superapp?

+ 2 - 2
app/views/settings/profiles/show.html.haml

@@ -5,8 +5,8 @@
   = render 'shared/error_messages', object: @account
 
   .fields-group
-    = f.input :display_name, placeholder: t('simple_form.labels.defaults.display_name'), hint: t('simple_form.hints.defaults.display_name', counter: "<span class=\"name-counter\">#{30-@account.display_name.size}</span>").html_safe
-    = f.input :note, placeholder: t('simple_form.labels.defaults.note'), hint: t('simple_form.hints.defaults.note', counter: "<span class=\"note-counter\">#{160-@account.note.size}</span>").html_safe
+    = f.input :display_name, placeholder: t('simple_form.labels.defaults.display_name'), hint: t('simple_form.hints.defaults.display_name', counter: "<span class=\"name-counter\">#{30 - @account.display_name.size}</span>").html_safe
+    = f.input :note, placeholder: t('simple_form.labels.defaults.note'), hint: t('simple_form.hints.defaults.note', counter: "<span class=\"note-counter\">#{160 - @account.note.size}</span>").html_safe
     = f.input :avatar, wrapper: :with_label, hint: t('simple_form.hints.defaults.avatar')
     = f.input :header, wrapper: :with_label, hint: t('simple_form.hints.defaults.header')
 

+ 1 - 1
app/views/settings/two_factor_authentication/confirmations/new.html.haml

@@ -5,7 +5,7 @@
   %p.hint= t('two_factor_authentication.instructions_html')
 
   .qr-wrapper
-    .qr-code= raw @qrcode.as_svg(padding: 0, module_size: 4)
+    .qr-code!= @qrcode.as_svg(padding: 0, module_size: 4)
 
     .qr-alternative
       %p.hint= t('two_factor_authentication.manual_instructions')

+ 5 - 5
app/views/stream_entries/_detailed_status.html.haml

@@ -1,7 +1,7 @@
 .detailed-status.light
   = link_to TagManager.instance.url_for(status.account), class: 'detailed-status__display-name p-author h-card', target: stream_link_target, rel: 'noopener' do
     %div
-      %div.avatar
+      .avatar
         = image_tag status.account.avatar.url(:original), width: 48, height: 48, alt: '', class: 'u-photo'
     %span.display-name
       %strong.p-name.emojify= display_name(status.account)
@@ -10,16 +10,16 @@
   .status__content.p-name.emojify<
     - if status.spoiler_text?
       %p{ style: 'margin-bottom: 0' }<
-        %span.p-summary>= "#{status.spoiler_text} "
+        %span.p-summary> #{status.spoiler_text}&nbsp;
         %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
-    %div.e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
+    .e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
 
   - unless status.media_attachments.empty?
     - if status.media_attachments.first.video?
       .video-player
         - if status.sensitive?
           = render partial: 'stream_entries/content_spoiler'
-        %video{ src: status.media_attachments.first.file.url(:original), loop: true, class: 'u-video' }
+        %video.u-video{ src: status.media_attachments.first.file.url(:original), loop: true }
     - else
       .detailed-status__attachments
         - if status.sensitive?
@@ -28,7 +28,7 @@
           - status.media_attachments.each do |media|
             = render partial: 'stream_entries/media', locals: { media: media }
 
-  %div.detailed-status__meta
+  .detailed-status__meta
     %data.dt-published{ value: status.created_at.to_time.iso8601 }
     = link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: stream_link_target, rel: 'noopener' do
       %time{ datetime: status.created_at.iso8601, title: l(status.created_at), data: { format: t('time.formats.default') } }= l(status.created_at)

+ 1 - 1
app/views/stream_entries/_media.html.haml

@@ -1,4 +1,4 @@
 .media-item
-  = link_to media.remote_url.blank? ? media.file.url(:original) : media.remote_url, style: media.image? ? "background-image: url(#{media.file.url(:original)})" : "", target: '_blank', rel: 'noopener', class: "u-#{media.video? || media.gifv? ? 'video' : 'photo'}" do
+  = link_to media.remote_url.blank? ? media.file.url(:original) : media.remote_url, style: media.image? ? "background-image: url(#{media.file.url(:original)})" : '', target: '_blank', rel: 'noopener', class: "u-#{media.video? || media.gifv? ? 'video' : 'photo'}" do
     - unless media.image?
       %video{ src: media.file.url(:original), autoplay: true, loop: true }/

+ 2 - 2
app/views/stream_entries/_simple_status.html.haml

@@ -16,9 +16,9 @@
   .status__content.p-name.emojify<
     - if status.spoiler_text?
       %p{ style: 'margin-bottom: 0' }<
-        %span.p-summary>= "#{status.spoiler_text} "
+        %span.p-summary> #{status.spoiler_text}&nbsp;
         %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
-    %div.e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
+    .e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
 
   - unless status.media_attachments.empty?
     .status__attachments

+ 16 - 16
app/views/stream_entries/_status.html.haml

@@ -1,25 +1,25 @@
-- include_threads ||= false
-- is_predecessor  ||= false
-- is_successor    ||= false
-- direct_reply_id ||= false
-- parent_id       ||= false
-- is_direct_parent  = direct_reply_id == status.id
-- is_direct_child  = parent_id == status.in_reply_to_id
-- parent_id       ||= false
-- centered        ||= include_threads && !is_predecessor && !is_successor
-- h_class         = microformats_h_class(status, is_predecessor, is_successor, include_threads)
-- style_classes   = style_classes(status, is_predecessor, is_successor, include_threads)
-- mf_classes      = microformats_classes(status, is_direct_parent, is_direct_child)
-- entry_classes   = h_class + ' ' + mf_classes + ' ' + style_classes
+:ruby
+  include_threads ||= false
+  is_predecessor  ||= false
+  is_successor    ||= false
+  direct_reply_id ||= false
+  parent_id       ||= false
+  is_direct_parent = direct_reply_id == status.id
+  is_direct_child  = parent_id == status.in_reply_to_id
+  centered ||= include_threads && !is_predecessor && !is_successor
+  h_class       = microformats_h_class(status, is_predecessor, is_successor, include_threads)
+  style_classes = style_classes(status, is_predecessor, is_successor, include_threads)
+  mf_classes    = microformats_classes(status, is_direct_parent, is_direct_child)
+  entry_classes = h_class + ' ' + mf_classes + ' ' + style_classes
 
 - if status.reply? && include_threads
-  = render partial: 'stream_entries/status', collection: @ancestors, as: :status, locals: { is_predecessor: true, direct_reply_id: status.in_reply_to_id}
+  = render partial: 'stream_entries/status', collection: @ancestors, as: :status, locals: { is_predecessor: true, direct_reply_id: status.in_reply_to_id }
 
 .entry{ class: entry_classes }
 
   - if status.reblog?
     .pre-header
-      %div.pre-header__icon
+      .pre-header__icon
         = fa_icon('retweet fw')
       %span
         = link_to TagManager.instance.url_for(status.account), class: 'status__display-name muted' do
@@ -29,4 +29,4 @@
   = render (centered ? 'stream_entries/detailed_status' : 'stream_entries/simple_status'), status: status.proper
 
 - if include_threads
-  = render partial: 'stream_entries/status', collection: @descendants, as: :status, locals: { is_successor: true, parent_id: status.id}
+  = render partial: 'stream_entries/status', collection: @descendants, as: :status, locals: { is_successor: true, parent_id: status.id }

+ 1 - 1
app/views/tags/show.html.haml

@@ -4,7 +4,7 @@
 .compact-header
   %h1<
     = link_to site_title, root_path
-    %small= "##{@tag.name}"
+    %small ##{@tag.name}
 
 - if @statuses.empty?
   .accounts-grid