メンテナ情報をDBに保存するように

This commit is contained in:
syuilo 2018-11-07 01:12:26 +09:00
parent 9fdf438018
commit 2642bdd9c8
15 changed files with 77 additions and 33 deletions

View File

@ -1,10 +1,3 @@
maintainer:
name: example-maitainer-name # Your name
url: http://example.com/ # Your contact (http or mailto)
repository_url: https://github.com/syuilo/misskey # Repository URL
feedback_url: https://github.com/syuilo/misskey/issues # Feedback URL (e.g. github issue)
# Final accessible URL seen by a user.
url: https://example.tld/

View File

@ -1079,6 +1079,9 @@ admin/views/instance.vue:
instance-name: "インスタンス名"
instance-description: "インスタンスの紹介"
banner-url: "バナー画像URL"
maintainer-config: "管理者情報"
maintainer-name: "管理者名"
maintainer-email: "管理者の連絡先"
drive-config: "ドライブの設定"
cache-remote-files: "リモートのファイルをキャッシュする"
cache-remote-files-desc: "この設定を無効にすると、リモートファイルをキャッシュせず直リンクするようになります。そのためサーバーのストレージを節約できますが、プライバシー設定で直リンクを無効にしているユーザーにはファイルが見えなくなったり、サムネイルが生成されないので通信量が増加します。通常はこの設定をオンにしておくことをおすすめします。"

View File

