Skip to content

Commit

Permalink
day 18
Browse files Browse the repository at this point in the history
  • Loading branch information
typester committed Dec 21, 2009
1 parent edfa557 commit 088bea2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
16 changes: 16 additions & 0 deletions lib/Jobeet/Controller/Search.pm
@@ -0,0 +1,16 @@
package Jobeet::Controller::Search;
use Ark 'Controller';

use Jobeet::Models;

sub index :Path {
my ($self, $c) = @_;

my $query = $c->req->param('q')
or $c->detach('/default');

$c->stash->{jobs} = models('Schema::Job')->search_fulltext($query);
}

1;

14 changes: 14 additions & 0 deletions lib/Jobeet/Schema/ResultSet/Job.pm
Expand Up @@ -34,6 +34,20 @@ sub latest_post {


} }


sub search_fulltext {
my ($self, $word) = @_;

my $r = $self->search(
{
is_activated => 1,
-or => [
{ description => { -like => "%${word}%", } },
{ how_to_apply => { -like => "%${word}%", } },
]
},
{ order_by => { -desc => 'created_at' }, rows => 20 }
);
}


1; 1;


4 changes: 2 additions & 2 deletions root/common/base.mt
Expand Up @@ -27,8 +27,8 @@


<div class="search"> <div class="search">
<h2>Ask for a job</h2> <h2>Ask for a job</h2>
<form action="" method="get"> <form action="<?= $c->uri_for('/search') ?>" method="get">
<input type="text" name="keywords" <input type="text" name="q"
id="search_keywords" /> id="search_keywords" />
<input type="submit" value="search" /> <input type="submit" value="search" />
<div class="help"> <div class="help">
Expand Down
11 changes: 11 additions & 0 deletions root/search/index.mt
@@ -0,0 +1,11 @@
? extends 'common/jobs_base';

? block content => sub {

<div id="jobs">
?= include('job/partial_jobs', $c->stash->{jobs}->all );
</div>

? } # endblock content


0 comments on commit 088bea2

Please sign in to comment.