From a1eda903a497857017495f37a1fd3593ba7ab23c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 May 2021 11:36:33 +0200 Subject: Support '/w/' and '/w/p/' for watch page And use them as default in client --- .../edit-basic-configuration.component.html | 2 +- .../my-video-imports/my-video-imports.component.ts | 2 +- .../+page-not-found/page-not-found.component.ts | 2 - .../remote-interaction.component.ts | 2 +- client/src/app/+search/video-lazy-load.resolver.ts | 2 +- .../video-go-live.component.ts | 2 +- .../video-add-components/video-upload.component.ts | 2 +- .../+video-edit/video-update.component.html | 2 +- .../+videos/+video-edit/video-update.component.ts | 2 +- .../comment/video-comment.component.html | 4 +- .../+video-watch/video-watch-routing.module.ts | 2 +- .../+videos/+video-watch/video-watch.component.ts | 2 +- client/src/app/+videos/videos-routing.module.ts | 25 --------- client/src/app/app-routing.module.ts | 65 ++++++++++++++++++---- .../shared-main/users/user-notification.model.ts | 2 +- .../app/shared/shared-main/video/video.model.ts | 2 +- .../shared-share-modal/video-share.component.ts | 4 +- .../shared-thumbnail/video-thumbnail.component.ts | 2 +- .../shared-video-comment/video-comment.model.ts | 2 +- .../video-miniature.component.ts | 2 +- .../video-playlist-element-miniature.component.ts | 2 +- .../video-playlist-miniature.component.ts | 2 +- 22 files changed, 74 insertions(+), 60 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index 451e6a34a..03997ea40 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html @@ -489,7 +489,7 @@ If your instance is explicitly allowed by Twitter, a video player will be embedded in the Twitter feed on PeerTube video share.
If the instance is not, we use an image link card that will redirect to your PeerTube instance.

