diff options
author | Chocobozzz <chocobozzz@cpy.re> | 2021-05-27 15:59:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 15:59:55 +0200 |
commit | 2539932e16129992a2c0889b4ff527c265a8e2c7 (patch) | |
tree | fb5048e63e02a2485eb96d27455f43e4b22e8ae0 /client/src/app/shared/shared-main | |
parent | eb34ec30e0b57286fc6f85160490d2e973a3b0b1 (diff) | |
download | PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.tar.gz PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.tar.zst PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.zip |
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
Diffstat (limited to 'client/src/app/shared/shared-main')
3 files changed, 43 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-main/custom-page/custom-page.service.ts b/client/src/app/shared/shared-main/custom-page/custom-page.service.ts new file mode 100644 index 000000000..e5c2b3cd4 --- /dev/null +++ b/client/src/app/shared/shared-main/custom-page/custom-page.service.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import { of } from 'rxjs' | ||
2 | import { catchError, map } from 'rxjs/operators' | ||
3 | import { HttpClient } from '@angular/common/http' | ||
4 | import { Injectable } from '@angular/core' | ||
5 | import { RestExtractor } from '@app/core' | ||
6 | import { CustomPage } from '@shared/models' | ||
7 | import { environment } from '../../../../environments/environment' | ||
8 | |||
9 | @Injectable() | ||
10 | export class CustomPageService { | ||
11 | static BASE_INSTANCE_HOMEPAGE_URL = environment.apiUrl + '/api/v1/custom-pages/homepage/instance' | ||
12 | |||
13 | constructor ( | ||
14 | private authHttp: HttpClient, | ||
15 | private restExtractor: RestExtractor | ||
16 | ) { } | ||
17 | |||
18 | getInstanceHomepage () { | ||
19 | return this.authHttp.get<CustomPage>(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL) | ||
20 | .pipe( | ||
21 | catchError(err => { | ||
22 | if (err.status === 404) { | ||
23 | return of({ content: '' }) | ||
24 | } | ||
25 | |||
26 | this.restExtractor.handleError(err) | ||
27 | }) | ||
28 | ) | ||
29 | } | ||
30 | |||
31 | updateInstanceHomepage (content: string) { | ||
32 | return this.authHttp.put(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL, { content }) | ||
33 | .pipe( | ||
34 | map(this.restExtractor.extractDataBool), | ||
35 | catchError(err => this.restExtractor.handleError(err)) | ||
36 | ) | ||
37 | } | ||
38 | } | ||
diff --git a/client/src/app/shared/shared-main/custom-page/index.ts b/client/src/app/shared/shared-main/custom-page/index.ts new file mode 100644 index 000000000..7269ece95 --- /dev/null +++ b/client/src/app/shared/shared-main/custom-page/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './custom-page.service' | |||
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index 772198cb2..f9b6085cf 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -29,6 +29,7 @@ import { | |||
29 | } from './angular' | 29 | } from './angular' |
30 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' | 30 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' |
31 | import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' | 31 | import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' |
32 | import { CustomPageService } from './custom-page' | ||
32 | import { DateToggleComponent } from './date' | 33 | import { DateToggleComponent } from './date' |
33 | import { FeedComponent } from './feeds' | 34 | import { FeedComponent } from './feeds' |
34 | import { LoaderComponent, SmallLoaderComponent } from './loaders' | 35 | import { LoaderComponent, SmallLoaderComponent } from './loaders' |
@@ -171,7 +172,9 @@ import { VideoChannelService } from './video-channel' | |||
171 | 172 | ||
172 | VideoCaptionService, | 173 | VideoCaptionService, |
173 | 174 | ||
174 | VideoChannelService | 175 | VideoChannelService, |
176 | |||
177 | CustomPageService | ||
175 | ] | 178 | ] |
176 | }) | 179 | }) |
177 | export class SharedMainModule { } | 180 | export class SharedMainModule { } |