From: Thibaut Girka Date: Wed, 21 Oct 2020 17:10:50 +0000 (+0200) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=ec49aa81753ac71fa26b2ee86448fa5b481d49e4;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - `.github/dependabot.yml`: Updated upstream, we deleted it to not be flooded by Depandabot. Kept deleted. - `Gemfile.lock`: Puma updated on both sides, went for the most recent version. - `app/controllers/api/v1/mutes_controller.rb`: Upstream updated the serializer to support timed mutes, while glitch-soc added a custom API ages ago to get information that is already available elsewhere. Dropped the glitch-soc-specific API, went with upstream changes. - `app/javascript/core/admin.js`: Conflict due to changing how assets are loaded. Went with upstream. - `app/javascript/packs/public.js`: Conflict due to changing how assets are loaded. Went with upstream. - `app/models/mute.rb`: 🤷 - `app/models/user.rb`: New user setting added upstream while we have glitch-soc-specific user settings. Added upstream's user setting. - `config/settings.yml`: Upstream added a new user setting close to a user setting we had changed the defaults for. Added the new upstream setting. - `package.json`: Upstream dependency updated “too close” to a glitch-soc-specific dependency. No real conflict. Updated the dependency. --- ec49aa81753ac71fa26b2ee86448fa5b481d49e4 diff --cc app/controllers/settings/preferences_controller.rb index 87431f8cf,32b5d7948..d05ceb53f --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@@ -44,11 -43,11 +44,12 @@@ class Settings::PreferencesController :setting_display_media, :setting_expand_spoilers, :setting_reduce_motion, + :setting_disable_swiping, :setting_system_font_ui, + :setting_system_emoji_font, :setting_noindex, - :setting_theme, :setting_hide_network, + :setting_hide_followers_count, :setting_aggregate_reblogs, :setting_show_application, :setting_advanced_layout, diff --cc app/javascript/core/admin.js index f2334c254,65b8dc040..b9cc00d64 --- a/app/javascript/core/admin.js +++ b/app/javascript/core/admin.js @@@ -1,5 -1,4 +1,6 @@@ +// This file will be loaded on admin pages, regardless of theme. + + import './public-path'; import { delegate } from '@rails/ujs'; import ready from '../mastodon/ready'; diff --cc app/javascript/packs/public.js index 5ad25a9b0,39defa7ae..3f6700195 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@@ -1,3 -1,5 +1,4 @@@ + import './public-path'; -import escapeTextContentForBrowser from 'escape-html'; import loadPolyfills from '../mastodon/load_polyfills'; import ready from '../mastodon/ready'; import { start } from '../mastodon/common'; diff --cc app/lib/user_settings_decorator.rb index 2f9cfe3ad,e37bc6d9f..581101782 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@@ -28,12 -27,10 +28,13 @@@ class UserSettingsDecorato 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['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui') + user.settings['system_emoji_font'] = system_emoji_font_preference if change?('setting_system_emoji_font') user.settings['noindex'] = noindex_preference if change?('setting_noindex') - user.settings['theme'] = theme_preference if change?('setting_theme') + user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count') + user.settings['flavour'] = flavour_preference if change?('setting_flavour') + user.settings['skin'] = skin_preference if change?('setting_skin') 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') diff --cc app/models/mute.rb index 639120f7d,578345ef6..fe8b6f42c --- a/app/models/mute.rb +++ b/app/models/mute.rb @@@ -6,9 -6,10 +6,11 @@@ # id :bigint(8) not null, primary key # created_at :datetime not null # updated_at :datetime not null +# hide_notifications :boolean default(TRUE), not null # account_id :bigint(8) not null # target_account_id :bigint(8) not null + # hide_notifications :boolean default(TRUE), not null + # expires_at :datetime # class Mute < ApplicationRecord diff --cc app/models/user.rb index 6cd2ca6bd,7c8124fed..3dcfd820e --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -111,11 -112,11 +112,11 @@@ class User < ApplicationRecor has_many :session_activations, dependent: :destroy - delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal, - :reduce_motion, :system_font_ui, :noindex, :theme, :display_media, :hide_network, + delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal, + :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count, :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, - :default_content_type, :system_emoji_font, - :disable_swiping, ++ :disable_swiping, :default_content_type, :system_emoji_font, to: :settings, prefix: :setting, allow_nil: false attr_reader :invite_code, :sign_in_token_attempt diff --cc app/views/settings/preferences/appearance/show.html.haml index 5fc865814,14941d5fd..ccea2e9b7 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@@ -27,8 -30,8 +27,9 @@@ .fields-group = f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label, recommended: true = f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label + = f.input :setting_disable_swiping, as: :boolean, wrapper: :with_label = f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label + = f.input :setting_system_emoji_font, as: :boolean, wrapper: :with_label %h4= t 'appearance.toot_layout' diff --cc config/settings.yml index c61454e9e,217745f28..4d6a1cffc --- a/config/settings.yml +++ b/config/settings.yml @@@ -27,14 -26,11 +27,15 @@@ defaults: &default expand_spoilers: false preview_sensitive_media: false reduce_motion: false + disable_swiping: false - show_application: true + show_application: false system_font_ui: false + system_emoji_font: false noindex: false - theme: 'default' + hide_followers_count: false + enable_keybase: true + flavour: 'glitch' + skin: 'default' aggregate_reblogs: true advanced_layout: false use_blurhash: true diff --cc config/webpack/configuration.js index 926af9b39,e4f88a9c4..b34ba0e0a --- a/config/webpack/configuration.js +++ b/config/webpack/configuration.js @@@ -8,80 -7,21 +8,67 @@@ const glob = require('glob') const configPath = resolve('config', 'webpacker.yml'); const settings = safeLoad(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV]; +const flavourFiles = glob.sync('app/javascript/flavours/*/theme.yml'); +const skinFiles = glob.sync('app/javascript/skins/*/*'); +const flavours = {}; -const themePath = resolve('config', 'themes.yml'); -const themes = safeLoad(readFileSync(themePath), 'utf8'); +const core = function () { + const coreFile = resolve('app', 'javascript', 'core', 'theme.yml'); + const data = safeLoad(readFileSync(coreFile), 'utf8'); + if (!data.pack_directory) { + data.pack_directory = dirname(coreFile); + } + return data.pack ? data : {}; +}(); + +for (let i = 0; i < flavourFiles.length; i++) { + const flavourFile = flavourFiles[i]; + const data = safeLoad(readFileSync(flavourFile), 'utf8'); + data.name = basename(dirname(flavourFile)); + data.skin = {}; + if (!data.pack_directory) { + data.pack_directory = dirname(flavourFile); + } + if (data.locales) { + data.locales = join(dirname(flavourFile), data.locales); + } + if (data.pack && typeof data.pack === 'object') { + flavours[data.name] = data; + } +} + +for (let i = 0; i < skinFiles.length; i++) { + const skinFile = skinFiles[i]; + let skin = basename(skinFile); + const name = basename(dirname(skinFile)); + if (!flavours[name]) { + continue; + } + const data = flavours[name].skin; + if (lstatSync(skinFile).isDirectory()) { + data[skin] = {}; + const skinPacks = glob.sync(join(skinFile, '*.{css,scss}')); + for (let j = 0; j < skinPacks.length; j++) { + const pack = skinPacks[j]; + data[skin][basename(pack, extname(pack))] = pack; + } + } else if ((skin = skin.match(/^(.*)\.s?css$/i))) { + data[skin[1]] = { common: skinFile }; + } +} - function removeOuterSlashes(string) { - return string.replace(/^\/*/, '').replace(/\/*$/, ''); - } - - function formatPublicPath(host = '', path = '') { - let formattedHost = removeOuterSlashes(host); - if (formattedHost && !/^http/i.test(formattedHost)) { - formattedHost = `//${formattedHost}`; - } - const formattedPath = removeOuterSlashes(path); - return `${formattedHost}/${formattedPath}/`; - } - const output = { path: resolve('public', settings.public_output_path), - publicPath: formatPublicPath(env.CDN_HOST, settings.public_output_path), + publicPath: `/${settings.public_output_path}/`, }; module.exports = { settings, - themes, + core, + flavours, env: { - CDN_HOST: env.CDN_HOST, NODE_ENV: env.NODE_ENV, + PUBLIC_OUTPUT_PATH: settings.public_output_path, }, output, }; diff --cc package.json index 30dfbc471,833bfe794..5d07f31a5 --- a/package.json +++ b/package.json @@@ -70,10 -69,9 +70,10 @@@ "@babel/runtime": "^7.11.2", "@clusterws/cws": "^3.0.0", "@gamestdio/websocket": "^0.3.2", - "@github/webauthn-json": "^0.5.4", + "@github/webauthn-json": "^0.5.6", "@rails/ujs": "^6.0.3", "array-includes": "^3.1.1", + "atrament": "0.2.4", "arrow-key-navigation": "^1.2.0", "autoprefixer": "^9.8.6", "axios": "^0.20.0", @@@ -96,8 -94,7 +96,8 @@@ "escape-html": "^1.0.3", "exif-js": "^2.3.0", "express": "^4.17.1", + "favico.js": "^0.3.10", - "file-loader": "^6.1.0", + "file-loader": "^6.1.1", "font-awesome": "^4.7.0", "glob": "^7.1.6", "history": "^4.10.1",