diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 5f8d33782..3cfe830d9 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -51,6 +51,7 @@ import { SitemapModule } from './sitemap/sitemap.module'; import { SubscriptionModule } from './subscription/subscription.module'; import { SymbolModule } from './symbol/symbol.module'; import { UserModule } from './user/user.module'; +import { WebManifestModule } from './webmanifest/webmanifest.module'; @Module({ controllers: [AppController], @@ -126,8 +127,9 @@ import { UserModule } from './user/user.module'; SymbolModule, TagsModule, TwitterBotModule, - UserModule + UserModule, + WebManifestModule ], providers: [CronService] }) -export class AppModule {} \ No newline at end of file +export class AppModule {} diff --git a/apps/api/src/app/sitemap/sitemap.controller.ts b/apps/api/src/app/sitemap/sitemap.controller.ts index ea21906ef..aad5e39a1 100644 --- a/apps/api/src/app/sitemap/sitemap.controller.ts +++ b/apps/api/src/app/sitemap/sitemap.controller.ts @@ -9,8 +9,8 @@ import { personalFinanceTools } from '@ghostfolio/common/personal-finance-tools' import { Controller, Get, Res, VERSION_NEUTRAL, Version } from '@nestjs/common'; import { format } from 'date-fns'; import { Response } from 'express'; -import * as fs from 'fs'; -import * as path from 'path'; +import { readFileSync } from 'fs'; +import { join } from 'path'; @Controller('sitemap.xml') export class SitemapController { @@ -20,8 +20,8 @@ export class SitemapController { private readonly configurationService: ConfigurationService ) { try { - this.sitemapXml = fs.readFileSync( - path.join(__dirname, 'assets', 'sitemap.xml'), + this.sitemapXml = readFileSync( + join(__dirname, 'assets', 'sitemap.xml'), 'utf8' ); } catch {} diff --git a/apps/api/src/app/webmanifest/webmanifest.controller.ts b/apps/api/src/app/webmanifest/webmanifest.controller.ts index df04c1e67..b2dfe0ce0 100644 --- a/apps/api/src/app/webmanifest/webmanifest.controller.ts +++ b/apps/api/src/app/webmanifest/webmanifest.controller.ts @@ -1,31 +1,44 @@ -import { Controller, Get, Param, Res, Version, VERSION_NEUTRAL } from '@nestjs/common'; -import { Response } from 'express'; -import { interpolate } from '@ghostfolio/common/helper'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; -import * as fs from 'fs'; -import * as path from 'path'; +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 WebManifestController { - public webManifestTemplate: string; + private webManifest = ''; - public constructor(public readonly configService: ConfigurationService) { + public constructor( + public readonly configurationService: ConfigurationService + ) { try { - this.webManifestTemplate = fs.readFileSync( - path.resolve(__dirname, '../../assets/site.webmanifest'), + this.webManifest = readFileSync( + join(__dirname, 'assets', 'site.webmanifest'), 'utf8' ); - } catch (error) { - console.error('Error reading site.webmanifest:', error); - this.webManifestTemplate = ''; - } + } catch {} } @Get('/:languageCode/site.webmanifest') @Version(VERSION_NEUTRAL) - public getWebManifest(@Param('languageCode') languageCode: string, @Res() res: Response): void { - const rootUrl = this.configService.get('ROOT_URL') || 'https://default.url.com'; - const webManifest = interpolate(this.webManifestTemplate, { languageCode, rootUrl }); + public getWebManifest( + @Param('languageCode') languageCode: string, + @Res() res: Response + ): void { + const rootUrl = this.configurationService.get('ROOT_URL'); + const webManifest = interpolate(this.webManifest, { + languageCode, + rootUrl + }); res.setHeader('Content-Type', 'application/json'); res.send(webManifest); diff --git a/apps/api/src/app/webmanifest/webmanifest.module.ts b/apps/api/src/app/webmanifest/webmanifest.module.ts index 1324551e1..d8f366ee5 100644 --- a/apps/api/src/app/webmanifest/webmanifest.module.ts +++ b/apps/api/src/app/webmanifest/webmanifest.module.ts @@ -1,9 +1,11 @@ +import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; + import { Module } from '@nestjs/common'; + import { WebManifestController } from './webmanifest.controller'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; @Module({ controllers: [WebManifestController], - providers: [ConfigurationService], + providers: [ConfigurationService] }) export class WebManifestModule {} diff --git a/apps/api/src/assets/site.webmanifest b/apps/api/src/assets/site.webmanifest index f58668cbd..a28719625 100644 --- a/apps/api/src/assets/site.webmanifest +++ b/apps/api/src/assets/site.webmanifest @@ -1,32 +1,31 @@ { - "background_color": "#FFFFFF", - "categories": ["finance", "utilities"], - "description": "Open Source Wealth Management Software", - "display": "standalone", - "icons": [ - { - "sizes": "192x192", - "src": "/assets/android-chrome-192x192.png", - "type": "image/png" - }, - { - "purpose": "any", - "sizes": "512x512", - "src": "/assets/android-chrome-512x512.png", - "type": "image/png" - }, - { - "purpose": "maskable", - "sizes": "512x512", - "src": "/assets/android-chrome-512x512.png", - "type": "image/png" - } - ], - "name": "Ghostfolio", - "orientation": "portrait", - "short_name": "Ghostfolio", - "start_url": "/${languageCode}/", - "theme_color": "#FFFFFF", - "url": "${rootUrl}" - } - \ No newline at end of file + "background_color": "#FFFFFF", + "categories": ["finance", "utilities"], + "description": "Open Source Wealth Management Software", + "display": "standalone", + "icons": [ + { + "sizes": "192x192", + "src": "/assets/android-chrome-192x192.png", + "type": "image/png" + }, + { + "purpose": "any", + "sizes": "512x512", + "src": "/assets/android-chrome-512x512.png", + "type": "image/png" + }, + { + "purpose": "maskable", + "sizes": "512x512", + "src": "/assets/android-chrome-512x512.png", + "type": "image/png" + } + ], + "name": "Ghostfolio", + "orientation": "portrait", + "short_name": "Ghostfolio", + "start_url": "/${languageCode}/", + "theme_color": "#FFFFFF", + "url": "${rootUrl}" +} diff --git a/apps/client/ngsw-config.json b/apps/client/ngsw-config.json index c0f03a135..56e1cfd63 100644 --- a/apps/client/ngsw-config.json +++ b/apps/client/ngsw-config.json @@ -6,13 +6,7 @@ "name": "app", "installMode": "prefetch", "resources": { - "files": [ - "/favicon.ico", - "/index.html", - "/assets/site.webmanifest", - "/*.css", - "/*.js" - ] + "files": ["/favicon.ico", "/index.html", "/*.css", "/*.js"] } }, { diff --git a/apps/client/project.json b/apps/client/project.json index 160a27ea7..b2144d7b3 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -146,9 +146,6 @@ { "command": "shx cp apps/client/src/assets/robots.txt dist/apps/client" }, - { - "command": "shx cp apps/client/src/assets/site.webmanifest dist/apps/client" - }, { "command": "shx cp node_modules/ionicons/dist/index.js dist/apps/client" }, diff --git a/apps/client/src/assets/site.webmanifest b/apps/client/src/assets/site.webmanifest deleted file mode 100644 index 8f1eceefb..000000000 --- a/apps/client/src/assets/site.webmanifest +++ /dev/null @@ -1,31 +0,0 @@ -{ - "background_color": "#FFFFFF", - "categories": ["finance", "utilities"], - "description": "Open Source Wealth Management Software", - "display": "standalone", - "icons": [ - { - "sizes": "192x192", - "src": "/assets/android-chrome-192x192.png", - "type": "image/png" - }, - { - "purpose": "any", - "sizes": "512x512", - "src": "/assets/android-chrome-512x512.png", - "type": "image/png" - }, - { - "purpose": "maskable", - "sizes": "512x512", - "src": "/assets/android-chrome-512x512.png", - "type": "image/png" - } - ], - "name": "Ghostfolio", - "orientation": "portrait", - "short_name": "Ghostfolio", - "start_url": "/en/", - "theme_color": "#FFFFFF", - "url": "https://ghostfol.io" -} diff --git a/apps/client/src/index.html b/apps/client/src/index.html index 47f2c3d1a..fc111a72d 100644 --- a/apps/client/src/index.html +++ b/apps/client/src/index.html @@ -45,7 +45,10 @@ sizes="16x16" type="image/png" /> - +