Browse Source

add setting for round profile pics

main
Lerk 1 month ago
parent
commit
109b115bf4
  1. 1
      app/controllers/settings/preferences_controller.rb
  2. 6
      app/javascript/mastodon/components/avatar.js
  3. 1
      app/javascript/mastodon/initial_state.js
  4. 4
      app/javascript/styles/mastodon/_mixins.scss
  5. 55
      app/lib/user_settings_decorator.rb
  6. 2
      app/models/user.rb
  7. 1
      app/serializers/initial_state_serializer.rb
  8. 1
      app/views/settings/preferences/appearance/show.html.haml
  9. 1
      config/locales/simple_form.de.yml
  10. 1
      config/locales/simple_form.en.yml
  11. 1
      config/settings.yml
  12. 2
      db/structure.sql
  13. 2
      spec/lib/settings/scoped_settings_spec.rb

1
app/controllers/settings/preferences_controller.rb

@ -52,6 +52,7 @@ class Settings::PreferencesController < Settings::BaseController
:setting_aggregate_reblogs,
:setting_show_application,
:setting_advanced_layout,
:setting_rounded_profile_pics,
:setting_use_blurhash,
:setting_use_pending_items,
:setting_trends,

6
app/javascript/mastodon/components/avatar.js

@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { autoPlayGif } from '../initial_state';
import { autoPlayGif, roundedProfilePics } from '../initial_state';
export default class Avatar extends React.PureComponent {
@ -42,6 +42,10 @@ export default class Avatar extends React.PureComponent {
let className = 'account__avatar';
if(roundedProfilePics) {
className += ' rounded';
}
if (inline) {
className = className + ' account__avatar-inline';
}

1
app/javascript/mastodon/initial_state.js

@ -19,6 +19,7 @@ export const version = getMeta('version');
export const mascot = getMeta('mascot');
export const profile_directory = getMeta('profile_directory');
export const isStaff = getMeta('is_staff');
export const roundedProfilePics = getMeta('rounded_profile_pics');
export const forceSingleColumn = !getMeta('advanced_layout');
export const useBlurhash = getMeta('use_blurhash');
export const usePendingItems = getMeta('use_pending_items');

4
app/javascript/styles/mastodon/_mixins.scss

@ -3,6 +3,10 @@
background: transparent no-repeat;
background-position: 50%;
background-clip: padding-box;
&.rounded {
border-radius: 100%;
}
}
@mixin avatar-size($size: 48px) {

55
app/lib/user_settings_decorator.rb

@ -15,31 +15,32 @@ class UserSettingsDecorator
private
def process_update
user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
user.settings['interactions'] = merged_interactions if change?('interactions')
user.settings['default_privacy'] = default_privacy_preference if change?('setting_default_privacy')
user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive')
user.settings['default_language'] = default_language_preference if change?('setting_default_language')
user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal')
user.settings['boost_modal'] = boost_modal_preference if change?('setting_boost_modal')
user.settings['delete_modal'] = delete_modal_preference if change?('setting_delete_modal')
user.settings['auto_play_gif'] = auto_play_gif_preference if change?('setting_auto_play_gif')
user.settings['display_media'] = display_media_preference if change?('setting_display_media')
user.settings['expand_spoilers'] = expand_spoilers_preference if change?('setting_expand_spoilers')
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
user.settings['disable_swiping'] = disable_swiping_preference if change?('setting_disable_swiping')
user.settings['show_preferred_theme'] = show_preferred_theme_preference if change?('setting_show_preferred_theme')
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
user.settings['theme'] = theme_preference if change?('setting_theme')
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout')
user.settings['use_blurhash'] = use_blurhash_preference if change?('setting_use_blurhash')
user.settings['use_pending_items'] = use_pending_items_preference if change?('setting_use_pending_items')
user.settings['trends'] = trends_preference if change?('setting_trends')
user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images')
user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
user.settings['interactions'] = merged_interactions if change?('interactions')
user.settings['default_privacy'] = default_privacy_preference if change?('setting_default_privacy')
user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive')
user.settings['default_language'] = default_language_preference if change?('setting_default_language')
user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal')
user.settings['boost_modal'] = boost_modal_preference if change?('setting_boost_modal')
user.settings['delete_modal'] = delete_modal_preference if change?('setting_delete_modal')
user.settings['auto_play_gif'] = auto_play_gif_preference if change?('setting_auto_play_gif')
user.settings['display_media'] = display_media_preference if change?('setting_display_media')
user.settings['expand_spoilers'] = expand_spoilers_preference if change?('setting_expand_spoilers')
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
user.settings['disable_swiping'] = disable_swiping_preference if change?('setting_disable_swiping')
user.settings['show_preferred_theme'] = show_preferred_theme_preference if change?('setting_show_preferred_theme')
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
user.settings['theme'] = theme_preference if change?('setting_theme')
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout')
user.settings['rounded_profile_pics'] = rounded_profile_pics_preference if change?('setting_rounded_profile_pics')
user.settings['use_blurhash'] = use_blurhash_preference if change?('setting_use_blurhash')
user.settings['use_pending_items'] = use_pending_items_preference if change?('setting_use_pending_items')
user.settings['trends'] = trends_preference if change?('setting_trends')
user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images')
end
def merged_notification_emails
@ -126,6 +127,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_advanced_layout'
end
def rounded_profile_pics_preference
boolean_cast_setting 'setting_rounded_profile_pics'
end
def use_blurhash_preference
boolean_cast_setting 'setting_use_blurhash'
end

2
app/models/user.rb

@ -123,7 +123,7 @@ class User < ApplicationRecord
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
:reduce_motion, :system_font_ui, :show_preferred_theme, :noindex, :theme, :display_media, :hide_network,
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :rounded_profile_pics,
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
:disable_swiping,
to: :settings, prefix: :setting, allow_nil: false

1
app/serializers/initial_state_serializer.rb

@ -39,6 +39,7 @@ 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[:is_staff] = object.current_account.user.staff?
store[:rounded_profile_pics] = object.current_account.user.setting_rounded_profile_pics
store[:trends] = Setting.trends && object.current_account.user.setting_trends
store[:crop_images] = object.current_account.user.setting_crop_images
else

1
app/views/settings/preferences/appearance/show.html.haml

@ -26,6 +26,7 @@
.fields-group
= f.input :setting_show_preferred_theme, as: :boolean, wrapper: :with_label, recommended: true
= f.input :setting_rounded_profile_pics, as: :boolean, wrapper: :with_label
%h4= t 'appearance.animations_and_accessibility'

1
config/locales/simple_form.de.yml

@ -165,6 +165,7 @@ de:
setting_hide_network: Netzwerk ausblenden
setting_noindex: Suchmaschinen-Indexierung verhindern
setting_reduce_motion: Bewegung in Animationen verringern
setting_rounded_profile_pics: Runde Profilfotos
setting_show_application: Anwendung preisgeben, die benutzt wurde um Beiträge zu versenden
setting_system_font_ui: Standardschriftart des Systems verwenden
setting_show_preferred_theme: Persönliches Theme auf öffentlichen Seiten anzeigen

1
config/locales/simple_form.en.yml

@ -148,6 +148,7 @@ en:
password: Password
phrase: Keyword or phrase
setting_advanced_layout: Enable advanced web interface
setting_rounded_profile_pics: Round profile pictures
setting_aggregate_reblogs: Group boosts in timelines
setting_auto_play_gif: Auto-play animated GIFs
setting_boost_modal: Show confirmation dialog before boosting

1
config/settings.yml

@ -33,6 +33,7 @@ defaults: &defaults
theme: 'default'
aggregate_reblogs: true
advanced_layout: false
rounded_profile_pics: false
use_blurhash: true
use_pending_items: false
trends: true

2
db/structure.sql

@ -32,7 +32,7 @@ CREATE FUNCTION public.timestamp_id(table_name text) RETURNS bigint
-- Take the first two bytes (four hex characters)
substr(
-- Of the MD5 hash of the data we documented
md5(table_name || 'a3cd7ef72e078abf228bd9290dcf0edb' || time_part::text),
md5(table_name || '6ebe4466a61d3b70868efdbe3af54590' || time_part::text),
1, 4
)
-- And turn it into a bigint

2
spec/lib/settings/scoped_settings_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Settings::ScopedSettings do
let(:object) { Fabricate(:user) }
let(:scoped_setting) { described_class.new(object) }
let(:val) { 'whatever' }
let(:methods) { %i(auto_play_gif default_sensitive unfollow_modal boost_modal delete_modal reduce_motion show_preferred_theme system_font_ui noindex theme) }
let(:methods) { %i(auto_play_gif default_sensitive unfollow_modal boost_modal delete_modal reduce_motion show_preferred_theme rounded_profile_pics system_font_ui noindex theme) }
describe '.initialize' do
it 'sets @object' do

Loading…
Cancel
Save