diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 8ae69b7fe066d1..8da323f2786991 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,7 +20,7 @@ def update private def account_params - params.require(:account).permit(:display_name, :note, :avatar, :header, :bot, fields_attributes: [:name, :value]) + params.require(:account).permit(:display_name, :note, :avatar, :header, :bot, :account_css, fields_attributes: [:name, :value]) end def set_account diff --git a/app/javascript/flavours/glitch/initial_state.js b/app/javascript/flavours/glitch/initial_state.js index 47679a88ff7850..c5628f51ce475c 100644 --- a/app/javascript/flavours/glitch/initial_state.js +++ b/app/javascript/flavours/glitch/initial_state.js @@ -49,7 +49,6 @@ * @property {string} status_page_url * @property {boolean} system_emoji_font * @property {string} default_content_type - * @property {string} account_css */ /** @@ -146,9 +145,6 @@ export const pollLimits = (initialState && initialState.poll_limits); export const defaultContentType = getMeta('default_content_type'); export const useSystemEmojiFont = getMeta('system_emoji_font'); -// Neuromatchstodon-specific settings -export const accountCSS = getMeta('account_css'); - /** * @returns {string | undefined} */ diff --git a/app/javascript/flavours/glitch/styles/neuromatchstodon/myspace.scss b/app/javascript/flavours/glitch/styles/neuromatchstodon/myspace.scss index f09b7421a411b4..62b2b1c4dc42b9 100644 --- a/app/javascript/flavours/glitch/styles/neuromatchstodon/myspace.scss +++ b/app/javascript/flavours/glitch/styles/neuromatchstodon/myspace.scss @@ -1,3 +1,3 @@ -#user_settings_attributes_neuromatchstodon\.account_css { +#account_account_css { font-family: $font-monospace; } diff --git a/app/models/account.rb b/app/models/account.rb index c344a30bbe98b9..63845221c828f8 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -45,12 +45,13 @@ # avatar_storage_schema_version :integer # header_storage_schema_version :integer # devices_url :string -# suspension_origin :integer # sensitized_at :datetime +# suspension_origin :integer # trendable :boolean # reviewed_at :datetime # requested_review_at :datetime # indexable :boolean default(FALSE), not null +# account_css :text # class Account < ApplicationRecord diff --git a/app/models/concerns/user/has_settings.rb b/app/models/concerns/user/has_settings.rb index 47148278da7a5e..b79726e38aedf6 100644 --- a/app/models/concerns/user/has_settings.rb +++ b/app/models/concerns/user/has_settings.rb @@ -123,10 +123,6 @@ def setting_hide_followers_count settings['hide_followers_count'] end - def setting_account_css - settings['neuromatchstodon.account_css'] - end - def allows_report_emails? settings['notification_emails.report'] end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 618799037d6b8f..3b245a4e461941 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -61,10 +61,6 @@ class KeyError < Error; end setting :must_be_following_dm, default: false end - namespace :neuromatchstodon do - setting :account_css, default: nil - end - def initialize(original_hash) @original_hash = original_hash || {} end diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index f149a39364ee9d..d7ca2037e776ef 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -11,8 +11,9 @@ - @account.fields.select(&:verifiable?).each do |field| %link{ rel: 'me', type: 'text/html', href: field.value }/ - -# - if @account.user_setting_account_css? - %meta{ name: 'account_css', content: @account.user_setting_account_css } + - if @account.account_css? + %style{ nonce: request.content_security_policy_nonce } + = @account.account_css = opengraph 'og:type', 'profile' = render 'og', account: @account, url: short_account_url(@account, only_path: false) diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index 43d346fa33cb12..b0cd1cba09d63c 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -86,10 +86,5 @@ .fields-group = ff.input :'web.expand_content_warnings', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_expand_spoilers') - %h4= t 'appearance.myspace_mode' - - .fields-group - = ff.input :'neuromatchstodon.account_css', as: :text, wrapper: :with_block_label, label: I18n.t('simple_form.labels.defaults.setting_myspace_account_css'), hint: I18n.t('simple_form.hints.defaults.setting_myspace_account_css'), neuromatchstodon_only: true - .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 61ba79c4491f02..fc44f01402e1d1 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -67,5 +67,10 @@ .fields-group = f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot') + %h4= t 'edit_profile.myspace_mode' + + .fields-group + = f.input :account_css, as: :text, wrapper: :with_block_label, label: I18n.t('simple_form.labels.account.account_css'), hint: I18n.t('simple_form.hints.account.account_css'), neuromatchstodon_only: true + .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/config/locales/en.yml b/config/locales/en.yml index 3d18620fbd466c..dccc71a8b65e9c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1060,7 +1060,6 @@ en: guide_link: https://crowdin.com/project/mastodon guide_link_text: Everyone can contribute. sensitive_content: Sensitive content - myspace_mode: "MySpace Mode" application_mailer: notification_preferences: Change email preferences salutation: "%{name}," @@ -1237,6 +1236,7 @@ en: basic_information: Basic information hint_html: "Customize what people see on your public profile and next to your posts. Other people are more likely to follow you back and interact with you when you have a filled out profile and a profile picture." other: Other + myspace_mode: "MySpace Mode" errors: '400': The request you submitted was invalid or malformed. '403': You don't have permission to view this page. diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 07bf9b7fc05e4d..9300b0f862d076 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -10,6 +10,7 @@ en: note: 'You can @mention other people or #hashtags.' show_collections: People will be able to browse through your follows and followers. People that you follow will see that you follow them regardless. unlocked: People will be able to follow you without requesting approval. Uncheck if you want to review follow requests and chose whether to accept or reject new followers. + account_css: Custom CSS that is applied to your account page account_alias: acct: Specify the username@domain of the account you want to move from account_migration: @@ -63,7 +64,6 @@ en: setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed username: You can use letters, numbers, and underscores whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word - setting_myspace_account_css: Custom CSS that is applied to your account page domain_allow: domain: This domain will be able to fetch data from this server and incoming data from it will be processed and stored email_domain_block: @@ -151,6 +151,7 @@ en: indexable: Include public posts in search results show_collections: Show follows and followers on profile unlocked: Automatically accept new followers + account_css: Account CSS account_alias: acct: Handle of the old account account_migration: @@ -234,7 +235,6 @@ en: username: Username username_or_email: Username or Email whole_word: Whole word - setting_myspace_account_css: Account CSS email_domain_block: with_dns_records: Include MX records and IPs of the domain featured_tag: diff --git a/db/migrate/20240828084252_add_account_css_to_account.rb b/db/migrate/20240828084252_add_account_css_to_account.rb new file mode 100644 index 00000000000000..01a14f31f37a37 --- /dev/null +++ b/db/migrate/20240828084252_add_account_css_to_account.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddAccountCssToAccount < ActiveRecord::Migration[7.1] + def change + add_column :accounts, :account_css, :text, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index a3afab78167fe8..5ac44d4d653c3f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_08_08_125420) do +ActiveRecord::Schema[7.1].define(version: 2024_08_28_084252) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -200,6 +200,7 @@ t.datetime "reviewed_at", precision: nil t.datetime "requested_review_at", precision: nil t.boolean "indexable", default: false, null: false + t.text "account_css" t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true t.index ["domain", "id"], name: "index_accounts_on_domain_and_id" @@ -1428,9 +1429,9 @@ add_index "instances", ["domain"], name: "index_instances_on_domain", unique: true create_view "user_ips", sql_definition: <<-SQL - SELECT user_id, - ip, - max(used_at) AS used_at + SELECT t0.user_id, + t0.ip, + max(t0.used_at) AS used_at FROM ( SELECT users.id AS user_id, users.sign_up_ip AS ip, users.created_at AS used_at @@ -1447,7 +1448,7 @@ login_activities.created_at FROM login_activities WHERE (login_activities.success = true)) t0 - GROUP BY user_id, ip; + GROUP BY t0.user_id, t0.ip; SQL create_view "account_summaries", materialized: true, sql_definition: <<-SQL SELECT accounts.id AS account_id, @@ -1468,9 +1469,9 @@ add_index "account_summaries", ["account_id"], name: "index_account_summaries_on_account_id", unique: true create_view "global_follow_recommendations", materialized: true, sql_definition: <<-SQL - SELECT account_id, - sum(rank) AS rank, - array_agg(reason) AS reason + SELECT t0.account_id, + sum(t0.rank) AS rank, + array_agg(t0.reason) AS reason FROM ( SELECT account_summaries.account_id, ((count(follows.id))::numeric / (1.0 + (count(follows.id))::numeric)) AS rank, 'most_followed'::text AS reason @@ -1494,8 +1495,8 @@ WHERE (follow_recommendation_suppressions.account_id = statuses.account_id))))) GROUP BY account_summaries.account_id HAVING (sum((status_stats.reblogs_count + status_stats.favourites_count)) >= (5)::numeric)) t0 - GROUP BY account_id - ORDER BY (sum(rank)) DESC; + GROUP BY t0.account_id + ORDER BY (sum(t0.rank)) DESC; SQL add_index "global_follow_recommendations", ["account_id"], name: "index_global_follow_recommendations_on_account_id", unique: true