Skip to content

Commit

Permalink
Merge branch 'main' into i18n-ko
Browse files Browse the repository at this point in the history
  • Loading branch information
ltlapy committed Sep 11, 2022
2 parents 6507f5f + c3820b9 commit b031081
Show file tree
Hide file tree
Showing 393 changed files with 22,972 additions and 3,397 deletions.
4,375 changes: 1,840 additions & 2,535 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
"url": "git+https://github.com/misskey-dev/misskey-hub.git"
},
"devDependencies": {
"@types/three": "^0.133.1",
"@types/three": "^0.143.0",
"@types/tinycolor2": "^1.4.3",
"@vuepress/plugin-register-components": "^2.0.0-beta.34",
"@vuepress/plugin-search": "^2.0.0-beta.34",
"@vuepress/plugin-register-components": "^2.0.0-beta.49",
"@vuepress/plugin-search": "^2.0.0-beta.49",
"execa": "^5.1.1",
"meshline": "^2.0.3",
"three": "^0.134.0",
"meshline": "^2.0.4",
"three": "^0.143.0",
"tinycolor2": "^1.4.2",
"vuepress": "^2.0.0-beta.34"
"vuepress": "^2.0.0-beta.49"
},
"dependencies": {
"deepmerge": "^4.2.2",
"element-plus": "^2.2.14",
"glob": "^7.2.0",
"json5": "^2.2.0"
"json5": "^2.2.1"
}
}
60 changes: 60 additions & 0 deletions src/.vuepress/_gen-api-defs-from-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as fs from 'fs';
import { App, createPage, Page } from '@vuepress/core';
import glob from 'glob';
import JSON5 from 'json5';
const merge = require('deepmerge')
var getDirName = require('path').dirname;

const combineMerge = (target, source, options) => {
const destination = target.slice()

source.forEach((item, index) => {
if (typeof destination[index] === 'undefined') {
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options)
} else if (options.isMergeableObject(item)) {
destination[index] = merge(target[index], item, options)
} else if (target.indexOf(item) === -1) {
destination.push(item)
}
})
return destination
}

const openApiDefinition = JSON.parse(fs.readFileSync(__dirname + '/api.json', 'utf8'));
const endpointPaths = Object.keys(openApiDefinition.paths);
const endpointTags = Array.from(new Set(Object.values(openApiDefinition.paths).flatMap(x => x.post.tags ?? [])));

function writeFile(path, contents, cb) {
fs.mkdir(getDirName(path), { recursive: true}, function (err) {
fs.writeFileSync(path, contents);
});
}

export async function generateEndpointPages(app: App) {
for (const endpointPath of endpointPaths) {
const name = endpointPath.substring(1);
const def = openApiDefinition.paths[endpointPath]['post'];
const requireCredential = def.security?.length > 0;
const errors = {};
for (const e of Object.keys(def.responses['400']?.content['application/json'].examples)) {
const err = def.responses['400']?.content['application/json'].examples[e].value.error;
if (err.id === '3d81ceae-475f-4600-b2a8-2bc116157532') continue; // INVALID_PARAMは全API共通なため
errors[err.id] = {
id: err.id,
code: err.code,
description: '',
};
}
const data = {
summary: '',
description: '',
tags: def.tags,
requireCredential,
req: def.requestBody.content['application/json']?.schema ?? {},
res: def.responses['200']?.content['application/json'].schema ?? {},
errors,
};

writeFile(__dirname + `/_api_/${name}.json5`, JSON5.stringify(data, null, '\t'), 'utf8');
}
}
1 change: 1 addition & 0 deletions src/.vuepress/api.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/.vuepress/api.locale.en-US.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
104 changes: 104 additions & 0 deletions src/.vuepress/api.locale.ja-JP.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
paths: {
'/ping': {
post: {
summary: '接続確認を行います。',
description: '接続確認を行います。',
responses: {
'200': {
content: {
'application/json': {
schema: {
properties: {
pong: {
description: 'レスポンス時の時刻です。',
},
},
},
},
},
},
},
},
},
'/notes': {
post: {
summary: 'ノート一覧を取得します。',
description: 'ノート一覧を取得します。',
requestBody: {
content: {
'application/json': {
schema: {
properties: {
local: {
description: 'ローカルで作成されたノートのみを取得します。',
},
reply: {
description: '`true` にすると返信だけを、 `false` にすると返信以外を取得します。値を設定しなければ返信であるかそうでないかに関係なくノートを取得します。',
},
renote: {
description: '`true` にするとリノートだけを、 `false` にするとリノート以外を取得します。値を設定しなければリノートであるかそうでないかに関係なくノートを取得します。',
},
withFiles: {
description: '`true` にすると添付ファイルのあるノートだけを、 `false` にすると添付ファイルがないノートだけを取得します。値を設定しなければ添付ファイルの有無にかかわらずノートを取得します。',
},
poll: {
description: '`true` にすると投票を含むノートだけを、 `false` にすると含まないノートだけを取得します。値を設定しなければ投票の有無にかかわらずノートを取得します。',
},
limit: {
description: '取得するノートの最大数を指定します。',
},
},
},
},
},
},
},
},
'/get-online-users-count': {
post: {
summary: 'オンラインになっているユーザ数を取得します。',
description: 'オンラインになっているユーザ数を取得します。',
responses: {
'200': {
content: {
'application/json': {
schema: {
properties: {
count: {
description: '現在オンライン(10分以内に何らかのアクションをとった)であるユーザ数です。',
},
},
},
},
},
},
},
},
},
'/i/pin': {
post: {
summary: 'ノートをピン留めします。',
description: 'ノートをピン留めします。ピン留めされたノートはMisskey Webのプロフィールページに表示されたりします。',
},
},
'/i/unpin': {
post: {
summary: 'ノートをピン留めから解除します。',
description: 'ノートをピン留めから解除します。',
},
},
'/clips/create': {
post: {
summary: 'クリップを作成します。',
description: 'クリップを作成します。',
},
},
'/clips/list': {
post: {
summary: '自分のクリップの一覧を取得します。',
description: '自分のクリップの一覧を取得します。',
},
},
},
}
8 changes: 8 additions & 0 deletions src/.vuepress/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineClientConfig } from '@vuepress/client'
import ElementPlus from 'element-plus'

