diff options
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r-- | server/controllers/client.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 022a17ff4..eb1ee6cbd 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -19,10 +19,11 @@ const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html') | |||
19 | 19 | ||
20 | // Special route that add OpenGraph and oEmbed tags | 20 | // Special route that add OpenGraph and oEmbed tags |
21 | // Do not use a template engine for a so little thing | 21 | // Do not use a template engine for a so little thing |
22 | clientsRouter.use('/videos/watch/playlist/:id', asyncMiddleware(generateWatchPlaylistHtmlPage)) | 22 | clientsRouter.use([ '/w/p/:id', '/videos/watch/playlist/:id' ], asyncMiddleware(generateWatchPlaylistHtmlPage)) |
23 | clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage)) | 23 | clientsRouter.use([ '/w/:id', '/videos/watch/:id' ], asyncMiddleware(generateWatchHtmlPage)) |
24 | clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) | 24 | clientsRouter.use([ '/accounts/:nameWithHost', '/a/:nameWithHost' ], asyncMiddleware(generateAccountHtmlPage)) |
25 | clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) | 25 | clientsRouter.use([ '/video-channels/:nameWithHost', '/c/:nameWithHost' ], asyncMiddleware(generateVideoChannelHtmlPage)) |
26 | clientsRouter.use('/@:nameWithHost', asyncMiddleware(generateActorHtmlPage)) | ||
26 | 27 | ||
27 | const embedMiddlewares = [ | 28 | const embedMiddlewares = [ |
28 | CONFIG.CSP.ENABLED | 29 | CONFIG.CSP.ENABLED |
@@ -77,7 +78,7 @@ clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE.C | |||
77 | 78 | ||
78 | // 404 for static files not found | 79 | // 404 for static files not found |
79 | clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => { | 80 | clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => { |
80 | res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 81 | res.status(HttpStatusCode.NOT_FOUND_404).end() |
81 | }) | 82 | }) |
82 | 83 | ||
83 | // Always serve index client page (the client is a single page application, let it handle routing) | 84 | // Always serve index client page (the client is a single page application, let it handle routing) |
@@ -104,7 +105,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) { | |||
104 | return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) | 105 | return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) |
105 | } | 106 | } |
106 | 107 | ||
107 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 108 | return res.status(HttpStatusCode.NOT_FOUND_404).end() |
108 | } | 109 | } |
109 | 110 | ||
110 | async function generateEmbedHtmlPage (req: express.Request, res: express.Response) { | 111 | async function generateEmbedHtmlPage (req: express.Request, res: express.Response) { |
@@ -155,6 +156,12 @@ async function generateVideoChannelHtmlPage (req: express.Request, res: express. | |||
155 | return sendHTML(html, res) | 156 | return sendHTML(html, res) |
156 | } | 157 | } |
157 | 158 | ||
159 | async function generateActorHtmlPage (req: express.Request, res: express.Response) { | ||
160 | const html = await ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res) | ||
161 | |||
162 | return sendHTML(html, res) | ||
163 | } | ||
164 | |||
158 | async function generateManifest (req: express.Request, res: express.Response) { | 165 | async function generateManifest (req: express.Request, res: express.Response) { |
159 | const manifestPhysicalPath = join(root(), 'client', 'dist', 'manifest.webmanifest') | 166 | const manifestPhysicalPath = join(root(), 'client', 'dist', 'manifest.webmanifest') |
160 | const manifestJson = await readFile(manifestPhysicalPath, 'utf8') | 167 | const manifestJson = await readFile(manifestPhysicalPath, 'utf8') |