28 |
|
|
29 |
opendir(DIR, $dir) or croak "Could not open '$dir': $!"; |
opendir(DIR, $dir) or croak "Could not open '$dir': $!"; |
30 |
DIRENT: for my $entry (readdir DIR) { |
DIRENT: for my $entry (readdir DIR) { |
|
# next unless $entry =~ /nt/; |
|
31 |
if (-f "$dir/$entry/desc.html") { |
if (-f "$dir/$entry/desc.html") { |
32 |
my $index = "$dir/$entry/index.html"; |
my $index = "$dir/$entry/index.html"; |
33 |
open F, $index or Carp::confess("Could not open $index: $!"); |
open F, $index or Carp::confess("Could not open $index: $!"); |
34 |
local $/; |
local $/; |
35 |
my $content = <F>; |
my $content = <F>; |
36 |
next DIRENT unless $content =~ m|<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\s+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\s+<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">\s+<head>\s+<!-- product id:|s; |
next DIRENT unless $content =~ m|<div|s; |
37 |
push @files, $entry; |
push @files, $entry; |
38 |
} |
} |
39 |
} |
} |
47 |
|
|
48 |
sub FETCH { |
sub FETCH { |
49 |
my $self = shift; |
my $self = shift; |
50 |
my $file = shift; |
my $id = shift; |
51 |
|
|
52 |
local($/) = undef; |
local($/) = undef; |
53 |
|
|
|
my $fh = IO::File->new(join('/',$self->{Dir},$file,'desc.html')); |
|
|
my $desc = conv_getline($fh); |
|
|
$fh = IO::File->new(join('/',$self->{Dir},$file,'author.html')); |
|
|
my $author = conv_getline($fh) if $fh; |
|
|
$fh = IO::File->new(join('/',$self->{Dir},$file,'index.html')); |
|
|
my $index = conv_getline($fh) if $fh; |
|
|
$fh = IO::File->new(join('/',$self->{Dir},$file,'colophon.html')); |
|
|
my $colophon = conv_getline($fh) if $fh; |
|
54 |
return { |
return { |
55 |
desc => $desc, |
desc => $self->conv_getline("$id/desc.html"), |
56 |
author => $author, |
author => $self->conv_getline("$id/author.html"), |
57 |
index => $index, |
index => $self->conv_getline("$id/index.html"), |
58 |
colophon => $colophon, |
colophon => $self->conv_getline("$id/colophon.html"), |
59 |
|
translator => $self->conv_getline("$id/translator.html"), |
60 |
|
toc => $self->conv_getline("$id/toc.html"), |
61 |
|
inx => $self->conv_getline("$id/inx.html"), |
62 |
}; |
}; |
63 |
} |
} |
64 |
|
|
65 |
# WAIT::Document::Ora::conv_getline |
# WAIT::Document::Ora::conv_getline |
66 |
sub conv_getline ($) { |
sub conv_getline { |
67 |
my($fh) = shift; |
my($self) = shift; |
68 |
|
my($file) = shift; |
69 |
|
my $fh = IO::File->new("$self->{Dir}/$file") or return ""; |
70 |
|
|
71 |
local $/ = "\n"; |
local $/ = "\n"; |
72 |
my $firstline = <$fh>; |
my $firstline = <$fh>; |
73 |
my $src_enc; |
my $src_enc; |