Created the redirect module
This commit is contained in:
31
modules/redirect/module.js
Normal file
31
modules/redirect/module.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
const Joi = require("joi");
|
||||||
|
|
||||||
|
module.exports.onClick = (id, accessId, metaData, controller) => {
|
||||||
|
controller.locals.meta.timer = controller.locals.meta.timer || 5;
|
||||||
|
controller.render(__dirname + "/web/index");
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.info = {
|
||||||
|
name: "Nutzer weiterleiten",
|
||||||
|
icon: "compass",
|
||||||
|
validationSchema: Joi.object({
|
||||||
|
shortenUrl: Joi.string().max(2500).uri().required(),
|
||||||
|
timer: Joi.number().min(1).max(60)
|
||||||
|
}),
|
||||||
|
meta: [{
|
||||||
|
name: "Link-Einstellungen",
|
||||||
|
type: "default",
|
||||||
|
fields: {
|
||||||
|
shortenUrl: {
|
||||||
|
type: "text",
|
||||||
|
name: "Zu kürzende URL",
|
||||||
|
description: "Die zu kürzende (lange) URL"
|
||||||
|
},
|
||||||
|
timer: {
|
||||||
|
type: "number",
|
||||||
|
name: "Weiterleitung in Sekunden",
|
||||||
|
description: "Wann soll weitergeleitet werden?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
42
modules/redirect/web/index.ejs
Normal file
42
modules/redirect/web/index.ejs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Automatische Weiterleitung</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
font-family: 'Courier New', serif;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
color: #0d6efd;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1>Automatische Weiterleitung</h1>
|
||||||
|
<p>Du wirst in <span id="time"><%= meta.timer %></span> Sekunden auf <span><%= meta.shortenUrl%></span> weitergeleitet.</p>
|
||||||
|
<a onclick="history.back()" href="#">Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
let seconds = <%= meta.timer %>;
|
||||||
|
setInterval(() => {
|
||||||
|
seconds--;
|
||||||
|
document.getElementById("time").innerText = seconds;
|
||||||
|
|
||||||
|
if (seconds === 0) location.href = "<%= meta.shortenUrl %>";
|
||||||
|
}, 1000, 0);
|
||||||
|
</script>
|
||||||
|
</html>
|
Reference in New Issue
Block a user