mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Merge remote-tracking branch 'origin/master' into 2.0.X
This commit is contained in:
commit
db4663d6be
14 changed files with 1759 additions and 1500 deletions
|
@ -6,6 +6,10 @@ Please report security issues to https://github.com/louislam/uptime-kuma/securit
|
|||
|
||||
Do not use the public issue tracker or discuss it in the public as it will cause more damage.
|
||||
|
||||
## Do you accept other 3rd-party bug bounty platforms?
|
||||
|
||||
At this moment, I DO NOT accept other bug bounty platforms, because I am not familiar with these platforms and someone have tried to send a phishing link to me by this already. To minimize my own risk, please report through GitHub Advisories only. I will ignore all 3rd-party bug bounty platforms emails.
|
||||
|
||||
## Supported Versions
|
||||
|
||||
### Uptime Kuma Versions
|
||||
|
|
4
db/patch-add-google-analytics-status-page-tag.sql
Normal file
4
db/patch-add-google-analytics-status-page-tag.sql
Normal file
|
@ -0,0 +1,4 @@
|
|||
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||
BEGIN TRANSACTION;
|
||||
ALTER TABLE status_page ADD google_analytics_tag_id VARCHAR;
|
||||
COMMIT;
|
3184
package-lock.json
generated
3184
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -71,6 +71,7 @@ class Database {
|
|||
"patch-ping-packet-size.sql": true,
|
||||
"patch-maintenance-table2.sql": true,
|
||||
"patch-add-gamedig-monitor.sql": true,
|
||||
"patch-add-google-analytics-status-page-tag.sql": true,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
24
server/google-analytics.js
Normal file
24
server/google-analytics.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const jsesc = require("jsesc");
|
||||
|
||||
/**
|
||||
* Returns a string that represents the javascript that is required to insert the Google Analytics scripts
|
||||
* into a webpage.
|
||||
* @param tagId Google UA/G/AW/DC Property ID to use with the Google Analytics script.
|
||||
* @returns {string}
|
||||
*/
|
||||
function getGoogleAnalyticsScript(tagId) {
|
||||
let escapedTagId = jsesc(tagId, { isScriptContext: true });
|
||||
|
||||
if (escapedTagId) {
|
||||
escapedTagId = escapedTagId.trim();
|
||||
}
|
||||
|
||||
return `
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=${escapedTagId}"></script>
|
||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());gtag('config', '${escapedTagId}'); </script>
|
||||
`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getGoogleAnalyticsScript,
|
||||
};
|
|
@ -4,6 +4,7 @@ const cheerio = require("cheerio");
|
|||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||
const jsesc = require("jsesc");
|
||||
const Maintenance = require("./maintenance");
|
||||
const googleAnalytics = require("../google-analytics");
|
||||
|
||||
class StatusPage extends BeanModel {
|
||||
|
||||
|
@ -53,9 +54,17 @@ class StatusPage extends BeanModel {
|
|||
|
||||
const head = $("head");
|
||||
|
||||
if (statusPage.googleAnalyticsTagId) {
|
||||
let escapedGoogleAnalyticsScript = googleAnalytics.getGoogleAnalyticsScript(statusPage.googleAnalyticsTagId);
|
||||
head.append($(escapedGoogleAnalyticsScript));
|
||||
}
|
||||
|
||||
// OG Meta Tags
|
||||
head.append(`<meta property="og:title" content="${statusPage.title}" />`);
|
||||
head.append(`<meta property="og:description" content="${description155}" />`);
|
||||
let ogTitle = $("<meta property=\"og:title\" content=\"\" />").attr("content", statusPage.title);
|
||||
head.append(ogTitle);
|
||||
|
||||
let ogDescription = $("<meta property=\"og:description\" content=\"\" />").attr("content", description155);
|
||||
head.append(ogDescription);
|
||||
|
||||
// Preload data
|
||||
// Add jsesc, fix https://github.com/louislam/uptime-kuma/issues/2186
|
||||
|
@ -225,6 +234,7 @@ class StatusPage extends BeanModel {
|
|||
customCSS: this.custom_css,
|
||||
footerText: this.footer_text,
|
||||
showPoweredBy: !!this.show_powered_by,
|
||||
googleAnalyticsId: this.google_analytics_tag_id,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -245,6 +255,7 @@ class StatusPage extends BeanModel {
|
|||
customCSS: this.custom_css,
|
||||
footerText: this.footer_text,
|
||||
showPoweredBy: !!this.show_powered_by,
|
||||
googleAnalyticsId: this.google_analytics_tag_id,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
|||
statusPage.custom_css = config.customCSS;
|
||||
statusPage.show_powered_by = config.showPoweredBy;
|
||||
statusPage.modified_date = R.isoDateTime();
|
||||
statusPage.google_analytics_tag_id = config.googleAnalyticsId;
|
||||
|
||||
await R.store(statusPage);
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ exports.mysqlQuery = function (connectionString, query) {
|
|||
reject(err);
|
||||
})
|
||||
.finally(() => {
|
||||
connection.end();
|
||||
connection.destroy();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -38,6 +38,7 @@ const languageList = {
|
|||
"th-TH": "ไทย",
|
||||
"el-GR": "Ελληνικά",
|
||||
"yue": "繁體中文 (廣東話 / 粵語)",
|
||||
"ro": "Limba română",
|
||||
};
|
||||
|
||||
let messages = {
|
||||
|
|
|
@ -691,5 +691,9 @@
|
|||
"onebotSafetyTips": "For safety, must set access token",
|
||||
"PushDeer Key": "PushDeer Key",
|
||||
"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",
|
||||
"Edit Tag": "Edit Tag",
|
||||
"Server Address": "Server Address",
|
||||
"Learn More": "Learn More"
|
||||
}
|
||||
|
|
3
src/lang/ro.json
Normal file
3
src/lang/ro.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"languageName": "Limba română"
|
||||
}
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
|
||||
<div class="text-center mt-3" style="font-size: 13px;">
|
||||
<a href="https://github.com/louislam/uptime-kuma/wiki/Maintenance" target="_blank">Learn More</a>
|
||||
<a href="https://github.com/louislam/uptime-kuma/wiki/Maintenance" target="_blank">{{ $t("Learn More") }}</a>
|
||||
</div>
|
||||
|
||||
<Confirm ref="confirmPause" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="pauseMaintenance">
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</p>
|
||||
|
||||
<div class="form-floating">
|
||||
<select id="language" v-model="$i18n.locale" class="form-select">
|
||||
<select id="language" v-model="$root.language" class="form-select">
|
||||
<option v-for="(lang, i) in $i18n.availableLocales" :key="`Lang${i}`" :value="lang">
|
||||
{{ $i18n.messages[lang].languageName }}
|
||||
</option>
|
||||
|
@ -59,9 +59,7 @@ export default {
|
|||
};
|
||||
},
|
||||
watch: {
|
||||
"$i18n.locale"() {
|
||||
localStorage.locale = this.$i18n.locale;
|
||||
},
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.$root.getSocket().emit("needSetup", (needSetup) => {
|
||||
|
|
|
@ -67,6 +67,12 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Google Analytics -->
|
||||
<div class="my-3">
|
||||
<label for="googleAnalyticsTag" class="form-label">{{ $t("Google Analytics ID") }}</label>
|
||||
<input id="googleAnalyticsTag" v-model="config.googleAnalyticsId" type="text" class="form-control">
|
||||
</div>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<div class="my-3">
|
||||
<div class="mb-1">{{ $t("Custom CSS") }}</div>
|
||||
|
|
Loading…
Reference in a new issue