diff options
-rw-r--r-- | CHANGES.md | 8 | ||||
-rw-r--r-- | jwebmail.development.conf | 26 | ||||
-rw-r--r-- | jwebmail.development.toml | 24 | ||||
-rw-r--r-- | lib/JWebmail.pm | 6 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/TOMLConfig.pm | 61 |
5 files changed, 93 insertions, 32 deletions
@@ -149,21 +149,21 @@ Current v1.1.0 - [ ] add basic telemetry (goatcounter?) - [ ] make mime_render return a mojo bytes object +- [x] compute hmac on the client side + - [x] better handling on form + - [ ] better random numbers - [ ] advance ini config plugin - [x] allow non-leaf nodes to be arrays - [ ] allow quotes - [ ] allow continuation over multiple lines - [ ] warn about overrides - [ ] add template support, maybe - - [ ] switch to TOML or a provided format, as INI is too basic + - [x] switch to TOML or a provided format, as INI is too basic - [ ] add config validation - [ ] improve i18n - [ ] add localization of dates and time - [x] refactor I18N plugin to allow independent translate provider - [x] extend matcher dynamic with a role -- [x] compute hmac on the client side - - [x] better handling on form - - [ ] better random numbers Future ------ diff --git a/jwebmail.development.conf b/jwebmail.development.conf deleted file mode 100644 index 4daeb16..0000000 --- a/jwebmail.development.conf +++ /dev/null @@ -1,26 +0,0 @@ -secret = TotalS3cr3t - -[defaults] -scriptadmin = me@example.com ; for complaints / support - -[i18n] -default_language = en -directory = lang - -[i18n::languages] -#en = English -#de = Deutsch - -[model::read::driver::devel::json] -[model::read::driver::devel::maildir] - -[model::write] -#sendmail = /usr/sbin/sendmail - -[development] -read_mock = JWebmail::Model::ReadMails::MockJSON ; JWebmail::Model::ReadMails::MockMaildir -block_writes = 1 - -[session] -# secure sesssion [none, cram, s3d] -secure = s3d diff --git a/jwebmail.development.toml b/jwebmail.development.toml new file mode 100644 index 0000000..3975c9f --- /dev/null +++ b/jwebmail.development.toml @@ -0,0 +1,24 @@ +[defaults] +scriptadmin = "me@example.com" # for complaints / support + +[i18n] +default_language = "en" +directory = "lang" + +[i18n.languages] +#en = English +#de = Deutsch + +[model.read.driver.devel.json] +[model.read.driver.devel.maildir] + +[model.write] +#sendmail = "/usr/sbin/sendmail" + +[development] +read_mock = "JWebmail::Model::ReadMails::MockJSON" # JWebmail::Model::ReadMails::MockMaildir +block_writes = 1 + +[session] +# secure sesssion [none, cram, s3d] +secure = "cram" diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 98001a1..8c01596 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -2,6 +2,8 @@ package JWebmail v1.2.0; use Mojo::Base Mojolicious; +use Module::Load 'load'; + use JWebmail::Controller::Webmail; use JWebmail::Model::ReadMails::Role; use JWebmail::Model::ReadMails::QMailAuthuser; @@ -43,7 +45,7 @@ sub startup { # load plugins push @{$self->plugins->namespaces}, 'JWebmail::Plugin'; - $self->plugin('INIConfig'); + $self->plugin('TOMLConfig'); #die unless $self->validateConf; $self->plugin('ServerSideSessionData'); @@ -57,7 +59,7 @@ sub startup { my $read_mails = do { if ($mode eq 'development') { my $cls = $self->config->{development}{read_mock}; - eval "require $cls" || die "Issue for module $cls with: $@"; + eval { load $cls; 1 } || die "Issue for module $cls with: $@"; $cls->new; } else { diff --git a/lib/JWebmail/Plugin/TOMLConfig.pm b/lib/JWebmail/Plugin/TOMLConfig.pm new file mode 100644 index 0000000..20a2950 --- /dev/null +++ b/lib/JWebmail/Plugin/TOMLConfig.pm @@ -0,0 +1,61 @@ +package JWebmail::Plugin::TOMLConfig; + +use Mojo::Base Mojolicious::Plugin::Config; + +use TOML::Tiny 'from_toml'; + + +has parse_func => sub { \&from_toml }; + + +sub parse { + my ($self, $content, $_file, $_plugin_conf, $_app) = @_; + + my $config = $self->parse_func->($content); + die "parse_func must return hash ref" unless ref $config eq 'HASH'; + + return $config; +} + +sub register { shift->SUPER::register(shift, {ext => 'toml', %{shift()}}) } + + +1 + +__END__ + +=encoding utf-8 + +=head1 NAME + +TOMLConfig - Reads in TOML config files. + +=head1 SYNOPSIS + + $app->plugin('TOMLConfig'); + + @@ my_app.toml + + # global section + key = "val" # line comment + [section] + other_key = "other_val" + number_key = 5 + [other.section] + values = ["key1", "key2", "key3"] + +=head1 DESCRIPTION + +TOML is my favorite config format :) + +=head1 OPTIONS + +=head2 default + +Sets default configuration values. + +=head1 DEPENDENCIES + +TOML::Tiny + +=cut |