From 421d935d256db5b77a652d8da0c9a38cb57147ba Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Aug 2019 17:09:43 +0200 Subject: Add about information in registration page --- .../shared/angular/peertube-template.directive.ts | 4 +- .../shared/forms/peertube-checkbox.component.html | 11 +++++- .../shared/forms/peertube-checkbox.component.ts | 24 ++++++++++-- .../instance-features-table.component.html | 6 ++- client/src/app/shared/instance/instance.service.ts | 45 +++++++++++++++++++++- client/src/app/shared/misc/help.component.html | 28 +++++++++----- client/src/app/shared/misc/help.component.ts | 36 ++++++++++++----- .../remote-subscribe.component.html | 22 +++++++---- .../app/shared/video/videos-selection.component.ts | 2 +- 9 files changed, 141 insertions(+), 37 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/angular/peertube-template.directive.ts b/client/src/app/shared/angular/peertube-template.directive.ts index a514b6057..e04c25d9a 100644 --- a/client/src/app/shared/angular/peertube-template.directive.ts +++ b/client/src/app/shared/angular/peertube-template.directive.ts @@ -3,8 +3,8 @@ import { Directive, Input, TemplateRef } from '@angular/core' @Directive({ selector: '[ptTemplate]' }) -export class PeerTubeTemplateDirective { - @Input('ptTemplate') name: string +export class PeerTubeTemplateDirective { + @Input('ptTemplate') name: T constructor (public template: TemplateRef) { // empty diff --git a/client/src/app/shared/forms/peertube-checkbox.component.html b/client/src/app/shared/forms/peertube-checkbox.component.html index 571a1a673..f1e3bf0bf 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.html +++ b/client/src/app/shared/forms/peertube-checkbox.component.html @@ -3,8 +3,15 @@ {{ labelText }} - + + + + - + + + + + diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.ts index a4b72aa37..3b8f39ed0 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.ts +++ b/client/src/app/shared/forms/peertube-checkbox.component.ts @@ -1,5 +1,6 @@ -import { ChangeDetectorRef, Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core' +import { AfterContentInit, ChangeDetectorRef, Component, ContentChildren, forwardRef, Input, QueryList, TemplateRef } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' +import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive' @Component({ selector: 'my-peertube-checkbox', @@ -13,20 +14,35 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' } ] }) -export class PeertubeCheckboxComponent implements ControlValueAccessor { +export class PeertubeCheckboxComponent implements ControlValueAccessor, AfterContentInit { @Input() checked = false @Input() inputName: string @Input() labelText: string - @Input() labelHtml: string - @Input() helpHtml: string @Input() helpPlacement = 'top' @Input() disabled = false + @ContentChildren(PeerTubeTemplateDirective) templates: QueryList> + // FIXME: https://github.com/angular/angular/issues/10816#issuecomment-307567836 @Input() onPushWorkaround = false + labelTemplate: TemplateRef + helpTemplate: TemplateRef + constructor (private cdr: ChangeDetectorRef) { } + ngAfterContentInit () { + { + const t = this.templates.find(t => t.name === 'label') + if (t) this.labelTemplate = t.template + } + + { + const t = this.templates.find(t => t.name === 'help') + if (t) this.helpTemplate = t.template + } + } + propagateChange = (_: any) => { /* empty */ } writeValue (checked: boolean) { diff --git a/client/src/app/shared/instance/instance-features-table.component.html b/client/src/app/shared/instance/instance-features-table.component.html index 845876f55..d1cb8fcbe 100644 --- a/client/src/app/shared/instance/instance-features-table.component.html +++ b/client/src/app/shared/instance/instance-features-table.component.html @@ -43,7 +43,11 @@ {{ initialUserVideoQuota | bytes: 0 }} ({{ dailyUserVideoQuota | bytes: 0 }} per day) - + + +
+
+
diff --git a/client/src/app/shared/instance/instance.service.ts b/client/src/app/shared/instance/instance.service.ts index d0c96941d..7c76bc98b 100644 --- a/client/src/app/shared/instance/instance.service.ts +++ b/client/src/app/shared/instance/instance.service.ts @@ -4,6 +4,9 @@ import { Injectable } from '@angular/core' import { environment } from '../../../environments/environment' import { RestExtractor, RestService } from '../rest' import { About } from '../../../../../shared/models/server' +import { MarkdownService } from '@app/shared/renderer' +import { peertubeTranslate } from '@shared/models' +import { ServerService } from '@app/core' @Injectable() export class InstanceService { @@ -13,7 +16,9 @@ export class InstanceService { constructor ( private authHttp: HttpClient, private restService: RestService, - private restExtractor: RestExtractor + private restExtractor: RestExtractor, + private markdownService: MarkdownService, + private serverService: ServerService ) { } @@ -34,4 +39,42 @@ export class InstanceService { .pipe(catchError(res => this.restExtractor.handleError(res))) } + + async buildHtml (about: About) { + const html = { + description: '', + terms: '', + codeOfConduct: '', + moderationInformation: '', + administrator: '' + } + + for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { + html[ key ] = await this.markdownService.textMarkdownToHTML(about.instance[ key ]) + } + + return html + } + + buildTranslatedLanguages (about: About, translations: any) { + const languagesArray = this.serverService.getVideoLanguages() + + return about.instance.languages + .map(l => { + const languageObj = languagesArray.find(la => la.id === l) + + return peertubeTranslate(languageObj.label, translations) + }) + } + + buildTranslatedCategories (about: About, translations: any) { + const categoriesArray = this.serverService.getVideoCategories() + + return about.instance.categories + .map(c => { + const categoryObj = categoriesArray.find(ca => ca.id === c) + + return peertubeTranslate(categoryObj.label, translations) + }) + } } diff --git a/client/src/app/shared/misc/help.component.html b/client/src/app/shared/misc/help.component.html index e31eef06a..9a6d3e48e 100644 --- a/client/src/app/shared/misc/help.component.html +++ b/client/src/app/shared/misc/help.component.html @@ -1,15 +1,25 @@ - -

-
-
+

+ +

-

+ +

+
- -
-

-
+

+ +

+ +

+ + +

+
+ +

+ +

> + isPopoverOpened = false mainHtml = '' + preHtmlTemplate: TemplateRef + customHtmlTemplate: TemplateRef + postHtmlTemplate: TemplateRef + constructor (private i18n: I18n) { } ngOnInit () { this.init() } + ngAfterContentInit () { + { + const t = this.templates.find(t => t.name === 'preHtml') + if (t) this.preHtmlTemplate = t.template + } + + { + const t = this.templates.find(t => t.name === 'customHtml') + if (t) this.customHtmlTemplate = t.template + } + + { + const t = this.templates.find(t => t.name === 'postHtml') + if (t) this.postHtmlTemplate = t.template + } + } + ngOnChanges () { this.init() } @@ -37,11 +58,6 @@ export class HelpComponent implements OnInit, OnChanges { } private init () { - if (this.helpType === 'custom') { - this.mainHtml = this.customHtml - return - } - if (this.helpType === 'markdownText') { this.mainHtml = this.formatMarkdownSupport(MarkdownService.TEXT_RULES) return diff --git a/client/src/app/shared/user-subscription/remote-subscribe.component.html b/client/src/app/shared/user-subscription/remote-subscribe.component.html index ec3636b3e..59ee1cb04 100644 --- a/client/src/app/shared/user-subscription/remote-subscribe.component.html +++ b/client/src/app/shared/user-subscription/remote-subscribe.component.html @@ -12,13 +12,21 @@ Remote interact - + + + + You can subscribe to the channel via any ActivityPub-capable fediverse instance.

+ For instance with Mastodon or Pleroma you can type the channel URL in the search box and subscribe there. +
+
- + + + + You can interact with this via any ActivityPub-capable fediverse instance.

+ For instance with Mastodon or Pleroma you can type the current URL in the search box and interact with it there. +
+
- \ No newline at end of file + diff --git a/client/src/app/shared/video/videos-selection.component.ts b/client/src/app/shared/video/videos-selection.component.ts index 994e0fa1e..064420056 100644 --- a/client/src/app/shared/video/videos-selection.component.ts +++ b/client/src/app/shared/video/videos-selection.component.ts @@ -35,7 +35,7 @@ export class VideosSelectionComponent extends AbstractVideoList implements OnIni @Input() titlePage: string @Input() miniatureDisplayOptions: MiniatureDisplayOptions @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable> - @ContentChildren(PeerTubeTemplateDirective) templates: QueryList + @ContentChildren(PeerTubeTemplateDirective) templates: QueryList> @Output() selectionChange = new EventEmitter() @Output() videosModelChange = new EventEmitter() -- cgit v1.2.3