From 09ab073f0cc5a8963c6d34fb76d3af84e0c0f40e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 9 Jan 2024 10:28:56 -0500 Subject: [PATCH 1/7] Fix `LineLength` haml-lint in `app/views/settings` area (#28663) --- .haml-lint_todo.yml | 8 +--- .../settings/applications/_fields.html.haml | 25 ++++++++-- .../settings/featured_tags/index.html.haml | 4 +- app/views/settings/imports/index.html.haml | 22 +++++++-- .../migration/redirects/new.html.haml | 6 ++- .../preferences/appearance/show.html.haml | 46 ++++++++++++++++--- .../settings/preferences/other/show.html.haml | 39 ++++++++++++++-- app/views/settings/profiles/show.html.haml | 10 +++- .../confirmations/new.html.haml | 7 ++- 9 files changed, 137 insertions(+), 30 deletions(-) diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index 09764c2f30..13ee2baaab 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -1,20 +1,16 @@ # This configuration was generated by # `haml-lint --auto-gen-config` -# on 2024-01-08 14:02:57 -0500 using Haml-Lint version 0.53.0. +# on 2024-01-09 10:00:31 -0500 using Haml-Lint version 0.53.0. # The point is for the user to remove these configuration records # one by one as the lints are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of Haml-Lint, may require this file to be generated again. linters: - # Offense count: 10 + # Offense count: 5 LineLength: exclude: - 'app/views/admin/roles/_form.html.haml' - 'app/views/auth/registrations/edit.html.haml' - 'app/views/auth/registrations/new.html.haml' - 'app/views/media/player.html.haml' - - 'app/views/settings/applications/_fields.html.haml' - - 'app/views/settings/imports/index.html.haml' - - 'app/views/settings/preferences/appearance/show.html.haml' - - 'app/views/settings/preferences/other/show.html.haml' diff --git a/app/views/settings/applications/_fields.html.haml b/app/views/settings/applications/_fields.html.haml index 29e2bcb5a3..ed97e880fc 100644 --- a/app/views/settings/applications/_fields.html.haml +++ b/app/views/settings/applications/_fields.html.haml @@ -1,11 +1,17 @@ .fields-group - = f.input :name, wrapper: :with_label, label: t('activerecord.attributes.doorkeeper/application.name') + = f.input :name, + label: t('activerecord.attributes.doorkeeper/application.name'), + wrapper: :with_label .fields-group - = f.input :website, wrapper: :with_label, label: t('activerecord.attributes.doorkeeper/application.website') + = f.input :website, + label: t('activerecord.attributes.doorkeeper/application.website'), + wrapper: :with_label .fields-group - = f.input :redirect_uri, wrapper: :with_block_label, label: t('activerecord.attributes.doorkeeper/application.redirect_uri'), hint: t('doorkeeper.applications.help.redirect_uri') + = f.input :redirect_uri, + label: t('activerecord.attributes.doorkeeper/application.redirect_uri'), hint: t('doorkeeper.applications.help.redirect_uri'), + wrapper: :with_block_label %p.hint= t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: content_tag(:code, Doorkeeper.configuration.native_redirect_uri)).html_safe @@ -15,4 +21,15 @@ %span.hint= t('simple_form.hints.defaults.scopes') - Doorkeeper.configuration.scopes.group_by { |s| s.split(':').first }.each_value do |value| - = f.input :scopes, label: false, hint: false, collection: value.sort, wrapper: :with_block_label, include_blank: false, label_method: ->(scope) { safe_join([content_tag(:samp, scope, class: class_for_scope(scope)), content_tag(:span, t("doorkeeper.scopes.#{scope}"), class: 'hint')]) }, selected: f.object.scopes.all, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li' + = f.input :scopes, + as: :check_boxes, + collection_wrapper_tag: 'ul', + collection: value.sort, + hint: false, + include_blank: false, + item_wrapper_tag: 'li', + label_method: ->(scope) { safe_join([content_tag(:samp, scope, class: class_for_scope(scope)), content_tag(:span, t("doorkeeper.scopes.#{scope}"), class: 'hint')]) }, + label: false, + required: false, + selected: f.object.scopes.all, + wrapper: :with_block_label diff --git a/app/views/settings/featured_tags/index.html.haml b/app/views/settings/featured_tags/index.html.haml index 387eb290e3..22f9180129 100644 --- a/app/views/settings/featured_tags/index.html.haml +++ b/app/views/settings/featured_tags/index.html.haml @@ -11,7 +11,9 @@ %p.lead= t('featured_tags.hint_html') .fields-group - = f.input :name, wrapper: :with_block_label, hint: safe_join([t('simple_form.hints.featured_tag.name'), safe_join(@recently_used_tags.map { |tag| link_to("##{tag.display_name}", settings_featured_tags_path(featured_tag: { name: tag.name }), method: :post) }, ', ')], ' ') + = f.input :name, + hint: safe_join([t('simple_form.hints.featured_tag.name'), safe_join(@recently_used_tags.map { |tag| link_to("##{tag.display_name}", settings_featured_tags_path(featured_tag: { name: tag.name }), method: :post) }, ', ')], ' '), + wrapper: :with_block_label .actions = f.button :button, t('featured_tags.add_new'), type: :submit diff --git a/app/views/settings/imports/index.html.haml b/app/views/settings/imports/index.html.haml index 5f7950b598..d5ca252dc1 100644 --- a/app/views/settings/imports/index.html.haml +++ b/app/views/settings/imports/index.html.haml @@ -3,13 +3,29 @@ = simple_form_for @import, url: settings_imports_path do |f| .field-group - = f.input :type, as: :grouped_select, collection: { constructive: %i(following bookmarks lists), destructive: %i(muting blocking domain_blocking) }, wrapper: :with_block_label, include_blank: false, label_method: ->(type) { I18n.t("imports.types.#{type}") }, group_label_method: ->(group) { I18n.t("imports.type_groups.#{group.first}") }, group_method: :last, hint: t('imports.preface') + = f.input :type, + as: :grouped_select, + collection: { constructive: %i(following bookmarks lists), destructive: %i(muting blocking domain_blocking) }, + group_label_method: ->(group) { I18n.t("imports.type_groups.#{group.first}") }, + group_method: :last, + hint: t('imports.preface'), + include_blank: false, + label_method: ->(type) { I18n.t("imports.types.#{type}") }, + wrapper: :with_block_label .fields-row .fields-group.fields-row__column.fields-row__column-6 - = f.input :data, as: :file, wrapper: :with_block_label, hint: t('simple_form.hints.imports.data') + = f.input :data, + as: :file, + hint: t('simple_form.hints.imports.data'), + wrapper: :with_block_label .fields-group.fields-row__column.fields-row__column-6 - = f.input :mode, as: :radio_buttons, collection: Import::MODES, label_method: ->(mode) { safe_join([I18n.t("imports.modes.#{mode}"), content_tag(:span, I18n.t("imports.modes.#{mode}_long"), class: 'hint')]) }, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li' + = f.input :mode, + as: :radio_buttons, + collection_wrapper_tag: 'ul', + collection: Import::MODES, + item_wrapper_tag: 'li', + label_method: ->(mode) { safe_join([I18n.t("imports.modes.#{mode}"), content_tag(:span, I18n.t("imports.modes.#{mode}_long"), class: 'hint')]) } .actions = f.button :button, t('imports.upload'), type: :submit diff --git a/app/views/settings/migration/redirects/new.html.haml b/app/views/settings/migration/redirects/new.html.haml index 3700878799..731acb9dbc 100644 --- a/app/views/settings/migration/redirects/new.html.haml +++ b/app/views/settings/migration/redirects/new.html.haml @@ -15,7 +15,11 @@ .fields-row .fields-row__column.fields-group.fields-row__column-6 - = f.input :acct, wrapper: :with_block_label, input_html: { autocapitalize: 'none', autocorrect: 'off' }, label: t('simple_form.labels.account_migration.acct'), hint: t('simple_form.hints.account_migration.acct') + = f.input :acct, + hint: t('simple_form.hints.account_migration.acct'), + input_html: { autocapitalize: 'none', autocorrect: 'off' }, + label: t('simple_form.labels.account_migration.acct'), + wrapper: :with_block_label .fields-row__column.fields-group.fields-row__column-6 - if current_user.encrypted_password.present? diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index 11fa2bfc43..76cd4381d8 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -7,13 +7,28 @@ = simple_form_for current_user, url: settings_preferences_appearance_path, html: { method: :put, id: 'edit_user' } do |f| .fields-row .fields-group.fields-row__column.fields-row__column-6 - = f.input :locale, collection: ui_languages, wrapper: :with_label, include_blank: false, label_method: ->(locale) { native_locale_name(locale) }, selected: I18n.locale, hint: false + = f.input :locale, + collection: ui_languages, + hint: false, + include_blank: false, + label_method: ->(locale) { native_locale_name(locale) }, + selected: I18n.locale, + wrapper: :with_label .fields-group.fields-row__column.fields-row__column-6 - = f.input :time_zone, wrapper: :with_label, collection: ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.formatted_offset}) #{tz.name}", tz.tzinfo.name] }, hint: false + = f.input :time_zone, + collection: ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.formatted_offset}) #{tz.name}", tz.tzinfo.name] }, + hint: false, + wrapper: :with_label .fields-group = f.simple_fields_for :settings, current_user.settings do |ff| - = ff.input :theme, collection: Themes.instance.names, label_method: ->(theme) { I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_theme'), include_blank: false, hint: false + = ff.input :theme, + collection: Themes.instance.names, + hint: false, + include_blank: false, + label_method: ->(theme) { I18n.t("themes.#{theme}", default: theme) }, + label: I18n.t('simple_form.labels.defaults.setting_theme'), + wrapper: :with_label - unless I18n.locale == :en .flash-message.translation-prompt @@ -25,11 +40,17 @@ %p.hint= t 'appearance.advanced_web_interface_hint' .fields-group - = ff.input :'web.advanced_layout', wrapper: :with_label, hint: false, label: I18n.t('simple_form.labels.defaults.setting_advanced_layout') + = ff.input :'web.advanced_layout', + hint: false, + label: I18n.t('simple_form.labels.defaults.setting_advanced_layout'), + wrapper: :with_label %h4= t 'appearance.animations_and_accessibility' .fields-group - = ff.input :'web.use_pending_items', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_pending_items'), hint: I18n.t('simple_form.hints.defaults.setting_use_pending_items') + = ff.input :'web.use_pending_items', + hint: I18n.t('simple_form.hints.defaults.setting_use_pending_items'), + label: I18n.t('simple_form.labels.defaults.setting_use_pending_items'), + wrapper: :with_label .fields-group = ff.input :'web.auto_play', wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_auto_play_gif') @@ -52,10 +73,21 @@ %h4= t 'appearance.sensitive_content' .fields-group - = ff.input :'web.display_media', collection: %w(default show_all hide_all), label_method: ->(item) { t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_display_media') + = ff.input :'web.display_media', + as: :radio_buttons, + collection_wrapper_tag: 'ul', + collection: %w(default show_all hide_all), + hint: false, + item_wrapper_tag: 'li', + label_method: ->(item) { t("simple_form.hints.defaults.setting_display_media_#{item}") }, + label: I18n.t('simple_form.labels.defaults.setting_display_media'), + wrapper: :with_floating_label .fields-group - = ff.input :'web.use_blurhash', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_blurhash'), hint: I18n.t('simple_form.hints.defaults.setting_use_blurhash') + = ff.input :'web.use_blurhash', + hint: I18n.t('simple_form.hints.defaults.setting_use_blurhash'), + label: I18n.t('simple_form.labels.defaults.setting_use_blurhash'), + wrapper: :with_label .fields-group = ff.input :'web.expand_content_warnings', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_expand_spoilers') diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 5228ce1190..e2888f7212 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -9,24 +9,53 @@ = f.simple_fields_for :settings, current_user.settings do |ff| .fields-group - = ff.input :aggregate_reblogs, wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_aggregate_reblogs'), hint: I18n.t('simple_form.hints.defaults.setting_aggregate_reblogs') + = ff.input :aggregate_reblogs, + hint: I18n.t('simple_form.hints.defaults.setting_aggregate_reblogs'), + label: I18n.t('simple_form.labels.defaults.setting_aggregate_reblogs'), + recommended: true, + wrapper: :with_label %h4= t 'preferences.posting_defaults' .fields-row .fields-group.fields-row__column.fields-row__column-6 - = ff.input :default_privacy, collection: Status.selectable_visibilities, wrapper: :with_label, include_blank: false, label_method: ->(visibility) { safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_privacy') + = ff.input :default_privacy, + collection: Status.selectable_visibilities, + hint: false, + include_blank: false, + label_method: ->(visibility) { safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, + label: I18n.t('simple_form.labels.defaults.setting_default_privacy'), + required: false, + wrapper: :with_label .fields-group.fields-row__column.fields-row__column-6 - = ff.input :default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: ->(locale) { locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_language') + = ff.input :default_language, + collection: [nil] + filterable_languages, + hint: false, + include_blank: false, + label_method: ->(locale) { locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, + label: I18n.t('simple_form.labels.defaults.setting_default_language'), + required: false, + wrapper: :with_label .fields-group - = ff.input :default_sensitive, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'), hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive') + = ff.input :default_sensitive, + hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive'), + label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'), + wrapper: :with_label %h4= t 'preferences.public_timelines' .fields-group - = f.input :chosen_languages, collection: filterable_languages, wrapper: :with_block_label, include_blank: false, label_method: ->(locale) { native_locale_name(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li' + = f.input :chosen_languages, + as: :check_boxes, + collection_wrapper_tag: 'ul', + collection: filterable_languages, + include_blank: false, + item_wrapper_tag: 'li', + label_method: ->(locale) { native_locale_name(locale) }, + required: false, + wrapper: :with_block_label .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index 5f9613c939..b7b0a0da92 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -33,7 +33,10 @@ .fields-row .fields-row__column.fields-row__column-6 .fields-group - = f.input :avatar, wrapper: :with_block_label, input_html: { accept: Account::Avatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(Account::Avatar::LIMIT)) + = f.input :avatar, + hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(Account::Avatar::LIMIT)), + input_html: { accept: Account::Avatar::IMAGE_MIME_TYPES.join(',') }, + wrapper: :with_block_label .fields-row__column.fields-row__column-6 .fields-group @@ -46,7 +49,10 @@ .fields-row .fields-row__column.fields-row__column-6 .fields-group - = f.input :header, wrapper: :with_block_label, input_html: { accept: Account::Header::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.header', dimensions: '1500x500', size: number_to_human_size(Account::Header::LIMIT)) + = f.input :header, + hint: t('simple_form.hints.defaults.header', dimensions: '1500x500', size: number_to_human_size(Account::Header::LIMIT)), + input_html: { accept: Account::Header::IMAGE_MIME_TYPES.join(',') }, + wrapper: :with_block_label .fields-row__column.fields-row__column-6 .fields-group 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 43830ac27f..0b8278a104 100644 --- a/app/views/settings/two_factor_authentication/confirmations/new.html.haml +++ b/app/views/settings/two_factor_authentication/confirmations/new.html.haml @@ -12,7 +12,12 @@ %samp.qr-alternative__code= @new_otp_secret.scan(/.{4}/).join(' ') .fields-group - = f.input :otp_attempt, wrapper: :with_label, hint: t('otp_authentication.code_hint'), label: t('simple_form.labels.defaults.otp_attempt'), input_html: { autocomplete: 'off' }, required: true + = f.input :otp_attempt, + hint: t('otp_authentication.code_hint'), + input_html: { autocomplete: 'off' }, + label: t('simple_form.labels.defaults.otp_attempt'), + required: true, + wrapper: :with_label .actions = f.button :button, t('otp_authentication.enable'), type: :submit From eed4eef39a92464459496a476e5e3cccfbe084ab Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 9 Jan 2024 11:03:16 -0500 Subject: [PATCH 2/7] Fix `LineLength` haml-lint in `app/views/auth` area (#28664) --- .haml-lint_todo.yml | 6 +-- app/views/auth/challenges/new.html.haml | 6 ++- app/views/auth/confirmations/new.html.haml | 8 ++- app/views/auth/passwords/edit.html.haml | 13 ++++- app/views/auth/passwords/new.html.haml | 7 ++- .../registrations/_account_warning.html.haml | 4 +- .../auth/registrations/_session.html.haml | 4 +- app/views/auth/registrations/edit.html.haml | 26 ++++++++-- app/views/auth/registrations/new.html.haml | 52 ++++++++++++++++--- app/views/auth/sessions/new.html.haml | 20 +++++-- .../_otp_authentication_form.html.haml | 7 ++- app/views/auth/setup/show.html.haml | 5 +- 12 files changed, 130 insertions(+), 28 deletions(-) diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index 13ee2baaab..ac9f763758 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -1,16 +1,14 @@ # This configuration was generated by # `haml-lint --auto-gen-config` -# on 2024-01-09 10:00:31 -0500 using Haml-Lint version 0.53.0. +# on 2024-01-09 10:48:44 -0500 using Haml-Lint version 0.53.0. # The point is for the user to remove these configuration records # one by one as the lints are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of Haml-Lint, may require this file to be generated again. linters: - # Offense count: 5 + # Offense count: 3 LineLength: exclude: - 'app/views/admin/roles/_form.html.haml' - - 'app/views/auth/registrations/edit.html.haml' - - 'app/views/auth/registrations/new.html.haml' - 'app/views/media/player.html.haml' diff --git a/app/views/auth/challenges/new.html.haml b/app/views/auth/challenges/new.html.haml index 4f21e4af6e..50dcebb00c 100644 --- a/app/views/auth/challenges/new.html.haml +++ b/app/views/auth/challenges/new.html.haml @@ -5,7 +5,11 @@ = f.input :return_to, as: :hidden .field-group - = f.input :current_password, wrapper: :with_block_label, input_html: { autocomplete: 'current-password', autofocus: true }, label: t('challenge.prompt'), required: true + = f.input :current_password, + input_html: { autocomplete: 'current-password', autofocus: true }, + label: t('challenge.prompt'), + required: true, + wrapper: :with_block_label .actions = f.button :button, t('challenge.confirm'), type: :submit diff --git a/app/views/auth/confirmations/new.html.haml b/app/views/auth/confirmations/new.html.haml index 0cb82a1f86..eaa9d9add0 100644 --- a/app/views/auth/confirmations/new.html.haml +++ b/app/views/auth/confirmations/new.html.haml @@ -21,7 +21,13 @@ = render 'shared/error_messages', object: resource .fields-group - = f.input :email, autofocus: true, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, readonly: current_user.present?, hint: current_user.present? && t('auth.confirmations.wrong_email_hint') + = f.input :email, + autofocus: true, + hint: current_user.present? && t('auth.confirmations.wrong_email_hint'), + input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, + label: t('simple_form.labels.defaults.email'), + readonly: current_user.present?, + wrapper: :with_label .actions = f.button :button, t('auth.resend_confirmation'), type: :submit diff --git a/app/views/auth/passwords/edit.html.haml b/app/views/auth/passwords/edit.html.haml index b95a9b676b..a75dc2d9fb 100644 --- a/app/views/auth/passwords/edit.html.haml +++ b/app/views/auth/passwords/edit.html.haml @@ -8,9 +8,18 @@ = f.input :reset_password_token, as: :hidden .fields-group - = f.input :password, wrapper: :with_label, autofocus: true, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label': t('simple_form.labels.defaults.new_password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, required: true + = f.input :password, + autofocus: true, + input_html: { 'aria-label': t('simple_form.labels.defaults.new_password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, + label: t('simple_form.labels.defaults.new_password'), + required: true, + wrapper: :with_label .fields-group - = f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_new_password'), autocomplete: 'new-password' }, required: true + = f.input :password_confirmation, + input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_new_password'), autocomplete: 'new-password' }, + label: t('simple_form.labels.defaults.confirm_new_password'), + required: true, + wrapper: :with_label .actions = f.button :button, t('auth.set_new_password'), type: :submit diff --git a/app/views/auth/passwords/new.html.haml b/app/views/auth/passwords/new.html.haml index 10ad108eaf..8d5adaf3b9 100644 --- a/app/views/auth/passwords/new.html.haml +++ b/app/views/auth/passwords/new.html.haml @@ -5,7 +5,12 @@ = render 'shared/error_messages', object: resource .fields-group - = f.input :email, autofocus: true, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, hint: false + = f.input :email, + autofocus: true, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, + label: t('simple_form.labels.defaults.email'), + wrapper: :with_label .actions = f.button :button, t('auth.reset_password'), type: :submit diff --git a/app/views/auth/registrations/_account_warning.html.haml b/app/views/auth/registrations/_account_warning.html.haml index 40e7e12968..19e5746ff6 100644 --- a/app/views/auth/registrations/_account_warning.html.haml +++ b/app/views/auth/registrations/_account_warning.html.haml @@ -5,7 +5,9 @@ = fa_icon 'warning' .log-entry__content .log-entry__title - = t('disputes.strikes.title', action: t(account_warning.action, scope: 'disputes.strikes.title_actions'), date: l(account_warning.created_at.to_date)) + = t 'disputes.strikes.title', + action: t(account_warning.action, scope: 'disputes.strikes.title_actions'), + date: l(account_warning.created_at.to_date) .log-entry__timestamp %time.formatted{ datetime: account_warning.created_at.iso8601 }= l(account_warning.created_at) diff --git a/app/views/auth/registrations/_session.html.haml b/app/views/auth/registrations/_session.html.haml index 28499a7c91..2fa7db70c7 100644 --- a/app/views/auth/registrations/_session.html.haml +++ b/app/views/auth/registrations/_session.html.haml @@ -3,7 +3,9 @@ %span{ title: session.user_agent }< = fa_icon "#{session_device_icon(session)} fw", 'aria-label': session_device_icon(session)   - = t 'sessions.description', browser: t("sessions.browsers.#{session.browser}", default: session.browser.to_s), platform: t("sessions.platforms.#{session.platform}", default: session.platform.to_s) + = t 'sessions.description', + browser: t("sessions.browsers.#{session.browser}", default: session.browser.to_s), + platform: t("sessions.platforms.#{session.platform}", default: session.platform.to_s) %td %samp= session.ip %td diff --git a/app/views/auth/registrations/edit.html.haml b/app/views/auth/registrations/edit.html.haml index f5ef4e97e4..48350f478e 100644 --- a/app/views/auth/registrations/edit.html.haml +++ b/app/views/auth/registrations/edit.html.haml @@ -15,15 +15,33 @@ - if (!use_seamless_external_login? || resource.encrypted_password.present?) && !omniauth_only? .fields-row .fields-row__column.fields-group.fields-row__column-6 - = f.input :email, wrapper: :with_label, input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, required: true, disabled: current_account.suspended? + = f.input :email, + disabled: current_account.suspended?, + input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, + required: true, + wrapper: :with_label .fields-row__column.fields-group.fields-row__column-6 - = f.input :current_password, wrapper: :with_label, input_html: { 'aria-label': t('simple_form.labels.defaults.current_password'), autocomplete: 'current-password' }, required: true, disabled: current_account.suspended?, hint: false + = f.input :current_password, + disabled: current_account.suspended?, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.current_password'), autocomplete: 'current-password' }, + required: true, + wrapper: :with_label .fields-row .fields-row__column.fields-group.fields-row__column-6 - = f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label': t('simple_form.labels.defaults.new_password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, hint: t('simple_form.hints.defaults.password'), disabled: current_account.suspended? + = f.input :password, + disabled: current_account.suspended?, + hint: t('simple_form.hints.defaults.password'), + input_html: { 'aria-label': t('simple_form.labels.defaults.new_password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, + label: t('simple_form.labels.defaults.new_password'), + wrapper: :with_label .fields-row__column.fields-group.fields-row__column-6 - = f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_new_password'), autocomplete: 'new-password' }, disabled: current_account.suspended? + = f.input :password_confirmation, + disabled: current_account.suspended?, + input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_new_password'), autocomplete: 'new-password' }, + label: t('simple_form.labels.defaults.confirm_new_password'), + wrapper: :with_label .actions = f.button :button, t('generic.save_changes'), type: :submit, class: 'button', disabled: current_account.suspended? diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml index 4cac7b51bd..1e5aac2976 100644 --- a/app/views/auth/registrations/new.html.haml +++ b/app/views/auth/registrations/new.html.haml @@ -19,25 +19,61 @@ .fields-group = f.simple_fields_for :account do |ff| - = ff.input :username, wrapper: :with_label, label: false, required: true, input_html: { 'aria-label': t('simple_form.labels.defaults.username'), autocomplete: 'off', placeholder: t('simple_form.labels.defaults.username'), pattern: '[a-zA-Z0-9_]+', maxlength: 30 }, append: "@#{site_hostname}" - = f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'username' }, hint: false - = f.input :password, placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label': t('simple_form.labels.defaults.password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, hint: false - = f.input :password_confirmation, placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_password'), autocomplete: 'new-password' }, hint: false - = f.input :confirm_password, as: :string, placeholder: t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), required: false, input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), autocomplete: 'off' }, hint: false - = f.input :website, as: :url, wrapper: :with_label, label: t('simple_form.labels.defaults.honeypot', label: 'Website'), required: false, input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: 'Website'), autocomplete: 'off' } + = ff.input :username, + append: "@#{site_hostname}", + input_html: { 'aria-label': t('simple_form.labels.defaults.username'), autocomplete: 'off', placeholder: t('simple_form.labels.defaults.username'), pattern: '[a-zA-Z0-9_]+', maxlength: 30 }, + label: false, + required: true, + wrapper: :with_label + = f.input :email, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'username' }, + placeholder: t('simple_form.labels.defaults.email'), + required: true + = f.input :password, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.password'), autocomplete: 'new-password', minlength: User.password_length.first, maxlength: User.password_length.last }, + placeholder: t('simple_form.labels.defaults.password'), + required: true + = f.input :password_confirmation, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.confirm_password'), autocomplete: 'new-password' }, + placeholder: t('simple_form.labels.defaults.confirm_password'), + required: true + = f.input :confirm_password, + as: :string, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), autocomplete: 'off' }, + placeholder: t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), + required: false + = f.input :website, + as: :url, + input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: 'Website'), autocomplete: 'off' }, + label: t('simple_form.labels.defaults.honeypot', label: 'Website'), + required: false, + wrapper: :with_label - if approved_registrations? && @invite.blank? %p.lead= t('auth.sign_up.manual_review', domain: site_hostname) .fields-group = f.simple_fields_for :invite_request, resource.invite_request || resource.build_invite_request do |invite_request_fields| - = invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: Setting.require_invite_text, label: false, hint: false + = invite_request_fields.input :text, + as: :text, + hint: false, + label: false, + required: Setting.require_invite_text, + wrapper: :with_block_label = hidden_field_tag :accept, params[:accept] = f.input :invite_code, as: :hidden .fields-group - = f.input :agreement, as: :boolean, wrapper: :with_label, label: t('auth.privacy_policy_agreement_html', rules_path: about_more_path, privacy_policy_path: privacy_policy_path), required: true + = f.input :agreement, + as: :boolean, + label: t('auth.privacy_policy_agreement_html', rules_path: about_more_path, privacy_policy_path: privacy_policy_path), + required: true, + wrapper: :with_label .actions = f.button :button, @invite.present? ? t('auth.register') : sign_up_message, type: :submit diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml index 7914e0157f..89903581a2 100644 --- a/app/views/auth/sessions/new.html.haml +++ b/app/views/auth/sessions/new.html.haml @@ -10,11 +10,25 @@ %p.lead= t('auth.sign_in.preamble_html', domain: site_hostname) .fields-group - if use_seamless_external_login? - = f.input :email, autofocus: true, wrapper: :with_label, label: t('simple_form.labels.defaults.username_or_email'), input_html: { 'aria-label': t('simple_form.labels.defaults.username_or_email') }, hint: false + = f.input :email, + autofocus: true, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.username_or_email') }, + label: t('simple_form.labels.defaults.username_or_email'), + wrapper: :with_label - else - = f.input :email, autofocus: true, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, hint: false + = f.input :email, + autofocus: true, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, + label: t('simple_form.labels.defaults.email'), + wrapper: :with_label .fields-group - = f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.password'), input_html: { 'aria-label': t('simple_form.labels.defaults.password'), autocomplete: 'current-password' }, hint: false + = f.input :password, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.password'), autocomplete: 'current-password' }, + label: t('simple_form.labels.defaults.password'), + wrapper: :with_label .actions = f.button :button, t('auth.login'), type: :submit diff --git a/app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml b/app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml index 8cc2c85610..30e97a68c1 100644 --- a/app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml +++ b/app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml @@ -5,7 +5,12 @@ %p.hint.authentication-hint= t('simple_form.hints.sessions.otp') .fields-group - = f.input :otp_attempt, type: :number, wrapper: :with_label, label: t('simple_form.labels.defaults.otp_attempt'), input_html: { 'aria-label': t('simple_form.labels.defaults.otp_attempt'), autocomplete: 'one-time-code' }, autofocus: true + = f.input :otp_attempt, + autofocus: true, + input_html: { 'aria-label': t('simple_form.labels.defaults.otp_attempt'), autocomplete: 'one-time-code' }, + label: t('simple_form.labels.defaults.otp_attempt'), + type: :number, + wrapper: :with_label .actions = f.button :button, t('auth.login'), type: :submit diff --git a/app/views/auth/setup/show.html.haml b/app/views/auth/setup/show.html.haml index 97c826d704..713f77470d 100644 --- a/app/views/auth/setup/show.html.haml +++ b/app/views/auth/setup/show.html.haml @@ -16,7 +16,10 @@ %p.lead= t('auth.setup.email_below_hint_html') .fields-group - = f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' } + = f.input :email, + hint: false, + input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }, + required: true .actions = f.button :button, t('auth.resend_confirmation'), type: :submit, class: 'button timer-button', disabled: true From 1f44903991168858d7cc00b3e3255617cd31154c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:08:02 +0100 Subject: [PATCH 3/7] Update dependency sidekiq-unique-jobs to v7.1.31 (#27818) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 549781aed4..91b3bf701f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -716,7 +716,7 @@ GEM rufus-scheduler (~> 3.2) sidekiq (>= 6, < 8) tilt (>= 1.4.0) - sidekiq-unique-jobs (7.1.30) + sidekiq-unique-jobs (7.1.31) brpoplpush-redis_script (> 0.1.1, <= 2.0.0) concurrent-ruby (~> 1.0, >= 1.0.5) redis (< 5.0) From 63d0b52cf3641a819853197bf837937b9f67ef8e Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Tue, 9 Jan 2024 22:58:19 +0100 Subject: [PATCH 4/7] Add a system spec for the `/share` endpoint (#28672) --- spec/system/share_entrypoint_spec.rb | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/system/share_entrypoint_spec.rb diff --git a/spec/system/share_entrypoint_spec.rb b/spec/system/share_entrypoint_spec.rb new file mode 100644 index 0000000000..fd02d1120c --- /dev/null +++ b/spec/system/share_entrypoint_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'ShareEntrypoint' do + include ProfileStories + + subject { page } + + let(:email) { 'test@example.com' } + let(:password) { 'password' } + let(:confirmed_at) { Time.zone.now } + let(:finished_onboarding) { true } + + before do + as_a_logged_in_user + visit share_path + end + + it 'can be used to post a new status' do + expect(subject).to have_css('div#mastodon-compose') + expect(subject).to have_css('.compose-form__publish-button-wrapper > button') + + status_text = 'This is a new status!' + + within('.compose-form') do + fill_in "What's on your mind?", with: status_text + click_on 'Publish!' + end + + expect(subject).to have_css('.notification-bar-message', text: 'Post published.') + end +end From a71e918e958de85e8295212d1a48925e93fae4e0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 10 Jan 2024 04:35:01 -0500 Subject: [PATCH 5/7] Fix `LineLength` haml-lint in `media/player` view (#28667) --- .haml-lint_todo.yml | 5 ++--- app/views/media/player.html.haml | 31 ++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index ac9f763758..af2d2e8f4e 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -1,14 +1,13 @@ # This configuration was generated by # `haml-lint --auto-gen-config` -# on 2024-01-09 10:48:44 -0500 using Haml-Lint version 0.53.0. +# on 2024-01-09 11:30:07 -0500 using Haml-Lint version 0.53.0. # The point is for the user to remove these configuration records # one by one as the lints are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of Haml-Lint, may require this file to be generated again. linters: - # Offense count: 3 + # Offense count: 1 LineLength: exclude: - 'app/views/admin/roles/_form.html.haml' - - 'app/views/media/player.html.haml' diff --git a/app/views/media/player.html.haml b/app/views/media/player.html.haml index f00c8f040b..df02cc4110 100644 --- a/app/views/media/player.html.haml +++ b/app/views/media/player.html.haml @@ -6,14 +6,39 @@ meta = @media_attachment.file.meta || {} - if @media_attachment.video? - = react_component :video, src: @media_attachment.file.url(:original), preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small), frameRate: meta.dig('original', 'frame_rate'), blurhash: @media_attachment.blurhash, width: 670, height: 380, editable: true, detailed: true, inline: true, alt: @media_attachment.description, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json do + = react_component :video, + alt: @media_attachment.description, + blurhash: @media_attachment.blurhash, + detailed: true, + editable: true, + frameRate: meta.dig('original', 'frame_rate'), + height: 380, + inline: true, + media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json, + preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small), + src: @media_attachment.file.url(:original), + width: 670 do %video{ controls: 'controls' } %source{ src: @media_attachment.file.url(:original) } - elsif @media_attachment.gifv? - = react_component :media_gallery, height: 380, standalone: true, autoplay: true, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer).as_json] do + = react_component :media_gallery, + autoplay: true, + height: 380, + media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer).as_json], + standalone: true do %video{ autoplay: 'autoplay', muted: 'muted', loop: 'loop' } %source{ src: @media_attachment.file.url(:original) } - elsif @media_attachment.audio? - = react_component :audio, src: @media_attachment.file.url(:original), poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url, backgroundColor: meta.dig('colors', 'background'), foregroundColor: meta.dig('colors', 'foreground'), accentColor: meta.dig('colors', 'accent'), width: 670, height: 380, fullscreen: true, alt: @media_attachment.description, duration: meta.dig(:original, :duration) do + = react_component :audio, + accentColor: meta.dig('colors', 'accent'), + alt: @media_attachment.description, + backgroundColor: meta.dig('colors', 'background'), + duration: meta.dig(:original, :duration), + foregroundColor: meta.dig('colors', 'foreground'), + fullscreen: true, + height: 380, + poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url, + src: @media_attachment.file.url(:original), + width: 670 do %audio{ controls: 'controls' } %source{ src: @media_attachment.file.url(:original) } From 742d8d30e2bdbd2bb42676fc8ab7ebf0ecf21966 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 10 Jan 2024 04:36:12 -0500 Subject: [PATCH 6/7] Add coverage for `--days` option to CLI `media refresh` command (#28669) --- spec/lib/mastodon/cli/media_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/lib/mastodon/cli/media_spec.rb b/spec/lib/mastodon/cli/media_spec.rb index 071bcd9e34..10005107aa 100644 --- a/spec/lib/mastodon/cli/media_spec.rb +++ b/spec/lib/mastodon/cli/media_spec.rb @@ -183,6 +183,21 @@ describe Mastodon::CLI::Media do .to output_results('Downloaded 1 media') end end + + context 'with --days option' do + before do + Fabricate(:media_attachment, remote_url: 'https://example.com/image.jpg', id: Mastodon::Snowflake.id_at(50.days.ago)) + Fabricate(:media_attachment, remote_url: 'https://example.com/image.jpg', id: Mastodon::Snowflake.id_at(5.days.ago)) + Fabricate(:media_attachment, remote_url: '', id: Mastodon::Snowflake.id_at(5.days.ago)) + end + + let(:options) { { days: 10 } } + + it 'redownloads the attachment file for the remote records more recent than the option' do + expect { subject } + .to output_results('Downloaded 1 media') + end + end end describe '#remove_orphans' do From 36b46ea3b5b4a4fb51cf1cd103b5a3c1103c300e Mon Sep 17 00:00:00 2001 From: zunda Date: Wed, 10 Jan 2024 09:37:31 +0000 Subject: [PATCH 7/7] bundle add csv (#28671) --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index e0980c0720..e096a5d685 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem 'omniauth', '~> 2.0' gem 'omniauth-rails_csrf_protection', '~> 1.0' gem 'color_diff', '~> 0.1' +gem 'csv', '~> 3.2' gem 'discard', '~> 1.2' gem 'doorkeeper', '~> 5.6' gem 'ed25519', '~> 1.3' diff --git a/Gemfile.lock b/Gemfile.lock index 91b3bf701f..595c9fd279 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -208,6 +208,7 @@ GEM crass (1.0.6) css_parser (1.14.0) addressable + csv (3.2.8) database_cleaner-active_record (2.1.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) @@ -845,6 +846,7 @@ DEPENDENCIES color_diff (~> 0.1) concurrent-ruby connection_pool + csv (~> 3.2) database_cleaner-active_record debug (~> 1.8) devise (~> 4.9)