Adding current route to allow open in the browser more easily.

This commit is contained in:
Sergiotarxz 2023-09-01 16:44:07 +02:00
parent e3f50b2c33
commit 64083df353
2 changed files with 3 additions and 2 deletions

View File

@ -19,12 +19,13 @@ sub startup ($self) {
); );
$self->hook( $self->hook(
before_render => sub($c, $args) { before_render => sub($c, $args) {
my $current_route = $c->url_for;
$c->stash(current_route => $current_route);
my $onion_base_url = $self->config->{onion_base_url}; my $onion_base_url = $self->config->{onion_base_url};
my $base_url = $self->config->{base_url}; my $base_url = $self->config->{base_url};
if (!defined $onion_base_url) { if (!defined $onion_base_url) {
return; return;
} }
my $current_route = $c->url_for;
$current_route =~ s/^$base_url//; $current_route =~ s/^$base_url//;
$c->res->headers->header('Onion-Location' => $onion_base_url.$current_route); $c->res->headers->header('Onion-Location' => $onion_base_url.$current_route);
} }

View File

@ -38,7 +38,7 @@
%= include 'page/_desktop_menu', categories => $categories, current_category_slug => $current_category_slug %= include 'page/_desktop_menu', categories => $categories, current_category_slug => $current_category_slug
%= include 'page/_mobile_foldable', categories => $categories %= include 'page/_mobile_foldable', categories => $categories
<div class="description android open-browser-container"> <div class="description android open-browser-container">
<a href="#" class="open-in-browser"> <a href="<%= $current_route %>" class="open-in-browser">
<img alt="" src="/img/firefox.svg"/> <img alt="" src="/img/firefox.svg"/>
<span>Abrir en el navegador.</span> <span>Abrir en el navegador.</span>
</a> </a>