From ebf9cd18c85a8d601941fae5af5a53b6d834346c Mon Sep 17 00:00:00 2001 From: ibrokemypie Date: Fri, 4 Jan 2019 05:02:40 +1100 Subject: [PATCH] Make instance logo customisable (#3829) --- locales/en-US.yml | 1 + src/client/app/admin/views/instance.vue | 4 ++++ src/client/app/desktop/views/pages/welcome.vue | 2 +- src/misc/fetch-meta.ts | 1 + src/models/meta.ts | 1 + src/server/api/endpoints/admin/update-meta.ts | 11 +++++++++++ src/server/api/endpoints/meta.ts | 1 + 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 89f8236c7..31741af15 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -992,6 +992,7 @@ admin/views/instance.vue: instance-name: "Instance name" instance-description: "Instance description" host: "Host" + logo-url: "Logo image URL" banner-url: "Banner image URL" error-image-url: "Error image URL" languages: "Language of this instance" diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index 5a29da034..4e7d59b8e 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -6,6 +6,7 @@ {{ $t('host') }} {{ $t('instance-name') }} {{ $t('instance-description') }} + {{ $t('logo-url') }} {{ $t('banner-url') }} {{ $t('error-image-url') }} {{ $t('languages') }}{{ $t('languages-desc') }} @@ -149,6 +150,7 @@ export default Vue.extend({ maintainerEmail: null, disableRegistration: false, disableLocalTimeline: false, + logoUrl: null, bannerUrl: null, errorImageUrl: null, name: null, @@ -196,6 +198,7 @@ export default Vue.extend({ this.maintainerEmail = meta.maintainer.email; this.disableRegistration = meta.disableRegistration; this.disableLocalTimeline = meta.disableLocalTimeline; + this.logoUrl = meta.logoUrl; this.bannerUrl = meta.bannerUrl; this.errorImageUrl = meta.errorImageUrl; this.name = meta.name; @@ -253,6 +256,7 @@ export default Vue.extend({ maintainerEmail: this.maintainerEmail, disableRegistration: this.disableRegistration, disableLocalTimeline: this.disableLocalTimeline, + logoUrl: this.logoUrl, bannerUrl: this.bannerUrl, errorImageUrl: this.errorImageUrl, name: this.name, diff --git a/src/client/app/desktop/views/pages/welcome.vue b/src/client/app/desktop/views/pages/welcome.vue index 8abadf2c6..0aa864546 100644 --- a/src/client/app/desktop/views/pages/welcome.vue +++ b/src/client/app/desktop/views/pages/welcome.vue @@ -35,7 +35,7 @@ {{ $t('signin') }}

- + diff --git a/src/misc/fetch-meta.ts b/src/misc/fetch-meta.ts index a49e4dbe7..138646e88 100644 --- a/src/misc/fetch-meta.ts +++ b/src/misc/fetch-meta.ts @@ -19,6 +19,7 @@ const defaultMeta: any = { enableExternalUserRecommendation: false, externalUserRecommendationEngine: 'https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}', externalUserRecommendationTimeout: 300000, + logoUrl: '/assets/ai.png', errorImageUrl: 'https://ai.misskey.xyz/aiart/yubitun.png', enableServiceWorker: false }; diff --git a/src/models/meta.ts b/src/models/meta.ts index fd07438a8..b68ec43f1 100644 --- a/src/models/meta.ts +++ b/src/models/meta.ts @@ -185,6 +185,7 @@ export type IMeta = { disableRegistration?: boolean; disableLocalTimeline?: boolean; hidedTags?: string[]; + logoUrl?: string; bannerUrl?: string; errorImageUrl?: string; diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 6ceb2a98d..f84192792 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -39,6 +39,13 @@ export const meta = { } }, + logoUrl: { + validator: $.str.optional.nullable, + desc: { + 'ja-JP': 'インスタンスロゴ画像のURL' + } + }, + bannerUrl: { validator: $.str.optional.nullable, desc: { @@ -328,6 +335,10 @@ export default define(meta, (ps) => new Promise(async (res, rej) => { set.hidedTags = ps.hidedTags; } + if (ps.logoUrl !== undefined) { + set.logoUrl = ps.logoUrl; + } + if (ps.bannerUrl !== undefined) { set.bannerUrl = ps.bannerUrl; } diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index d406f59dc..641c7728f 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -65,6 +65,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { enableRecaptcha: instance.enableRecaptcha, recaptchaSiteKey: instance.recaptchaSiteKey, swPublickey: instance.swPublicKey, + logoUrl: instance.logoUrl, bannerUrl: instance.bannerUrl, errorImageUrl: instance.errorImageUrl, maxNoteTextLength: instance.maxNoteTextLength,