Fix #5 - Allow to use a fixed domain

This commit is contained in:
Luc Didry
2018-07-26 23:32:36 +02:00
parent 78bb3f37c7
commit f2f785e6d4
5 changed files with 31 additions and 14 deletions
+12
View File
@@ -51,6 +51,7 @@ sub register {
$app->helper(decrypt => \&_decrypt);
$app->helper(delete_image => \&_delete_image);
$app->helper(iso639_native_name => \&_iso639_native_name);
$app->helper(prefix => \&_prefix);
}
sub _pg {
@@ -321,4 +322,15 @@ sub _iso639_native_name {
return ucfirst(decode 'UTF-8', get_iso639_1(shift)->{nativeName});
}
sub _prefix {
my $c = shift;
my $prefix = $c->url_for('/')->to_abs;
# Forced domain
$prefix->host($c->config('fixed_domain')) if (defined($c->config('fixed_domain')) && $c->config('fixed_domain') ne '');
# Hack for prefix (subdir) handling
$prefix .= '/' unless ($prefix =~ m#/$#);
return $prefix;
}
1;