Monday, December 15, 2008

Catalyst::Action::Fixup::XHTML

Catalyst::Action::Fixup::XHTML is on CPAN now.

as what I said yesterday, I just made up a Catalyst Action for XHTML header.
the code is really very simple and most are copied from Catalyst::View::TT::XHTML.
and the test code too.

I also wrote tests for my MojoX::Fixup::XHTML. you can find here: http://fayland.googlecode.com/svn/trunk/CPAN/MojoX-Fixup-XHTML/t/live-test.t

Just enjoy!

Thanks.

Labels: ,

Sunday, December 14, 2008

MojoX::Fixup::XHTML

inspired from Day 13. Using XHTML Strict mode during application development., I just created a MojoX::Fixup::XHTML based on Catalyst::View::TT::XHTML

but it's more than TT. every template render can use it, it's in sub dispatch.
I'm thinking to create a Catalyst::Action::Fixup::XHTML to do more than TT, but I don't have much time now.

at last I applied to http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp.pm

the source code is simple which can be found here: http://fayland.googlecode.com/svn/trunk/CPAN/MojoX-Fixup-XHTML/lib/MojoX/Fixup/XHTML.pm

Enjoy!

Labels:

Wednesday, November 19, 2008

Learn Mojo 1: start a project and a bit more

Mojo is created by sri, the one who created Catalyst.
since sri is very SMART, we should follow him a bit.

Mojo is not a web framework. it is "a collection of libraries and example web frameworks for web framework developers.". u can treat it as something like Catalyst::Engine or HTTP::Engine.

but Mojolicious is a web framework built on Mojo.

install Mojo should be very simple and it doesn't have the half of CPAN. :)

start a project based on Mojolicous, you just type:
mojolicious generate app DayDayUp
cd day_day_up
perl bin/day_day_up deamon
then you can view a sample through http://127.0.0.1:3000/

it's like Catalyst but it's really much more faster than catalyst server.pl

Mojolicous is still in its early stage. but luckily, we have MojoX::Renderer::TT by ask.

something inside:
1, in Controller $c, it is an instance of DayDayUp::Context which based on Mojolicious::Context.
check http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp/Context.pm
we added config and dbh there. after this, you can call $c->config and $c->dbh in controller like
http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp/Notes.pm
it's very flexible. you can add DBIx::Class there, it's not a problem.
2, routines. you don't have any :Global :Regex :Chained in Mojolicous. instead, we defined all those url mapping things in DayDayUp.pm sub start.
http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp.pm
indeed, I like it. :)
remember it has an order. so you should put the default at the last of routines like
    # route
$r->route('/notes/:id/:action', id => qr/\d+/)
->to(controller => 'notes', action => 'index');
# Default route
$r->route('/:controller/:action')
->to(controller => 'index', action => 'index');

set ENV MOJOX_ROUTES_DEBUG on that you can debug the dispatch.
(1) / is matching ":/controller/:action" with default controller => 'index', action => 'index'
(2) /notes is matching ":/contorller/:action" with controller to be notes and action still be index.
(3) /notes/add is matching ":/controller/:action" with controller "notes" and action "add"
(4) /notes/1/edit is matching '/notes/:id/:action' with action as edit.
much much more you can find it here: Mojo::Manual::Mojolicious
it's simple but powerful.

I'll write more next time. but it's for now.

Thanks.

Labels: ,

Monday, November 17, 2008

Window git and mojo

download the win git from http://code.google.com/p/msysgit/

and try
git clone git://github.com/kraih/mojo.git mojo

I'm playing the Mojo from today. and I'll post more later.

Thanks.

Labels: ,