@ -7,6 +7,11 @@
<ui-textarea v-model="description">%i18n:@instance-description%</ui-textarea>
<ui-input v-model="bannerUrl"><i slot="icon"><fa icon="link"/></i>%i18n:@banner-url%</ui-input>
</section>
<section class="fit-bottom">
<header><fa icon="headset"/> %i18n:@maintainer-config%</header>
<ui-input v-model="maintainerName">%i18n:@maintainer-name%</ui-input>
<ui-input v-model="maintainerEmail">%i18n:@maintainer-email%</ui-input>
</section>
<section class="fit-top fit-bottom">
<ui-input v-model="maxNoteTextLength">%i18n:@max-note-text-length%</ui-input>
</section>
@ -56,6 +61,8 @@ import Vue from "vue";
export default Vue.extend({
data() {
return {
maintainerName: null,
maintainerEmail: null,
disableRegistration: false,
disableLocalTimeline: false,
bannerUrl: null,
@ -75,6 +82,8 @@ export default Vue.extend({
created() {
(this as any).os.getMeta().then(meta => {
this.maintainerName = meta.maintainer.name;
this.maintainerEmail = meta.maintainer.email;
this.bannerUrl = meta.bannerUrl;
this.name = meta.name;
this.description = meta.description;
@ -103,6 +112,8 @@ export default Vue.extend({
updateMeta() {
(this as any).api('admin/update-meta', {
maintainerName: this.maintainerName,
maintainerEmail: this.maintainerEmail,
disableRegistration: this.disableRegistration,
disableLocalTimeline: this.disableLocalTimeline,
bannerUrl: this.bannerUrl,

View File

@ -4,7 +4,7 @@
<ui-input v-if="meta.disableRegistration" v-model="invitationCode" type="text" :autocomplete="Math.random()" spellcheck="false" required styl="fill">
<span>%i18n:@invitation-code%</span>
<span slot="prefix"><fa icon="id-card-alt"/></span>
<p slot="desc" v-html="'%i18n:@invitation-info%'.replace('{}', meta.maintainer.url)"></p>
<p slot="desc" v-html="'%i18n:@invitation-info%'.replace('{}', 'mailto:' + meta.maintainer.email)"></p>
</ui-input>
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]{1,20}$" :autocomplete="Math.random()" spellcheck="false" required @input="onChangeUsername" styl="fill">
<span>%i18n:@username%</span>

View File

@ -5,7 +5,7 @@
<h1><fa icon="heart"/>%i18n:@title%</h1>
<p v-if="meta">
{{ '%i18n:@text%'.substr(0, '%i18n:@text%'.indexOf('{')) }}
<a :href="meta.maintainer.url">{{ meta.maintainer.name }}</a>
<a :href="'mailto:' + meta.maintainer.email">{{ meta.maintainer.name }}</a>
{{ '%i18n:@text%'.substr('%i18n:@text%'.indexOf('}') + 1) }}
</p>
</article>

View File

@ -1,6 +1,6 @@
<template>
<div class="info">
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Machine: {{ meta.machine }}</p>
<p>Node: {{ meta.node }}</p>
</div>

View File

@ -247,7 +247,7 @@
<ui-card class="other" v-show="page == 'other'">
<div slot="title"><fa icon="info-circle"/> %i18n:@about%</div>
<section>
<p v-if="meta">%i18n:@operator%: <i><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></i></p>
<p v-if="meta">%i18n:@operator%: <i><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></i></p>
</section>
</ui-card>

View File

@ -87,7 +87,7 @@
<div>
<div v-if="meta" class="body">
<p>Version: <b>{{ meta.version }}</b></p>
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
</div>
</div>
</div>

View File

@ -62,7 +62,7 @@
</article>
<div class="info" v-if="meta">
<p>Version: <b>{{ meta.version }}</b></p>
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
</div>
<footer>
<small>{{ copyright }}</small>

View File

@ -2,22 +2,8 @@
*
*/
export type Source = {
/**
*
*/
maintainer: {
/**
*
*/
name: string;
/**
* (URLかmailto形式のURL)
*/
url: string;
email?: string;
repository_url?: string;
feedback_url?: string;
};
languages?: string[];
url: string;
port: number;

View File

@ -88,17 +88,46 @@ if ((config as any).ghost) {
}
});
}
if ((config as any).maintainer) {
Meta.findOne({}).then(m => {
if (m != null && m.maintainer == null) {
Meta.update({}, {
$set: {
maintainer: (config as any).maintainer
}
});
}
});
}
export type IMeta = {
name?: string;
description?: string;
/**
*
*/
maintainer: {
/**
*
*/
name: string;
/**
*
*/
email?: string;
};
broadcasts?: any[];
stats?: {
notesCount: number;
originalNotesCount: number;
usersCount: number;
originalUsersCount: number;
};
disableRegistration?: boolean;
disableLocalTimeline?: boolean;
hidedTags?: string[];

View File

@ -6,7 +6,7 @@ import config from './config';
if (config.sw) {
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録
push.setVapidDetails(
config.maintainer.url,
config.url,
config.sw.public_key,
config.sw.private_key);
}

View File

@ -114,7 +114,21 @@ export const meta = {
proxyAccount: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'Proxy account username'
'ja-JP': 'プロキシアカウントのユーザー名'
}
},
maintainerName: {
validator: $.str.optional,
desc: {
'ja-JP': 'インスタンスの管理者名'
}
},
maintainerEmail: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'インスタンス管理者の連絡先メールアドレス'
}
}
}
@ -183,6 +197,14 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
set.proxyAccount = ps.proxyAccount;
}
if (ps.maintainerName !== undefined) {
set['maintainer.name'] = ps.maintainerName;
}
if (ps.maintainerEmail !== undefined) {
set['maintainer.email'] = ps.maintainerEmail;
}
await Meta.update({}, {
$set: set
}, { upsert: true });

View File

@ -36,7 +36,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
});
const response: any = {
maintainer: config.maintainer,
maintainer: instance.maintainer,
version: pkg.version,
clientVersion: client.version,

View File

@ -48,7 +48,7 @@ router.get('/v1/instance', async ctx => { // TODO: This is a temporary implement
uri: config.hostname,
title: meta.name || 'Misskey',
description: meta.description || '',
email: config.maintainer.email || config.maintainer.url.startsWith('mailto:') ? config.maintainer.url.slice(7) : '',
email: meta.maintainer.email,
version: `0.0.0:compatible:misskey:${pkg.version}`, // TODO: How to tell about that this is an api for compatibility?
thumbnail: meta.bannerUrl,
/*