summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-10-21 10:41:33 +0000
committerfukachan <fukachan>2001-10-21 10:41:33 +0000
commit11e12e8adea7b81006a2a22b1dc7607768504cb5 (patch)
tree1137b9dd4305b56c8ed8ae9cd7ad827f05de4558 /fml
parent91418878d120dcdd453d17c7a9bf63b334135a59 (diff)
downloadfml8-11e12e8adea7b81006a2a22b1dc7607768504cb5.tar.gz
fml8-11e12e8adea7b81006a2a22b1dc7607768504cb5.tar.bz2
fml8-11e12e8adea7b81006a2a22b1dc7607768504cb5.zip
clean up debug code
prepare top level entrance functions: htmlify_file() for file htmlify_dir() for directory
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/Mail/HTML/Lite.pm119
1 files changed, 73 insertions, 46 deletions
diff --git a/fml/lib/Mail/HTML/Lite.pm b/fml/lib/Mail/HTML/Lite.pm
index f23e4475..61c234f2 100644
--- a/fml/lib/Mail/HTML/Lite.pm
+++ b/fml/lib/Mail/HTML/Lite.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Lite.pm,v 1.14 2001/10/21 05:53:58 fukachan Exp $
+# $FML: Lite.pm,v 1.15 2001/10/21 07:37:07 fukachan Exp $
#
package Mail::HTML::Lite;
@@ -15,7 +15,7 @@ use Carp;
my $debug = $ENV{'debug'} ? 1 : 0;
my $URL = "<A HREF=\"http://www.fml.org/software/\">Mail::HTML::Lite</A>";
-my $version = q$FML: Lite.pm,v 1.14 2001/10/21 05:53:58 fukachan Exp $;
+my $version = q$FML: Lite.pm,v 1.15 2001/10/21 07:37:07 fukachan Exp $;
if ($version =~ /,v\s+([\d\.]+)\s+/) {
$version = "$URL $1";
}
@@ -1692,76 +1692,103 @@ sub _decode_mime_string
}
-#
-# debug
-#
+=head1 useful functions as entrance
+
+=head2 C<htmlify_file($file, $args)>
+
+try to convert rfc822 message C<$file> to HTML.
+
+ $args = {
+ directory => "destination directory",
+ };
+
+=head2 C<htmlify_dir($dir, $args)>
+
+try to convert all rfc822 messages to HTML in C<$dir> directory.
-sub _debug
+ $args = {
+ directory => "destination directory",
+ };
+
+=cut
+
+
+# Descriptions:
+# Arguments: $self $args
+# Side Effects:
+# Return Value: none
+sub htmlify_file
{
- my ($file) = @_;
+ my ($file, $args) = @_;
+ my $dst_dir = $args->{ directory };
use File::Basename;
- my $f = basename($file);
+ my $id = basename($file);
my $html = new Mail::HTML::Lite {
charset => "euc-jp",
- directory => "/tmp/htdocs",
+ directory => $dst_dir,
};
- printf STDERR "_debug( id=%-6s src=%s )\n", $f, $file;
+ printf STDERR "htmlify_file( id=%-6s src=%s )\n", $id, $file;
$html->htmlfy_rfc822_message({
- id => $f,
+ id => $id,
src => $file,
});
- $html->update_relation( $f );
- $html->update_id_monthly_index({
- title => "monthly index",
- id => $f,
- });
+ $html->update_relation( $id );
+ $html->update_id_monthly_index({ id => $id });
+ $html->update_id_index({ id => $id });
+ $html->update_thread_index({ id => $id });
- # update index.html
- $html->update_id_index({
- title => "index",
- id => $f,
- });
+ # no more action for old files
+ if ($html->is_ignore($id)) {
+ warn("not process $id (already exists)");
+ }
+}
- # update thread.html
- my $start_time = time;
- $html->update_thread_index({
- title => "thread",
- id => $f,
- });
- # no more action for old files
- if ($html->is_ignore($f)) {
- warn("not process $f (already exists)");
+# Descriptions:
+# Arguments: $self $args
+# Side Effects:
+# Return Value: none
+sub htmlify_dir
+{
+ my ($src_dir, $args) = @_;
+ my $dst_dir = $args->{ directory };
+ my $max = 0;
+
+ use DirHandle;
+ my $dh = new DirHandle $src_dir;
+ if (defined $dh) {
+ FILE:
+ for my $file ( $dh->read() ) {
+ next FILE unless $file =~ /^\d+$/;
+ $max = $max < $file ? $file : $max;
+ }
+ }
+
+ for my $id ( 1 .. $max ) {
+ use File::Spec;
+ my $file = File::Spec->catfile($src_dir, $id);
+ htmlify_file($file, { directory => $dst_dir });
}
}
+#
+# debug
+#
if ($0 eq __FILE__) {
+ my $dir = "/tmp/htdocs";
+
eval q{
for my $x (@ARGV) {
if (-f $x) {
- _debug($x);
+ htmlify_file($x, { directory => $dir });
}
elsif (-d $x) {
- my $max = 0;
- use DirHandle;
- my $dh = new DirHandle $x;
- if (defined $dh) {
- for my $file ( $dh->read() ) {
- next unless $file =~ /^\d+$/;
- $max = $max < $file ? $file : $max;
- }
- }
-
- for my $f ( 1 .. $max ) {
- use File::Spec;
- my $file = File::Spec->catfile($x, $f);
- _debug( $file );
- }
+ htmlify_dir($x, { directory => $dir });
}
}
};