Skip to content

Commit

Permalink
improve search
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieren Diment committed Dec 29, 2009
1 parent 35d780d commit 4e8b727
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
17 changes: 15 additions & 2 deletions lib/Text/TranscriptMiner/Web/Controller/Docs/Search.pm
Expand Up @@ -10,7 +10,13 @@ sub start :Chained("") :PathPart("docs/search") :CaptureArgs(0) {

sub get_root :Chained("start") :PathPart("") :Args(0) {
my ($self, $c ) = @_;
$c->stash( template => 'search/results.tt' );
if ($c->req->params->{txt} == 1) {
$c->stash( template => 'search/results_txt.tt',
nowrapper => 1);
}
else {
$c->stash( template => 'search/results.tt' );
}
}

sub tag_search :Chained("start") :PathPart("tags") :Args(0) {
Expand Down Expand Up @@ -52,7 +58,14 @@ sub display_text_for_single_tag : Chained("start") PathPart('') Args(1) {
{start_dir => $c->config->{start_dir}});
my $interviews = $corpus_object->search_for_subnodes($docs);
my @interviews = $corpus_object->get_interviews($c->config->{start_dir}, @$interviews);
$c->stash(template => 'search/results.tt',
if ($c->req->params->{txt} == 1) {
$c->stash( template => 'search/results_txt.tt',
nowrapper => 1);
}
else {
$c->stash( template => 'search/results.tt' );
}
$c->stash(
search => $tag,
interviews => \@interviews,
);
Expand Down
22 changes: 13 additions & 9 deletions root/search/results_txt.tt
@@ -1,21 +1,25 @@
<h1># Search for "[% search %]" </h1> [% uncoded = [ ] %]
<p> source: [% c.req.uri %]
# Search for "[% search %]" [% uncoded = [ ] %]

source: [% c.req.uri %]
[% FOREACH i IN interviews %]
[% SET doc_file = i.file.relative(c.config.start_dir) %]
[% SET code_search = i.get_this_tag(search); %]
[% IF code_search.size == 0; uncoded.push(doc_file); NEXT; END;
SET search_url = c.uri_for('/docs', doc_file) _"#$search" %]
<h2>## <a href="[% search_url %]"> [% doc_file %]</a> </h2>
<p> source: [% search_url %] </p>
## [% doc_file %]

source: [% search_url %]

[% FOREACH res IN code_search %]
<p> <div class="result">[% FILTER html_line_break; res; END %] </div></p> <br /> &nbsp;
[% res %]

[% END %]
[% END %]


<h2>## Documents in this set without the code [% search %]</h2>
<ul>
## Documents in this set without the code [% search %]

[% FOREACH empty IN uncoded; SET search_url = c.uri_for('/docs', empty) _"#$search" %]
<li> <a href="[% search_url %]"> [% empty %]</a> ( [% search_url %] ) </li>
* [% empty %] ( [% search_url %] )
[% END %]
</ul>

0 comments on commit 4e8b727

Please sign in to comment.