summaryrefslogtreecommitdiff
path: root/_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.textile
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2013-11-26 10:36:10 -0800
committerFranck Cuny <franck.cuny@gmail.com>2013-11-26 10:36:10 -0800
commit8ddf2e94df70707b458528a437759b96046d3e01 (patch)
treed442818d92d3c9c6f7fcdc92857a1228963849a1 /_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.textile
parentDon't need to use the IP in the makefile. (diff)
downloadlumberjaph-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-13-a-simple-feed-aggregator-with-modern-perl-part-4.md (renamed from _posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.textile)56
1 files changed, 29 insertions, 27 deletions
diff --git a/_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.textile b/_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.md
index ca7849e..aace6ea 100644
--- a/_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.textile
+++ b/_posts/2009-05-13-a-simple-feed-aggregator-with-modern-perl-part-4.md
@@ -1,33 +1,33 @@
---
layout: post
title: A simple feed aggregator with modern Perl - part 4
-category: perl
+summary: In which we reach the conclusion on how to write a feed aggregator.
---
-We have the model, the aggregator (and some tests), now we can do a basic frontend to read our feed. For this I will create a webapp using "catalyst":http://www.catalystframework.org.
+We have the model, the aggregator (and some tests), now we can do a basic frontend to read our feed. For this I will create a webapp using [Catalyst](http://www.catalystframework.org).
-"Catalyst::Devel":http://search.cpan.org/perldoc?Catalyst::Devel is required for developping catalyst application, so we will install it first:
+[Catalyst::Devel](http://search.cpan.org/perldoc?Catalyst::Devel) is required for developping catalyst application, so we will install it first:
{% highlight perl %}
-cpan Catalyst::Devel
+% cpan Catalyst::Devel
{% endhighlight %}
Now we can create our catalyst application using the helper:
{% highlight perl %}
-catalyst.pl MyFeedReader
+% catalyst.pl MyFeedReader
{% endhighlight %}
-This command initialise the framework for our application *MyFeedReader*. A number of files are created, like the structure of the MVC directory, some tests, helpers, ...
+This command initialise the framework for our application **MyFeedReader**. A number of files are created, like the structure of the MVC directory, some tests, helpers, ...
-We start by creating a view, using "TTSite":http://search.cpan.org/perldoc?Catalyst::View::TT. TTSite generate some templates for us, and the configuration for this template. We will also have a basic CSS, a header, footer, etc.
+We start by creating a view, using [TTSite](http://search.cpan.org/perldoc?Catalyst::View::TT). TTSite generate some templates for us, and the configuration for this template. We will also have a basic CSS, a header, footer, etc.
{% highlight bash %}
cd MyFeedReader
perl script/myfeedreader_create.pl view TT TTSite
{% endhighlight %}
-TTSite files are under *root/src* and *root/lib*. A *MyAggregator/View/TT.pm* file is also created. We edit it to make it look like this:
+TTSite files are under **root/src** and **root/lib**. A **MyAggregator/View/TT.pm** file is also created. We edit it to make it look like this:
{% highlight perl %}
__PACKAGE__->config({
@@ -43,15 +43,17 @@ __PACKAGE__->config({
});
{% endhighlight %}
-Now we create our first template, in *root/src/index.tt2*
+Now we create our first template, in **root/src/index.tt2**
-bq. to <a href="/feed/">your feeds</a>
+{% highlight html %}
+to <a href="/feed/">your feeds</a>
+{% endhighlight %}
-If you start the application (using _perl script/myfeedreader_server.pl_) and point your browser on http://localhost:3000/, this template will be rendered.
+If you start the application (using `perl script/myfeedreader_server.pl`) and point your browser on http://localhost:3000/, this template will be rendered.
We need two models, one for KiokuDB and another one for MyModel:
-*lib/MyFeedReader/Model/KiokuDB.pm*
+**lib/MyFeedReader/Model/KiokuDB.pm**
{% highlight perl %}
package MyFeedReader::Model::KiokuDB;
@@ -60,15 +62,15 @@ BEGIN { extends qw(Catalyst::Model::KiokuDB) }
1;
{% endhighlight %}
-we edit the configuration file (*myfeedreader.conf*), and set the dsn for our kiokudb backend
+we edit the configuration file (**myfeedreader.conf**), and set the dsn for our kiokudb backend
-{% highlight perl %}
+{% highlight xml %}
<Model KiokuDB>
dsn dbi:SQLite:../MyAggregator/foo.db
</Model>
{% endhighlight %}
-*lib/MyFeedReader/Model/MyModel.pm*
+**lib/MyFeedReader/Model/MyModel.pm**
{% highlight perl %}
package MyFeedReader::Model::MyModel;
@@ -78,7 +80,7 @@ use base qw/Catalyst::Model::DBIC::Schema/;
and the configuration:
-{% highlight perl %}
+{% highlight xml %}
<Model MyModel>
connect_info dbi:SQLite:../MyModel/model.db
schema_class MyModel
@@ -87,7 +89,7 @@ and the configuration:
We got our view and our model, we can do the code for the controller. We need 2 controller, one for the feed, and one for the entries. The Feed controller will list them and display entries titles for a given feed. The Entry controller will just display them.
-*lib/MyFeedReader/Controller/Feed.pm*
+**lib/MyFeedReader/Controller/Feed.pm**
{% highlight perl %}
package MyFeedReader::Controller::Feed;
@@ -112,13 +114,13 @@ sub view : Chained('/') : PathPart('feed/view') : Args(1) {
1;
{% endhighlight %}
-The function *index* list the feeds, while the function *view* list the entries for a give feed. We use the chained action mechanism to dispatch this url, so we can have urls like this _/feed/*_
+The function `index` list the feeds, while the function `view` list the entries for a give feed. We use the chained action mechanism to dispatch this url, so we can have urls like this **/feed/\***
We create our 2 templates (for index and view):
-*root/src/feed/index.tt2*
+**root/src/feed/index.tt2**
-{% highlight perl %}
+{% highlight html %}
<ul>
[% FOREACH feed IN feeds %]
<li><a href="/feed/view/[% feed.id %]">[% feed.url %]</a></li>
@@ -126,9 +128,9 @@ We create our 2 templates (for index and view):
</ul>
{% endhighlight %}
-*root/src/feed/vew.tt2*
+**root/src/feed/vew.tt2**
-{% highlight perl %}
+{% highlight html %}
<h1>[% feed.url %]</h1>
<h3>entries</h3>
@@ -166,11 +168,11 @@ sub view : Chained('/') : PathPart('entry') : Args(1) {
1;
{% endhighlight %}
-The function *view* fetch an entry from the kiokudb backend, and store it in the stash, so we can use it in our template.
+The function **view** fetch an entry from the kiokudb backend, and store it in the stash, so we can use it in our template.
-*root/src/entry/view.tt2*
+**root/src/entry/view.tt2**
-{% highlight perl %}
+{% highlight html %}
<h1><a href="[% entry.permalink %]">[% entry.title %]</a></h1>
<span>Posted [% entry.date %] by [% entry.author %]</span>
<div id="content">
@@ -178,10 +180,10 @@ The function *view* fetch an entry from the kiokudb backend, and store it in the
</div>
{% endhighlight %}
-If you point your browser to an entry (something like *http://localhost:3000/entry/somesha256value*), you will see an entry:
+If you point your browser to an entry (something like **http://localhost:3000/entry/somesha256value**), you will see an entry:
!/static/imgs/show_entry.png(show entry)!
Et voila, we are done with a really basic feed reader. You can add methods to add or delete feed, mark an entry as read, ...
-"The code is available on github":http://github.com/franckcuny/ironman-myfeedreader/tree/master
+[The code is available on GitHub](http://github.com/franckcuny/ironman-myfeedreader/tree/master)