mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-12 04:59:05 +08:00
Add custom html code to head
With this PR a new text field will be added that allows setting custom html code to the `<head>` of a status page. The implementation will be similar to https://github.com/louislam/uptime-kuma/pull/2567/files, but with a multi-line text field and without escaping any special chars. For security reasons the env var `UPTIME_KUMA_ALLOW_CUSTOM_HTML` must be set to `1` to enable this feature. This will allow tracking with most analytic platforms and has been requested several times. Closes #2818
This commit is contained in:
committed by
Frank Elsinga
parent
10ebdcacaa
commit
7f0d3a3043
@@ -66,6 +66,10 @@ class StatusPage extends BeanModel {
|
||||
head.append($(escapedGoogleAnalyticsScript));
|
||||
}
|
||||
|
||||
if (process.env.UPTIME_KUMA_ALLOW_CUSTOM_HTML === "1") {
|
||||
head.append(statusPage.customHtml);
|
||||
}
|
||||
|
||||
// OG Meta Tags
|
||||
let ogTitle = $("<meta property=\"og:title\" content=\"\" />").attr("content", statusPage.title);
|
||||
head.append(ogTitle);
|
||||
@@ -247,6 +251,7 @@ class StatusPage extends BeanModel {
|
||||
showPoweredBy: !!this.show_powered_by,
|
||||
googleAnalyticsId: this.google_analytics_tag_id,
|
||||
showCertificateExpiry: !!this.show_certificate_expiry,
|
||||
customHtml: this.custom_html
|
||||
};
|
||||
}
|
||||
|
||||
@@ -270,6 +275,7 @@ class StatusPage extends BeanModel {
|
||||
showPoweredBy: !!this.show_powered_by,
|
||||
googleAnalyticsId: this.google_analytics_tag_id,
|
||||
showCertificateExpiry: !!this.show_certificate_expiry,
|
||||
customHtml: this.custom_html
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -167,6 +167,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
||||
statusPage.show_certificate_expiry = config.showCertificateExpiry;
|
||||
statusPage.modified_date = R.isoDateTime();
|
||||
statusPage.google_analytics_tag_id = config.googleAnalyticsId;
|
||||
statusPage.custom_html = config.customHtml;
|
||||
|
||||
await R.store(statusPage);
|
||||
|
||||
|
Reference in New Issue
Block a user