1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-10 04:07:35 +02:00

Implementing custom header support #331, #325, fixes #404,

This commit is contained in:
Patrik J. Braun 2022-01-14 10:56:21 +01:00
parent 58e1857c9a
commit 2ca74ef8b4
4 changed files with 20 additions and 1 deletions

View File

@ -78,7 +78,15 @@ export class PublicRouter {
res.tpl.user.csrfToken = req.csrfToken();
}
}
res.tpl.Config = {Client: Config.Client.toJSON({attachVolatile: true})};
const confCopy = {Client: Config.Client.toJSON({attachVolatile: true})};
// Escaping html tags, like <script></script>
confCopy.Client.Other.customHTMLHead = confCopy.Client.Other.customHTMLHead.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
res.tpl.Config = confCopy;
res.tpl.customHTMLHead = Config.Client.Other.customHTMLHead;
return next();
});

View File

@ -111,6 +111,8 @@ export class NavBarConfig {
@SubConfigClass()
export class ClientOtherConfig {
@ConfigProperty()
customHTMLHead: string = '';
@ConfigProperty()
enableCache: boolean = true;
@ConfigProperty()

View File

@ -105,6 +105,14 @@
required="true">
</app-settings-entry>
<app-settings-entry
name="Custom HTML Head"
description="Injects the content of this between the <head></head> HTML tags of the app. (You can use it add analytics or custom code to the app)"
[ngModel]="states.Client.customHTMLHead"
i18n-name
[simplifiedMode]="simplifiedMode">
</app-settings-entry>
<button class="btn btn-success float-right"

View File

@ -20,6 +20,7 @@
var ServerInject = {user: <%- JSON.stringify(user); %>, ConfigInject: <%- JSON.stringify(Config); %>}
</script>
<%- customHTMLHead %>
</head>
<body style="overflow-y: scroll; padding-right: 0 !important;">