<commit_before>package Mojolicious::Plugin::Mail;
use Mojo::Base 'Mojolicious::Plugin';

use MIME::Lite;

has version => 0.1;
has about   => 'Plugin for Mail system.';
has depends => sub { [ qw/Message/ ] };
has config  => sub {{
    from => '<EMAIL>'
}};

sub joke {
    my ( $self, $app ) = @_;
    {
       version => $self->version,
       about   => $self->about,
       depends => $self->depends,
       config  => $self->config
    }
}

sub register {
    my ( $c, $app, $conf ) = @_;
    
    $conf ||= {};
    
    if ( defined %$conf ) {
        $self->config->{$_} = $conf->{$_} for keys %$conf;
    }
    
    $app->helper( mail => sub {
        my ( $self, $type, $mail, $title, $data ) = @_;
        
        return $self->error('Not enough data for mail!') unless defined $type && defined $mail;
        $title ||= '';
        $data  ||= {};
        
        $self->stash(
            %$data,
            title => $title,
            host  => 'http://lorcode.org:3000',
        );
        
        my $html = $self->render (
            partial    => 1,
            template   => "mail/$type"
        );
        
        MIME::Lite->new (
            From    => '<EMAIL>',
            To      => $mail,
            Subject => $self->l($title),
            Type    => 'text/html',
            Data    => $html,
        )->send;
    });
}

1;

__END__

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011, <NAME>.

This program is free software, you can redistribute it and/or modify it under
the terms of the Artistic License version 2.0.

=cut
<commit_msg>one more fix fore mail<commit_after>package Mojolicious::Plugin::Mail;
use Mojo::Base 'Mojolicious::Plugin';

use Storable 'thaw';
use MIME::Lite;

has version => 0.1;
has about   => 'Plugin for Mail system.';
has depends => sub { [ qw/Message/ ] };
has config  => sub {{
    from => '',
    site => '',
}};

sub joke {
    my ( $self, $app ) = @_;
    {
       version => $self->version,
       about   => $self->about,
       depends => $self->depends,
       config  => $self->config
    }
}

sub register {
    my ( $plugin, $app, $conf ) = @_;

    my $plug = $app->data->read_one(jokes => {name => 'Mail'});
    
    $plugin->config(thaw $plug->{config}) if defined $plug->{config} && length $plug->{config};
    
    $app->helper( mail => sub {
        my ( $self, $type, $mail, $title, $data ) = @_;

        return $self->error('Not enough data for mail!') unless defined $type && defined $mail;
        $title ||= '';
        $data  ||= {};

        $self->stash(
            %$data,
            title => $title,
            host  => $plugin->config->{site},
        );
        
        my $html = $self->render (
            partial    => 1,
            template   => "mail/$type"
        );
        
        MIME::Lite->new (
            From    => $plugin->config->{from},
            To      => $mail,
            Subject => $self->l($title),
            Type    => 'text/html',
            Data    => $html,
        )->send;
    });
}

1;

__END__

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011, <NAME>.

This program is free software, you can redistribute it and/or modify it under
the terms of the Artistic License version 2.0.

=cut

{'fraction_non_alphanumeric': 0.17442582247051522, 'fraction_numerical': 0.008069522036002483, 'mean_word_length': 1.7856525496974935, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1439908', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1042, 'n_words': 274}