From 48594b18e6285d87ee2f58daa08d356b571c8aa6 Mon Sep 17 00:00:00 2001 From: yhirano Date: Mon, 8 May 2017 10:35:25 +0900 Subject: [PATCH] Added haml-lint and fix warnings (#2773) * add haml_lint to Gemfile * add .haml-lint.yml * fix warnings of haml_lint --- .haml-lint.yml | 108 ++++++++++++++++++ Gemfile | 1 + Gemfile.lock | 9 ++ app/views/about/_contact.html.haml | 2 +- app/views/about/_registration.html.haml | 4 +- app/views/about/more.html.haml | 4 +- app/views/about/show.html.haml | 6 +- app/views/accounts/_grid_card.html.haml | 2 +- app/views/accounts/_header.html.haml | 4 +- app/views/admin/accounts/_card.html.haml | 2 +- app/views/admin/reports/_report.html.haml | 6 +- app/views/admin/settings/edit.html.haml | 2 +- app/views/application/_flashes.html.haml | 2 +- app/views/auth/confirmations/new.html.haml | 2 +- app/views/auth/passwords/edit.html.haml | 6 +- app/views/auth/passwords/new.html.haml | 2 +- app/views/auth/registrations/edit.html.haml | 6 +- app/views/auth/registrations/new.html.haml | 6 +- app/views/auth/sessions/new.html.haml | 2 +- app/views/auth/sessions/two_factor.html.haml | 2 +- app/views/authorize_follows/_card.html.haml | 2 +- app/views/errors/403.html.haml | 2 +- app/views/errors/404.html.haml | 2 +- app/views/home/index.html.haml | 4 +- app/views/layouts/admin.html.haml | 2 +- app/views/layouts/application.html.haml | 23 ++-- app/views/layouts/auth.html.haml | 2 +- app/views/layouts/embedded.html.haml | 4 +- app/views/layouts/error.html.haml | 12 +- app/views/layouts/public.html.haml | 6 +- app/views/oauth/authorizations/new.html.haml | 2 +- .../authorized_applications/index.html.haml | 2 +- app/views/settings/profiles/show.html.haml | 4 +- .../confirmations/new.html.haml | 2 +- .../stream_entries/_detailed_status.html.haml | 10 +- app/views/stream_entries/_media.html.haml | 2 +- .../stream_entries/_simple_status.html.haml | 4 +- app/views/stream_entries/_status.html.haml | 32 +++--- app/views/tags/show.html.haml | 2 +- 39 files changed, 207 insertions(+), 90 deletions(-) create mode 100644 .haml-lint.yml diff --git a/.haml-lint.yml b/.haml-lint.yml new file mode 100644 index 0000000000..7853d81d7c --- /dev/null +++ b/.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 diff --git a/Gemfile b/Gemfile index 7a2a16c3aa..efc227646e 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index 0c9c15e526..d0888c177d 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/views/about/_contact.html.haml b/app/views/about/_contact.html.haml index d8c54c1829..39e4e98ec1 100644 --- a/app/views/about/_contact.html.haml +++ b/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 diff --git a/app/views/about/_registration.html.haml b/app/views/about/_registration.html.haml index c7a9a488b4..4f38c1eccf 100644 --- a/app/views/about/_registration.html.haml +++ b/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') } diff --git a/app/views/about/more.html.haml b/app/views/about/more.html.haml index 55580f9967..cce7495610 100644 --- a/app/views/about/more.html.haml +++ b/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 diff --git a/app/views/about/show.html.haml b/app/views/about/show.html.haml index 7bdfb1d2ad..fd21c2a7f6 100644 --- a/app/views/about/show.html.haml +++ b/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 diff --git a/app/views/accounts/_grid_card.html.haml b/app/views/accounts/_grid_card.html.haml index d5418fca5a..0571d1d5e2 100644 --- a/app/views/accounts/_grid_card.html.haml +++ b/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) diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index ed13ab57ca..6451a5573d 100644 --- a/app/views/accounts/_header.html.haml +++ b/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 diff --git a/app/views/admin/accounts/_card.html.haml b/app/views/admin/accounts/_card.html.haml index 549d10f59f..bb33582eba 100644 --- a/app/views/admin/accounts/_card.html.haml +++ b/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 diff --git a/app/views/admin/reports/_report.html.haml b/app/views/admin/reports/_report.html.haml index 2be1f8f2ab..d5eb161b99 100644 --- a/app/views/admin/reports/_report.html.haml +++ b/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 diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 59a8f53ed1..edb69e3603 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/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 diff --git a/app/views/application/_flashes.html.haml b/app/views/application/_flashes.html.haml index 63587e7779..6f29d315f0 100644 --- a/app/views/application/_flashes.html.haml +++ b/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 diff --git a/app/views/auth/confirmations/new.html.haml b/app/views/auth/confirmations/new.html.haml index a5a228cfa6..07ca4a7da9 100644 --- a/app/views/auth/confirmations/new.html.haml +++ b/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' diff --git a/app/views/auth/passwords/edit.html.haml b/app/views/auth/passwords/edit.html.haml index 706684a74f..88cc36bf32 100644 --- a/app/views/auth/passwords/edit.html.haml +++ b/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' diff --git a/app/views/auth/passwords/new.html.haml b/app/views/auth/passwords/new.html.haml index 077a6cea30..f4d22031a5 100644 --- a/app/views/auth/passwords/new.html.haml +++ b/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' diff --git a/app/views/auth/registrations/edit.html.haml b/app/views/auth/registrations/edit.html.haml index 39b726f9c2..8ab188f0c2 100644 --- a/app/views/auth/registrations/edit.html.haml +++ b/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 diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml index 7fd36f009b..82d5483dd5 100644 --- a/app/views/auth/registrations/new.html.haml +++ b/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' diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml index 93b9629f1d..f613100c10 100644 --- a/app/views/auth/sessions/new.html.haml +++ b/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' diff --git a/app/views/auth/sessions/two_factor.html.haml b/app/views/auth/sessions/two_factor.html.haml index 3dec40c44c..0321e1ec7d 100644 --- a/app/views/auth/sessions/two_factor.html.haml +++ b/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' diff --git a/app/views/authorize_follows/_card.html.haml b/app/views/authorize_follows/_card.html.haml index ee76f628d0..13d9c77197 100644 --- a/app/views/authorize_follows/_card.html.haml +++ b/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) diff --git a/app/views/errors/403.html.haml b/app/views/errors/403.html.haml index c6e421f4f5..5a500b87ad 100644 --- a/app/views/errors/403.html.haml +++ b/app/views/errors/403.html.haml @@ -2,4 +2,4 @@ = t('errors.403') - content_for :content do - = t('errors.403') \ No newline at end of file + = t('errors.403') diff --git a/app/views/errors/404.html.haml b/app/views/errors/404.html.haml index 5ffba3ca90..80ef1665ec 100644 --- a/app/views/errors/404.html.haml +++ b/app/views/errors/404.html.haml @@ -2,4 +2,4 @@ = t('errors.404') - content_for :content do - = t('errors.404') \ No newline at end of file + = t('errors.404') diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 55fbfe60e2..87cfcaff40 100644 --- a/app/views/home/index.html.haml +++ b/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) } } diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index f7cea41e2e..59d95a0c68 100644 --- a/app/views/layouts/admin.html.haml +++ b/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' } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 683d0272f5..73fab9a5c4 100755 --- a/app/views/layouts/application.html.haml +++ b/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) diff --git a/app/views/layouts/auth.html.haml b/app/views/layouts/auth.html.haml index 2478776abc..e5429a8ed0 100644 --- a/app/views/layouts/auth.html.haml +++ b/app/views/layouts/auth.html.haml @@ -13,4 +13,4 @@ = yield -= render template: "layouts/application" += render template: 'layouts/application' diff --git a/app/views/layouts/embedded.html.haml b/app/views/layouts/embedded.html.haml index fcc474ff60..f0fd1b00df 100644 --- a/app/views/layouts/embedded.html.haml +++ b/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 diff --git a/app/views/layouts/error.html.haml b/app/views/layouts/error.html.haml index 543881d7d9..08b94af54a 100644 --- a/app/views/layouts/error.html.haml +++ b/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 diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 9b94ad9a4b..36cb1b4ad8 100644 --- a/app/views/layouts/public.html.haml +++ b/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' diff --git a/app/views/oauth/authorizations/new.html.haml b/app/views/oauth/authorizations/new.html.haml index 1f951c272d..05ff9582e7 100644 --- a/app/views/oauth/authorizations/new.html.haml +++ b/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| "#{s}"}.to_sentence.html_safe + != @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "#{s}" }.to_sentence = form_tag oauth_authorization_path, method: :post, class: 'simple_form' do = hidden_field_tag :client_id, @pre_auth.client.uid diff --git a/app/views/oauth/authorized_applications/index.html.haml b/app/views/oauth/authorized_applications/index.html.haml index 421ed317d5..ba0c084950 100644 --- a/app/views/oauth/authorized_applications/index.html.haml +++ b/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('
').html_safe + %th!= application.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.join('
') %td= l application.created_at %td - unless application.superapp? diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index 52373a9595..ed76885de9 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/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: "#{30-@account.display_name.size}").html_safe - = f.input :note, placeholder: t('simple_form.labels.defaults.note'), hint: t('simple_form.hints.defaults.note', counter: "#{160-@account.note.size}").html_safe + = f.input :display_name, placeholder: t('simple_form.labels.defaults.display_name'), hint: t('simple_form.hints.defaults.display_name', counter: "#{30 - @account.display_name.size}").html_safe + = f.input :note, placeholder: t('simple_form.labels.defaults.note'), hint: t('simple_form.hints.defaults.note', counter: "#{160 - @account.note.size}").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') diff --git a/app/views/settings/two_factor_authentication/confirmations/new.html.haml b/app/views/settings/two_factor_authentication/confirmations/new.html.haml index 9d950c78e7..b7eb0c23da 100644 --- a/app/views/settings/two_factor_authentication/confirmations/new.html.haml +++ b/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') diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index 4cf8acb0dc..d22afb0822 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/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}  %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) diff --git a/app/views/stream_entries/_media.html.haml b/app/views/stream_entries/_media.html.haml index cd7faa7002..779f02c8d9 100644 --- a/app/views/stream_entries/_media.html.haml +++ b/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 }/ diff --git a/app/views/stream_entries/_simple_status.html.haml b/app/views/stream_entries/_simple_status.html.haml index 972f2abdca..3fa347f74d 100644 --- a/app/views/stream_entries/_simple_status.html.haml +++ b/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}  %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 diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index 6c763bde26..50a3737436 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/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 } diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index 829f003a73..15bf714c28 100644 --- a/app/views/tags/show.html.haml +++ b/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