Browse Source

Refactoring

release/2.147.0-beta.1
Thomas Kaul 4 days ago
parent
commit
44e76bd802
  1. 6
      apps/api/src/app/app.module.ts
  2. 8
      apps/api/src/app/sitemap/sitemap.controller.ts
  3. 45
      apps/api/src/app/webmanifest/webmanifest.controller.ts
  4. 6
      apps/api/src/app/webmanifest/webmanifest.module.ts
  5. 61
      apps/api/src/assets/site.webmanifest
  6. 8
      apps/client/ngsw-config.json
  7. 3
      apps/client/project.json
  8. 31
      apps/client/src/assets/site.webmanifest
  9. 5
      apps/client/src/index.html

6
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 {}
export class AppModule {}

8
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 {}

45
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);

6
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 {}

61
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}"
}
"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}"
}

8
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"]
}
},
{

3
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"
},

31
apps/client/src/assets/site.webmanifest

@ -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"
}

5
apps/client/src/index.html

@ -45,7 +45,10 @@
sizes="16x16"
type="image/png"
/>
<link href="../assets/site.webmanifest" rel="manifest" />
<link
href="${rootUrl}/api/assets/${languageCode}/site.webmanifest"
rel="manifest"
/>
</head>
<body>
<gf-root></gf-root>

Loading…
Cancel
Save