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 --- client/src/app/shared/instance/instance.service.ts | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/instance/instance.service.ts') 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) + }) + } } -- cgit v1.2.3