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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
package CiderWebmail;
use Moose;
use strict;
use warnings;
use Catalyst::Runtime '5.80';
# Set flags and add plugins for the application
#
# -Debug: activates the debug mode for very useful log messages
# ConfigLoader: will load the configuration from a YAML file in the
# application's home directory
# Static::Simple: will serve static files from the application's root
# directory
my @unicode_encoding;
BEGIN {
# Unicode::Encoding is autoloaded since Catalyst 5.90040
@unicode_encoding = 'Unicode::Encoding' if $Catalyst::Runtime::VERSION < 5.90040;
}
use Catalyst qw/
ConfigLoader
StackTrace
Static::Simple
Authentication
Session
Session::Store::FastMmap
Session::State::Cookie
CiderWebmail::ErrorHandler
Log::Dispatch
/, @unicode_encoding;
our $VERSION = '1.05';
# Configure the application.
#
# Note that settings in ciderwebmail.yml (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 => 'CiderWebmail',
default_view => 'Petal',
encoding => 'UTF-8',
authentication => {
default_realm => 'imap',
realms => {
imap => {
credential => {
class => 'Password',
password_type => 'self_check',
password_field => 'password',
},
store => {
class => 'IMAP',
host => undef,
},
},
},
},
);
#don't display password in debugging output
around 'log_request_parameters' => sub {
my $super = shift;
my($c, %params) = @_;
$params{body}{password} = 'XXX-password-removed-XXX';
$c->$super(%params)
};
# Start the application
__PACKAGE__->setup;
unless (defined $ENV{TEST_USER}) {
__PACKAGE__->log->info("CiderWebmail $VERSION loaded!");
}
unless (__PACKAGE__->config->{language}) {
print "Missing language configuration.\n";
print "Maybe CiderWebmail could not find your configuration file?\n";
exit 1;
}
__PACKAGE__->config->{authentication}{realms}{imap}{store}{host} ||= ($ENV{IMAPHOST} || __PACKAGE__->config->{server}{host});
=head1 NAME
CiderWebmail - Catalyst based application
=head1 SYNOPSIS
script/ciderwebmail_server.pl
=head1 DESCRIPTION
CiderWebmail: webmail sucks - we suck less!
=head1 METHODS
=head2 langs()
Returns all languages supported by this version.
=cut
my @langs;
sub langs {
my ($self) = @_;
@langs = map { m!/([^/]*)\z!xm } grep { -d } glob $self->config->{root} . "/templates/*"
unless @langs;
return @langs;
}
=head1 SEE ALSO
L<CiderWebmail::Controller::Root>, L<Catalyst>
=head1 AUTHOR
Stefan Seifert
=head1 LICENSE
This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;
|