mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-11 22:06:59 +08:00
Compare commits
3 Commits
2.0.0-beta
...
custom-hea
Author | SHA1 | Date | |
---|---|---|---|
|
4b0e7de3e4 | ||
|
2a556e714f | ||
|
7f0d3a3043 |
14
db/knex_migrations/2023-10-13-1200-add-custom-html.js
Normal file
14
db/knex_migrations/2023-10-13-1200-add-custom-html.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
exports.up = function (knex) {
|
||||||
|
// Insert column for custom HTML code
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("status_page", function (table) {
|
||||||
|
table.text("custom_html").nullable().defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("custom_html");
|
||||||
|
});
|
||||||
|
};
|
2
package-lock.json
generated
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",
|
||||||
|
@@ -66,6 +66,10 @@ class StatusPage extends BeanModel {
|
|||||||
head.append($(escapedGoogleAnalyticsScript));
|
head.append($(escapedGoogleAnalyticsScript));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.UPTIME_KUMA_ALLOW_CUSTOM_HTML === "1") {
|
||||||
|
head.append(statusPage.customHtml);
|
||||||
|
}
|
||||||
|
|
||||||
// OG Meta Tags
|
// OG Meta Tags
|
||||||
let ogTitle = $("<meta property=\"og:title\" content=\"\" />").attr("content", statusPage.title);
|
let ogTitle = $("<meta property=\"og:title\" content=\"\" />").attr("content", statusPage.title);
|
||||||
head.append(ogTitle);
|
head.append(ogTitle);
|
||||||
@@ -247,6 +251,7 @@ class StatusPage extends BeanModel {
|
|||||||
showPoweredBy: !!this.show_powered_by,
|
showPoweredBy: !!this.show_powered_by,
|
||||||
googleAnalyticsId: this.google_analytics_tag_id,
|
googleAnalyticsId: this.google_analytics_tag_id,
|
||||||
showCertificateExpiry: !!this.show_certificate_expiry,
|
showCertificateExpiry: !!this.show_certificate_expiry,
|
||||||
|
customHtml: this.custom_html
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +275,7 @@ class StatusPage extends BeanModel {
|
|||||||
showPoweredBy: !!this.show_powered_by,
|
showPoweredBy: !!this.show_powered_by,
|
||||||
googleAnalyticsId: this.google_analytics_tag_id,
|
googleAnalyticsId: this.google_analytics_tag_id,
|
||||||
showCertificateExpiry: !!this.show_certificate_expiry,
|
showCertificateExpiry: !!this.show_certificate_expiry,
|
||||||
|
customHtml: this.custom_html
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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,6 +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;
|
||||||
|
}
|
||||||
|
|
||||||
await R.store(statusPage);
|
await R.store(statusPage);
|
||||||
|
|
||||||
|
@@ -776,6 +776,9 @@
|
|||||||
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {0} .",
|
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {0} .",
|
||||||
"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",
|
||||||
|
"customHtmlEnvVarDisabled": "environment variable {allow_custom_html} must be set to inject html to the head",
|
||||||
|
"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",
|
||||||
|
@@ -104,6 +104,22 @@
|
|||||||
<prism-editor v-model="config.customCSS" class="css-editor" :highlight="highlighter" line-numbers></prism-editor>
|
<prism-editor v-model="config.customCSS" class="css-editor" :highlight="highlighter" line-numbers></prism-editor>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Custom HTML -->
|
||||||
|
<div class="my-3">
|
||||||
|
<div class="mb-1">{{ $t("Custom HTML") }}</div>
|
||||||
|
<prism-editor v-model="config.customHtml" class="css-editor" :highlight="highlighter" line-numbers :readonly="!config.allowEditingCustomHtml"></prism-editor>
|
||||||
|
<i18n-t v-if="config.allowEditingCustomHtml" tag="div" class="form-text" keypath="customHtmlEnvVarEnabled">
|
||||||
|
<template #allow_custom_html>
|
||||||
|
<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 class="danger-zone">
|
<div class="danger-zone">
|
||||||
<button class="btn btn-danger me-2" @click="deleteDialog">
|
<button class="btn btn-danger me-2" @click="deleteDialog">
|
||||||
<font-awesome-icon icon="trash" />
|
<font-awesome-icon icon="trash" />
|
||||||
|
Reference in New Issue
Block a user