export default defineClientConfig({
enhance({app, router, siteData}) {
app.use(ElementPlus, { })
},
})
111 changes: 98 additions & 13 deletions src/.vuepress/components/MkApiConsole.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,109 @@
<template>
<div class="mk-api-console">
<input v-model="host">
<el-collapse v-model="expands">
<el-collapse-item title="API Console" name="console">
<el-form :model="form" label-width="120px">
<el-form-item label="Host" :rules="[{ required: true }]">
<el-input v-model="host" placeholder="misskey.example.com">
<template #prepend>https://</template>
</el-input>
</el-form-item>
<el-form-item label="Endpoint" :rules="[{ required: true }]">
<el-input v-model="endpoint" placeholder="foo/bar">
<template #prepend>https://{{ host }}/api/</template>
</el-input>
</el-form-item>
<el-form-item label="Params">
<el-input v-model="params" type="textarea" :autosize="{ minRows: 8 }">
</el-input>
</el-form-item>
<el-form-item label="Token">
<el-input v-model="token" placeholder="Token or API key">
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">Send</el-button>
</el-form-item>
<el-form-item label="Response">
<el-input v-model="res" readonly type="textarea" autosize>
</el-input>
</el-form-item>
</el-form>
</el-collapse-item>
</el-collapse>
</div>
</template>

<script>
import { } from 'vue';
<script lang="ts" setup>
import { ref, watch } from 'vue';
import JSON5 from 'json5';
export default {
props: {
def: {
type: Object,
required: true,
}
},
const props = defineProps<{
name: string;
def: any;
}>();
setup(props) {
const params = ref();
},
};
const endpointBody = {};
if (props.def.req) {
for (const [k, v] of Object.entries(props.def.req.properties ?? {})) {
endpointBody[k] =
v.type === 'string' ? '' :
v.type === 'integer' ? 0 :
v.type === 'boolean' ? false :
v.type === 'array' ? [] :
v.type === 'object' ? {} :
null;
}
}
params.value = JSON5.stringify(endpointBody, null, 2);
const endpoint = ref(props.name);
const host = ref(localStorage.getItem('host') ?? '');
const token = ref(localStorage.getItem('token') ?? '');
const res = ref(null);
const expands = ref([]);
watch(host, () => {
localStorage.setItem('host', host.value)
});
watch(token, () => {
localStorage.setItem('token', token.value)
});
function request() {
const promise = new Promise((resolve, reject) => {
const data = {
...params.value,
i: token.value && token.value.trim() !== '' ? token.value : undefined,
};
fetch(`https://${host.value}/api/${endpoint.value}`, {
method: 'POST',
body: JSON.stringify(data),
credentials: 'omit',
cache: 'no-cache',
}).then(async (res) => {
const body = res.status === 204 ? null : await res.json();
if (res.status === 200) {
resolve(body);
} else if (res.status === 204) {
resolve();
} else {
reject(body.error);
}
}).catch(reject);
});
return promise;
}
async function onSubmit() {
const _res = await request();
res.value = JSON5.stringify(_res, null, '\t');
}
</script>

<style lang="scss" scoped>
Expand Down
45 changes: 45 additions & 0 deletions src/.vuepress/components/MkApiErrors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<div class="mk-api-errors">
<el-tabs v-model="activeName">
<el-tab-pane label="固有のエラー" name="a">
<template v-if="Object.keys(errors).length > 0">
<el-collapse v-model="expands">
<el-collapse-item v-for="e in errors" :title="e.code" :name="e.id">
<div>{{ e.description }}</div>
<div class="_mono">ID: {{ e.id }}</div>
</el-collapse-item>
</el-collapse>
</template>
<template v-else>
<el-alert title="なし" type="success" :closable="false" />
</template>
</el-tab-pane>
<el-tab-pane label="共通のエラー" name="b">
<el-collapse v-model="commonExpands">
<el-collapse-item v-for="e in commonErrors" :title="e.code" :name="e.id">
<div>{{ e.description }}</div>
<div class="_mono">ID: {{ e.id }}</div>
</el-collapse-item>
</el-collapse>
</el-tab-pane>
</el-tabs>
</div>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue';
import JSON5 from 'json5';
const props = defineProps<{
errors: any[];
commonErrors: any[];
}>();
const activeName = ref('a')
const expands = ref([]);
const commonExpands = ref([]);
</script>

<style lang="scss" scoped>
</style>
23 changes: 23 additions & 0 deletions src/.vuepress/components/MkApiResources.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="mk-api-resources">
<el-collapse v-model="expands">
<el-collapse-item title="Definition" name="definition">
{{ def }}
</el-collapse-item>
</el-collapse>
</div>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue';
import JSON5 from 'json5';
const props = defineProps<{
def: any;
}>();
const expands = ref([]);
</script>

<style lang="scss" scoped>
</style>
Loading

0 comments on commit b031081

Please sign in to comment.