- Check this checkbox, save the configuration and test with a video URL of your instance (https://example.com/videos/watch/blabla) on + Check this checkbox, save the configuration and test with a video URL of your instance (https://example.com/w/blabla) on https://cards-dev.twitter.com/validator to see if you instance is allowed.
diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts index 359535526..bb9d70524 100644 --- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts +++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts @@ -55,7 +55,7 @@ export class MyVideoImportsComponent extends RestTable implements OnInit { } getVideoUrl (video: { uuid: string }) { - return '/videos/watch/' + video.uuid + return '/w/' + video.uuid } getEditVideoUrl (video: { uuid: string }) { diff --git a/client/src/app/+page-not-found/page-not-found.component.ts b/client/src/app/+page-not-found/page-not-found.component.ts index 695568898..639e5db78 100644 --- a/client/src/app/+page-not-found/page-not-found.component.ts +++ b/client/src/app/+page-not-found/page-not-found.component.ts @@ -2,8 +2,6 @@ import { Component, OnInit } from '@angular/core' import { Title } from '@angular/platform-browser' import { Router } from '@angular/router' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' - - @Component({ selector: 'my-page-not-found', templateUrl: './page-not-found.component.html', diff --git a/client/src/app/+remote-interaction/remote-interaction.component.ts b/client/src/app/+remote-interaction/remote-interaction.component.ts index 3ebe62f49..6ddf5b58d 100644 --- a/client/src/app/+remote-interaction/remote-interaction.component.ts +++ b/client/src/app/+remote-interaction/remote-interaction.component.ts @@ -39,7 +39,7 @@ export class RemoteInteractionComponent implements OnInit { if (videoResult.data.length !== 0) { const video = videoResult.data[0] - redirectUrl = '/videos/watch/' + video.uuid + redirectUrl = '/w/' + video.uuid } else if (channelResult.data.length !== 0) { const channel = new VideoChannel(channelResult.data[0]) diff --git a/client/src/app/+search/video-lazy-load.resolver.ts b/client/src/app/+search/video-lazy-load.resolver.ts index d4fe6ed79..e43e0089b 100644 --- a/client/src/app/+search/video-lazy-load.resolver.ts +++ b/client/src/app/+search/video-lazy-load.resolver.ts @@ -28,7 +28,7 @@ export class VideoLazyLoadResolver implements Resolve { const video = result.data[0] - return this.router.navigateByUrl('/videos/watch/' + video.uuid) + return this.router.navigateByUrl('/w/' + video.uuid) }) ) } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 8e035b6bb..727bbc32f 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -127,7 +127,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView () => { this.notifier.success($localize`Live published.`) - this.router.navigate(['/videos/watch', video.uuid]) + this.router.navigate(['/w', video.uuid]) }, err => { diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index bca1b6eb6..e20f08879 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -244,7 +244,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.isUploadingVideo = false this.notifier.success($localize`Video published.`) - this.router.navigate([ '/videos/watch', video.uuid ]) + this.router.navigate([ '/w', video.uuid ]) }, err => { diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html index 3ce3e623e..9629081e3 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.html +++ b/client/src/app/+videos/+video-edit/video-update.component.html @@ -1,7 +1,7 @@
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index 2973c6840..574669a23 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -156,7 +156,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.isUpdatingVideo = false this.loadingBar.useRef().complete() this.notifier.success($localize`Video updated.`) - this.router.navigate([ '/videos/watch', this.video.uuid ]) + this.router.navigate([ '/w', this.video.uuid ]) }, err => { diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.html b/client/src/app/+videos/+video-watch/comment/video-comment.component.html index fc0d66ffd..06548edc8 100644 --- a/client/src/app/+videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.html @@ -20,7 +20,7 @@
- + {{ comment.createdAt | myFromNow }} @@ -45,7 +45,7 @@ diff --git a/client/src/app/+videos/+video-watch/video-watch-routing.module.ts b/client/src/app/+videos/+video-watch/video-watch-routing.module.ts index cb77685c0..657fd10f8 100644 --- a/client/src/app/+videos/+video-watch/video-watch-routing.module.ts +++ b/client/src/app/+videos/+video-watch/video-watch-routing.module.ts @@ -4,7 +4,7 @@ import { VideoWatchComponent } from './video-watch.component' const videoWatchRoutes: Routes = [ { - path: 'playlist/:playlistId', + path: 'p/:playlistId', component: VideoWatchComponent }, { diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 88c5cef52..0acd44524 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -690,7 +690,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (this.playlist) { this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo()) } else if (this.nextVideoUuid) { - this.router.navigate([ '/videos/watch', this.nextVideoUuid ]) + this.router.navigate([ '/w', this.nextVideoUuid ]) } } diff --git a/client/src/app/+videos/videos-routing.module.ts b/client/src/app/+videos/videos-routing.module.ts index f9f476b18..926dfaab0 100644 --- a/client/src/app/+videos/videos-routing.module.ts +++ b/client/src/app/+videos/videos-routing.module.ts @@ -74,31 +74,6 @@ const videosRoutes: Routes = [ key: 'local-videos-list' } } - }, - { - path: 'upload', - loadChildren: () => import('@app/+videos/+video-edit/video-add.module').then(m => m.VideoAddModule), - data: { - meta: { - title: $localize`Upload a video` - } - } - }, - { - path: 'update/:uuid', - loadChildren: () => import('@app/+videos/+video-edit/video-update.module').then(m => m.VideoUpdateModule), - data: { - meta: { - title: $localize`Edit a video` - } - } - }, - { - path: 'watch', - loadChildren: () => import('@app/+videos/+video-watch/video-watch.module').then(m => m.VideoWatchModule), - data: { - preload: 3000 - } } ] } diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 444b6f134..e35f540be 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -36,16 +36,27 @@ const routes: Routes = [ loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule), canActivateChild: [ MetaGuard ] }, + + { + path: 'accounts', + redirectTo: 'a' + }, { path: 'a', loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule), canActivateChild: [ MetaGuard ] }, + + { + path: 'video-channels', + redirectTo: 'c' + }, { path: 'c', loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule), canActivateChild: [ MetaGuard ] }, + { path: 'about', loadChildren: () => import('./+about/about.module').then(m => m.AboutModule), @@ -71,31 +82,60 @@ const routes: Routes = [ loadChildren: () => import('./+search/search.module').then(m => m.SearchModule), canActivateChild: [ MetaGuard ] }, + { - path: 'videos', - loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule), - canActivateChild: [ MetaGuard ] + path: 'videos/upload', + loadChildren: () => import('@app/+videos/+video-edit/video-add.module').then(m => m.VideoAddModule), + data: { + meta: { + title: $localize`Upload a video` + } + } }, { - path: 'remote-interaction', - loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule), + path: 'videos/update/:uuid', + loadChildren: () => import('@app/+videos/+video-edit/video-update.module').then(m => m.VideoUpdateModule), + data: { + meta: { + title: $localize`Edit a video` + } + } + }, + + { + path: 'videos/watch/playlist', + redirectTo: 'w/p' + }, + { + path: 'videos/watch', + redirectTo: 'w' + }, + { + path: 'w', + loadChildren: () => import('@app/+videos/+video-watch/video-watch.module').then(m => m.VideoWatchModule), + data: { + preload: 3000 + } + }, + { + path: 'videos', + loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule), canActivateChild: [ MetaGuard ] }, { path: 'video-playlists/watch', redirectTo: 'videos/watch/playlist' }, + { - path: 'accounts', - redirectTo: 'a' - }, - { - path: 'video-channels', - redirectTo: 'c' + path: 'remote-interaction', + loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule), + canActivateChild: [ MetaGuard ] }, + + // Matches /@:actorName { matcher: (url): UrlMatchResult => { - // Matches /@:actorName const regex = new RegExp(`^@(${USER_USERNAME_REGEX_CHARACTERS}+)$`) if (url.length !== 1) return null @@ -113,6 +153,7 @@ const routes: Routes = [ canActivate: [ ActorRedirectGuard ], component: EmptyComponent }, + { path: '', component: EmptyComponent // Avoid 404, app component will redirect dynamically diff --git a/client/src/app/shared/shared-main/users/user-notification.model.ts b/client/src/app/shared/shared-main/users/user-notification.model.ts index 002a01583..c80bc13b0 100644 --- a/client/src/app/shared/shared-main/users/user-notification.model.ts +++ b/client/src/app/shared/shared-main/users/user-notification.model.ts @@ -238,7 +238,7 @@ export class UserNotification implements UserNotificationServer { } private buildVideoUrl (video: { uuid: string }) { - return '/videos/watch/' + video.uuid + return '/w/' + video.uuid } private buildAccountUrl (account: { name: string, host: string }) { diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index 526d10e32..e7f739bfe 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -88,7 +88,7 @@ export class Video implements VideoServerModel { pluginData?: any static buildClientUrl (videoUUID: string) { - return '/videos/watch/' + videoUUID + return '/w/' + videoUUID } constructor (hash: VideoServerModel, translations = {}) { diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index e8760bfcc..2a73e6166 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts @@ -98,14 +98,14 @@ export class VideoShareComponent { getVideoUrl () { let baseUrl = this.customizations.originUrl ? this.video.originInstanceUrl : window.location.origin - baseUrl += '/videos/watch/' + this.video.uuid + baseUrl += '/w/' + this.video.uuid const options = this.getVideoOptions(baseUrl) return buildVideoLink(options) } getPlaylistUrl () { - const base = window.location.origin + '/videos/watch/playlist/' + this.playlist.uuid + const base = window.location.origin + '/w/p/' + this.playlist.uuid if (!this.includeVideoInPlaylist) return base diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts index bdede17a3..d5583c29f 100644 --- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts +++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts @@ -57,7 +57,7 @@ export class VideoThumbnailComponent { getVideoRouterLink () { if (this.videoRouterLink) return this.videoRouterLink - return [ '/videos/watch', this.video.uuid ] + return [ '/w', this.video.uuid ] } onWatchLaterClick (event: Event) { diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts index 1a2fe03db..94d6c5fa8 100644 --- a/client/src/app/shared/shared-video-comment/video-comment.model.ts +++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts @@ -85,7 +85,7 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel { id: hash.video.id, uuid: hash.video.uuid, name: hash.video.name, - localUrl: '/videos/watch/' + hash.video.uuid + localUrl: '/w/' + hash.video.uuid } this.localUrl = this.video.localUrl + ';threadId=' + this.threadId diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index b58c118be..aac55a6e9 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts @@ -125,7 +125,7 @@ export class VideoMiniatureComponent implements OnInit { buildVideoLink () { if (this.videoLinkType === 'internal' || !this.video.url) { - this.videoRouterLink = [ '/videos/watch', this.video.uuid ] + this.videoRouterLink = [ '/w', this.video.uuid ] return } diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts index 7c083ae26..86c281a1e 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts @@ -71,7 +71,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { buildRouterLink () { if (!this.playlist) return null - return [ '/videos/watch/playlist', this.playlist.uuid ] + return [ '/w/p', this.playlist.uuid ] } buildRouterQuery () { diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts index 6b0b1056f..9bbec6038 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts @@ -18,6 +18,6 @@ export class VideoPlaylistMiniatureComponent { if (this.toManage) return [ '/my-library/video-playlists', this.playlist.uuid ] if (this.playlist.videosLength === 0) return null - return [ '/videos/watch/playlist', this.playlist.uuid ] + return [ '/w/p', this.playlist.uuid ] } } -- cgit v1.2.3