diff options
-rw-r--r-- | CHANGES.md | 20 | ||||
-rw-r--r-- | Makefile.PL | 1 | ||||
-rwxr-xr-x | actions.sh | 12 | ||||
-rw-r--r-- | lib/JWebmail/Controller/Webmail.pm | 2 | ||||
-rw-r--r-- | lib/JWebmail/Model/ReadMails/MockJSON.pm | 6 | ||||
-rw-r--r-- | lib/JWebmail/Plugin/I18N2.pm | 6 | ||||
-rw-r--r-- | t/Extract.t | 29 | ||||
-rw-r--r-- | t/Webmail.t | 4 | ||||
-rw-r--r-- | templates/webmail/about.html.ep | 2 |
9 files changed, 53 insertions, 29 deletions
@@ -109,20 +109,15 @@ Current v1.1.0 - [x] add actions script - [ ] repurpose status field in displayheader - [x] currently just renamed -- [ ] advance ini config plugin - - [ ] allow non-leaf nodes to be arrays +- [x] 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 - [ ] improve i18n - [ ] add localization of dates and time -- [ ] improve performance, consider alternatives to Extract.pm - - [ ] based on Maildir::Light - - [ ] reimplementation in Rust -- [x] refactor I18N plugin to allow independent provider -- [ ] refactor driver into a role -- [ ] merge read and row (with content type) + - [x] refactor I18N plugin to allow independent translate provider - [ ] fix tests - [ ] consider using more mojo functions - [x] use Mojolicious::Types to replace File::Type @@ -132,7 +127,16 @@ Current v1.1.0 - [ ] creating new folders - [ ] backend - [ ] specify protocol for backend interaction + - [ ] choose tool for validation - [ ] cleanup README +- [ ] improve performance of backend, consider alternatives to Mail::Box::Manager + - [ ] based on Maildir::Light + - [x] reimplementation in Rust +- [x] refactor ReadMails into a role +- [x] made languages in about clickable +- [ ] cache mail reads +- [ ] make loading auth data from session easier +- [ ] merge read and row (with content type) Future ------ diff --git a/Makefile.PL b/Makefile.PL index ac6013a..6e07149 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,6 +13,7 @@ WriteMakefile( 'Email::MIME' => 0, 'Mail::Box::Manager' => 'v3.9', 'Role::Tiny' => 'v2.0.1', + 'Class::Method::Modifiers' => 'v2.13', }, test => {TESTS => 't/*.t'} ) @@ -2,14 +2,22 @@ set -euC -test () { +run_tests () { eval "prove -l ${1-} t/" } -start () { +foreground () { script/jwebmail daemon } +start_dev () { + MOJO_MODE=development hypnotoad script/jwebmail +} + +stop_dev () { + MOJO_MODE=development hypnotoad -s script/jwebmail +} + logrotate () { mode=${1:-development} mv -i "log/$mode.log" "log/${mode}_$(date --iso-8601=minutes).log" diff --git a/lib/JWebmail/Controller/Webmail.pm b/lib/JWebmail/Controller/Webmail.pm index 3566c83..6e3ff8b 100644 --- a/lib/JWebmail/Controller/Webmail.pm +++ b/lib/JWebmail/Controller/Webmail.pm @@ -60,13 +60,13 @@ sub login { my $user = $v->required('userid')->size(4, 50)->param; my $passwd = $v->required('password')->size(4, 50)->like(qr/^.+$/)->param; # no new-lines - my $auth = $self->users->Auth(user => $user, password => $passwd); if ($v->has_error) { $self->res->code(400); return $self->render(action => 'noaction'); } + my $auth = $self->users->Auth(user => $user, password => $passwd); my $valid = _time { $self->users->verify_user($auth) } $self, 'verify user'; if ($valid) { diff --git a/lib/JWebmail/Model/ReadMails/MockJSON.pm b/lib/JWebmail/Model/ReadMails/MockJSON.pm index bb105d1..8918040 100644 --- a/lib/JWebmail/Model/ReadMails/MockJSON.pm +++ b/lib/JWebmail/Model/ReadMails/MockJSON.pm @@ -6,17 +6,17 @@ use utf8; use List::Util 'sum'; +use Mojo::JSON qw(decode_json); + use Role::Tiny::With; -use Mojo::JSON qw(decode_json); +use namespace::clean; use constant { VALID_USER => 'mockjson@example.com', VALID_PW => 'vwxyz', }; -use namespace::clean; - with 'JWebmail::Model::ReadMails::Role'; diff --git a/lib/JWebmail/Plugin/I18N2.pm b/lib/JWebmail/Plugin/I18N2.pm index 35367e9..c951eec 100644 --- a/lib/JWebmail/Plugin/I18N2.pm +++ b/lib/JWebmail/Plugin/I18N2.pm @@ -93,7 +93,7 @@ package JWebmail::Plugin::I18N2::Match { if (my $lang = $self->_i18n2_stash->{lang}) { @args = __add_option_no_override(lang => $lang, @args); } - return $self->SUPER::path_for(@args); + return $self->next::method(@args); } } @@ -118,7 +118,7 @@ sub register { { local $" = ','; - $i18n_log->debug("loaded languages (@{[$t->languages]})"); + $i18n_log->info("loaded languages (@{[$t->languages]})"); if (keys $conf->{languages}->%* > $t->languages) { $i18n_log->warn("missing languages"); @@ -137,7 +137,7 @@ sub register { my $res = $t->translate($lang, $word); unless ($res) { local $" = ' '; - $app->log->warn('[' . __PACKAGE__ . "] missing translation for '$lang':'$word' @{[ caller(1) ]}[0..2]"); + $app->log->warn('[' . __PACKAGE__ . "] missing translation for $lang:'$word' @{[ caller(1) ]}[0..2]"); } return $res; }); diff --git a/t/Extract.t b/t/Extract.t index 5b719da..7b1ddbf 100644 --- a/t/Extract.t +++ b/t/Extract.t @@ -5,11 +5,12 @@ use utf8; use Test::More; use JSON::PP 'decode_json'; +use List::Util 'min'; no warnings 'experimental::smartmatch'; my $EXTRACT = { - perl_mail_box => 'perl lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm ', + perl_mail_box => 'perl script/qmauth.pl ', rust_maildir => 'extract/target/debug/jwebmail-extract', }->{perl_mail_box}; my $MAILDIR = 't/'; @@ -18,6 +19,14 @@ my $MAIL_USER = 'maildir'; my $PROG = "$EXTRACT $MAILDIR $SYS_USER $MAIL_USER"; +my $MAIL_COUNT = do { + opendir(my $dh, "$MAILDIR/$MAIL_USER/cur"); + my @all = grep { /^[^.]/ } readdir($dh); + closedir($dh); + local $" = ' '; + note "@all"; + @all +}; subtest start => sub { my @res = `$PROG invalid`; @@ -46,21 +55,22 @@ subtest count => sub { is @res, 1; my $result = decode_json $res[0]; - is($result->{count}, 2); + is($result->{count}, $MAIL_COUNT); #is($result->{new}, 0); }; subtest list => sub { - my @res = `$PROG list 0 10 date ''`; + my $s = "$PROG list 0 4 date ''"; + my @res = `$s`; is($? >> 8, 0); is @res, 1; my $result = decode_json $res[0]; - is(@$result, 2); + is(@$result, min($MAIL_COUNT, 5)); ok($result->[0]{mid}); - ok($result->[0]{from}); - ok($result->[0]{to}); + ok($result->[0]{head}{from}) or diag $s; + ok($result->[0]{head}{to}); }; subtest read => sub { @@ -71,13 +81,14 @@ subtest read => sub { my $pre_result = decode_json $pre_res[0]; ok(my $mid = $pre_result->[0]{mid}); - my @res = `$PROG read-mail '$mid'`; + my $s = "$PROG read-mail '$mid'"; + my @res = `$s`; - is($? >> 8, 0); + is($? >> 8, 0) or (diag $s, return); is @res, 1; my $result = decode_json $res[0]; - is_deeply($result->{from}, [{address => 'shipment-tracking@amazon.de', name => 'Amazon.de'}]); + is_deeply($result->{head}{from}, [{address => 'shipment-tracking@amazon.de', name => 'Amazon.de'}]); ok($result->{date_received}); ok(index($result->{date_received}, '2019-02-22T10:06:54') != -1); like($result->{date_received}, qr'2019-02-22T10:06:54'); diff --git a/t/Webmail.t b/t/Webmail.t index 4cef937..45eeda9 100644 --- a/t/Webmail.t +++ b/t/Webmail.t @@ -9,8 +9,8 @@ use JWebmail::Model::ReadMails::MockJSON; use constant DEFAULT_LANGUAGE => 'en'; -my $user = JWebmail::Model::Driver::MockJSON::VALID_USER; -my $pw = JWebmail::Model::Driver::MockJSON::VALID_PW; +my $user = JWebmail::Model::ReadMails::MockJSON::VALID_USER; +my $pw = JWebmail::Model::ReadMails::MockJSON::VALID_PW; my $t = Test::Mojo->new('JWebmail', { diff --git a/templates/webmail/about.html.ep b/templates/webmail/about.html.ep index c6d1247..49ecc1a 100644 --- a/templates/webmail/about.html.ep +++ b/templates/webmail/about.html.ep @@ -47,7 +47,7 @@ <li>Supported languages: <p class=languages> % foreach (@$languages) { - <%= $_ %> + <a href="<%= url_for(lang => $_) %>"><%= $_ %></a> % } </p> </li> |