summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-04-20 05:02:27 +0000
committerfukachan <fukachan>2002-04-20 05:02:27 +0000
commit632b9b6c786c9765c0487e2aabdc983fb5374ed2 (patch)
tree329d53d5b595f9f603a4a447799109bb63774812 /fml
parent06bf3832bc4100ac3fde6d01e988e21e644beeb9 (diff)
downloadfml8-632b9b6c786c9765c0487e2aabdc983fb5374ed2.tar.gz
fml8-632b9b6c786c9765c0487e2aabdc983fb5374ed2.tar.bz2
fml8-632b9b6c786c9765c0487e2aabdc983fb5374ed2.zip
use FML::Command::HTMLify to share htmlify code between fmlhtmlify and
"makefml htmlify".
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Command/HTMLify.pm132
-rw-r--r--fml/lib/FML/Process/HTMLify.pm71
2 files changed, 139 insertions, 64 deletions
diff --git a/fml/lib/FML/Command/HTMLify.pm b/fml/lib/FML/Command/HTMLify.pm
new file mode 100644
index 00000000..c4d3b10c
--- /dev/null
+++ b/fml/lib/FML/Command/HTMLify.pm
@@ -0,0 +1,132 @@
+#-*- perl -*-
+#
+# Copyright (C) 2002 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $FML: HTMLify.pm,v 1.16 2002/04/08 12:44:24 fukachan Exp $
+#
+
+package FML::Command::HTMLify;
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+use File::Spec;
+use FML::Log qw(Log LogWarn LogError);
+
+=head1 NAME
+
+FML::Command::HTMLify - utility functions to convert
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+This module provides several utility functions to send back article
+and file in C<$ml_home_dir>.
+
+=head1 METHODS
+
+=cut
+
+
+# Descriptions:
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects:
+# Return Value: none
+sub convert
+{
+ my ($curproc, $args, $optargs) = @_;
+ my $src_dir = $optargs->{ src_dir };
+ my $dst_dir = $optargs->{ dst_dir };
+
+ unless (-d $src_dir) {
+ croak("no such source directory");
+ }
+
+ my ($is_subdir_exists, $subdirs) = _check_subdir_exists($src_dir);
+ if ($is_subdir_exists) { Log("looks subdir exists");}
+
+ if (defined $dst_dir) {
+ unless (-d $dst_dir) {
+ use File::Utils qw(mkdirhier);
+ mkdirhier($dst_dir, 0755);
+ }
+
+ if ($is_subdir_exists) {
+ for my $xdir (@$subdirs) {
+ eval q{
+ use Mail::Message::ToHTML;
+ &Mail::Message::ToHTML::htmlify_dir($xdir, {
+ directory => $dst_dir,
+ });
+ };
+ croak($@) if $@;
+ }
+ }
+ else {
+ eval q{
+ use Mail::Message::ToHTML;
+ &Mail::Message::ToHTML::htmlify_dir($src_dir, {
+ directory => $dst_dir,
+ });
+ };
+ croak($@) if $@;
+ }
+ }
+ else {
+ croak("no destination directory\n");
+ }
+}
+
+
+# Descriptions: check wheter $src_dir has sub-directories in it
+# Arguments: STR($src_dir)
+# Side Effects: none
+# Return Value: ARRAY( STR, ARRAY_REF )
+sub _check_subdir_exists
+{
+ my ($src_dir) = @_;
+ my $status = 0;
+ my $subdir = '';
+ my @subdir = ();
+
+ use File::Spec;
+ use DirHandle;
+ my $dh = new DirHandle $src_dir;
+ if (defined $dh) {
+ while (defined($_ = $dh->read)) {
+ next if /^\./;
+ $subdir = File::Spec->catfile($src_dir, $_);
+
+ if (-d $subdir) {
+ push(@subdir, $subdir);
+ $status = 1;
+ }
+ }
+ }
+
+ return( $status, \@subdir );
+}
+
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2002 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+FML::Command::HTMLify appeared in fml5 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+=cut
+
+
+1;
diff --git a/fml/lib/FML/Process/HTMLify.pm b/fml/lib/FML/Process/HTMLify.pm
index c275585b..a0b3286b 100644
--- a/fml/lib/FML/Process/HTMLify.pm
+++ b/fml/lib/FML/Process/HTMLify.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: HTMLify.pm,v 1.16 2002/04/19 05:21:54 fukachan Exp $
+# $FML: HTMLify.pm,v 1.17 2002/04/20 04:25:22 fukachan Exp $
#
package FML::Process::HTMLify;
@@ -123,75 +123,18 @@ sub run
unshift(@INC, $options->{ I });
}
- unless (-d $src_dir) {
- croak("no such source directory");
- }
-
- my ($is_subdir_exists, $subdirs) = _check_subdir_exists($src_dir);
- if ($is_subdir_exists) { Log("looks subdir exists");}
-
- if (defined $dst_dir) {
- unless (-d $dst_dir) {
- use File::Utils qw(mkdirhier);
- mkdirhier($dst_dir, 0755);
- }
-
- if ($is_subdir_exists) {
- for my $xdir (@$subdirs) {
- eval q{
- use Mail::Message::ToHTML;
- &Mail::Message::ToHTML::htmlify_dir($xdir, {
- directory => $dst_dir,
- });
- };
- croak($@) if $@;
- }
- }
- else {
- eval q{
- use Mail::Message::ToHTML;
- &Mail::Message::ToHTML::htmlify_dir($src_dir, {
- directory => $dst_dir,
- });
- };
- croak($@) if $@;
- }
- }
- else {
- croak("no destination directory\n");
- }
+ # main converter
+ use FML::Command::HTMLify;
+ &FML::Command::HTMLify::convert($curproc, $args, {
+ src_dir => $src_dir,
+ dst_dir => $dst_dir,
+ });
$eval = $config->get_hook( 'fmlhtmlify_run_end_hook' );
if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
-sub _check_subdir_exists
-{
- my ($src_dir) = @_;
- my $status = 0;
- my $subdir = '';
- my @subdir = ();
-
- use File::Spec;
- use DirHandle;
- my $dh = new DirHandle $src_dir;
- if (defined $dh) {
- while (defined($_ = $dh->read)) {
- next if /^\./;
- $subdir = File::Spec->catfile($src_dir, $_);
-
- if (-d $subdir) {
- push(@subdir, $subdir);
- $status = 1;
- }
- }
- }
-
- return( $status, \@subdir );
-}
-
-
# Descriptions: show help
# Arguments: none
# Side Effects: none