Skip to content

Commit

Permalink
feat: custom splash text(動くかわからない)
Browse files Browse the repository at this point in the history
  • Loading branch information
Esurio committed Aug 18, 2024
1 parent d6d97f7 commit b7fc6e9
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,8 @@ sensitiveWordsDescription2: "Using spaces will create AND expressions and surrou
prohibitedWords: "Prohibited words"
prohibitedWordsDescription: "Enables an error when attempting to post a note containing the set word(s). Multiple words can be set, separated by a new line."
prohibitedWordsDescription2: "Using spaces will create AND expressions and surrounding keywords with slashes will turn them into a regular expression."
customSplashText: "Custom splash text"
customSplashTextDescription: "This text will be displayed on the loading page."
hiddenTags: "Hidden hashtags"
hiddenTagsDescription: "Select tags which will not shown on trend list.\nMultiple tags could be registered by lines."
notesSearchNotAvailable: "Note search is unavailable."
Expand Down
8 changes: 8 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4756,6 +4756,14 @@ export interface Locale extends ILocale {
* スペースで区切るとAND指定になり、キーワードをスラッシュで囲むと正規表現になります。
*/
"prohibitedWordsDescription2": string;
/**
* カスタムスプラッシュテキスト
*/
"customSplashText": string;
/**
* ロード画面に表示されるテキストを設定します。改行で区切って複数設定できます。
*/
"customSplashTextDescription": string;
/**
* 非表示ハッシュタグ
*/
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@ sensitiveWordsDescription2: "スペースで区切るとAND指定になり、キ
prohibitedWords: "禁止ワード"
prohibitedWordsDescription: "設定したワードが含まれるノートを投稿しようとした際、エラーとなるようにします。改行で区切って複数設定できます。"
prohibitedWordsDescription2: "スペースで区切るとAND指定になり、キーワードをスラッシュで囲むと正規表現になります。"
customSplashText: "カスタムスプラッシュテキスト"
customSplashTextDescription: "ロード画面に表示されるテキストを設定します。改行で区切って複数設定できます。"
hiddenTags: "非表示ハッシュタグ"
hiddenTagsDescription: "設定したタグをトレンドに表示させないようにします。改行で区切って複数設定できます。"
notesSearchNotAvailable: "ノート検索は利用できません。"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1723982389378-AddCustomSplash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class AddCustomSplash1723982389378 {
name = 'AddCustomSplash1723982389378'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "customSplashText" character varying(1024) array NOT NULL DEFAULT '{}'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "customSplashText"`);
}
}
7 changes: 7 additions & 0 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,11 @@ export class MiMeta {
nullable: true,
})
public skipCherryPickVersion: string | null;

@Column('varchar', {
length: 1024,
array: true,
default: '{}',
})
public customSplashText: string[];
}
8 changes: 8 additions & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ export const meta = {
type: 'string',
optional: true, nullable: true,
},
customSplashText: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
},
},
},
},
} as const;
Expand Down Expand Up @@ -731,6 +738,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
enableReceivePrerelease: instance.enableReceivePrerelease,
skipVersion: instance.skipVersion,
skipCherryPickVersion: instance.skipCherryPickVersion,
customSplashText: instance.customSplashText,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ export const paramDef = {
enableReceivePrerelease: { type: 'boolean' },
skipVersion: { type: 'boolean' },
skipCherryPickVersion: { type: 'string', nullable: true },
customSplashText: { type: 'array', nullable: true, items: {
type: 'string',
}},
},
required: [],
} as const;
Expand Down Expand Up @@ -769,6 +772,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.skipCherryPickVersion = ps.skipCherryPickVersion;
}

if (Array.isArray(ps.customSplashText)) {
set.customSplashText = ps.customSplashText.filter(Boolean);
}

const before = await this.metaService.fetch(true);

await this.metaService.update(set);
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class ClientServerService {
instanceUrl: this.config.url,
metaJson: htmlSafeJsonStringify(await this.metaEntityService.packDetailed(meta)),
now: Date.now(),
customSplashText: meta.customSplashText[Math.floor(Math.random() * meta.customSplashText.length)],
};
}

Expand Down
11 changes: 11 additions & 0 deletions packages/backend/src/server/web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ html {
stroke-linecap: round;
animation: dash 1.2s ease-in-out infinite;
}
#splashText {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
display: inline-block;
text-align: center;
transform: translateY(40px);
}

@keyframes splashSpinner {
0% {
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,6 @@ html
<svg class="spinner" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="6px" style="fill: none; stroke: currentColor; stroke-width: 6px;"></circle>
</svg>
div#splashText
block customSplashText = customSplashText
block content
2 changes: 2 additions & 0 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5407,6 +5407,7 @@ export type operations = {
enableReceivePrerelease: boolean;
skipVersion: boolean;
skipCherryPickVersion?: string | null;
customSplashText: string[];
};
};
};
Expand Down Expand Up @@ -10205,6 +10206,7 @@ export type operations = {
enableReceivePrerelease?: boolean;
skipVersion?: boolean;
skipCherryPickVersion?: string | null;
customSplashText?: string[] | null;
};
};
};
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/pages/admin/branding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkTextarea v-model="manifestJsonOverride">
<template #label>{{ i18n.ts._serverSettings.manifestJsonOverride }}</template>
</MkTextarea>

<MkTextarea v-model="customSplashText">
<template #label>{{ i18n.ts.customSplashText }}</template>
<template #caption>{{ i18n.ts.customSplashTextDescription }}</template>
</MkTextarea>
</div>
</FormSuspense>
</MkSpacer>
Expand Down Expand Up @@ -133,6 +138,7 @@ const notFoundImageUrl = ref<string | null>(null);
const repositoryUrl = ref<string | null>(null);
const feedbackUrl = ref<string | null>(null);
const manifestJsonOverride = ref<string>('{}');
const customSplashText = ref<string>('');

async function init() {
const meta = await misskeyApi('admin/meta');
Expand All @@ -150,6 +156,7 @@ async function init() {
repositoryUrl.value = meta.repositoryUrl;
feedbackUrl.value = meta.feedbackUrl;
manifestJsonOverride.value = meta.manifestJsonOverride === '' ? '{}' : JSON.stringify(JSON.parse(meta.manifestJsonOverride), null, '\t');
customSplashText.value = meta.customSplashText.join('\n');
}

function save() {
Expand All @@ -168,6 +175,7 @@ function save() {
repositoryUrl: repositoryUrl.value === '' ? null : repositoryUrl.value,
feedbackUrl: feedbackUrl.value === '' ? null : feedbackUrl.value,
manifestJsonOverride: manifestJsonOverride.value === '' ? '{}' : JSON.stringify(JSON5.parse(manifestJsonOverride.value)),
customSplashText: customSplashText.value.split('\n'),
}).then(() => {
fetchInstance(true);
});
Expand Down

0 comments on commit b7fc6e9

Please sign in to comment.