diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-05 16:18:52 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-05 16:18:52 +0900 |
| commit | 863054214652378c11f0596591eff0b259cfc5d1 (patch) | |
| tree | 2ff78a1bf533201c8b2e55c97141c58fb40db619 /src/server/web | |
| parent | Update abuses.vue (diff) | |
| download | sharkey-863054214652378c11f0596591eff0b259cfc5d1.tar.gz sharkey-863054214652378c11f0596591eff0b259cfc5d1.tar.bz2 sharkey-863054214652378c11f0596591eff0b259cfc5d1.zip | |
ドキュメントをmisskey-hubに移行
Diffstat (limited to 'src/server/web')
| -rw-r--r-- | src/server/web/index.ts | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 35337868d9..2af6ecb0bb 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -4,7 +4,6 @@ import * as os from 'os'; import * as fs from 'fs'; -import { fileURLToPath } from 'url'; import { dirname } from 'path'; import * as ms from 'ms'; import * as Koa from 'koa'; @@ -12,8 +11,6 @@ import * as Router from '@koa/router'; import * as send from 'koa-send'; import * as favicon from 'koa-favicon'; import * as views from 'koa-views'; -import * as glob from 'glob'; -import * as MarkdownIt from 'markdown-it'; import packFeed from './feed'; import { fetchMeta } from '@/misc/fetch-meta'; @@ -30,19 +27,7 @@ import * as locales from '../../../locales/index'; const _filename = __filename; const _dirname = dirname(_filename); -const markdown = MarkdownIt({ - html: true -}); - -const changelog = fs.readFileSync(`${_dirname}/../../../CHANGELOG.md`, { encoding: 'utf8' }); -function genDoc(path: string): string { - let md = fs.readFileSync(path, { encoding: 'utf8' }); - md = md.replace('<!--[CHANGELOG]-->', changelog); - return md; -} - const staticAssets = `${_dirname}/../../../assets/`; -const docAssets = `${_dirname}/../../../src/docs/`; const assets = `${_dirname}/../../assets/`; // Init app @@ -79,14 +64,6 @@ router.get('/static-assets/(.*)', async ctx => { }); }); -router.get('/doc-assets/(.*)', async ctx => { - if (ctx.path.includes('..')) return; - const path = `${_dirname}/../../../src/docs/${ctx.path.replace('/doc-assets/', '')}`; - const doc = genDoc(path); - ctx.set('Content-Type', 'text/plain; charset=utf-8'); - ctx.body = doc; -}); - router.get('/assets/(.*)', async ctx => { await send(ctx as any, ctx.path.replace('/assets/', ''), { root: assets, @@ -149,64 +126,6 @@ router.get('/api.json', async ctx => { ctx.body = genOpenapiSpec(); }); -router.get('/docs.json', async ctx => { - const lang = ctx.query.lang; - const query = ctx.query.q; - if (!Object.keys(locales).includes(lang)) { - ctx.body = []; - return; - } - const dirPath = `${_dirname}/../../../src/docs/${lang}`.replace(/\\/g, '/'); - const paths = glob.sync(`${dirPath}/**/*.md`); - const docs: { path: string; title: string; summary: string; }[] = []; - for (const path of paths) { - const md = genDoc(path); - - if (query && query.length > 0) { - // TODO: カタカナをひらがなにして比較するなどしたい - if (!md.includes(query)) continue; - } - - const parsed = markdown.parse(md, {}); - if (parsed.length === 0) return; - - const buf = [...parsed]; - const headingTokens = []; - - // もっとも上にある見出しを抽出する - while (buf[0].type !== 'heading_open') { - buf.shift(); - } - buf.shift(); - while (buf[0].type as string !== 'heading_close') { - const token = buf.shift(); - if (token) { - headingTokens.push(token); - } - } - - const firstParagrapfTokens = []; - while (buf[0].type !== 'paragraph_open') { - buf.shift(); - } - buf.shift(); - while (buf[0].type as string !== 'paragraph_close') { - const token = buf.shift(); - if (token) { - firstParagrapfTokens.push(token); - } - } - - docs.push({ - path: path.match(new RegExp(`docs\/${lang}\/(.+?)\.md$`))![1], - title: markdown.renderer.render(headingTokens, {}, {}), - summary: markdown.renderer.render(firstParagrapfTokens, {}, {}), - }); - } - - ctx.body = docs; -}); - const getFeed = async (acct: string) => { const { username, host } = parseAcct(acct); const user = await Users.findOne({ |