From 2539932e16129992a2c0889b4ff527c265a8e2c7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 27 May 2021 15:59:55 +0200 Subject: 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 --- client/src/app/core/menu/menu.service.ts | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'client/src/app/core/menu') diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index 502d3bb2f..77592cbb6 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts @@ -1,8 +1,19 @@ import { fromEvent } from 'rxjs' import { debounceTime } from 'rxjs/operators' import { Injectable } from '@angular/core' +import { GlobalIconName } from '@app/shared/shared-icons' +import { sortObjectComparator } from '@shared/core-utils/miscs/miscs' +import { ServerConfig } from '@shared/models/server' import { ScreenService } from '../wrappers' +export type MenuLink = { + icon: GlobalIconName + label: string + menuLabel: string + path: string + priority: number +} + @Injectable() export class MenuService { isMenuDisplayed = true @@ -48,6 +59,53 @@ export class MenuService { this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser } + buildCommonLinks (config: ServerConfig) { + let entries: MenuLink[] = [ + { + icon: 'globe' as 'globe', + label: $localize`Discover videos`, + menuLabel: $localize`Discover`, + path: '/videos/overview', + priority: 150 + }, + { + icon: 'trending' as 'trending', + label: $localize`Trending videos`, + menuLabel: $localize`Trending`, + path: '/videos/trending', + priority: 140 + }, + { + icon: 'recently-added' as 'recently-added', + label: $localize`Recently added videos`, + menuLabel: $localize`Recently added`, + path: '/videos/recently-added', + priority: 130 + }, + { + icon: 'octagon' as 'octagon', + label: $localize`Local videos`, + menuLabel: $localize`Local videos`, + path: '/videos/local', + priority: 120 + } + ] + + if (config.homepage.enabled) { + entries.push({ + icon: 'home' as 'home', + label: $localize`Home`, + menuLabel: $localize`Home`, + path: '/home', + priority: 160 + }) + } + + entries = entries.sort(sortObjectComparator('priority', 'desc')) + + return entries + } + private handleWindowResize () { // On touch screens, do not handle window resize event since opened menu is handled with a content overlay if (this.screenService.isInTouchScreen()) return -- cgit v1.2.3