From 8ee25e17b88b970703f4df9e74cb4726bbffd837 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 31 May 2021 11:33:49 +0200 Subject: Add ability to set custom markdown in description --- .../button-markup.component.html | 1 + .../button-markup.component.scss | 3 ++ .../button-markup.component.ts | 34 ++++++++++++ .../channel-miniature-markup.component.html | 8 +++ .../channel-miniature-markup.component.scss | 9 ++++ .../channel-miniature-markup.component.ts | 26 ++++++++++ .../peertube-custom-tags/embed-markup.component.ts | 22 ++++++++ .../peertube-custom-tags/index.ts | 6 +++ .../playlist-miniature-markup.component.html | 2 + .../playlist-miniature-markup.component.scss | 7 +++ .../playlist-miniature-markup.component.ts | 38 ++++++++++++++ .../video-miniature-markup.component.html | 6 +++ .../video-miniature-markup.component.scss | 7 +++ .../video-miniature-markup.component.ts | 44 ++++++++++++++++ .../videos-list-markup.component.html | 13 +++++ .../videos-list-markup.component.scss | 9 ++++ .../videos-list-markup.component.ts | 60 ++++++++++++++++++++++ 17 files changed, 295 insertions(+) create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.html create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.scss create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.html create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.scss create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/index.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.html create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.scss create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.scss create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.scss create mode 100644 client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts (limited to 'client/src/app/shared/shared-custom-markup/peertube-custom-tags') diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.html new file mode 100644 index 000000000..619bb9d8c --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.html @@ -0,0 +1 @@ +{{ label }} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.scss b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.scss new file mode 100644 index 000000000..f43d6b400 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.scss @@ -0,0 +1,3 @@ +@import '_variables'; +@import '_mixins'; + diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts new file mode 100644 index 000000000..987b37d19 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts @@ -0,0 +1,34 @@ +import { Component, Input } from '@angular/core' +import { VideoChannel } from '../../shared-main' + +/* + * Markup component that creates a button +*/ + +@Component({ + selector: 'my-button-markup', + templateUrl: 'button-markup.component.html', + styleUrls: [ 'button-markup.component.scss' ] +}) +export class ButtonMarkupComponent { + @Input() theme: 'primary' | 'secondary' + @Input() href: string + @Input() label: string + @Input() blankTarget?: boolean + + channel: VideoChannel + + getTarget () { + if (this.blankTarget === true) return '_blank' + + return '' + } + + getClasses () { + const additionalClass = this.theme === 'primary' + ? 'orange-button' + : 'grey-button' + + return [ 'peertube-button-link', additionalClass ] + } +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.html new file mode 100644 index 000000000..da81006b9 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.html @@ -0,0 +1,8 @@ +
+ + +
{{ channel.displayName }}
+
{{ channel.name }}
+ +
{{ channel.description }}
+
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.scss b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.scss new file mode 100644 index 000000000..85018afe2 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.scss @@ -0,0 +1,9 @@ +@import '_variables'; +@import '_mixins'; + +.channel { + border-radius: 15px; + padding: 10px; + width: min-content; + border: 1px solid pvar(--mainColor); +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts new file mode 100644 index 000000000..25deafb80 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -0,0 +1,26 @@ +import { Component, Input, OnInit } from '@angular/core' +import { VideoChannel, VideoChannelService } from '../../shared-main' + +/* + * Markup component that creates a channel miniature only +*/ + +@Component({ + selector: 'my-channel-miniature-markup', + templateUrl: 'channel-miniature-markup.component.html', + styleUrls: [ 'channel-miniature-markup.component.scss' ] +}) +export class ChannelMiniatureMarkupComponent implements OnInit { + @Input() name: string + + channel: VideoChannel + + constructor ( + private channelService: VideoChannelService + ) { } + + ngOnInit () { + this.channelService.getVideoChannel(this.name) + .subscribe(channel => this.channel = channel) + } +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts new file mode 100644 index 000000000..a854d89f6 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts @@ -0,0 +1,22 @@ +import { buildPlaylistLink, buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' +import { environment } from 'src/environments/environment' +import { Component, ElementRef, Input, OnInit } from '@angular/core' + +@Component({ + selector: 'my-embed-markup', + template: '' +}) +export class EmbedMarkupComponent implements OnInit { + @Input() uuid: string + @Input() type: 'video' | 'playlist' = 'video' + + constructor (private el: ElementRef) { } + + ngOnInit () { + const link = this.type === 'video' + ? buildVideoLink({ baseUrl: `${environment.originServerUrl}/videos/embed/${this.uuid}` }) + : buildPlaylistLink({ baseUrl: `${environment.originServerUrl}/video-playlists/embed/${this.uuid}` }) + + this.el.nativeElement.innerHTML = buildVideoOrPlaylistEmbed(link, this.uuid) + } +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/index.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/index.ts new file mode 100644 index 000000000..ee2a8f330 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/index.ts @@ -0,0 +1,6 @@ +export * from './button-markup.component' +export * from './channel-miniature-markup.component' +export * from './embed-markup.component' +export * from './playlist-miniature-markup.component' +export * from './video-miniature-markup.component' +export * from './videos-list-markup.component' diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.html new file mode 100644 index 000000000..4e1d1a13f --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.html @@ -0,0 +1,2 @@ + + diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.scss b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.scss new file mode 100644 index 000000000..281cef726 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.scss @@ -0,0 +1,7 @@ +@import '_variables'; +@import '_mixins'; + +my-video-playlist-miniature { + display: inline-block; + width: $video-thumbnail-width; +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts new file mode 100644 index 000000000..eddc3636e --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts @@ -0,0 +1,38 @@ +import { Component, Input, OnInit } from '@angular/core' +import { MiniatureDisplayOptions } from '../../shared-video-miniature' +import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist' + +/* + * Markup component that creates a playlist miniature only +*/ + +@Component({ + selector: 'my-playlist-miniature-markup', + templateUrl: 'playlist-miniature-markup.component.html', + styleUrls: [ 'playlist-miniature-markup.component.scss' ] +}) +export class PlaylistMiniatureMarkupComponent implements OnInit { + @Input() uuid: string + + playlist: VideoPlaylist + + displayOptions: MiniatureDisplayOptions = { + date: true, + views: true, + by: true, + avatar: false, + privacyLabel: false, + privacyText: false, + state: false, + blacklistInfo: false + } + + constructor ( + private playlistService: VideoPlaylistService + ) { } + + ngOnInit () { + this.playlistService.getVideoPlaylist(this.uuid) + .subscribe(playlist => this.playlist = playlist) + } +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html new file mode 100644 index 000000000..9b4930b6d --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html @@ -0,0 +1,6 @@ + + diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.scss b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.scss new file mode 100644 index 000000000..81e265f29 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.scss @@ -0,0 +1,7 @@ +@import '_variables'; +@import '_mixins'; + +my-video-miniature { + display: inline-block; + width: $video-thumbnail-width; +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts new file mode 100644 index 000000000..c833c56c7 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts @@ -0,0 +1,44 @@ +import { Component, Input, OnInit } from '@angular/core' +import { AuthService } from '@app/core' +import { Video, VideoService } from '../../shared-main' +import { MiniatureDisplayOptions } from '../../shared-video-miniature' + +/* + * Markup component that creates a video miniature only +*/ + +@Component({ + selector: 'my-video-miniature-markup', + templateUrl: 'video-miniature-markup.component.html', + styleUrls: [ 'video-miniature-markup.component.scss' ] +}) +export class VideoMiniatureMarkupComponent implements OnInit { + @Input() uuid: string + + video: Video + + displayOptions: MiniatureDisplayOptions = { + date: true, + views: true, + by: true, + avatar: false, + privacyLabel: false, + privacyText: false, + state: false, + blacklistInfo: false + } + + constructor ( + private auth: AuthService, + private videoService: VideoService + ) { } + + getUser () { + return this.auth.getUser() + } + + ngOnInit () { + this.videoService.getVideo({ videoId: this.uuid }) + .subscribe(video => this.video = video) + } +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html new file mode 100644 index 000000000..501f35e04 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html @@ -0,0 +1,13 @@ +
+

{{ title }}

+
{{ description }}
+ +
+ + +
+
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.scss b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.scss new file mode 100644 index 000000000..dcd931090 --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.scss @@ -0,0 +1,9 @@ +@import '_variables'; +@import '_mixins'; + +my-video-miniature { + margin-right: 15px; + display: inline-block; + min-width: $video-thumbnail-width; + max-width: $video-thumbnail-width; +} diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts new file mode 100644 index 000000000..8d9e223da --- /dev/null +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts @@ -0,0 +1,60 @@ +import { Component, Input, OnInit } from '@angular/core' +import { AuthService } from '@app/core' +import { VideoSortField } from '@shared/models' +import { Video, VideoService } from '../../shared-main' +import { MiniatureDisplayOptions } from '../../shared-video-miniature' + +/* + * Markup component list videos depending on criterias +*/ + +@Component({ + selector: 'my-videos-list-markup', + templateUrl: 'videos-list-markup.component.html', + styleUrls: [ 'videos-list-markup.component.scss' ] +}) +export class VideosListMarkupComponent implements OnInit { + @Input() title: string + @Input() description: string + @Input() sort = '-publishedAt' + @Input() categoryOneOf: number[] + @Input() languageOneOf: string[] + @Input() count = 10 + + videos: Video[] + + displayOptions: MiniatureDisplayOptions = { + date: true, + views: true, + by: true, + avatar: false, + privacyLabel: false, + privacyText: false, + state: false, + blacklistInfo: false + } + + constructor ( + private auth: AuthService, + private videoService: VideoService + ) { } + + getUser () { + return this.auth.getUser() + } + + ngOnInit () { + const options = { + videoPagination: { + currentPage: 1, + itemsPerPage: this.count + }, + categoryOneOf: this.categoryOneOf, + languageOneOf: this.languageOneOf, + sort: this.sort as VideoSortField + } + + this.videoService.getVideos(options) + .subscribe(({ data }) => this.videos = data) + } +} -- cgit v1.2.3