mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Instance homepage support (#4007)
* Prepare homepage parsers * Add ability to update instance hompage * Add ability to set homepage as landing page * Add homepage preview in admin * Dynamically update left menu for homepage * Inject home content in homepage * Add videos list and channel miniature custom markup * Remove unused elements in markup service
This commit is contained in:
parent
eb34ec30e0
commit
2539932e16
84 changed files with 1761 additions and 407 deletions
42
server/controllers/api/custom-page.ts
Normal file
42
server/controllers/api/custom-page.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import * as express from 'express'
|
||||
import { ServerConfigManager } from '@server/lib/server-config-manager'
|
||||
import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
import { UserRight } from '@shared/models'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||
|
||||
const customPageRouter = express.Router()
|
||||
|
||||
customPageRouter.get('/homepage/instance',
|
||||
asyncMiddleware(getInstanceHomepage)
|
||||
)
|
||||
|
||||
customPageRouter.put('/homepage/instance',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_INSTANCE_CUSTOM_PAGE),
|
||||
asyncMiddleware(updateInstanceHomepage)
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
customPageRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function getInstanceHomepage (req: express.Request, res: express.Response) {
|
||||
const page = await ActorCustomPageModel.loadInstanceHomepage()
|
||||
if (!page) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
|
||||
return res.json(page.toFormattedJSON())
|
||||
}
|
||||
|
||||
async function updateInstanceHomepage (req: express.Request, res: express.Response) {
|
||||
const content = req.body.content
|
||||
|
||||
await ActorCustomPageModel.updateInstanceHomepage(content)
|
||||
ServerConfigManager.Instance.updateHomepageState(content)
|
||||
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue