From 8dc9ec06f806bc8a2e6f128e99aa76af3e9b4647 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Aug 2018 01:37:05 +0900 Subject: 良い感じに MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/boot.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 952881f6cb..6bcceec217 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -38,12 +38,18 @@ //#endregion //#region Detect the user language - let lang = navigator.language; + let lang = null; - if (!LANGS.includes(lang)) lang = lang.split('-')[0]; + if (LANGS.includes(navigator.language)) { + lang = navigator.language; + } else { + lang = LANGS.find(x => x.split('-')[0] == lang); - // The default language is English - if (!LANGS.includes(lang)) lang = 'en'; + if (lang == null) { + // Fallback + lang = 'en-US'; + } + } if (settings) { if (settings.device.lang) lang = settings.device.lang; -- cgit v1.2.3-freya From 1b9c69f7939391afb536abe10b02572584ed564f Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Aug 2018 01:55:39 +0900 Subject: Fix bug --- src/client/app/boot.js | 2 +- src/misc/i18n.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 6bcceec217..86d48faf1a 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -43,7 +43,7 @@ if (LANGS.includes(navigator.language)) { lang = navigator.language; } else { - lang = LANGS.find(x => x.split('-')[0] == lang); + lang = LANGS.find(x => x.split('-')[0] == navigator.language); if (lang == null) { // Fallback diff --git a/src/misc/i18n.ts b/src/misc/i18n.ts index a07af3e939..8379b2f538 100644 --- a/src/misc/i18n.ts +++ b/src/misc/i18n.ts @@ -30,7 +30,7 @@ export default class Replacer { if (text.hasOwnProperty(path)) { text = text[path]; } else { - if (this.lang === 'ja') console.warn(`path '${path}' not found`); + if (this.lang === 'ja-JP') console.warn(`path '${path}' not found`); return key; // Fallback } } @@ -46,10 +46,10 @@ export default class Replacer { }); if (error) { - if (this.lang === 'ja') console.warn(`key '${key}' not found in '${path}'`); + if (this.lang === 'ja-JP') console.warn(`key '${key}' not found in '${path}'`); return key; // Fallback } else if (typeof text !== 'string') { - if (this.lang === 'ja') console.warn(`key '${key}' is not string in '${path}'`); + if (this.lang === 'ja-JP') console.warn(`key '${key}' is not string in '${path}'`); return key; // Fallback } else { return text; -- cgit v1.2.3-freya From d129151fdf32de7134cdcee57d255fef82caf796 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Aug 2018 02:28:58 +0900 Subject: Fix #2410 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit なぜか .ts という拡張子で来るのかは不明 --- src/misc/i18n.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/misc/i18n.ts b/src/misc/i18n.ts index 8379b2f538..3dbfd7fe7b 100644 --- a/src/misc/i18n.ts +++ b/src/misc/i18n.ts @@ -27,6 +27,8 @@ export default class Replacer { let text = texts; if (path) { + path = path.replace('.ts', ''); + if (text.hasOwnProperty(path)) { text = text[path]; } else { -- cgit v1.2.3-freya From d98c67e13c1d9a12921f436c1434b902b66e34c8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Aug 2018 02:47:12 +0900 Subject: Add control panel link in nav --- locales/ja-JP.yml | 2 ++ src/client/app/desktop/views/components/ui.header.account.vue | 11 +++++++---- src/client/app/mobile/views/components/ui.nav.vue | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index dc93c9dddc..dfcdb59e1c 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -857,6 +857,7 @@ desktop/views/components/ui.header.account.vue: lists: "リスト" follow-requests: "フォロー申請" customize: "ホームのカスタマイズ" + admin: "管理" settings: "設定" signout: "サインアウト" dark: "闇に飲まれる" @@ -1214,6 +1215,7 @@ mobile/views/components/ui.nav.vue: game: "ゲーム" darkmode: "ダークモード" settings: "設定" + admin: "管理" about: "Misskeyについて" mobile/views/components/user-timeline.vue: diff --git a/src/client/app/desktop/views/components/ui.header.account.vue b/src/client/app/desktop/views/components/ui.header.account.vue index 4e0fc1cf1a..5e26389d89 100644 --- a/src/client/app/desktop/views/components/ui.header.account.vue +++ b/src/client/app/desktop/views/components/ui.header.account.vue @@ -30,10 +30,8 @@
  • %fa:cog%%i18n:@settings%%fa:angle-right%

  • - -
      -
    • -

      %fa:power-off%%i18n:@signout%

      +
    • + %fa:terminal%%i18n:@admin%%fa:angle-right%
      @@ -41,6 +39,11 @@

      %i18n:@dark%

    +
      +
    • +

      %fa:power-off%%i18n:@signout%

      +
    • +
    diff --git a/src/client/app/mobile/views/components/ui.nav.vue b/src/client/app/mobile/views/components/ui.nav.vue index 74564a48bb..39ea513b76 100644 --- a/src/client/app/mobile/views/components/ui.nav.vue +++ b/src/client/app/mobile/views/components/ui.nav.vue @@ -30,6 +30,7 @@ -- cgit v1.2.3-freya From 8ba178f795c771fd84739f4ff5ce65f135ca69ca Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Aug 2018 03:19:57 +0900 Subject: コントロールパネルから招待制のオンオフを切り替えられるように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desktop/views/pages/admin/admin.dashboard.vue | 14 ++++++++ src/server/api/endpoints/admin/update-meta.ts | 37 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/server/api/endpoints/admin/update-meta.ts (limited to 'src') diff --git a/src/client/app/desktop/views/pages/admin/admin.dashboard.vue b/src/client/app/desktop/views/pages/admin/admin.dashboard.vue index 3567585cb8..e0d23331b8 100644 --- a/src/client/app/desktop/views/pages/admin/admin.dashboard.vue +++ b/src/client/app/desktop/views/pages/admin/admin.dashboard.vue @@ -11,6 +11,10 @@
    +

    Code: {{ inviteCode }}

    @@ -28,6 +32,7 @@ export default Vue.extend({ data() { return { stats: null, + disableRegistration: false, inviteCode: null, connection: null, connectionId: null @@ -37,6 +42,10 @@ export default Vue.extend({ this.connection = (this as any).os.streams.serverStatsStream.getConnection(); this.connectionId = (this as any).os.streams.serverStatsStream.use(); + (this as any).os.getMeta().then(meta => { + this.disableRegistration = meta.disableRegistration; + }); + (this as any).api('stats').then(stats => { this.stats = stats; }); @@ -49,6 +58,11 @@ export default Vue.extend({ (this as any).api('admin/invite').then(x => { this.inviteCode = x.code; }); + }, + updateMeta() { + (this as any).api('admin/update-meta', { + disableRegistration: this.disableRegistration + }); } } }); diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts new file mode 100644 index 0000000000..bfcab9d6a6 --- /dev/null +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -0,0 +1,37 @@ +import $ from 'cafy'; +import Meta from '../../../../models/meta'; +import getParams from '../../get-params'; + +export const meta = { + desc: { + ja: 'インスタンスの設定を更新します。' + }, + + requireCredential: true, + requireAdmin: true, + + params: { + disableRegistration: $.bool.optional.nullable.note({ + desc: { + ja: '招待制か否か' + } + }), + } +}; + +export default (params: any) => new Promise(async (res, rej) => { + const [ps, psErr] = getParams(meta, params); + if (psErr) return rej(psErr); + + const set = {} as any; + + if (ps.disableRegistration === true || ps.disableRegistration === false) { + set.disableRegistration = ps.disableRegistration; + } + + await Meta.update({}, { + $set: set + }, { upsert: true }); + + res(); +}); -- cgit v1.2.3-freya