From 547355442290043013e3b7b9f51ad93dcaa64732 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sat, 2 Dec 2023 22:13:02 +0100 Subject: [PATCH] feat: Add proper success page --- controllers/GET.php | 6 +++++- controllers/manage/POST.php | 13 +++++++++---- html/static/css/main.css | 4 ++++ templates/pages/components/creation-successful.php | 5 +++++ templates/pages/components/url-form.php | 14 ++++++++++++++ templates/pages/homepage.php | 5 +---- 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 templates/pages/components/creation-successful.php create mode 100644 templates/pages/components/url-form.php diff --git a/controllers/GET.php b/controllers/GET.php index 4f452c0..692536c 100644 --- a/controllers/GET.php +++ b/controllers/GET.php @@ -3,5 +3,9 @@ return function (array &$context) { $data = []; - require(ROOT . "/templates/pages/homepage.php"); + if (key_exists("formonly", $_GET)) { + require(ROOT . "/templates/pages/components/url-form.php"); + } else { + require(ROOT . "/templates/pages/homepage.php"); + } }; diff --git a/controllers/manage/POST.php b/controllers/manage/POST.php index 9508241..f01ab51 100644 --- a/controllers/manage/POST.php +++ b/controllers/manage/POST.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"); }; diff --git a/html/static/css/main.css b/html/static/css/main.css index 5746c48..1bb721d 100644 --- a/html/static/css/main.css +++ b/html/static/css/main.css @@ -57,4 +57,8 @@ html { font-size: 3vw; width: 100%; margin-top: 1vw; +} + +.result { + font-size: 2vw; } \ No newline at end of file diff --git a/templates/pages/components/creation-successful.php b/templates/pages/components/creation-successful.php new file mode 100644 index 0000000..75fe3c3 --- /dev/null +++ b/templates/pages/components/creation-successful.php @@ -0,0 +1,5 @@ +
+ " target="_blank"> +
+ +Click here to create a new link. diff --git a/templates/pages/components/url-form.php b/templates/pages/components/url-form.php new file mode 100644 index 0000000..5e982bc --- /dev/null +++ b/templates/pages/components/url-form.php @@ -0,0 +1,14 @@ + +
+ +
+ + +
+ "> + +
\ No newline at end of file diff --git a/templates/pages/homepage.php b/templates/pages/homepage.php index 05cb432..e74534e 100644 --- a/templates/pages/homepage.php +++ b/templates/pages/homepage.php @@ -10,10 +10,7 @@ require(__DIR__ . "/../layout/top.php"); picture of a vile with a tag 'Drnk Me'
-
- "> - -
+