/[swish]/trunk/spider/filter.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/spider/filter.pm

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

revision 57 by dpavlin, Sun Jan 25 16:49:50 2004 UTC revision 61 by dpavlin, Thu Jan 29 18:26:19 2004 UTC
# Line 1  Line 1 
1  sub filter {  sub filter {
2          my $contents = shift || return;          my $contents = shift || return;
3    
4  #       my $verbose = 1;          my $verbose = 0;
5                    
6          # if you don't want content to be indexed, include it in          # if you don't want content to be indexed, include it in
7          # <noindex> foobar </noindex> tags or surround it with comments          # <noindex> foobar </noindex> tags or surround it with comments
# Line 48  sub filter { Line 48  sub filter {
48    
49          if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) {          if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) {
50                  $new_title = $1;                  $new_title = $1;
51          } elsif ($contents =~ m,<h\d\sclass="docPartTitle"[^>]*>([^<]+)</h\d>,is) {          } elsif ($contents =~ m,<h\d\sclass="docPartTitle"[^>]*>(.+?)</h\d>,is) {
52                  $new_title = $1;                  $new_title = $1;
53          } elsif ($contents =~ m,<h\d\sclass="docChapterTitle"[^>]*>([^<]+)</h\d>,is) {          } elsif ($contents =~ m,<h\d\sclass="docChapterTitle"[^>]*>(.+?)</h\d>,is) {
54                  $new_title = $1;                  $new_title = $1;
55          } elsif ($contents =~ m,<h\d\sclass="docSection1Title"[^>]*>([^<]+)</h\d>,is) {          } elsif ($contents =~ m,<h\d\sclass="docSection1Title"[^>]*>(.+?)</h\d>,is) {
56                    $new_title = $1;
57            } elsif ($contents =~ m,<h\d\sclass="chapter"[^>]*>(.+?)</h\d>,is) {
58                    $new_title = $1;
59            } elsif ($contents =~ m,<h\d\sclass="sect1"[^>]*>(.+?)</h\d>,is) {
60                  $new_title = $1;                  $new_title = $1;
61          } else {          } else {
62                  if ($contents =~ m,<title>([^<]+)</title>,is) {                  if ($contents =~ m,<title>([^<]+)</title>,is) {
# Line 63  sub filter { Line 67  sub filter {
67          }          }
68    
69          if ($new_title) {          if ($new_title) {
70                    # nuke html in title
71                    $new_title =~ s/<br>\s+/: /gs;
72                    $new_title =~ s/<\/*[^>]+>//gs;
73            
74                  # check if new title is same as collection name                  # check if new title is same as collection name
75                  my ($a,$b) = ($new_title,$collection);                  my ($a,$b) = ($new_title,$collection);
76                  $a =~ s/([^a-zA-Z])+/ /gs;                  $a =~ s/([^a-zA-Z])+/ /gs;

Legend:
Removed from v.57  
changed lines
  Added in v.61

  ViewVC Help
Powered by ViewVC 1.1.26