From 71ea81d18ebc5f39af91cf5002991ce0489b10fd Mon Sep 17 00:00:00 2001 From: swaggboi Date: Sat, 7 Oct 2023 15:15:55 -0400 Subject: [PATCH] Some routes --- README.md | 3 ++- lib/Hyperlink-Redirect.rakumod | 11 +++++++++++ templates/header.tt | 1 + templates/index.tt | 13 ++++++++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7d1fa4e..9ed5483 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,5 @@ A "useful" tool for turning hyperlinks into redirects in the name of shortening ## TODO -1. Fix my `.emacs` to style stuff in a way that is not in fact insane +1. Process the form input +1. Make the return url gzip/base64'd diff --git a/lib/Hyperlink-Redirect.rakumod b/lib/Hyperlink-Redirect.rakumod index 10074cd..4312340 100644 --- a/lib/Hyperlink-Redirect.rakumod +++ b/lib/Hyperlink-Redirect.rakumod @@ -14,3 +14,14 @@ my $router = Router.new(root => '/'); $router.get(-> $request, $response { $response.html($templates.process: 'index'); }); + +$router.post(-> $request, $response { + $response.html($templates.process: 'index'); +}); + +# Try a wildcard to catch 'all' path +$router.get('/**', -> $request, $response { + my $url = $request.path.substr(1); # Omits the leading slash + + $response.redirect($url); +}); diff --git a/templates/header.tt b/templates/header.tt index 0440a28..ee2f927 100644 --- a/templates/header.tt +++ b/templates/header.tt @@ -4,3 +4,4 @@ [% title %] +

[% title %]

diff --git a/templates/index.tt b/templates/index.tt index 75633ee..f0e5ad4 100644 --- a/templates/index.tt +++ b/templates/index.tt @@ -1,5 +1,12 @@ [% INCLUDE 'header' - title = 'Test page' %] -

Ayy...

-

lmao

+ title = 'Create new hyperlink' %] +[% IF hyperlink %] +

Your hyperlink is: [% hyperlink %]

+[% END %] +
+ + + +
[% INCLUDE 'footer' %]