Custom splash icons!

This commit is contained in:
ThatOneCalculator 2022-07-27 10:25:30 -07:00
parent 4644065f1a
commit 690b03979b
11 changed files with 81 additions and 3 deletions

View File

@ -903,7 +903,8 @@ enterSendsMessage: "Press Return in Messaging to send message (off is Ctrl + Ret
adminCustomCssWarn: "This setting should only be used if you know what it does. Entering improper values may cause EVERYONE'S clients to stop functioning normally. Please ensure your CSS works properly by testing it in your user settings." adminCustomCssWarn: "This setting should only be used if you know what it does. Entering improper values may cause EVERYONE'S clients to stop functioning normally. Please ensure your CSS works properly by testing it in your user settings."
customMOTD: "Custom MOTD (splash screen messages)" customMOTD: "Custom MOTD (splash screen messages)"
customMOTDDescription: "Custom messages for the MOTD (splash screen) separated by line breaks to be shown randomly every time a user loads/reloads the page." customMOTDDescription: "Custom messages for the MOTD (splash screen) separated by line breaks to be shown randomly every time a user loads/reloads the page."
customSplashIcons: "Custom splash screen icons (urls)"
customSplashIconsDescription: "URLs for custom splash screen icons separated by line breaks to be shown randomly every time a user loads/reloads the page. Please make sure the images are on a static URL, preferably all resized to 192x192."
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server."

View File

@ -903,6 +903,8 @@ move: "移動"
adminCustomCssWarn: "この設定は、それが何をするものであるかを知っている場合のみ使用してください。不適切な値を入力すると、クライアントが正常に動作しなくなる可能性があります。ユーザー設定でCSSをテストし、正しく動作することを確認してください。" adminCustomCssWarn: "この設定は、それが何をするものであるかを知っている場合のみ使用してください。不適切な値を入力すると、クライアントが正常に動作しなくなる可能性があります。ユーザー設定でCSSをテストし、正しく動作することを確認してください。"
customMOTD: "カスタムMOTDスプラッシュスクリーンメッセージ" customMOTD: "カスタムMOTDスプラッシュスクリーンメッセージ"
customMOTDDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたMOTDスプラッシュスクリーン用のカスタムメッセージ" customMOTDDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたMOTDスプラッシュスクリーン用のカスタムメッセージ"
customSplashIcons: "カスタムスプラッシュスクリーンアイコン"
customSplashIconsDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたカスタムスプラッシュスクリーンアイコンの URL。画像は静的なURLで、できればすべて192x192にリサイズしてください。"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。"

View File

@ -0,0 +1,8 @@
export class CustomSplashIcons1658941974648 {
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "customSplashIcons" character varying(256) array NOT NULL DEFAULT '{}'::varchar[]`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "customSplashIcons"`);
}
}

View File

@ -72,6 +72,11 @@ export class Meta {
}) })
public customMOTD: string[]; public customMOTD: string[];
@Column('varchar', {
length: 256, array: true, default: '{}',
})
public customSplashIcons: string[];
@Column('varchar', { @Column('varchar', {
length: 256, array: true, default: '{}', length: 256, array: true, default: '{}',
}) })

View File

