/[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 71 by dpavlin, Sat Apr 3 15:15:36 2004 UTC revision 85 by dpavlin, Mon Aug 30 11:14:24 2004 UTC
# Line 48  sub filter { Line 48  sub filter {
48                  }                  }
49                  $contents =~ s,(<title>)([^<]+)(</title>),$1$2: $title$3,gsi if ($title);                  $contents =~ s,(<title>)([^<]+)(</title>),$1$2: $title$3,gsi if ($title);
50    
51            } elsif ($contents =~ m,<!--\s+METADATA(.*?)METADATA\s+-->,is) {
52                    # LJ metadata
53                    my $metadata = $1;
54                    my $title = "LJ";
55    
56                    $title .= "$1: " if ($metadata =~ m,<issue>(.+?)</issue>,is);
57                    $title .= "$1 - " if ($metadata =~ m,<category>(.+?)</category>,is);
58                    $title .= $1 if ($metadata =~ m,<title>(.+?)</title>,is);
59                    $title =~ s/\s+/ /gsi;
60                    $contents =~ s,<title>[^<]+</title>,<title>$title</title>,is;
61          }          }
62    
63          # is second argument collection?          # is second argument collection?
# Line 58  sub filter { Line 68  sub filter {
68    
69          if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) {          if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) {
70                  $new_title = $1;                  $new_title = $1;
71          } elsif ($contents =~ m,<(h\d)\sclass="docPartTitle"[^>]*>(.+?)<\1>,is) {                  print STDERR "using title '$new_title' from <!--SafTocEntry-->\n" if ($verbose);
72            } elsif ($contents =~ m,<(h\d)\s+class="docPartTitle"[^>]*>(.+?)</\1>,is) {
73                    $new_title = $2;
74                    print STDERR "using title '$new_title' from docPartTitle\n" if ($verbose);
75            } elsif ($contents =~ m,<(h\d)\s+class="docChapterTitle"[^>]*>(.+?)</\1>,is) {
76                  $new_title = $2;                  $new_title = $2;
77          } elsif ($contents =~ m,<(h\d)\sclass="docChapterTitle"[^>]*>(.+?)<\1>,is) {                  print STDERR "using title '$new_title' from docChapterTitle\n" if ($verbose);
78            } elsif ($contents =~ m,<(h\d)\s+class="docSection1Title"[^>]*>(.+?)</\1>,is) {
79                  $new_title = $2;                  $new_title = $2;
80          } elsif ($contents =~ m,<(h\d)\sclass="docSection1Title"[^>]*>(.+?)<\1>,is) {                  print STDERR "using title '$new_title' from docSection1Title\n" if ($verbose);
81            } elsif ($contents =~ m,<(h\d)\s+class="doc[^"]*Title"[^>]*>(.+?)</\1>,is) {
82                  $new_title = $2;                  $new_title = $2;
83          } elsif ($contents =~ m,<(h\d)\sclass="chapter"[^>]*>(.+?)<\1>,is) {                  print STDERR "using title '$new_title' from doc.+Title\n" if ($verbose);
84            } elsif ($contents =~ m,<(h\d)\s+class="chapter"[^>]*>(.+?)</\1>,is) {
85                  $new_title = $2;                  $new_title = $2;
86          } elsif ($contents =~ m,<(h\d)\sclass="sect1"[^>]*>(.+?)<\1>,is) {                  print STDERR "using title '$new_title' from chapter\n" if ($verbose);
87            } elsif ($contents =~ m,<(h\d)\s+class="sect1"[^>]*>(.+?)</\1>,is) {
88                  $new_title = $2;                  $new_title = $2;
89                    print STDERR "using title '$new_title' from sect1\n" if ($verbose);
90          } else {          } else {
91                  if ($contents =~ m,<title>([^<]+)</title>,is) {                  if ($contents =~ m,<title>([^<]+)</title>,is) {
92                          $new_title = $1;                          $new_title = $1;
93                            print STDERR "using title '$new_title' from <title>\n" if ($verbose);
94                  } elsif ($contents =~ m,<h\d[^>]*>([^<]+)</h\d>,is) {                  } elsif ($contents =~ m,<h\d[^>]*>([^<]+)</h\d>,is) {
95                          $new_title = $1;                          $new_title = $1;
96                            print STDERR "using title '$new_title' from <h_>\n" if ($verbose);
97                  }                  }
98          }          }
99    
# Line 87  sub filter { Line 108  sub filter {
108                  $b =~ s/([^a-zA-Z])+/ /gs;                  $b =~ s/([^a-zA-Z])+/ /gs;
109                  if ($a =~ m/$b/i) {                  if ($a =~ m/$b/i) {
110                          $new_title = $collection;                          $new_title = $collection;
111                            print STDERR "new_title and collection are same! [$new_title]\n" if ($verbose);
112                  } else {                  } else {
113                          $new_title = "$collection :: $new_title";                          $new_title = "$collection :: $new_title";
114                  }                  }

Legend:
Removed from v.71  
changed lines
  Added in v.85

  ViewVC Help
Powered by ViewVC 1.1.26