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/+home/home-routing.module.ts | 18 ++++++++++++++++++ client/src/app/+home/home.component.html | 4 ++++ client/src/app/+home/home.component.scss | 3 +++ client/src/app/+home/home.component.ts | 26 ++++++++++++++++++++++++++ client/src/app/+home/home.module.ts | 25 +++++++++++++++++++++++++ client/src/app/+home/index.ts | 3 +++ 6 files changed, 79 insertions(+) create mode 100644 client/src/app/+home/home-routing.module.ts create mode 100644 client/src/app/+home/home.component.html create mode 100644 client/src/app/+home/home.component.scss create mode 100644 client/src/app/+home/home.component.ts create mode 100644 client/src/app/+home/home.module.ts create mode 100644 client/src/app/+home/index.ts (limited to 'client/src/app/+home') diff --git a/client/src/app/+home/home-routing.module.ts b/client/src/app/+home/home-routing.module.ts new file mode 100644 index 000000000..1eaee4449 --- /dev/null +++ b/client/src/app/+home/home-routing.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { MetaGuard } from '@ngx-meta/core' +import { HomeComponent } from './home.component' + +const homeRoutes: Routes = [ + { + path: '', + component: HomeComponent, + canActivateChild: [ MetaGuard ] + } +] + +@NgModule({ + imports: [ RouterModule.forChild(homeRoutes) ], + exports: [ RouterModule ] +}) +export class HomeRoutingModule {} diff --git a/client/src/app/+home/home.component.html b/client/src/app/+home/home.component.html new file mode 100644 index 000000000..645b9dc69 --- /dev/null +++ b/client/src/app/+home/home.component.html @@ -0,0 +1,4 @@ +
+
+
+ diff --git a/client/src/app/+home/home.component.scss b/client/src/app/+home/home.component.scss new file mode 100644 index 000000000..6c73e9248 --- /dev/null +++ b/client/src/app/+home/home.component.scss @@ -0,0 +1,3 @@ +.root { + padding-top: 20px; +} diff --git a/client/src/app/+home/home.component.ts b/client/src/app/+home/home.component.ts new file mode 100644 index 000000000..16d3a6df7 --- /dev/null +++ b/client/src/app/+home/home.component.ts @@ -0,0 +1,26 @@ + +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' +import { CustomMarkupService } from '@app/shared/shared-custom-markup' +import { CustomPageService } from '@app/shared/shared-main/custom-page' + +@Component({ + templateUrl: './home.component.html', + styleUrls: [ './home.component.scss' ] +}) + +export class HomeComponent implements OnInit { + @ViewChild('contentWrapper') contentWrapper: ElementRef + + constructor ( + private customMarkupService: CustomMarkupService, + private customPageService: CustomPageService + ) { } + + async ngOnInit () { + this.customPageService.getInstanceHomepage() + .subscribe(async ({ content }) => { + const element = await this.customMarkupService.buildElement(content) + this.contentWrapper.nativeElement.appendChild(element) + }) + } +} diff --git a/client/src/app/+home/home.module.ts b/client/src/app/+home/home.module.ts new file mode 100644 index 000000000..102cdc296 --- /dev/null +++ b/client/src/app/+home/home.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core' +import { SharedCustomMarkupModule } from '@app/shared/shared-custom-markup' +import { SharedMainModule } from '@app/shared/shared-main' +import { HomeRoutingModule } from './home-routing.module' +import { HomeComponent } from './home.component' + +@NgModule({ + imports: [ + HomeRoutingModule, + + SharedMainModule, + SharedCustomMarkupModule + ], + + declarations: [ + HomeComponent + ], + + exports: [ + HomeComponent + ], + + providers: [ ] +}) +export class HomeModule { } diff --git a/client/src/app/+home/index.ts b/client/src/app/+home/index.ts new file mode 100644 index 000000000..7c77cf9fd --- /dev/null +++ b/client/src/app/+home/index.ts @@ -0,0 +1,3 @@ +export * from './home-routing.module' +export * from './home.component' +export * from './home.module' -- cgit v1.2.3