Merge pull request #1187 from hedgedoc/improvement/remove-banner-from-frontend-config

This commit is contained in:
David Mehren 2021-04-25 21:32:16 +02:00 committed by GitHub
commit 6129f21ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 50 deletions

1
.gitignore vendored
View file

@ -41,5 +41,6 @@ dist
public/uploads/* public/uploads/*
!public/uploads/.gitkeep !public/uploads/.gitkeep
!public/.gitkeep
uploads uploads
test_uploads test_uploads

0
public/.gitkeep Normal file
View file

View file

@ -7,7 +7,6 @@
import { import {
IsArray, IsArray,
IsBoolean, IsBoolean,
IsDate,
IsNumber, IsNumber,
IsOptional, IsOptional,
IsString, IsString,
@ -78,22 +77,6 @@ export class AuthProviders {
internal: boolean; internal: boolean;
} }
export class BannerDto {
/**
* The text that is shown in the banner
* @example This is a test banner
*/
@IsString()
text: string;
/**
* When the banner was last changed
* @example "2020-12-01 12:23:34"
*/
@IsDate()
updateTime: Date;
}
export class BrandingDto { export class BrandingDto {
/** /**
* The name to be displayed next to the HedgeDoc logo * The name to be displayed next to the HedgeDoc logo
@ -227,12 +210,6 @@ export class FrontendConfigDto {
@ValidateNested() @ValidateNested()
branding: BrandingDto; branding: BrandingDto;
/**
* An optional banner that will be shown
*/
@ValidateNested()
banner: BannerDto;
/** /**
* The custom names of auth providers, which can be specified multiple times * The custom names of auth providers, which can be specified multiple times
*/ */

View file

@ -276,10 +276,6 @@ describe('FrontendConfigService', () => {
authConfig.oauth2.length !== 0, authConfig.oauth2.length !== 0,
); );
expect(config.allowAnonymous).toEqual(false); expect(config.allowAnonymous).toEqual(false);
expect(config.banner.text).toEqual('');
expect(config.banner.updateTime).toEqual(
new Date(0),
);
expect(config.branding.name).toEqual(customName); expect(config.branding.name).toEqual(customName);
expect(config.branding.logo).toEqual( expect(config.branding.logo).toEqual(
customLogo ? new URL(customLogo) : undefined, customLogo ? new URL(customLogo) : undefined,

View file

@ -8,7 +8,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { ConsoleLoggerService } from '../logger/console-logger.service'; import { ConsoleLoggerService } from '../logger/console-logger.service';
import { import {
AuthProviders, AuthProviders,
BannerDto,
BrandingDto, BrandingDto,
CustomAuthNamesDto, CustomAuthNamesDto,
FrontendConfigDto, FrontendConfigDto,
@ -24,8 +23,6 @@ import externalServicesConfiguration, {
ExternalServicesConfig, ExternalServicesConfig,
} from '../config/external-services.config'; } from '../config/external-services.config';
import { getServerVersionFromPackageJson } from '../utils/serverVersion'; import { getServerVersionFromPackageJson } from '../utils/serverVersion';
import { promises as fs, Stats } from 'fs';
import { join } from 'path';
@Injectable() @Injectable()
export class FrontendConfigService { export class FrontendConfigService {
@ -49,7 +46,6 @@ export class FrontendConfigService {
allowAnonymous: false, allowAnonymous: false,
allowRegister: this.authConfig.email.enableRegister, allowRegister: this.authConfig.email.enableRegister,
authProviders: this.getAuthProviders(), authProviders: this.getAuthProviders(),
banner: await FrontendConfigService.getBanner(),
branding: this.getBranding(), branding: this.getBranding(),
customAuthNames: this.getCustomAuthNames(), customAuthNames: this.getCustomAuthNames(),
iframeCommunication: this.getIframeCommunication(), iframeCommunication: this.getIframeCommunication(),
@ -138,23 +134,4 @@ export class FrontendConfigService {
: new URL(this.appConfig.domain), : new URL(this.appConfig.domain),
}; };
} }
private static async getBanner(): Promise<BannerDto> {
const path = join(__dirname, '../../banner.md');
try {
const bannerContent: string = await fs.readFile(path, {
encoding: 'utf8',
});
const fileStats: Stats = await fs.stat(path);
return {
text: bannerContent,
updateTime: fileStats.mtime,
};
} catch (e) {
return {
text: '',
updateTime: new Date(0),
};
}
}
} }

View file

@ -55,6 +55,13 @@ async function bootstrap(): Promise<void> {
prefix: '/uploads/', prefix: '/uploads/',
}); });
} }
logger.log(
`Serving the local folder 'public' under '/public'`,
'AppBootstrap',
);
app.useStaticAssets('public', {
prefix: '/public/',
});
await app.listen(appConfig.port); await app.listen(appConfig.port);
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap'); logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
} }