diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-14 16:12:45 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-05-27 16:00:13 +0200 |
commit | 0f01a8bacddf6c502e6470e34fdac7750bb76e89 (patch) | |
tree | c0eb33e4b74f955979f2cb9ee747dfc81d7ff4fb /client/src/app/core | |
parent | 05ded92ed16bc83a33e71ecccf0f3ee9751fd7b0 (diff) | |
download | PeerTube-0f01a8bacddf6c502e6470e34fdac7750bb76e89.tar.gz PeerTube-0f01a8bacddf6c502e6470e34fdac7750bb76e89.tar.zst PeerTube-0f01a8bacddf6c502e6470e34fdac7750bb76e89.zip |
Remove ngx-meta
Unmaintained
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/core.module.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/routing/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/routing/meta-guard.service.ts | 23 | ||||
-rw-r--r-- | client/src/app/core/routing/meta.service.ts | 40 |
4 files changed, 70 insertions, 2 deletions
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index 3152a7003..de3274544 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts | |||
@@ -14,7 +14,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard' | |||
14 | import { Notifier } from './notification' | 14 | import { Notifier } from './notification' |
15 | import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' | 15 | import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' |
16 | import { RestExtractor, RestService } from './rest' | 16 | import { RestExtractor, RestService } from './rest' |
17 | import { LoginGuard, RedirectService, UnloggedGuard, UserRightGuard } from './routing' | 17 | import { LoginGuard, MetaGuard, MetaService, RedirectService, UnloggedGuard, UserRightGuard } from './routing' |
18 | import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' | 18 | import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' |
19 | import { ServerConfigResolver } from './routing/server-config-resolver.service' | 19 | import { ServerConfigResolver } from './routing/server-config-resolver.service' |
20 | import { ScopedTokensService } from './scoped-tokens' | 20 | import { ScopedTokensService } from './scoped-tokens' |
@@ -77,7 +77,10 @@ import { LocalStorageService, ScreenService, SessionStorageService } from './wra | |||
77 | MessageService, | 77 | MessageService, |
78 | PeerTubeSocket, | 78 | PeerTubeSocket, |
79 | ServerConfigResolver, | 79 | ServerConfigResolver, |
80 | CanDeactivateGuard | 80 | CanDeactivateGuard, |
81 | |||
82 | MetaService, | ||
83 | MetaGuard | ||
81 | ] | 84 | ] |
82 | }) | 85 | }) |
83 | export class CoreModule { | 86 | export class CoreModule { |
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts index 239c27caf..4314ea475 100644 --- a/client/src/app/core/routing/index.ts +++ b/client/src/app/core/routing/index.ts | |||
@@ -3,6 +3,8 @@ export * from './custom-reuse-strategy' | |||
3 | export * from './disable-for-reuse-hook' | 3 | export * from './disable-for-reuse-hook' |
4 | export * from './login-guard.service' | 4 | export * from './login-guard.service' |
5 | export * from './menu-guard.service' | 5 | export * from './menu-guard.service' |
6 | export * from './meta-guard.service' | ||
7 | export * from './meta.service' | ||
6 | export * from './preload-selected-modules-list' | 8 | export * from './preload-selected-modules-list' |
7 | export * from './redirect.service' | 9 | export * from './redirect.service' |
8 | export * from './server-config-resolver.service' | 10 | export * from './server-config-resolver.service' |
diff --git a/client/src/app/core/routing/meta-guard.service.ts b/client/src/app/core/routing/meta-guard.service.ts new file mode 100644 index 000000000..bedb3450e --- /dev/null +++ b/client/src/app/core/routing/meta-guard.service.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' | ||
3 | import { MetaService } from './meta.service' | ||
4 | |||
5 | @Injectable() | ||
6 | export class MetaGuard implements CanActivate, CanActivateChild { | ||
7 | |||
8 | constructor (private meta: MetaService) { } | ||
9 | |||
10 | canActivate (route: ActivatedRouteSnapshot): boolean { | ||
11 | const metaSettings = route.data?.meta | ||
12 | |||
13 | if (metaSettings) { | ||
14 | this.meta.update(metaSettings) | ||
15 | } | ||
16 | |||
17 | return true | ||
18 | } | ||
19 | |||
20 | canActivateChild (route: ActivatedRouteSnapshot): boolean { | ||
21 | return this.canActivate(route) | ||
22 | } | ||
23 | } | ||
diff --git a/client/src/app/core/routing/meta.service.ts b/client/src/app/core/routing/meta.service.ts new file mode 100644 index 000000000..a5ac778dc --- /dev/null +++ b/client/src/app/core/routing/meta.service.ts | |||
@@ -0,0 +1,40 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { Meta, Title } from '@angular/platform-browser' | ||
3 | import { HTMLServerConfig } from '@shared/models/server' | ||
4 | import { ServerService } from '../server' | ||
5 | |||
6 | export interface MetaSettings { | ||
7 | title?: string | ||
8 | } | ||
9 | |||
10 | @Injectable() | ||
11 | export class MetaService { | ||
12 | private config: HTMLServerConfig | ||
13 | |||
14 | constructor ( | ||
15 | private titleService: Title, | ||
16 | private meta: Meta, | ||
17 | private server: ServerService | ||
18 | ) { | ||
19 | this.config = this.server.getTmpConfig() | ||
20 | this.server.getConfig() | ||
21 | .subscribe(config => this.config = config) | ||
22 | } | ||
23 | |||
24 | setTitle (subTitle?: string) { | ||
25 | let title = '' | ||
26 | if (subTitle) title += `${subTitle} - ` | ||
27 | |||
28 | title += this.config.instance.name | ||
29 | |||
30 | this.titleService.setTitle(title) | ||
31 | } | ||
32 | |||
33 | setTag (name: string, value: string) { | ||
34 | this.meta.addTag({ name, content: value }) | ||
35 | } | ||
36 | |||
37 | update (meta: MetaSettings) { | ||
38 | this.setTitle(meta.title) | ||
39 | } | ||
40 | } | ||