5 posts tagged “cpan”
uploaded!!
and, I'll upload the Sledge::Plugin::Laziness tomorrow.
Back in the day, this module is in the MoFedge.But, I hope to use this module by all Sledge users.
Yeah, I released Sledge::View on CPAN.
You can use the alpha version of Sledge::View.
http://search.cpan.org/~tokuhirom/Sledge-View-0.01/
and, Sledge::View's svn repository is here: http://code.mfac.jp/svn/CPAN/tokuhirom/Sledge-View/
Yeah. I wrote the prototype of the Sledge::View.
http://code.mfac.jp/trac/browser/CPAN/tokuhirom/Sledge-View/
This module constructed by 4 modules.
- Sledge::Plugin::View
- change Sledge::Pages::Base...
- Sledge::Response
- HTTP Response object
- Sledge::View
- abstract base class for Sledge::View::*
- Sledge::View::Template
- compatibility for Sledge::Pages::Base->(make_content|output_content)
Now this modules are beta.But, I want to release on CPAN at this week, with more tests.
I want to Sledge 2.0.from Sledge's last release, many and many changes in the Web Application Framework World.
Rails and Catalyst
But, I don't think "Sledge is obsolete".
follow list is feature list of Sledge 2.0(now thinking...)
-
use Encode.
follow is module based list.
-
add
- Sledge::View
- Sledge::View::TT
- Sledge::View::JSON
- Sledge::View::GD
- Sledge::View::Imager
- Sledge::Validator::Simple
- with FormValidator::Simple
- Sledge::Controller
- Sledge::Plugin::Mobile::*
- Yeah.
- N/A
- Sledge::Pages::*
- Sledge::Template
- Sledge::MobileGate
- Jcode
Today, I wrote the Sledge::Plugin::Inflate.This module help to inflate object from request or session.
For example, follow is basic CRUD in Sledge(MoFedge style).
package CDStand::Pages::CD;
use Sledge::Plugin::Pager; # I don't release yet.
use Sledge::Plugin::Stash;sub dispatch_index {
my $self = shift;
$self->pager('CDStand::Data::CD')->retrieve_all;
}sub dispatch_add { }
sub post_dispatch_add {
my $self = shift;
CDStand::Data::CD->create_from_sledge($self);
$self->redirect('/cd/');
}sub dispatch_edit {
my $self = shift;
my $cd = CDStand::Data::CD->retrieve($self->r->param('cd_id'));
$self->fillin_form->fdat($cd->as_fdat);
$self->stash->{cd} = $cd;
}
sub post_dispatch_edit {
my $self = shift;
my $cd = CDStand::Data::CD->retrieve($self->r->param('cd_id'));
$self->stash->{cd} = $cd;
$self->redirect('/cd/');
}sub dispatch_delete {
my $self = shift;
my $cd = CDStand::Data::CD->retrieve($self->r->param('cd_id'));
$self->stash->{cd} = $cd;
}
sub dispatch_delete {
my $self = shift;
my $cd = CDStand::Data::CD->retrieve($self->r->param('cd_id'));
$cd->delete;
$self->redirect('/cd/');
}sub dispatch_show {
my $self = shift;
my $cd = CDStand::Data::CD->retrieve($self->r->param('cd_id'));
$self->stash->{cd} = $cd;
}
Follow is equevalent program but use the S::P::Inflate.
Yes.DRY Style.package CDStand::Pages::CD;
use Sledge::Plugin::Pager; # I don't release yet.
use Sledge::Plugin::Stash;
use Sledge::Plugin::Inflate;
__PACKAGE__->add_inflate_rule(
{
cd_id => sub {
my $self = shift;
return CDStand::Data::CD->retrieve($self->r->param('cd_id'));
}
}
);
sub dispatch_index {
my $self = shift;
$self->pager('CDStand::Data::CD')->retrieve_all;
}sub dispatch_add { }
sub post_dispatch_add {
my $self = shift;
CDStand::Data::CD->create_from_sledge($self);
$self->redirect('/cd/');
}sub dispatch_edit {
my $self = shift;
my $cd = $self->r->inflate('cd_id');
$self->fillin_form->fdat($cd->as_fdat);
$self->stash->{cd} = $cd;
}
sub post_dispatch_edit {
my $self = shift;
my $cd = $self->r->inflate('cd_id');
$self->stash->{cd} = $cd;
$self->redirect('/cd/');
}sub dispatch_delete {
my $self = shift;
my $cd = $self->r->inflate('cd_id');
$self->stash->{cd} = $cd;
}
sub dispatch_delete {
my $self = shift;
my $cd = $self->r->inflate('cd_id');
$cd->delete;
$self->redirect('/cd/');
}sub dispatch_show {
my $self = shift;
my $cd = $self->r->inflate('cd_id');
$self->stash->{cd} = $cd;
}
and, more and more DRY Style.Auto inflate by convention.
package CDStand::Pages::Base;
use String::CamelCase qw/camelize/; # hio_d++
use UNIVERSAL::require;
__PACKAGE__->add_inflate_rule(
{
qr/^((.+)_id)$/ => sub {
my $self = shift;
my ($key, $table) = $1, $2;
my $model = "CDStand::Data::" . camelize($table);
$model->use or die $@;
return $model->retrieve($self->r->param($table);
}
}
);