-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { escapeHTML } from '@peertube/peertube-core-utils' | ||
import express from 'express' | ||
import { CONFIG } from '../../../initializers/config.js' | ||
import { WEBSERVER } from '../../../initializers/constants.js' | ||
import { PageHtml } from './page-html.js' | ||
import { TagsHtml } from './tags-html.js' | ||
|
||
export type VideosOrderType = 'local' | 'trending' | 'overview' | 'recently-added' | ||
|
||
export class VideosHtml { | ||
|
||
static async getVideosHTML (type: VideosOrderType, req: express.Request, res: express.Response) { | ||
const html = await PageHtml.getIndexHTML(req, res) | ||
|
||
return this.buildVideosHTML({ | ||
html, | ||
type, | ||
currentPage: req.query.page | ||
}) | ||
} | ||
|
||
// --------------------------------------------------------------------------- | ||
// Private | ||
// --------------------------------------------------------------------------- | ||
|
||
private static buildVideosHTML (options: { | ||
html: string | ||
type: VideosOrderType | ||
currentPage: string | ||
}) { | ||
const { html, currentPage, type } = options | ||
|
||
const title = type === 'recently-added' ? 'Recently added' : type.slice(0, 1).toUpperCase() + type.slice(1) | ||
let customHTML = TagsHtml.addTitleTag(html, title) | ||
customHTML = TagsHtml.addDescriptionTag(customHTML) | ||
|
||
let url = WEBSERVER.URL + '/videos/' + type | ||
|
||
if (currentPage) { | ||
url += `?page=${currentPage}` | ||
} | ||
|
||
return TagsHtml.addTags(customHTML, { | ||
url, | ||
|
||
escapedSiteName: escapeHTML(CONFIG.INSTANCE.NAME), | ||
escapedTitle: title, | ||
|
||
indexationPolicy: 'always' | ||
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / stats
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (types-package)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (client)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (api-1)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (api-2)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (api-3)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (api-4)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (api-5)
Check failure on line 49 in server/core/lib/html/shared/videos-html.ts GitHub Actions / test (transcription)
|
||
}, {}) | ||
} | ||
} |