mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Add standalone manifest.json for each status page. Close #1668
This commit is contained in:
parent
624678826d
commit
27dbc021b4
|
@ -45,6 +45,8 @@ class StatusPage extends BeanModel {
|
|||
$("link[rel=icon]")
|
||||
.attr("href", statusPage.icon)
|
||||
.removeAttr("type");
|
||||
|
||||
$("link[rel=apple-touch-icon]").remove();
|
||||
}
|
||||
|
||||
const head = $("head");
|
||||
|
@ -61,6 +63,9 @@ class StatusPage extends BeanModel {
|
|||
</script>
|
||||
`);
|
||||
|
||||
// manifest.json
|
||||
$("link[rel=manifest]").attr("href", `/api/status-page/${statusPage.slug}/manifest.json`);
|
||||
|
||||
return $.root().html();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,4 +107,42 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
|||
}
|
||||
});
|
||||
|
||||
// Status page's manifest.json
|
||||
router.get("/api/status-page/:slug/manifest.json", cache("1440 minutes"), async (request, response) => {
|
||||
allowDevAllOrigin(response);
|
||||
let slug = request.params.slug;
|
||||
|
||||
try {
|
||||
// Get Status Page
|
||||
let statusPage = await R.findOne("status_page", " slug = ? ", [
|
||||
slug
|
||||
]);
|
||||
|
||||
if (!statusPage) {
|
||||
response.statusCode = 404;
|
||||
response.json({
|
||||
msg: "Not Found"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Response
|
||||
response.json({
|
||||
"name": statusPage.title,
|
||||
"start_url": "/status/" + statusPage.slug,
|
||||
"display": "standalone",
|
||||
"icons": [
|
||||
{
|
||||
"src": statusPage.icon,
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
send403(response, error.message);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
Loading…
Reference in a new issue