/[mws]/trunk/httpd.pl
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/httpd.pl

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

revision 28 by dpavlin, Sat May 8 22:18:38 2004 UTC revision 34 by dpavlin, Sun May 9 10:16:51 2004 UTC
# Line 85  while ( my $c = $d->accept ) { Line 85  while ( my $c = $d->accept ) {
85                  my $url = $r->url->path;                  my $url = $r->url->path;
86    
87                  # XXX LOG                  # XXX LOG
88                  print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug);                  print $r->method," ",$url,"\n";
89                    print Dumper($param),"\n" if ($debug);
90    
91                  # is this static page?                  # is this static page?
92                  if ($static_html && -f "$static_html/$url") {                  if ($static_html && -f "$static_html/$url") {
# Line 173  while ( my $c = $d->accept ) { Line 174  while ( my $c = $d->accept ) {
174                          $tpl_var->{results} = \@res if (@res);                          $tpl_var->{results} = \@res if (@res);
175                          $tpl_var->{total_hits} = $mws->{total_hits} || 0;                          $tpl_var->{total_hits} = $mws->{total_hits} || 0;
176    
177                            # no hits, offer suggestions
178                            if (! $tpl_var->{results}) {
179                                    @{$tpl_var->{apropos}} = $mws->apropos_index($param->{'search_fld'}, $param->{'search_val'});
180                            }
181    
182                  }                  }
183    
184    
# Line 208  while ( my $c = $d->accept ) { Line 214  while ( my $c = $d->accept ) {
214  # template toolkit filter  # template toolkit filter
215    
216  sub html_escape($) {  sub html_escape($) {
217          my $text = shift;          my $text = shift || return;
218    
219            # don't re-escape html
220            #return $text if ($text =~ /&(:?lt|gt|amp|quot);/);
221    
222          # Escape <, >, & and ", and to produce valid XML          # Escape <, >, & and ", and to produce valid XML
223          my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');          my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
224          my $escape_re  = join '|' => keys %escape;          my $escape_re  = join '|' => keys %escape;
225    
226          $text =~ s/($escape_re)/$escape{$1}/gs;          $text =~ s/($escape_re)/$escape{$1}/gs;
227    
228            while ($text =~ s/#-#(quote|signature)(\d*)##(.+?)##\1\2#-#/<span class="$1">$3<\/span>/gs) { } ;
229    
230          return $text;          return $text;
231  }  }
232    
# Line 228  sub body5_filter { Line 240  sub body5_filter {
240          # remove quote author          # remove quote author
241          $text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs;          $text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs;
242          $text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs;          $text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs;
243            $text =~ s/#-q-#[\n\r]*//gs;
244          # outlook quoting          # outlook quoting
245          $text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si;          $text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si;
246          $text =~ s/(\s*--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$//si;          $text =~ s/(\s*--+\s*Forwarded\s+message.+\s*--+.*)$//si;
247    
248          # remove signature          # remove signature
249          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;
# Line 242  sub body5_filter { Line 255  sub body5_filter {
255          $text =~ s/^\n+//gs;          $text =~ s/^\n+//gs;
256          $text =~ s/[\s\n]+$//gs;          $text =~ s/[\s\n]+$//gs;
257    
258            if ($text eq "") {
259                    $text="#-#quote##forwarded message##quote#-#";
260            }
261    
262          # cut to 5 lines;          # cut to 5 lines;
263          if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) {          if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) {
264                  $text =~ s/[\n\r]*$/ .../;                  $text =~ s/[\n\r]*$/ .../;
# Line 264  sub body_filter { Line 281  sub body_filter {
281          }          }
282    
283          # find quoted text          # find quoted text
284          $text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote##$1##quote#-#/msg;          $text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote1##$1##quote1#-#/msg;
285          $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote##$1##quote#-#/si || $text =~ s/(--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$/#-#quote##$1##quote#-#/si;          $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote2##$1##quote2#-#/si;
286            $text =~ s/(--+\s*Forwarded\s+message.+\s*--+.*)$/#-#quote3##$1##quote3#-#/si;
287    
288          $text = html_escape($text . $sig);          $text = html_escape($text . $sig);
         $text =~ s/#-#(quote|signature)##(.+?)##(\1)#-#/<span class="$1">$2<\/span>/gs;  
289          return $text;          return $text;
290  }  }
291    

Legend:
Removed from v.28  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26