diff options
| author | Franck Cuny <franck.cuny@gmail.com> | 2013-11-26 10:36:10 -0800 |
|---|---|---|
| committer | Franck Cuny <franck.cuny@gmail.com> | 2013-11-26 10:36:10 -0800 |
| commit | 8ddf2e94df70707b458528a437759b96046d3e01 (patch) | |
| tree | d442818d92d3c9c6f7fcdc92857a1228963849a1 /_posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.md | |
| parent | Don't need to use the IP in the makefile. (diff) | |
| download | lumberjaph-8ddf2e94df70707b458528a437759b96046d3e01.tar.gz | |
Huge update.
Moved all posts from textile to markdown. Updated all the CSS and
styles. Added a new page for the resume.
Diffstat (limited to '')
| -rw-r--r-- | _posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.md (renamed from _posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.textile) | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/_posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.textile b/_posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.md index 2577b4f..8f0e033 100644 --- a/_posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.textile +++ b/_posts/2009-05-18-a-simple-feed-aggregator-with-modern-perl-part-4.1.md @@ -1,12 +1,12 @@ --- layout: post title: A simple feed aggregator with modern Perl - part 4.1 -category: perl +summary: In which we had one more article on how to write a feed aggregator. --- -You can thanks "bobtfish":http://github.com/bobtfish for being such a pedantic guy, 'cause now you will have a better chained examples. He forked my repository from github and fix some code that I'll explain here. +You can thanks [bobtfish](http://github.com/bobtfish) for being such a pedantic guy, 'cause now you will have a better chained examples. He forked my repository from GitHub and fix some code that I'll explain here. -h3. lib/MyFeedReader.pm +### lib/MyFeedReader.pm {% highlight perl %} package MyFeedReader; @@ -23,14 +23,14 @@ h3. lib/MyFeedReader.pm +extends 'Catalyst'; {% endhighlight %} -You can see that he use "Moose":http://search.cpan.org/perldoc?Moose, so we can remove +You can see that he use [Moose](http://search.cpan.org/perldoc?Moose), so we can remove {% highlight perl %} use strict; use warnings; {% endhighlight %} -and have a more elegant way to inherit from "Catalyst":http://search.cpan.org/perldoc?Catalyst with +and have a more elegant way to inherit from [Catalyst](http://search.cpan.org/perldoc?Catalyst) with {% highlight perl %} extends 'Catalyst'; @@ -42,9 +42,9 @@ instead of use parent qw/Catalyst/; {% endhighlight %} -He also have updated the *Catalyst::Runtime* version, and added *namespace::autoclean*. The purpose of this module is to keep imported methods out of you namespace. Take a look at the "documentation":http://search.cpan.org/perldoc?namespace::autoclean, it's easy to understand how and why it's usefull. +He also have updated the **Catalyst::Runtime** version, and added **namespace::autoclean**. The purpose of this module is to keep imported methods out of you namespace. Take a look at the "documentation":http://search.cpan.org/perldoc?namespace::autoclean, it's easy to understand how and why it's usefull. -h3. lib/MyFeedReader/Controller/Root.pm +### lib/MyFeedReader/Controller/Root.pm {% highlight perl %} -use strict; @@ -71,9 +71,9 @@ h3. lib/MyFeedReader/Controller/Root.pm $c->response->status(404); {% endhighlight %} -A new method, *root*, that will be the root path for our application. All our methods will be chained from this action. If start you catalyst server and go to *http://localhost:3000/* you will be served with the Catalyst's welcome message as before. +A new method, `root`, that will be the root path for our application. All our methods will be chained from this action. If start you catalyst server and go to **http://localhost:3000/** you will be served with the Catalyst's welcome message as before. -h3. lib/MyFeedReader/Controller/Entry.pm +### lib/MyFeedReader/Controller/Entry.pm {% highlight perl %} -use warnings; @@ -97,9 +97,9 @@ h3. lib/MyFeedReader/Controller/Entry.pm +__PACKAGE__->meta->make_immutable; {% endhighlight %} -We extends the _Catalyst::Controller_ in a Moose way, and the _make_immutable_ instruction is a Moose recommanded best practice (you can alsa add _no Moose_ after the make_immutable). +We extends the **Catalyst::Controller** in a Moose way, and the `make_immutable` instruction is a Moose recommanded best practice (you can alsa add `no Moose` after the make_immutable). -h3. lib/MyFeedreader/Controller/Feed.pm +### lib/MyFeedreader/Controller/Feed.pm {% highlight perl %} +use Moose; @@ -133,25 +133,24 @@ h3. lib/MyFeedreader/Controller/Feed.pm +__PACKAGE__->meta->make_immutable; {% endhighlight %} -We got _feed_ which is chained to root. _index_ is chained to feed, and take no arguments. This method display the list of our feeds. And we got the _view_ method, chained to feed too, but with one argument, that display the content of an entry. +We got `feed` which is chained to root. `index` is chained to feed, and take no arguments. This method display the list of our feeds. And we got the `view` method, chained to feed too, but with one argument, that display the content of an entry. If you start the application, you will see the following routes: -{% highlight perl %} - .-------------------------------------+--------------------------------------. - | Path Spec | Private | - +-------------------------------------+--------------------------------------+ - | /root/entry/* | /root (0) | - | | => /entry/view | - | /root/feed | /root (0) | - | | -> /feed/feed (0) | - | | => /feed/index | - | /root/feed/view/* | /root (0) | - | | -> /feed/feed (0) | - | | => /feed/view | - | /root | /root (0) | - | | => /index | - '-------------------------------------+--------------------------------------' -{% endhighlight %} + +> .-------------------------------------+--------------------------------------. +> | Path Spec | Private | +> +-------------------------------------+--------------------------------------+ +> | /root/entry/* | /root (0) | +> | | => /entry/view | +> | /root/feed | /root (0) | +> | | -> /feed/feed (0) | +> | | => /feed/index | +> | /root/feed/view/* | /root (0) | +> | | -> /feed/feed (0) | +> | | => /feed/view | +> | /root | /root (0) | +> | | => /index | +> '-------------------------------------+--------------------------------------' I hope you got a better idea about chained action in catalyst now. And again, thanks to bobtfish for the code. |
