Foorum
    
    
  
  
  
view release on metacpan or search on metacpan
docs/Tutorial2.html view on Meta::CPAN
            $new_task->worker();
        }
    }
    sleep 5;
</pre><p>Where does new task from? Foorum has two ways, always one is form Foorum/Controller|Model, the other is from cron scripts.</p><p>example code:</p><ol><li>in Foorum/Model </li></ol><pre class="prettyprint">use Foorum::ExternalUtils qw/theschw...
my $client = theschwartz();
$client->insert(
    'Foorum::TheSchwartz::Worker::WorkerExample',
    @args
);
</pre><ol><li>in cron script. <a href="http://foorum.googlecode.com/svn/trunk/bin/cron/TheSchwartz_client.pl" rel="nofollow">http://foorum.googlecode.com/svn/trunk/bin/cron/TheSchwartz_client.pl</a> </li></ol><p>That's a simple introduction. Maybe I'...
</div>
<h1>WHERE TO GO NEXT</h1>
<ul>
<li>Get the lastest version from <a href="http://code.google.com/p/foorum/wiki/Tutorial2">http://code.google.com/p/foorum/wiki/Tutorial2</a></li>
<li><a href="index.html">Index Page</a></li>
</ul>
<script src="static/prettify.js"></script>
<script>
 prettyPrint();
</script>
lib/Foorum/Manual/Tutorial2.pod view on Meta::CPAN
  * Foorum::TheSchwartz::Worker::RemoveOldDataFromDB
  * Foorum::TheSchwartz::Worker::ResizeProfilePhoto
  * Foorum::TheSchwartz::Worker::SendScheduledEmail
  * Foorum::TheSchwartz::Worker::SendStarredNofication
  * etc.
There is a simple L<Foorum::Manual::RULES> that why we use TheSchwartz, put heavy code on backend script instead of httpd.
  * Hit is a cron script to update topic hits and Popular.
  * RemoveOldDataFromDB - remove useless data from database because it's outdated.
  * ResizeProfilePhoto  - let httpd load Image::Magick is not so good.
  * SendScheduledEmail  - send email, web insert data into table then this worker send email behind
  * SendStarredNofication - oh, typo here, should be Notification. ;)
=head2 How to write a Worker in Foorum?
OK, please borrow code from exist ones.
=head1 SEE ALSO
L<Foorum::Manual::Tutorial1>, L<Foorum::Manual::Tutorial3>, L<Foorum::Manual::Tutorial4>, L<Foorum::Manual::Tutorial5>
lib/Foorum/TheSchwartz/Worker/ResizeProfilePhoto.pm view on Meta::CPAN
package Foorum::TheSchwartz::Worker::ResizeProfilePhoto;
use strict;
use warnings;
our $VERSION = '1.001000';
use base qw( TheSchwartz::Moosified::Worker );
use Foorum::SUtils qw/schema/;
use Foorum::XUtils qw/base_path/;
use Image::Magick;
use File::Copy ();
use File::Spec;
sub work {
    my $class = shift;
    my $job   = shift;
    my @args = $job->arg;
    my $schema    = schema();
lib/Foorum/TheSchwartz/Worker/ResizeProfilePhoto.pm view on Meta::CPAN
    my $directory_2 = int( $upload_id / 3200 );
    my $file        = abs_path(
        File::Spec->catfile(
            $base_path,   'root',
            'upload',     $directory_1,
            $directory_2, $upload->filename
        )
    );
    # resize photo
    my $p = new Image::Magick;
    $p->Read($file);
    $p->Scale( geometry => '120x120' );
    $p->Sharpen( geometry => '0.0x1.0' );
    $p->Set( quality => '75' );
    my ( $width, $height, $size ) = $p->Get( 'width', 'height', 'filesize' );
    my $tmp_file = $file . '.tmp';
    $p->Write($tmp_file);
lib/Foorum/TheSchwartz/Worker/ResizeProfilePhoto.pm view on Meta::CPAN
=head1 NAME
Foorum::TheSchwartz::Worker::ResizeProfilePhoto - resize profile photo in cron job
=head1 SYNOPSIS
  # check bin/cron/TheSchwartz_client.pl and bin/cron/TheSchwartz_worker.pl for usage
=head1 DESCRIPTION
Since L<Image::Magick> is a bit heavy to load into httpd, we move use Image::Magick; in this cron job.
=head1 SEE ALSO
L<TheSchwartz>
=head1 AUTHOR
Fayland Lam <fayland at gmail.com>
=cut
( run in 1.243 second using v1.01-cache-2.11-cpan-c333fce770f )