From 1c6d88fc313e78bc01417280c91928c215532fec Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 21 Sep 2023 12:48:05 -0500 Subject: [PATCH] Remove strip-formatting patch --- app/helpers/statuses_helper.rb | 11 -- .../styles/mastodon/components.scss | 173 +----------------- app/models/concerns/has_user_settings.rb | 4 - app/serializers/initial_state_serializer.rb | 2 - .../rest/preferences_serializer.rb | 5 - .../preferences/appearance/show.html.haml | 1 - app/views/statuses/_detailed_status.html.haml | 2 +- app/views/statuses/_simple_status.html.haml | 2 +- config/locales/en-DG.yml | 7 - config/locales/en-LN.yml | 7 - config/locales/en-SQ.yml | 7 - config/locales/simple_form.en-DG.yml | 1 - config/locales/simple_form.en-LN.yml | 1 - config/locales/simple_form.en-SQ.yml | 1 - config/settings.yml | 1 - .../20230215074423_move_user_settings.rb | 1 - lib/sanitize_ext/sanitize_config.rb | 5 +- 17 files changed, 4 insertions(+), 227 deletions(-) diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb index 38bb31f0e..286c53d83 100644 --- a/app/helpers/statuses_helper.rb +++ b/app/helpers/statuses_helper.rb @@ -65,17 +65,6 @@ module StatusesHelper embedded_view? ? '_blank' : nil end - def text_formatting_classes - case current_user&.setting_strip_formatting - when 'none', nil - 'rich-text rich-blocks' - when 'blocks' - 'rich-text' - when 'all' - nil - end - end - def fa_visibility_icon(status) case status.visibility when 'public' diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 625c38579..418a9cfea 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -835,9 +835,7 @@ body > [data-popper-placement] { margin: -3px 0 0; } - p, - pre, - blockquote { + p { margin-bottom: 22px; white-space: pre-wrap; unicode-bidi: plaintext; @@ -847,175 +845,6 @@ body > [data-popper-placement] { } } - h1, - h2, - h3, - h4, - h5 { - margin-bottom: 20px; - } - - blockquote { - white-space: normal; - - p:last-child { - margin-bottom: 0; - } - } - - ul, - ol { - p { - margin-bottom: 0; - } - } - - &:not(.rich-text) { - del { - text-decoration: none; - - &::before, - &::after { - content: '~~'; - } - } - - code { - font-family: inherit; - } - - u { - text-decoration: none; - - &::before, - &::after { - content: '__'; - } - } - - h1::before { - content: '# '; - } - - h2::before { - content: '## '; - } - - h3::before { - content: '### '; - } - - h4::before { - content: '#### '; - } - - h5::before { - content: '##### '; - } - - b, - strong { - &::before, - &::after { - content: '**'; - } - } - - em, - i { - &::before, - &::after { - content: '*'; - } - } - } - - &:not(.rich-blocks) { - blockquote { - position: relative; - padding-left: 1em; - overflow: hidden; - } - - blockquote::before { - position: absolute; - content: '>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a>\a'; - white-space: pre-wrap; - left: 0; - top: 0; - } - - li::before { - position: absolute; - content: '*'; - left: 0; - top: 0; - } - - li { - position: relative; - padding-left: 1em; - } - } - - &.rich-text { - h1, - h2 { - font-weight: 700; - } - - h3, - h4, - h5 { - font-weight: 500; - } - - b, - strong { - font-weight: 700; - } - - em, - i { - font-style: italic; - } - - sub { - font-size: smaller; - text-align: sub; - } - } - - &.rich-blocks { - h1, - h2 { - font-size: 18px; - } - - h2 { - font-size: 16px; - } - - blockquote { - padding-left: 10px; - border-left: 3px solid $darker-text-color; - color: $darker-text-color; - } - - ul, - ol { - margin-left: 1em; - } - - ul { - list-style-type: disc; - } - - ol { - list-style-type: decimal; - } - } - a { color: $secondary-text-color; text-decoration: none; diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb index 948b1a962..5d05019f6 100644 --- a/app/models/concerns/has_user_settings.rb +++ b/app/models/concerns/has_user_settings.rb @@ -23,10 +23,6 @@ module HasUserSettings settings['web.auto_play'] end - def setting_strip_formatting - settings['strip_formatting'] - end - def setting_default_sensitive settings['default_sensitive'] end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 2439962ed..b707d6fcb 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -51,13 +51,11 @@ class InitialStateSerializer < ActiveModel::Serializer store[:use_blurhash] = object.current_account.user.setting_use_blurhash store[:use_pending_items] = object.current_account.user.setting_use_pending_items store[:show_trends] = Setting.trends && object.current_account.user.setting_trends - store[:strip_formatting] = object.current_account.user.setting_strip_formatting else store[:auto_play_gif] = Setting.auto_play_gif store[:display_media] = Setting.display_media store[:reduce_motion] = Setting.reduce_motion store[:use_blurhash] = Setting.use_blurhash - store[:strip_formatting] = Setting.strip_formatting end store[:disabled_account_id] = object.disabled_account.id.to_s if object.disabled_account diff --git a/app/serializers/rest/preferences_serializer.rb b/app/serializers/rest/preferences_serializer.rb index fcebc0c77..e1c654460 100644 --- a/app/serializers/rest/preferences_serializer.rb +++ b/app/serializers/rest/preferences_serializer.rb @@ -8,7 +8,6 @@ class REST::PreferencesSerializer < ActiveModel::Serializer attribute :reading_default_sensitive_media, key: 'reading:expand:media' attribute :reading_default_sensitive_text, key: 'reading:expand:spoilers' attribute :reading_autoplay_gifs, key: 'reading:autoplay:gifs' - attribute :reading_strip_formatting, key: 'reading:formatting:strip' def posting_default_privacy object.user.setting_default_privacy @@ -33,8 +32,4 @@ class REST::PreferencesSerializer < ActiveModel::Serializer def reading_autoplay_gifs object.user.setting_auto_play_gif end - - def reading_strip_formatting - object.user.setting_strip_formatting - end end diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index 7331b1957..ea33487c3 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -36,7 +36,6 @@ = ff.input :'web.reduce_motion', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_reduce_motion') = ff.input :'web.disable_swiping', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_disable_swiping') = ff.input :'web.use_system_font', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_system_font_ui') - = ff.input :strip_formatting, collection: ['none', 'blocks', 'all'], wrapper: :with_floating_label, include_blank: false, label_method: lambda { |value| safe_join([I18n.t("statuses.strip_formatting.#{value}"), content_tag(:span, I18n.t("statuses.strip_formatting.#{value}_long"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', hint: false %h4= t 'appearance.discovery' diff --git a/app/views/statuses/_detailed_status.html.haml b/app/views/statuses/_detailed_status.html.haml index 7af11407c..70cfbd6b8 100644 --- a/app/views/statuses/_detailed_status.html.haml +++ b/app/views/statuses/_detailed_status.html.haml @@ -15,7 +15,7 @@ = account_action_button(status.account) - .status__content.emojify{ class: text_formatting_classes, data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }< + .status__content.emojify{ data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }< - if status.spoiler_text? %p< %span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}  diff --git a/app/views/statuses/_simple_status.html.haml b/app/views/statuses/_simple_status.html.haml index 1670a6662..32584c92a 100644 --- a/app/views/statuses/_simple_status.html.haml +++ b/app/views/statuses/_simple_status.html.haml @@ -27,7 +27,7 @@ %span.display-name__account = acct(status.account) = fa_icon('lock') if status.account.locked? - .status__content.emojify{ class: text_formatting_classes, data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }< + .status__content.emojify{ data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }< - if status.spoiler_text? %p< %span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}  diff --git a/config/locales/en-DG.yml b/config/locales/en-DG.yml index 4d995c6dc..3febaeb32 100644 --- a/config/locales/en-DG.yml +++ b/config/locales/en-DG.yml @@ -1541,13 +1541,6 @@ en-DG: show_older: Show older show_thread: Show thread sign_in_to_participate: Sign in to participate in the conversation - strip_formatting: - all: All - all_long: Strip all advanced formatting - blocks: Block elements - blocks_long: Strip formatting for title headers and block quotes - none: None - none_long: Do not strip any formatting supported by Mastodon title: '%{name}: "%{quote}"' visibilities: direct: Direct diff --git a/config/locales/en-LN.yml b/config/locales/en-LN.yml index aecb0398f..f26f865fb 100644 --- a/config/locales/en-LN.yml +++ b/config/locales/en-LN.yml @@ -1541,13 +1541,6 @@ en-LN: show_older: Show older show_thread: Show thread sign_in_to_participate: Sign in to participate in the conversation - strip_formatting: - all: All - all_long: Strip all advanced formatting - blocks: Block elements - blocks_long: Strip formatting for title headers and block quotes - none: None - none_long: Do not strip any formatting supported by Mastodon title: '%{name}: "%{quote}"' visibilities: direct: Direct diff --git a/config/locales/en-SQ.yml b/config/locales/en-SQ.yml index 6bc5b0319..f5a144142 100644 --- a/config/locales/en-SQ.yml +++ b/config/locales/en-SQ.yml @@ -1541,13 +1541,6 @@ en-SQ: show_older: Show older show_thread: Show thread sign_in_to_participate: Sign in to participate in the conversation - strip_formatting: - all: All - all_long: Strip all advanced formatting - blocks: Block elements - blocks_long: Strip formatting for title headers and block quotes - none: None - none_long: Do not strip any formatting supported by Mastodon title: '%{name}: "%{quote}"' visibilities: direct: Direct diff --git a/config/locales/simple_form.en-DG.yml b/config/locales/simple_form.en-DG.yml index 2f7132b86..4a9e23bdc 100644 --- a/config/locales/simple_form.en-DG.yml +++ b/config/locales/simple_form.en-DG.yml @@ -211,7 +211,6 @@ en-DG: setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations setting_show_application: Disclose application used to send toots - setting_strip_formatting: Strip formatting setting_system_font_ui: Use system's default font setting_theme: Site theme setting_trends: Show today's trends diff --git a/config/locales/simple_form.en-LN.yml b/config/locales/simple_form.en-LN.yml index 954b9f13e..92054e512 100644 --- a/config/locales/simple_form.en-LN.yml +++ b/config/locales/simple_form.en-LN.yml @@ -211,7 +211,6 @@ en-LN: setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations setting_show_application: Disclose application used to send toots - setting_strip_formatting: Strip formatting setting_system_font_ui: Use system's default font setting_theme: Site theme setting_trends: Show today's trends diff --git a/config/locales/simple_form.en-SQ.yml b/config/locales/simple_form.en-SQ.yml index 37a54311b..f12977a28 100644 --- a/config/locales/simple_form.en-SQ.yml +++ b/config/locales/simple_form.en-SQ.yml @@ -211,7 +211,6 @@ en-SQ: setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations setting_show_application: Disclose application used to send toots - setting_strip_formatting: Strip formatting setting_system_font_ui: Use system's default font setting_theme: Site theme setting_trends: Show today's trends diff --git a/config/settings.yml b/config/settings.yml index 54a638643..67297c26c 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -20,7 +20,6 @@ defaults: &defaults trends: true trends_as_landing_page: true trendable_by_default: false - strip_formatting: 'none' reserved_usernames: - admin - support diff --git a/db/migrate/20230215074423_move_user_settings.rb b/db/migrate/20230215074423_move_user_settings.rb index 7031def51..27caac101 100644 --- a/db/migrate/20230215074423_move_user_settings.rb +++ b/db/migrate/20230215074423_move_user_settings.rb @@ -22,7 +22,6 @@ class MoveUserSettings < ActiveRecord::Migration[6.1] disable_swiping: 'web.disable_swiping', show_application: 'show_application', system_font_ui: 'web.use_system_font', - strip_formatting: 'strip_formatting', aggregate_reblogs: 'aggregate_reblogs', advanced_layout: 'web.advanced_layout', use_blurhash: 'web.use_blurhash', diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index ab9dbcfc3..bdb4c56a0 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -81,10 +81,7 @@ class Sanitize }, }, - protocols: { - 'a' => { 'href' => HTTP_PROTOCOLS }, - 'blockquote' => { 'cite' => HTTP_PROTOCOLS }, - }, + protocols: {}, transformers: [ CLASS_WHITELIST_TRANSFORMER,