aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-26 01:53:13 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-28 15:55:34 +0100
commit3da68f0a781ebd893521e2e6fa200280c92ae815 (patch)
tree11bddf841118703c725a96851318603407fd581d /client/src/app/core
parent28eeb811c40325a28208231324f66f4032e5cf67 (diff)
downloadPeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.gz
PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.zst
PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.zip
add default trending page choice, revert comments count for hot strategy
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/core.module.ts4
-rw-r--r--client/src/app/core/routing/index.ts1
-rw-r--r--client/src/app/core/routing/redirect.service.ts26
-rw-r--r--client/src/app/core/routing/trending-guard.service.ts14
-rw-r--r--client/src/app/core/server/server.service.ts8
5 files changed, 48 insertions, 5 deletions
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts
index c4fc9995e..32dfc8f36 100644
--- a/client/src/app/core/core.module.ts
+++ b/client/src/app/core/core.module.ts
@@ -7,7 +7,6 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
7import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service' 7import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service'
8import { HooksService } from '@app/core/plugins/hooks.service' 8import { HooksService } from '@app/core/plugins/hooks.service'
9import { PluginService } from '@app/core/plugins/plugin.service' 9import { PluginService } from '@app/core/plugins/plugin.service'
10import { UnloggedGuard } from '@app/core/routing/unlogged-guard.service'
11import { AuthService } from './auth' 10import { AuthService } from './auth'
12import { ConfirmService } from './confirm' 11import { ConfirmService } from './confirm'
13import { CheatSheetComponent } from './hotkeys' 12import { CheatSheetComponent } from './hotkeys'
@@ -16,7 +15,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard'
16import { Notifier } from './notification' 15import { Notifier } from './notification'
17import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' 16import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer'
18import { RestExtractor, RestService } from './rest' 17import { RestExtractor, RestService } from './rest'
19import { LoginGuard, RedirectService, UserRightGuard } from './routing' 18import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard, TrendingGuard } from './routing'
20import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' 19import { CanDeactivateGuard } from './routing/can-deactivate-guard.service'
21import { ServerConfigResolver } from './routing/server-config-resolver.service' 20import { ServerConfigResolver } from './routing/server-config-resolver.service'
22import { ScopedTokensService } from './scoped-tokens' 21import { ScopedTokensService } from './scoped-tokens'
@@ -57,6 +56,7 @@ import { LocalStorageService, ScreenService, SessionStorageService } from './wra
57 LoginGuard, 56 LoginGuard,
58 UserRightGuard, 57 UserRightGuard,
59 UnloggedGuard, 58 UnloggedGuard,
59 TrendingGuard,
60 60
61 PluginService, 61 PluginService,
62 HooksService, 62 HooksService,
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts
index 239c27caf..b3985d870 100644
--- a/client/src/app/core/routing/index.ts
+++ b/client/src/app/core/routing/index.ts
@@ -8,3 +8,4 @@ export * from './redirect.service'
8export * from './server-config-resolver.service' 8export * from './server-config-resolver.service'
9export * from './unlogged-guard.service' 9export * from './unlogged-guard.service'
10export * from './user-right-guard.service' 10export * from './user-right-guard.service'
11export * from './trending-guard.service'
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 3218040bf..76e28e461 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -7,11 +7,14 @@ export class RedirectService {
7 // Default route could change according to the instance configuration 7 // Default route could change according to the instance configuration
8 static INIT_DEFAULT_ROUTE = '/videos/trending' 8 static INIT_DEFAULT_ROUTE = '/videos/trending'
9 static DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE 9 static DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE
10 static INIT_DEFAULT_TRENDING_ROUTE = '/videos/most-viewed'
11 static DEFAULT_TRENDING_ROUTE = RedirectService.INIT_DEFAULT_TRENDING_ROUTE
10 12
11 private previousUrl: string 13 private previousUrl: string
12 private currentUrl: string 14 private currentUrl: string
13 15
14 private redirectingToHomepage = false 16 private redirectingToHomepage = false
17 private redirectingToTrending = false
15 18
16 constructor ( 19 constructor (
17 private router: Router, 20 private router: Router,
@@ -19,18 +22,28 @@ export class RedirectService {
19 ) { 22 ) {
20 // The config is first loaded from the cache so try to get the default route 23 // The config is first loaded from the cache so try to get the default route
21 const tmpConfig = this.serverService.getTmpConfig() 24 const tmpConfig = this.serverService.getTmpConfig()
22 if (tmpConfig && tmpConfig.instance && tmpConfig.instance.defaultClientRoute) { 25 if (tmpConfig && tmpConfig.instance) {
23 RedirectService.DEFAULT_ROUTE = tmpConfig.instance.defaultClientRoute 26 if (tmpConfig.instance.defaultClientRoute) {
27 RedirectService.DEFAULT_ROUTE = tmpConfig.instance.defaultClientRoute
28 }
29 if (tmpConfig.instance.defaultTrendingRoute) {
30 RedirectService.DEFAULT_TRENDING_ROUTE = tmpConfig.instance.defaultTrendingRoute
31 }
24 } 32 }
25 33
26 // Load default route 34 // Load default route
27 this.serverService.getConfig() 35 this.serverService.getConfig()
28 .subscribe(config => { 36 .subscribe(config => {
29 const defaultRouteConfig = config.instance.defaultClientRoute 37 const defaultRouteConfig = config.instance.defaultClientRoute
38 const defaultTrendingConfig = config.instance.defaultTrendingRoute
30 39
31 if (defaultRouteConfig) { 40 if (defaultRouteConfig) {
32 RedirectService.DEFAULT_ROUTE = defaultRouteConfig 41 RedirectService.DEFAULT_ROUTE = defaultRouteConfig
33 } 42 }
43
44 if (defaultTrendingConfig) {
45 RedirectService.DEFAULT_TRENDING_ROUTE = defaultTrendingConfig
46 }
34 }) 47 })
35 48
36 // Track previous url 49 // Track previous url
@@ -57,6 +70,15 @@ export class RedirectService {
57 return this.redirectToHomepage() 70 return this.redirectToHomepage()
58 } 71 }
59 72
73 redirectToTrending () {
74 if (this.redirectingToTrending) return
75
76 this.redirectingToTrending = true
77
78 this.router.navigate([ RedirectService.DEFAULT_TRENDING_ROUTE ])
79 .then(() => this.redirectingToTrending = false)
80 }
81
60 redirectToHomepage (skipLocationChange = false) { 82 redirectToHomepage (skipLocationChange = false) {
61 if (this.redirectingToHomepage) return 83 if (this.redirectingToHomepage) return
62 84
diff --git a/client/src/app/core/routing/trending-guard.service.ts b/client/src/app/core/routing/trending-guard.service.ts
new file mode 100644
index 000000000..7db7fe994
--- /dev/null
+++ b/client/src/app/core/routing/trending-guard.service.ts
@@ -0,0 +1,14 @@
1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'
3import { RedirectService } from './redirect.service'
4
5@Injectable()
6export class TrendingGuard implements CanActivate {
7
8 constructor (private redirectService: RedirectService) {}
9
10 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
11 this.redirectService.redirectToTrending()
12 return false
13 }
14}
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index b1d8fcf83..5f13190b4 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -36,9 +36,15 @@ export class ServerService {
36 name: 'PeerTube', 36 name: 'PeerTube',
37 shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' + 37 shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' +
38 'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.', 38 'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.',
39 defaultClientRoute: '',
40 isNSFW: false, 39 isNSFW: false,
41 defaultNSFWPolicy: 'do_not_list' as 'do_not_list', 40 defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
41 defaultClientRoute: '',
42 defaultTrendingRoute: '',
43 pages: {
44 hot: {
45 enabled: true
46 }
47 },
42 customizations: { 48 customizations: {
43 javascript: '', 49 javascript: '',
44 css: '' 50 css: ''