Skip to content

Commit

Permalink
Make root path catch-all URL handler that redirects to short URLs. Up…
Browse files Browse the repository at this point in the history
…date hard-coded URLs that reference what are now short URLs.
  • Loading branch information
BusterNeece committed Apr 11, 2024
1 parent f689123 commit 83dc9a2
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
6 changes: 6 additions & 0 deletions backend/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,10 @@

$app->get('/short_url[/{url}]', App\Controller\GetShortUrlAction::class)
->setName('short_url');

/*
* Catch-all handler for base URLs to check the Short URL database.
*/

$app->get('/{url}', App\Controller\GetShortUrlAction::class);
};
5 changes: 2 additions & 3 deletions backend/src/Controller/GetShortUrlAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Controller;

use App\Exception\NotFoundException;
use App\Http\Response;
use App\Http\ServerRequest;
use Doctrine\DBAL\Connection;
Expand Down Expand Up @@ -40,9 +41,7 @@ public function __invoke(
);

if (false === $shortUrl) {
return $response->withRedirect(
$request->getUri()->withQuery('')->withPath('/' . $url)
);
throw new NotFoundException($request, 'Page not found!');
}

$this->db->executeQuery(
Expand Down
2 changes: 1 addition & 1 deletion backend/templates/about.twig
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
through our TV network, is a gateway to new horizons and limitless possibilities.</p>

<div class="d-grid gap-2 mt-3">
<a href="{{ urlFor('discord') }}" class="btn btn-primary btn-lg">Join WaterWolf</a>
<a href="/discord" class="btn btn-primary btn-lg">Join WaterWolf</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion backend/templates/dashboard/short_urls/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<th scope="col"><code>{{ row.short_url }}</code></th>
<td>{{ row.long_url }}</td>
<td>{{ row.views }}</td>
<td>
<td class="text-nowrap">
<a class="btn btn-sm btn-warning"
href="{{ urlFor('dashboard:short_urls:edit', {id: row.id}) }}">
Edit
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/events/defective.twig
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
</div>

<div class="buttons">
<a href="https://www.twitch.tv/waterwolfvr" class="btn btn-lg btn-primary">
<a href="/twitch" class="btn btn-lg btn-primary">
<i class="bi-twitch" aria-hidden="true"></i> Twitch Stream
</a>
<a href="{{ urlFor('register') }}" class="btn btn-lg btn-success">
<i class="bi-key-fill" aria-hidden="true"></i> Create Account
</a>
<a href="{{ urlFor('discord') }}" class="btn btn-lg btn-secondary">
<a href="/discord" class="btn btn-lg btn-secondary">
<i class="bi-discord" aria-hidden="true"></i> Join the Discord
</a>
</div>
Expand Down
6 changes: 2 additions & 4 deletions backend/templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
<img src="/static/img/amy_isaac.png" class="img-fluid">
</div>
<div class="d-grid g-2">
<a href="{{ urlFor('discord') }}" class="btn btn-primary btn-block btn-lg">Join
<a href="/discord" class="btn btn-primary btn-block btn-lg">Join
Discord</a>
</div>

<p class="mt-3">Join the WaterWolf network, Make an account and get connected to tools to
make
your VRC
experience amazing!
make your VRC experience amazing!
</p>
<div class="text-center">
<img src="/static/img/tech_ada.png" class="img-fluid">
Expand Down
8 changes: 4 additions & 4 deletions backend/templates/layouts/sections/footer.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
</div>
<div class="flex-shrink-1 mt-lg-0 mt-2">
<div class="d-inline-flex footer-icons">
<a href="{{ urlFor('github') }}" target="_blank">
<a href="/github" target="_blank">
<i class="bi-github"></i>
<span class="visually-hidden">GitHub</span>
</a>
<a href="mailto:[email protected]">
<i class="bi-envelope"></i>
<span class="visually-hidden">E-mail</span>
</a>
<a href="{{ urlFor('twitter') }}" target="_blank">
<a href="/twitter" target="_blank">
<i class="bi-twitter-x"></i>
<span class="visually-hidden">Twitter/X</span>
</a>
<a href="{{ urlFor('twitch') }}" target="_blank">
<a href="/twitch" target="_blank">
<i class="bi-twitch"></i>
<span class="visually-hidden">Twitch</span>
</a>
<a href="{{ urlFor('discord') }}" target="_blank">
<a href="/discord" target="_blank">
<i class="bi-discord"></i>
<span class="visually-hidden">Discord</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion backend/templates/layouts/sections/nav.twig
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ urlFor('discord') }}" target="_blank">
<a class="nav-link" href="/discord" target="_blank">
<i class="bi-discord" aria-hidden="true"></i> Discord
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/portals.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
</div>
<div class="card-body">
<div class="buttons">
<a href="{{ urlFor('discord') }}" class="btn btn-lg btn-primary">Join the
<a href="/discord" class="btn btn-lg btn-primary">Join the
Community</a>
<a href="{{ urlFor('discord') }}" class="btn btn-lg btn-success">Contact Us</a>
<a href="/discord" class="btn btn-lg btn-success">Contact Us</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 83dc9a2

Please sign in to comment.