/[Frey]/trunk/lib/Frey/View/NoPager.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/View/NoPager.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 956 by dpavlin, Tue Dec 16 14:25:52 2008 UTC revision 957 by dpavlin, Wed Jan 7 17:50:03 2009 UTC
# Line 13  use Data::Dump qw/dump/; Line 13  use Data::Dump qw/dump/;
13  has search => (  has search => (
14          is => 'rw',          is => 'rw',
15          isa => 'Str',          isa => 'Str',
16          required => 1,  #       required => 1,
17          default => '',          default => '',
18  );  );
19    
# Line 48  sub json { Line 48  sub json {
48  }  }
49    
50  sub results_as_markup {  sub results_as_markup {
51          my $self = shift;          my ($self) = @_;
52    
53          my ($search,$page) = ( $self->search , $self->on_page );          my ($search,$page) = ( $self->search , $self->on_page );
54    
55          sub next_page {          sub next_page {
56                  my ($self) = @_;                  my $self = shift;
57                  return                  return
58                     qq|<div id="next_page">|                     qq|<div id="next_page">|
59                   . join("\n", @_) . $self->json()                   . join("\n", @_) . $self->json()
# Line 144  sub results_as_markup { Line 144  sub results_as_markup {
144                          return $text;                          return $text;
145                  }                  }
146    
147                  my @template;                  my $result = q|
148                  open(my $t, 'result.html')  || die "result.html: $!";                          <div class="result">
149                  while(<$t>) {                          <h1><% attr_regex( $rdoc, '@title' ) %></h1>
150                          push @template, $_;                          <p>
151                  }                          <% html_snippet( $rdoc->snippet ) %>
152                  close($t);                          </p>
153                            <span style="color: #888"><% $nr %></span>
154                            <strong><% attr_regex( $rdoc, 'source' ) %></strong>
155                            <em>
156                            <% attr_regex( $rdoc, '@size' ) %> bytes
157                            </em>
158                            <% attr_regex( $rdoc, '@mdate' ) %>
159                            <br/><a href="<% $uri %>"><tt><% $uri %></tt></a>
160                            </div>
161                    |;
162    
163                    my @result = split(/\n/, $result);
164                    warn "# result template has ", $#result + 1, " lines";
165    
166                  # for each document in results                  # for each document in results
167                  for my $i ( 0 ... $nres->doc_num - 1 ) {                  for my $i ( 0 ... $nres->doc_num - 1 ) {
# Line 162  sub results_as_markup { Line 174  sub results_as_markup {
174                                  my $l = $_;                                  my $l = $_;
175                                  $l =~ s/<%(.+?)%>/eval "$1"/ge;                                  $l =~ s/<%(.+?)%>/eval "$1"/ge;
176                                  $out .= $l;                                  $out .= $l;
177                          } @template;                          } @result;
178    
179                  }                  }
180    
# Line 179  sub results_as_markup { Line 191  sub results_as_markup {
191                  );                  );
192          }          }
193    
194            $self->wrap_in_page( 0 ); # disable <body> and status bar
195    
196          return $out;          return $out;
197    
198  }  }
# Line 186  sub results_as_markup { Line 200  sub results_as_markup {
200  sub as_markup {  sub as_markup {
201          my ($self) = @_;          my ($self) = @_;
202    
203          $self->add_css('static/Frey/NoPager.css');          $self->add_css('static/Frey/View/NoPager.css');
204          $self->add_js ('static/Frey/NoPager.js');          $self->add_js ('static/Frey/View/NoPager.js');
205    
206          $self->add_js(q|          $self->add_js(q|
207                  $(document).ready( function() {                  $(document).ready( function() {
# Line 199  sub as_markup { Line 213  sub as_markup {
213                  });                  });
214          |);          |);
215    
216          return qq|          my $html = join("\n",
217            qq|
218                  <div id="search_form_div">                  <div id="search_form_div">
219                          <form id="search_form" method="get">                          <form id="search_form" method="get">
220                                    
221                          <input autocomplete="off" name="search" type="input" value="|, $self->search, qq|">                                  <input autocomplete="off" name="search" type="input" value="|, $self->search, qq|">
222                          |, $self->sort, qq|                                  |, $self->sort, qq|
223                          <input type="submit" class="submit" value="search">                                  <input type="submit" class="submit" value="search">
224    
225                          <span id="status" class="note">                                  <span id="status" class="note">
226                          |, $v->{status}, qq|                                  |, $v->{status}, qq|
227                          </span>                                  </span>
228                  </form>  
229                            </form>
230                    </div>
231    
232                  <div style="margin-top: 3em;">                  <div style="margin-top: 3em;">
233                  <!-- Dynamic Content -->                  <!-- Dynamic Content -->
# Line 225  sub as_markup { Line 242  sub as_markup {
242    
243                  </div>                  </div>
244    
245          </div>          |
246          |;          );
247    
248            $self->wrap_in_page( 1 ); # FIXME results_as_markup will turn it off
249            return $html;
250  }  }
251    
252  1;  1;

Legend:
Removed from v.956  
changed lines
  Added in v.957

  ViewVC Help
Powered by ViewVC 1.1.26