From 9a911038d9ac38bf590e9199b3b7477ebf91de19 Mon Sep 17 00:00:00 2001 From: Kimsible Date: Sat, 24 Apr 2021 01:44:39 +0200 Subject: Add shorter URLs for accounts and channels server-side --- server/controllers/client.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 022a17ff4..35e5af9d1 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -21,8 +21,9 @@ const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html') // Do not use a template engine for a so little thing clientsRouter.use('/videos/watch/playlist/:id', asyncMiddleware(generateWatchPlaylistHtmlPage)) clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage)) -clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) -clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) +clientsRouter.use([ '/accounts/:nameWithHost', '/a/:nameWithHost' ], asyncMiddleware(generateAccountHtmlPage)) +clientsRouter.use([ '/video-channels/:nameWithHost', '/c/:nameWithHost' ], asyncMiddleware(generateVideoChannelHtmlPage)) +clientsRouter.use('/@:nameWithHost', asyncMiddleware(generateActorHtmlPage)) const embedMiddlewares = [ CONFIG.CSP.ENABLED @@ -155,6 +156,12 @@ async function generateVideoChannelHtmlPage (req: express.Request, res: express. return sendHTML(html, res) } +async function generateActorHtmlPage (req: express.Request, res: express.Response) { + const html = await ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res) + + return sendHTML(html, res) +} + async function generateManifest (req: express.Request, res: express.Response) { const manifestPhysicalPath = join(root(), 'client', 'dist', 'manifest.webmanifest') const manifestJson = await readFile(manifestPhysicalPath, 'utf8') -- cgit v1.2.3