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 @@ +
+ +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 @@ + +