Skip to content
Browse files

day 16

  • Loading branch information...
1 parent 47d9ac1 commit 188e06b085744f468cf85d7bd5dfce438402c294 @typester committed Dec 21, 2009
Showing with 67 additions and 1 deletion.
  1. +7 −0 lib/Jobeet.pm
  2. +10 −0 lib/Jobeet/Controller/Job.pm
  3. +10 −0 lib/Jobeet/Schema/ResultSet/Job.pm
  4. +5 −1 root/common/base.mt
  5. +35 −0 root/job/atom.mt
View
7 lib/Jobeet.pm
@@ -2,6 +2,7 @@ package Jobeet;
use Ark;
use Data::Page::Navigation;
+use Digest::SHA1 ();
our $VERSION = '0.01';
@@ -25,4 +26,10 @@ config 'Plugin::Session::Store::Model' => {
model => 'cache',
};
+config 'View::MT' => {
+ macro => {
+ sha1_hex => \&Digest::SHA1::sha1_hex,
+ },
+};
+
1;
View
10 lib/Jobeet/Controller/Job.pm
@@ -4,6 +4,7 @@ use Ark 'Controller';
with 'Ark::ActionClass::Form';
use DateTime;
+use DateTime::Format::W3CDTF;
use Jobeet::Models;
sub index :Path {
@@ -12,6 +13,15 @@ sub index :Path {
$c->stash->{categories} = models('Schema::Category')->get_with_jobs;
}
+sub atom :Local {
+ my ($self, $c) = @_;
+ $c->res->content_type('application/atom+xml; charset=utf-8');
+
+ $c->stash->{w3c_date} = DateTime::Format::W3CDTF->new;
+ $c->stash->{latest_post} = models('Schema::Job')->latest_post;
+ $c->forward('index');
+}
+
sub show :Path :Args(1) {
my ($self, $c, $job_token) = @_;
View
10 lib/Jobeet/Schema/ResultSet/Job.pm
@@ -24,6 +24,16 @@ sub create_from_form {
$job;
}
+sub latest_post {
+ my ($self) = @_;
+
+ my $r = $self->search( { is_activated => 1, },
+ { order_by => { -desc => 'created_at' } } );
+
+ $r->first;
+
+}
+
1;
View
6 root/common/base.mt
@@ -4,6 +4,8 @@
<head>
<title><? block title => sub { 'Jobeet - Your best job board' } ?></title>
<link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="alternate" type="application/atom+xml" title="Latest Jobs"
+ href="<?= $c->uri_for('/job/atom') ?>" />
<? block javascripts => '' ?>
<? block stylesheets => '' ?>
</head>
@@ -68,7 +70,9 @@
</span>
<ul>
<li><a href="">About Jobeet</a></li>
- <li class="feed"><a href="">Full feed</a></li>
+ <li class="feed">
+ <a href="<?= $c->uri_for('/job/atom') ?>">Full feed</a>
+ </li>
<li><a href="">Jobeet API</a></li>
<li class="last"><a href="">Affiliates</a></li>
</ul>
View
35 root/job/atom.mt
@@ -0,0 +1,35 @@
+? my $w3c = $c->stash->{w3c_date};
+? my $latest_post = $c->stash->{latest_post};
+<?= raw_string qq[<\?xml version="1.0" encoding="utf-8"?\>] ?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Jobeet</title>
+ <subtitle>Latest Jobs</subtitle>
+ <link href="<?= $c->uri_for('/job/atom') ?>" rel="self"/>
+ <link href="<?= $c->uri_for('/job') ?>"/>
+ <updated><?= $w3c->format_datetime($latest_post->created_at) ?></updated>
+ <author><name>Jobeet</name></author>
+ <id><?= sha1_hex($c->uri_for('/job/atom')) ?></id>
+
+? my $max_rows = Jobeet::Models->get('conf')->{max_jobs_on_homepage};
+? for my $category ($c->stash->{categories}->all) {
+? for my $job ($category->get_active_jobs({ rows => $max_rows })->all) {
+ <entry>
+ <title><?= $job->position ?> (<?= $job->location ?>)</title>
+ <link href="" />
+ <id><?= sha1_hex($job->id) ?></id>
+ <updated><?= $w3c->format_datetime($job->created_at) ?></updated>
+ <summary type="xhtml">
+ <div><?= $job->description ?></div>
+
+ <h4>How to apply?</h4>
+ <p><?= $job->how_to_apply ?></p>
+ </summary>
+ <author>
+ <name><?= $job->company ?></name>
+ </author>
+ </entry>
+? } # endfor $job
+? } # endfor $category
+
+</feed>
+

0 comments on commit 188e06b

Please sign in to comment.
Something went wrong with that request. Please try again.