18 |
|
|
19 |
#$verbose = 1; |
#$verbose = 1; |
20 |
my $debug = 0; |
my $debug = 0; |
21 |
|
my $force = 0; |
22 |
|
|
23 |
my $result = GetOptions( |
my $result = GetOptions( |
24 |
"collection=s" => \$collection, |
"collection=s" => \$collection, |
27 |
"debug!" => \$debug, |
"debug!" => \$debug, |
28 |
"exclude=s" => \$exclude, |
"exclude=s" => \$exclude, |
29 |
"node=s" => \$node_url, |
"node=s" => \$node_url, |
30 |
|
"force!" => \$force, |
31 |
); |
); |
32 |
|
|
33 |
my $dir = shift @ARGV || die "usage: $0 [dir]"; |
my $dir = shift @ARGV || die "usage: $0 [dir]"; |
34 |
|
|
35 |
|
if (! -e $dir) { |
36 |
|
warn "directory $dir doesn't exist, skipping\n"; |
37 |
|
exit 1; |
38 |
|
} |
39 |
|
|
40 |
#my $basedir = $0; |
#my $basedir = $0; |
41 |
#$basedir =~ s,/[^/]+$,/,; |
#$basedir =~ s,/[^/]+$,/,; |
42 |
#require "$basedir/filter.pm"; |
#require "$basedir/filter.pm"; |
106 |
# create a document object |
# create a document object |
107 |
my $doc = HyperEstraier::Document->new; |
my $doc = HyperEstraier::Document->new; |
108 |
|
|
109 |
my $title = $1 if ($contents =~ m#<title>(.+)</title>#is); |
my $title = $1 if ($contents =~ m#<title>(.+?)</title>#is); |
110 |
|
|
111 |
# chop long titles to 100 chars |
# chop long titles to 100 chars |
112 |
$title = substr($title, 0, 100) . '...' if ($title && length($title) > 100); |
$title = substr($title, 0, 100) . '...' if ($title && length($title) > 100); |
141 |
my $path = $_; |
my $path = $_; |
142 |
my $contents; |
my $contents; |
143 |
|
|
144 |
return if (-l $path || $path =~ m#/.svn# || $path =~ m/(~|.bak)$/); |
return if (! $force && -l $path || $path =~ m#/.svn# || $path =~ m/(~|.bak)$/); |
145 |
|
|
146 |
my $mtime = (stat($path))[9]; |
my $mtime = (stat($path))[9] || -1; |
147 |
my $mtime_db = $db->get_doc_attr_by_uri("file:///$path", '@mtime') || -2; |
my $mtime_db = $db->get_doc_attr_by_uri("file:///$path", '@mtime') || -2; |
148 |
|
|
149 |
if ($mtime == $mtime_db) { |
if ($mtime == $mtime_db) { |
150 |
print STDERR "# same: $path $mtime\n" if ($verbose); |
print STDERR "# same: $path $mtime\n" if ($verbose); |
151 |
return; |
return unless($force); |
152 |
} else { |
} else { |
153 |
print STDERR "# changed: $path $mtime != $mtime_db\n" if ($debug); |
print STDERR "# changed: $path $mtime != $mtime_db\n" if ($debug); |
154 |
} |
} |
196 |
print STDERR " $page_nr" if ($verbose); |
print STDERR " $page_nr" if ($verbose); |
197 |
my $pre_tmp = $pre_html; |
my $pre_tmp = $pre_html; |
198 |
$pre_tmp =~ s/##page_nr##/$page_nr<\/title>/s; |
$pre_tmp =~ s/##page_nr##/$page_nr<\/title>/s; |
199 |
dump_contents($db, $pre_tmp . $page . $post_html, $mtime, $path) if ($page !~ m/^\s*$/s); |
dump_contents($db, $pre_tmp . $page . $post_html, $mtime, "$path#$page_nr") if ($page !~ m/^\s*$/s); |
200 |
$page_nr++; |
$page_nr++; |
201 |
} |
} |
202 |
|
|