Release 1.180.1 (#1170)
This commit is contained in:
parent
20195b2b1a
commit
52f0fb5ab8
@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## 1.180.0 - 18.08.2022
|
## 1.180.1 - 18.08.2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
@ -1,39 +1,57 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
|
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
|
||||||
import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
|
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FrontendMiddleware implements NestMiddleware {
|
export class FrontendMiddleware implements NestMiddleware {
|
||||||
use(req: Request, res: Response, next: NextFunction) {
|
public indexHtmlDe = fs.readFileSync(
|
||||||
if (req.url.includes('cover.png')) {
|
this.getPathOfIndexHtmlFile('de'),
|
||||||
Logger.log(`Referer: ${req.headers.referer}`, 'FrontendMiddleware');
|
'utf8'
|
||||||
|
);
|
||||||
|
public indexHtmlEn = fs.readFileSync(
|
||||||
|
this.getPathOfIndexHtmlFile(DEFAULT_LANGUAGE_CODE),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
// Resolve feature graphic for blog post
|
public constructor(
|
||||||
if (req.headers.referer?.includes('500-stars-on-github')) {
|
private readonly configurationService: ConfigurationService
|
||||||
res.sendFile(
|
) {}
|
||||||
path.join(
|
|
||||||
__dirname,
|
public use(req: Request, res: Response, next: NextFunction) {
|
||||||
'..',
|
let featureGraphicPath = 'assets/cover.png';
|
||||||
'client',
|
|
||||||
'assets',
|
if (
|
||||||
'images',
|
req.path === '/en/blog/2022/08/500-stars-on-github' ||
|
||||||
'blog',
|
req.path === '/en/blog/2022/08/500-stars-on-github/'
|
||||||
'500-stars-on-github.jpg'
|
) {
|
||||||
)
|
featureGraphicPath = 'assets/images/blog/500-stars-on-github.jpg';
|
||||||
);
|
}
|
||||||
} else {
|
|
||||||
// Skip
|
if (req.path.startsWith('/api/') || this.isFileRequest(req.url)) {
|
||||||
next();
|
|
||||||
}
|
|
||||||
} else if (req.path.startsWith('/api/') || this.isFileRequest(req.url)) {
|
|
||||||
// Skip
|
// Skip
|
||||||
next();
|
next();
|
||||||
} else if (req.path.startsWith('/de/')) {
|
} else if (req.path === '/de' || req.path.startsWith('/de/')) {
|
||||||
res.sendFile(this.getPathOfIndexHtmlFile('de'));
|
res.send(
|
||||||
|
this.interpolate(this.indexHtmlDe, {
|
||||||
|
featureGraphicPath,
|
||||||
|
languageCode: 'de',
|
||||||
|
path: req.path,
|
||||||
|
rootUrl: this.configurationService.get('ROOT_URL')
|
||||||
|
})
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
res.sendFile(this.getPathOfIndexHtmlFile(DEFAULT_LANGUAGE_CODE));
|
res.send(
|
||||||
|
this.interpolate(this.indexHtmlEn, {
|
||||||
|
featureGraphicPath,
|
||||||
|
languageCode: DEFAULT_LANGUAGE_CODE,
|
||||||
|
path: req.path,
|
||||||
|
rootUrl: this.configurationService.get('ROOT_URL')
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +59,16 @@ export class FrontendMiddleware implements NestMiddleware {
|
|||||||
return path.join(__dirname, '..', 'client', aLocale, 'index.html');
|
return path.join(__dirname, '..', 'client', aLocale, 'index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private interpolate(template: string, context: any) {
|
||||||
|
return template.replace(/[$]{([^}]+)}/g, (_, objectPath) => {
|
||||||
|
const properties = objectPath.split('.');
|
||||||
|
return properties.reduce(
|
||||||
|
(previous, current) => previous?.[current],
|
||||||
|
context
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private isFileRequest(filename: string) {
|
private isFileRequest(filename: string) {
|
||||||
if (filename === '/assets/LICENSE') {
|
if (filename === '/assets/LICENSE') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="h-100 position-relative" lang="en">
|
<html class="h-100 position-relative" lang="${languageCode}">
|
||||||
<head>
|
<head>
|
||||||
<title>Ghostfolio – Open Source Wealth Management Software</title>
|
<title>Ghostfolio – Open Source Wealth Management Software</title>
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
@ -19,7 +19,7 @@
|
|||||||
name="twitter:description"
|
name="twitter:description"
|
||||||
content="Ghostfolio is a lightweight wealth management application for individuals to keep track of stocks, ETFs or cryptocurrencies"
|
content="Ghostfolio is a lightweight wealth management application for individuals to keep track of stocks, ETFs or cryptocurrencies"
|
||||||
/>
|
/>
|
||||||
<meta name="twitter:image" content="https://ghostfol.io/assets/cover.png" />
|
<meta name="twitter:image" content="${rootUrl}/${featureGraphicPath}" />
|
||||||
<meta
|
<meta
|
||||||
name="twitter:title"
|
name="twitter:title"
|
||||||
content="Ghostfolio – Open Source Wealth Management Software"
|
content="Ghostfolio – Open Source Wealth Management Software"
|
||||||
@ -34,8 +34,8 @@
|
|||||||
content="Ghostfolio – Open Source Wealth Management Software"
|
content="Ghostfolio – Open Source Wealth Management Software"
|
||||||
/>
|
/>
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:url" content="https://ghostfol.io" />
|
<meta property="og:url" content="${rootUrl}${path}" />
|
||||||
<meta property="og:image" content="https://ghostfol.io/assets/cover.png" />
|
<meta property="og:image" content="${rootUrl}/${featureGraphicPath}" />
|
||||||
<meta property="og:updated_time" content="2022-08-18T00:00:00+00:00" />
|
<meta property="og:updated_time" content="2022-08-18T00:00:00+00:00" />
|
||||||
<meta
|
<meta
|
||||||
property="og:site_name"
|
property="og:site_name"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ghostfolio",
|
"name": "ghostfolio",
|
||||||
"version": "1.180.0",
|
"version": "1.180.1",
|
||||||
"homepage": "https://ghostfol.io",
|
"homepage": "https://ghostfol.io",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user