Skip to content

Commit

Permalink
Updated to Turnaround :)
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Apr 16, 2012
1 parent 48cf582 commit 01bb1ba
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "contrib/lamework"]
path = contrib/lamework
url = https://github.com/vti/lamework
[submodule "contrib/turnaround"]
path = contrib/turnaround
url = https://github.com/vti/turnaround.git
2 changes: 1 addition & 1 deletion app.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BEGIN {
File::Spec->rel2abs(File::Basename::dirname(Cwd::realpath(__FILE__)));

unshift @INC, "$root/lib";
unshift @INC, "$root/contrib/lamework/lib";
unshift @INC, "$root/contrib/turnaround/lib";
}

use Look2RemoveMe;
Expand Down
1 change: 0 additions & 1 deletion contrib/lamework
Submodule lamework deleted from bf93d3
1 change: 1 addition & 0 deletions contrib/turnaround
Submodule turnaround added at b8b2af
30 changes: 15 additions & 15 deletions lib/Look2RemoveMe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package Look2RemoveMe;
use strict;
use warnings;

use base 'Lamework';
use base 'Turnaround';

use Lamework::ActionFactory;
use Lamework::Config;
use Lamework::Dispatcher::Routes;
use Lamework::Displayer;
use Lamework::I18N;
use Lamework::Renderer::Caml;
use Lamework::Routes;
use Turnaround::ActionFactory;
use Turnaround::Config;
use Turnaround::Dispatcher::Routes;
use Turnaround::Displayer;
use Turnaround::I18N;
use Turnaround::Renderer::Caml;
use Turnaround::Routes;

use Look2RemoveMe::File;

Expand All @@ -21,7 +21,7 @@ sub startup {
$self->{config} = {};

my $config =
Lamework::Config->new->load($self->{home}->catfile('config.yml'));
Turnaround::Config->new->load($self->{home}->catfile('config.yml'));
$self->{config} = $config;

$self->services->register(home => $self->{home});
Expand All @@ -30,10 +30,10 @@ sub startup {
Look2RemoveMe::File->set_root($self->{home}->catfile('htdocs', 'uploads'));

my $displayer =
Lamework::Displayer->new(
renderer => Lamework::Renderer::Caml->new(home => $self->{home}));
Turnaround::Displayer->new(
renderer => Turnaround::Renderer::Caml->new(home => $self->{home}));

my $i18n = Lamework::I18N->new(app_class => __PACKAGE__);
my $i18n = Turnaround::I18N->new(app_class => __PACKAGE__);

$self->add_middleware(
'Static',
Expand Down Expand Up @@ -66,11 +66,11 @@ sub startup {

$self->add_middleware('RequestDispatcher',
dispatcher =>
Lamework::Dispatcher::Routes->new(routes => $self->_build_routes));
Turnaround::Dispatcher::Routes->new(routes => $self->_build_routes));

$self->add_middleware(
'ActionDispatcher',
action_factory => Lamework::ActionFactory->new(
action_factory => Turnaround::ActionFactory->new(
namespace => ref($self) . '::Action::'
)
);
Expand All @@ -83,7 +83,7 @@ sub startup {
sub _build_routes {
my $self = shift;

my $routes = Lamework::Routes->new;
my $routes = Turnaround::Routes->new;

$routes->add_route('/', name => 'index', method => 'get');
$routes->add_route('/', name => 'upload', method => 'post');
Expand Down
12 changes: 6 additions & 6 deletions lib/Look2RemoveMe/Action.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package Look2RemoveMe::Action;
use strict;
use warnings;

use base 'Lamework::Action';
use base 'Turnaround::Action';

sub new {
my $self = shift->SUPER::new(@_);

$self->set_layout('layout');

$self->set_var(
loc => sub { $self->{env}->{'lamework.i18n.maketext'}->loc($_[1]) });
$self->set_var(language => $self->{env}->{'lamework.i18n.language'});
$self->set_var(languages => $self->{env}->{'lamework.i18n.languages'});
loc => sub { $self->{env}->{'turnaround.i18n.maketext'}->loc($_[1]) });
$self->set_var(language => $self->{env}->{'turnaround.i18n.language'});
$self->set_var(languages => $self->{env}->{'turnaround.i18n.languages'});

return $self;
}
Expand All @@ -22,14 +22,14 @@ sub set_template {
my $self = shift;
my ($template) = @_;

$self->{env}->{'lamework.displayer.template'} = $template;
$self->{env}->{'turnaround.displayer.template'} = $template;
}

sub set_layout {
my $self = shift;
my ($layout) = @_;

$self->{env}->{'lamework.displayer.layout'} = $layout;
$self->{env}->{'turnaround.displayer.layout'} = $layout;
}

1;
8 changes: 4 additions & 4 deletions lib/Look2RemoveMe/Action/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings;
use base 'Look2RemoveMe::Action';

use Try::Tiny;
use Lamework::Exception;
use Turnaround::Exception;

use Look2RemoveMe::File;

Expand All @@ -23,11 +23,11 @@ sub run {
my $max_size_in_megs = $self->service('config')->{max_upload_size} || 10;

try {
raise 'Lamework::Exception::Base' => "Doesn't look like an image to me"
raise 'Turnaround::Exception::Base' => "Doesn't look like an image to me"
unless $upload->content_type =~ m{^image/};

if ($upload->size > $max_size_in_megs * 1024 * 1024) {
Lamework::Exception->throw(
Turnaround::Exception->throw(
"File size is too big (max $max_size_in_megs Mb)");
}

Expand All @@ -39,7 +39,7 @@ sub run {
catch {
my $e = $_;

$e->rethrow unless $e->does('Lamework::Exception');
$e->rethrow unless $e->does('Turnaround::Exception');

$self->set_var('errors' => {image => $e->message});
};
Expand Down
2 changes: 1 addition & 1 deletion lib/Look2RemoveMe/App/FileWithRTL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sub serve_path {
open my $fh, "<:raw", $file
or return $self->return_403;

my $home = $env->{'lamework.services'}->service('home');
my $home = $env->{'turnaround.services'}->service('home');

my @stat = stat $file;
Plack::Util::set_io_path($fh, Cwd::realpath($file));
Expand Down
21 changes: 0 additions & 21 deletions t/counter.t

This file was deleted.

0 comments on commit 01bb1ba

Please sign in to comment.