mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Add endpoint to localize site.webmanifest * Refactor rootUrl * Update changelog --------- Co-authored-by: Thomas Kaul <4159106+dtslvr@users.noreply.github.com>pull/4458/head^2
committed by
GitHub
15 changed files with 96 additions and 28 deletions
@ -0,0 +1,46 @@ |
|||
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|||
import { interpolate } from '@ghostfolio/common/helper'; |
|||
|
|||
import { |
|||
Controller, |
|||
Get, |
|||
Param, |
|||
Res, |
|||
Version, |
|||
VERSION_NEUTRAL |
|||
} from '@nestjs/common'; |
|||
import { Response } from 'express'; |
|||
import { readFileSync } from 'fs'; |
|||
import { join } from 'path'; |
|||
|
|||
@Controller('assets') |
|||
export class AssetsController { |
|||
private webManifest = ''; |
|||
|
|||
public constructor( |
|||
public readonly configurationService: ConfigurationService |
|||
) { |
|||
try { |
|||
this.webManifest = readFileSync( |
|||
join(__dirname, 'assets', 'site.webmanifest'), |
|||
'utf8' |
|||
); |
|||
} catch {} |
|||
} |
|||
|
|||
@Get('/:languageCode/site.webmanifest') |
|||
@Version(VERSION_NEUTRAL) |
|||
public getWebManifest( |
|||
@Param('languageCode') languageCode: string, |
|||
@Res() response: Response |
|||
): void { |
|||
const rootUrl = this.configurationService.get('ROOT_URL'); |
|||
const webManifest = interpolate(this.webManifest, { |
|||
languageCode, |
|||
rootUrl |
|||
}); |
|||
|
|||
response.setHeader('Content-Type', 'application/json'); |
|||
response.send(webManifest); |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|||
|
|||
import { Module } from '@nestjs/common'; |
|||
|
|||
import { AssetsController } from './assets.controller'; |
|||
|
|||
@Module({ |
|||
controllers: [AssetsController], |
|||
providers: [ConfigurationService] |
|||
}) |
|||
export class AssetsModule {} |
@ -1,4 +1,7 @@ |
|||
import { DEFAULT_HOST, DEFAULT_PORT } from '@ghostfolio/common/config'; |
|||
|
|||
export const environment = { |
|||
production: true, |
|||
rootUrl: `http://${DEFAULT_HOST}:${DEFAULT_PORT}`, |
|||
version: `${require('../../../../package.json').version}` |
|||
}; |
|||
|
@ -1,4 +1,7 @@ |
|||
import { DEFAULT_HOST } from '@ghostfolio/common/config'; |
|||
|
|||
export const environment = { |
|||
production: false, |
|||
rootUrl: `https://${DEFAULT_HOST}:4200`, |
|||
version: 'dev' |
|||
}; |
|||
|
Loading…
Reference in new issue