implemented additional changes

custom-head
Frank Elsinga 6 months ago
parent 7f0d3a3043
commit 2a556e714f

2
package-lock.json generated

@ -74,7 +74,7 @@
"socket.io": "~4.6.1", "socket.io": "~4.6.1",
"socket.io-client": "~4.6.1", "socket.io-client": "~4.6.1",
"socks-proxy-agent": "6.1.1", "socks-proxy-agent": "6.1.1",
"sqlite3": "^5.1.7", "sqlite3": "~5.1.7",
"tar": "~6.2.1", "tar": "~6.2.1",
"tcp-ping": "~0.1.1", "tcp-ping": "~0.1.1",
"thirty-two": "~1.0.2", "thirty-two": "~1.0.2",

@ -101,10 +101,11 @@ module.exports.statusPageSocketHandler = (socket) => {
if (!statusPage) { if (!statusPage) {
throw new Error("No slug?"); throw new Error("No slug?");
} }
const config = await statusPage.toJSON();
config.allowEditingCustomHtml = import.meta.env.UPTIME_KUMA_ALLOW_CUSTOM_HTML === '1';
callback({ callback({
ok: true, ok: true,
config: await statusPage.toJSON(), config,
}); });
} catch (error) { } catch (error) {
callback({ callback({
@ -167,7 +168,9 @@ module.exports.statusPageSocketHandler = (socket) => {
statusPage.show_certificate_expiry = config.showCertificateExpiry; statusPage.show_certificate_expiry = config.showCertificateExpiry;
statusPage.modified_date = R.isoDateTime(); statusPage.modified_date = R.isoDateTime();
statusPage.google_analytics_tag_id = config.googleAnalyticsId; statusPage.google_analytics_tag_id = config.googleAnalyticsId;
if (process.env.UPTIME_KUMA_ALLOW_CUSTOM_HTML === "1"){
statusPage.custom_html = config.customHtml; statusPage.custom_html = config.customHtml;
}
await R.store(statusPage); await R.store(statusPage);

@ -777,8 +777,8 @@
"Custom Monitor Type": "Custom Monitor Type", "Custom Monitor Type": "Custom Monitor Type",
"Google Analytics ID": "Google Analytics ID", "Google Analytics ID": "Google Analytics ID",
"Custom HTML": "Custom HTML", "Custom HTML": "Custom HTML",
"customHtmlEnvVar1": "The environment variable", "customHtmlEnvVarDisabled": "environment variable {allow_custom_html} must be set to inject html to the head",
"customHtmlEnvVar2": "must be set to", "customHtmlEnvVarEnabled": "Because the environment variable {allow_custom_html} is set, arbitrary html can be injected into the head. Make sure to remove the environment variable after use",
"Edit Tag": "Edit Tag", "Edit Tag": "Edit Tag",
"Server Address": "Server Address", "Server Address": "Server Address",
"Learn More": "Learn More", "Learn More": "Learn More",

@ -107,10 +107,17 @@
<!-- Custom HTML --> <!-- Custom HTML -->
<div class="my-3"> <div class="my-3">
<div class="mb-1">{{ $t("Custom HTML") }}</div> <div class="mb-1">{{ $t("Custom HTML") }}</div>
<prism-editor v-model="config.customHtml" class="css-editor" :highlight="highlighter" line-numbers></prism-editor> <prism-editor v-model="config.customHtml" class="css-editor" :highlight="highlighter" line-numbers :readonly="!config.allowEditingCustomHtml"></prism-editor>
<div class="form-text"> <i18n-t v-if="config.allowEditingCustomHtml" tag="div" class="form-text" keypath="customHtmlEnvVarEnabled">
{{ $t("customHtmlEnvVar1") }} <code>UPTIME_KUMA_ALLOW_CUSTOM_HTML</code> {{ $t("customHtmlEnvVar2") }} <code>1</code>. <template #allow_custom_html>
</div> <code>UPTIME_KUMA_ALLOW_CUSTOM_HTML</code>
</template>
</i18n-t>
<i18n-t v-else tag="div" class="form-text" keypath="customHtmlEnvVarDisabled">
<template #allow_custom_html>
<code>UPTIME_KUMA_ALLOW_CUSTOM_HTML=1</code>
</template>
</i18n-t>
</div> </div>
<div class="danger-zone"> <div class="danger-zone">

Loading…
Cancel
Save