aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/instance/instance.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/instance/instance.service.ts')
-rw-r--r--client/src/app/shared/instance/instance.service.ts45
1 files changed, 44 insertions, 1 deletions
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'
4import { environment } from '../../../environments/environment' 4import { environment } from '../../../environments/environment'
5import { RestExtractor, RestService } from '../rest' 5import { RestExtractor, RestService } from '../rest'
6import { About } from '../../../../../shared/models/server' 6import { About } from '../../../../../shared/models/server'
7import { MarkdownService } from '@app/shared/renderer'
8import { peertubeTranslate } from '@shared/models'
9import { ServerService } from '@app/core'
7 10
8@Injectable() 11@Injectable()
9export class InstanceService { 12export class InstanceService {
@@ -13,7 +16,9 @@ export class InstanceService {
13 constructor ( 16 constructor (
14 private authHttp: HttpClient, 17 private authHttp: HttpClient,
15 private restService: RestService, 18 private restService: RestService,
16 private restExtractor: RestExtractor 19 private restExtractor: RestExtractor,
20 private markdownService: MarkdownService,
21 private serverService: ServerService
17 ) { 22 ) {
18 } 23 }
19 24
@@ -34,4 +39,42 @@ export class InstanceService {
34 .pipe(catchError(res => this.restExtractor.handleError(res))) 39 .pipe(catchError(res => this.restExtractor.handleError(res)))
35 40
36 } 41 }
42
43 async buildHtml (about: About) {
44 const html = {
45 description: '',
46 terms: '',
47 codeOfConduct: '',
48 moderationInformation: '',
49 administrator: ''
50 }
51
52 for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) {
53 html[ key ] = await this.markdownService.textMarkdownToHTML(about.instance[ key ])
54 }
55
56 return html
57 }
58
59 buildTranslatedLanguages (about: About, translations: any) {
60 const languagesArray = this.serverService.getVideoLanguages()
61
62 return about.instance.languages
63 .map(l => {
64 const languageObj = languagesArray.find(la => la.id === l)
65
66 return peertubeTranslate(languageObj.label, translations)
67 })
68 }
69
70 buildTranslatedCategories (about: About, translations: any) {
71 const categoriesArray = this.serverService.getVideoCategories()
72
73 return about.instance.categories
74 .map(c => {
75 const categoryObj = categoriesArray.find(ca => ca.id === c)
76
77 return peertubeTranslate(categoryObj.label, translations)
78 })
79 }
37} 80}