mirror of
https://github.com/sigmasternchen/drnk.me
synced 2025-03-15 09:48:54 +00:00
feat: Add proper success page
This commit is contained in:
parent
803c54e4d4
commit
5473554422
6 changed files with 38 additions and 9 deletions
|
@ -3,5 +3,9 @@
|
|||
return function (array &$context) {
|
||||
$data = [];
|
||||
|
||||
if (key_exists("formonly", $_GET)) {
|
||||
require(ROOT . "/templates/pages/components/url-form.php");
|
||||
} else {
|
||||
require(ROOT . "/templates/pages/homepage.php");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,9 +22,10 @@ return function (array &$context) {
|
|||
|
||||
if (!$url) {
|
||||
setStatusCode(400);
|
||||
echo json_encode(
|
||||
errorResponse("URL missing", "Please provide a URL.")
|
||||
);
|
||||
$data = [
|
||||
"error" => "Something went wrong. Please try again later."
|
||||
];
|
||||
require(ROOT . "/templates/pages/components/url-form.php");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,5 +50,9 @@ return function (array &$context) {
|
|||
$accessKey
|
||||
));
|
||||
|
||||
echo json_encode($result);
|
||||
$data = [
|
||||
"url" => "https://drnk.me/$slug",
|
||||
"accessKey" => $accessKey,
|
||||
];
|
||||
require(ROOT . "/templates/pages/components/creation-successful.php");
|
||||
};
|
||||
|
|
|
@ -58,3 +58,7 @@ html {
|
|||
width: 100%;
|
||||
margin-top: 1vw;
|
||||
}
|
||||
|
||||
.result {
|
||||
font-size: 2vw;
|
||||
}
|
5
templates/pages/components/creation-successful.php
Normal file
5
templates/pages/components/creation-successful.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<div class="result">
|
||||
<a href="<?php echo $data["url"] ?? ""; ?>" target="_blank"><?php echo $data["url"] ?? ""; ?></a>
|
||||
</div>
|
||||
<!-- <?php echo $data["accessKey"] ?? ""; ?> -->
|
||||
Click <a hx-get="/?formonly" hx-swap="innerHTML" hx-target=".center-panel" href="/">here</a> to create a new link.
|
14
templates/pages/components/url-form.php
Normal file
14
templates/pages/components/url-form.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
if ($data["error"] ?? false) {
|
||||
?>
|
||||
<div class="error">
|
||||
<?php echo $data["error"]; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="/manage" method="POST" hx-post="/manage" hx-swap="innerHTML" hx-target=".center-panel">
|
||||
<input type="text" name="url" placeholder="<?php echo $data["url"] ?? "URL" ?>">
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
|
@ -10,10 +10,7 @@ require(__DIR__ . "/../layout/top.php");
|
|||
<img class="bottle" src="/static/img/bottle.png" alt="picture of a vile with a tag 'Drnk Me'" />
|
||||
|
||||
<div class="center-panel">
|
||||
<form action="/manage" method="POST">
|
||||
<input type="text" name="url" placeholder="<?php echo $data["url"] ?? "URL" ?>">
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
<?php require(__DIR__ . "/components/url-form.php"); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
|
Loading…
Reference in a new issue