@ -269,6 +269,7 @@ import * as ep___pages_update from './endpoints/pages/update.js';
import * as ep___ping from './endpoints/ping.js'; import * as ep___ping from './endpoints/ping.js';
import * as ep___pinnedUsers from './endpoints/pinned-users.js'; import * as ep___pinnedUsers from './endpoints/pinned-users.js';
import * as ep___customMOTD from './endpoints/custom-motd.js'; import * as ep___customMOTD from './endpoints/custom-motd.js';
import * as ep___customSplashIcons from './endpoints/custom-splash-icons.js';
import * as ep___promo_read from './endpoints/promo/read.js'; import * as ep___promo_read from './endpoints/promo/read.js';
import * as ep___requestResetPassword from './endpoints/request-reset-password.js'; import * as ep___requestResetPassword from './endpoints/request-reset-password.js';
import * as ep___resetDb from './endpoints/reset-db.js'; import * as ep___resetDb from './endpoints/reset-db.js';
@ -587,6 +588,7 @@ const eps = [
['ping', ep___ping], ['ping', ep___ping],
['pinned-users', ep___pinnedUsers], ['pinned-users', ep___pinnedUsers],
['custom-motd', ep___customMOTD], ['custom-motd', ep___customMOTD],
['custom-motd', ep___customSplashIcons],
['promo/read', ep___promo_read], ['promo/read', ep___promo_read],
['request-reset-password', ep___requestResetPassword], ['request-reset-password', ep___requestResetPassword],
['reset-db', ep___resetDb], ['reset-db', ep___resetDb],

View File

@ -179,6 +179,14 @@ export const meta = {
optional: false, nullable: false, optional: false, nullable: false,
}, },
}, },
customSplashIcons: {
type: 'array',
optional: true, nullable: false,
items: {
type: 'string',
optional: false, nullable: false,
},
},
hiddenTags: { hiddenTags: {
type: 'array', type: 'array',
optional: true, nullable: false, optional: true, nullable: false,
@ -411,6 +419,7 @@ export default define(meta, paramDef, async (ps, me) => {
useStarForReactionFallback: instance.useStarForReactionFallback, useStarForReactionFallback: instance.useStarForReactionFallback,
pinnedUsers: instance.pinnedUsers, pinnedUsers: instance.pinnedUsers,
customMOTD: instance.customMOTD, customMOTD: instance.customMOTD,
customSplashIcons: instance.customSplashIcons,
hiddenTags: instance.hiddenTags, hiddenTags: instance.hiddenTags,
blockedHosts: instance.blockedHosts, blockedHosts: instance.blockedHosts,
allowedHosts: instance.allowedHosts, allowedHosts: instance.allowedHosts,

View File

@ -24,6 +24,9 @@ export const paramDef = {
customMOTD: { type: 'array', nullable: true, items: { customMOTD: { type: 'array', nullable: true, items: {
type: 'string', type: 'string',
} }, } },
customSplashIcons: { type: 'array', nullable: true, items: {
type: 'string',
} },
hiddenTags: { type: 'array', nullable: true, items: { hiddenTags: { type: 'array', nullable: true, items: {
type: 'string', type: 'string',
} }, } },
@ -142,6 +145,10 @@ export default define(meta, paramDef, async (ps, me) => {
set.customMOTD = ps.customMOTD.filter(Boolean); set.customMOTD = ps.customMOTD.filter(Boolean);
} }
if (Array.isArray(ps.customSplashIcons)) {
set.customSplashIcons = ps.customSplashIcons.filter(Boolean);
}
if (Array.isArray(ps.hiddenTags)) { if (Array.isArray(ps.hiddenTags)) {
set.hiddenTags = ps.hiddenTags.filter(Boolean); set.hiddenTags = ps.hiddenTags.filter(Boolean);
} }

View File

@ -19,7 +19,7 @@ export const meta = {
} as const; } as const;
export const paramDef = { export const paramDef = {
type: 'array', type: 'object',
properties: {}, properties: {},
required: [], required: [],
} as const; } as const;

View File

@ -0,0 +1,32 @@
// import { IsNull } from 'typeorm';
import { fetchMeta } from '@/misc/fetch-meta.js';
import define from '../define.js';
export const meta = {
tags: ['meta'],
requireCredential: false,
requireCredentialPrivateMode: true,
res: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
optional: false, nullable: false,
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async () => {
const meta = await fetchMeta();
const icons = await Promise.all(meta.customSplashIcons.map(x => x));
return icons;
});

View File

@ -530,12 +530,16 @@ router.get('(.*)', async ctx => {
if (meta.customMOTD.length > 0) { if (meta.customMOTD.length > 0) {
motd = meta.customMOTD; motd = meta.customMOTD;
} }
let iconUrl = meta.iconUrl;
if (meta.customSplashIcons.length > 0) {
iconUrl = meta.customSplashIcons[Math.floor(Math.random() * meta.customSplashIcons.length)];
}
await ctx.render('base', { await ctx.render('base', {
img: meta.bannerUrl, img: meta.bannerUrl,
title: meta.name || 'Calckey', title: meta.name || 'Calckey',
instanceName: meta.name || 'Calckey', instanceName: meta.name || 'Calckey',
desc: meta.description, desc: meta.description,
icon: meta.iconUrl, icon: iconUrl,
themeColor: meta.themeColor, themeColor: meta.themeColor,
privateMode: meta.privateMode, privateMode: meta.privateMode,
randomMOTD: motd[Math.floor(Math.random() * motd.length)], randomMOTD: motd[Math.floor(Math.random() * motd.length)],

View File

@ -39,6 +39,11 @@
<template #caption>{{ i18n.ts.customMOTDDescription }}</template> <template #caption>{{ i18n.ts.customMOTDDescription }}</template>
</FormTextarea> </FormTextarea>
<FormTextarea v-model="customSplashIcons" class="_formBlock">
<template #label>{{ i18n.ts.customSplashIcons }}</template>
<template #caption>{{ i18n.ts.customSplashIconsDescription }}</template>
</FormTextarea>
<FormSection> <FormSection>
<FormSwitch v-model="enableRegistration" class="_formBlock"> <FormSwitch v-model="enableRegistration" class="_formBlock">
<template #label>{{ i18n.ts.enableRegistration }}</template> <template #label>{{ i18n.ts.enableRegistration }}</template>
@ -182,6 +187,7 @@ let enableLocalTimeline: boolean = $ref(false);
let enableGlobalTimeline: boolean = $ref(false); let enableGlobalTimeline: boolean = $ref(false);
let pinnedUsers: string = $ref(''); let pinnedUsers: string = $ref('');
let customMOTD: string = $ref(''); let customMOTD: string = $ref('');
let customSplashIcons: string = $ref('');
let cacheRemoteFiles: boolean = $ref(false); let cacheRemoteFiles: boolean = $ref(false);
let localDriveCapacityMb: any = $ref(0); let localDriveCapacityMb: any = $ref(0);
let remoteDriveCapacityMb: any = $ref(0); let remoteDriveCapacityMb: any = $ref(0);
@ -210,6 +216,7 @@ async function init() {
enableGlobalTimeline = !meta.disableGlobalTimeline; enableGlobalTimeline = !meta.disableGlobalTimeline;
pinnedUsers = meta.pinnedUsers.join('\n'); pinnedUsers = meta.pinnedUsers.join('\n');
customMOTD = meta.customMOTD.join('\n'); customMOTD = meta.customMOTD.join('\n');
customSplashIcons = meta.customSplashIcons.join('\n');
cacheRemoteFiles = meta.cacheRemoteFiles; cacheRemoteFiles = meta.cacheRemoteFiles;
localDriveCapacityMb = meta.driveCapacityPerLocalUserMb; localDriveCapacityMb = meta.driveCapacityPerLocalUserMb;
remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb; remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb;
@ -239,6 +246,7 @@ function save() {
disableGlobalTimeline: !enableGlobalTimeline, disableGlobalTimeline: !enableGlobalTimeline,
pinnedUsers: pinnedUsers.split('\n'), pinnedUsers: pinnedUsers.split('\n'),
customMOTD: customMOTD.split('\n'), customMOTD: customMOTD.split('\n'),
customSplashIcons: customSplashIcons.split('\n'),
cacheRemoteFiles, cacheRemoteFiles,
localDriveCapacityMb: parseInt(localDriveCapacityMb, 10), localDriveCapacityMb: parseInt(localDriveCapacityMb, 10),
remoteDriveCapacityMb: parseInt(remoteDriveCapacityMb, 10), remoteDriveCapacityMb: parseInt(remoteDriveCapacityMb, 10),