-
Notifications
You must be signed in to change notification settings - Fork 0
/
CAP.pm
65 lines (54 loc) · 1.36 KB
/
CAP.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package CAP;
use strict;
use warnings;
use Catalyst::Runtime '5.70';
use FindBin;
use Catalyst qw/
ConfigLoader
ConfigLoader::Environment
Static::Simple
StackTrace
/;
# Configure the application.
# Note that settings in cap.conf (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
# with a external configuration file acting as an override for
# local deployment.
__PACKAGE__->config(
name => 'CAP',
'Plugin::ConfigLoader' => {
driver => {
General => {
-AutoTrue => 1, # treat 1/yes/on/true == true; 0/no/off/false == false
-UTF8 => 1, # Enable support for UTF8 strings in the config file
},
},
},
);
# Start the application
__PACKAGE__->setup();
sub portal_id {
my ($c) = @_;
if ( $c->stash->{portal} ) {
return $c->stash->{portal}->id;
} else {
return '';
}
}
sub portal_title {
my ($c) = @_;
if ( $c->stash->{portal} && $c->stash->{lang} ) {
return $c->stash->{portal}->{label}->{ $c->stash->{lang} };
} else {
return '';
}
}
sub loc {
my ( $c, $tag, @args ) = @_;
die 'Trying to localize a string without $c->stash->{lang} set'
unless $c->stash->{lang};
return $c->model("I18N")->localize( $c->stash->{lang}, $tag, @args );
}
1;