From 162993bc201a7edeeea220a2c7efb0948c60dd2f Mon Sep 17 00:00:00 2001 From: fukachan Date: Fri, 9 Nov 2001 12:08:45 +0000 Subject: modify method names clean up nuke some "*cost*" indicator codes Print::CGI -> Print::HTML for symmetric naming convention (Text, HTML, ..) --- fml/lib/Mail/ThreadTrack/Print.pm | 86 +++++++------- fml/lib/Mail/ThreadTrack/Print/CGI.pm | 200 -------------------------------- fml/lib/Mail/ThreadTrack/Print/HTML.pm | 201 +++++++++++++++++++++++++++++++++ fml/lib/Mail/ThreadTrack/Print/Sort.pm | 6 +- fml/lib/Mail/ThreadTrack/Print/Text.pm | 1 + 5 files changed, 251 insertions(+), 243 deletions(-) delete mode 100644 fml/lib/Mail/ThreadTrack/Print/CGI.pm create mode 100644 fml/lib/Mail/ThreadTrack/Print/HTML.pm diff --git a/fml/lib/Mail/ThreadTrack/Print.pm b/fml/lib/Mail/ThreadTrack/Print.pm index 22a580a5..e4d2c808 100644 --- a/fml/lib/Mail/ThreadTrack/Print.pm +++ b/fml/lib/Mail/ThreadTrack/Print.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: Print.pm,v 1.10 2001/11/09 10:42:07 fukachan Exp $ +# $FML: Print.pm,v 1.11 2001/11/09 11:30:30 fukachan Exp $ # package Mail::ThreadTrack::Print; @@ -65,26 +65,13 @@ It is also larger if $status is C. =cut -sub _load_library -{ - my ($self) = @_; - - require Mail::ThreadTrack::Print::Message; - require Mail::ThreadTrack::Print::Sort; - unshift(@ISA, qw( - Mail::ThreadTrack::Print::Message - Mail::ThreadTrack::Print::Sort - )); -} - - sub summary { my ($self, @opts) = @_; $self->_load_library(); $self->db_open(); - $self->do_summary(@opts); + $self->_do_summary(@opts); $self->db_close(); } @@ -95,13 +82,36 @@ sub review $self->_load_library(); $self->db_open(); - $self->do_review(@opts); + $self->_do_review(@opts); $self->db_close(); } -sub do_summary +sub _load_library +{ + my ($self) = @_; + my $mode = $self->get_mode || 'text'; + + require Mail::ThreadTrack::Print::Message; + require Mail::ThreadTrack::Print::Sort; + my @list = + qw(Mail::ThreadTrack::Print::Message Mail::ThreadTrack::Print::Sort); + + if ($mode eq 'text') { + require Mail::ThreadTrack::Print::Text; + push(@list, 'Mail::ThreadTrack::Print::Text'); + } + elsif ($mode eq 'html') { + require Mail::ThreadTrack::Print::HTML; + push(@list, 'Mail::ThreadTrack::Print::HTML'); + } + + unshift(@ISA, @list); +} + + +sub _do_summary { my ($self) = @_; my ($tid, $status, $thread_id); @@ -112,20 +122,14 @@ sub do_summary $thread_id = $self->list_up_thread_id(); if (@$thread_id) { - # sort the thread output order it out by cost - # and print the thread summary in that order. - $self->sort($thread_id); - - if ($mode eq 'html') { - print $fd "\n"; - $self->_print_thread_summary($thread_id); - print $fd "
\n"; - } - else { - $self->_print_thread_summary($thread_id); - - # show short summary for each article - $self->_print_article_summary($thread_id); + # sort the thread output order by cost and + # print the thread summary in that order. + $self->sort_thread_id($thread_id); + $self->_print_thread_summary($thread_id); + + # show short summary for each message + unless ($mode eq 'html') { + $self->_print_message_summary($thread_id); } } } @@ -142,6 +146,7 @@ sub _print_thread_summary my $format = "%10s %5s %8s %-20s %s\n"; if ($mode eq 'text') { + print $fd "\n"; printf($fd $format, 'date', 'age', 'status', 'thread id', 'articles'); print $fd "-" x60; print $fd "\n"; @@ -167,8 +172,8 @@ sub _print_thread_summary if ($mode eq 'html') { eval q{ - use Mail::ThreadTrack::Print::CGI; - push(@ISA, qw(Mail::ThreadTrack::Print::CGI)); + use Mail::ThreadTrack::Print::HTML; + push(@ISA, qw(Mail::ThreadTrack::Print::HTML)); }; } else { @@ -176,6 +181,10 @@ sub _print_thread_summary $date, $age, $status, $tid, $rh->{ _articles }->{ $tid }); } } + + if ($mode eq 'html') { + print $fd "
\n"; + } } @@ -192,7 +201,7 @@ sub _cost_to_indicator } -sub _print_article_summary +sub _print_message_summary { my ($self, $thread_id) = @_; my $config = $self->{ _config }; @@ -203,12 +212,9 @@ sub _print_article_summary if (defined $config->{ spool_dir }) { my ($aid, @aid, $file); - - if ($is_show_cost_indicate) { - print $fd "\n\"!\" mark: stalled? please check and reply it.\n"; - } - my $spool_dir = $config->{ spool_dir }; + + THREAD_ID_LIST: for my $tid (@$thread_id) { if ($is_show_cost_indicate) { my $how_bad = _cost_to_indicator( $cost->{ $tid } ); @@ -232,7 +238,7 @@ sub _print_article_summary } -sub do_review +sub _do_review { my ($self, $str, $min, $max) = @_; my $config = $self->{ _config }; diff --git a/fml/lib/Mail/ThreadTrack/Print/CGI.pm b/fml/lib/Mail/ThreadTrack/Print/CGI.pm deleted file mode 100644 index b1d19115..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/CGI.pm +++ /dev/null @@ -1,200 +0,0 @@ -package Mail::ThreadTrack::Print::CGI; - -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); -use Carp; -use Mail::ThreadTrack::Print::Utils qw(decode_mime_string STR2EUC); - - -sub STR2EUC -{ - my ($str) = @_; - - use Jcode; - &Jcode::convert(\$str, 'euc'); - return $str; -} - - -sub show_articles_for_thread -{ - my ($self, $thread_id) = @_; - my $mode = $self->get_mode || 'text'; - my $config = $self->{ _config }; - my $spool_dir = $config->{ spool_dir }; - - $self->db_open(); - - my $articles = $self->{ _hash_table }->{ _articles }->{ $thread_id }; - - print ""; - print "show contents related with thread_id=$thread_id\n"; - print ""; - print "
"; - print "
\n";
-
-    if (defined($articles) && defined($spool_dir) && -d $spool_dir) {
-	use FileHandle;
-
-	my $s = '';
-	for (split(/\s+/, $articles)) {
-	    my $file = File::Spec->catfile($spool_dir, $_);
-	    my $fh   = new FileHandle $file;
-	    while (defined($_ = $fh->getline())) {
-		next if 1 .. /^$/;
-
-		$s = STR2EUC($_);
-		$s =~ s/&/&/g;
-		$s =~ s//>/g;
-		$s =~ s/\"/"/g;
-		print $s;
-	    }
-	    $fh->close;
-	}
-    }
-
-    print "
"; - - $self->db_close(); -} - - -sub cgi_top_menu -{ - my ($self) = @_; - my $config = $self->{ _config }; - my $action = 'fmlthread.cgi'; - my $target = $config->{ thread_cgi_target_window } || 'ThreadCGIWindow'; - - use DirHandle; - my $dh = new DirHandle $config->{ ml_home_prefix }; - my @dirlist; - my $prefix = $config->{ ml_home_prefix }; - while ($_ = $dh->read()) { - next if /^\./; - next if /^\@/; - push(@dirlist, $_) if -f "$prefix/$_/config.cf"; - } - $dh->close; - - if ($self->get_mode eq 'html') { - require 'ctime.pl'; - my $time = ctime(time); - my $ml_name = $config->{ ml_name }; - print "[$time] the brief summary for \"$ml_name\" ML
"; - } - - use CGI qw/:standard/; - print start_form(-action=>$action, -target=>$target); - print "mailing list: ", - popup_menu(-name => 'ml_name', -values => \@dirlist), - submit(-name => 'go'), - end_form; -} - - - -# This shows summary on C<$thread_id> in HTML language. -# It is used in C. -sub _show_thread_by_html_table -{ - my ($self, $optargs) = @_; - my $config = $self->{ _config }; - my $ml_name = $config->{ ml_name }; - my $spool_dir = $config->{ spool_dir }; - my $action = 'fmlthread.cgi'; - my $target = $config->{ thread_cgi_target_window } || 'ThreadCGIWindow'; - - # printf($fd $format, - # $date, $age, $status, $tid, $rh->{ _articles }->{ $tid }); - my $format = $optargs->{ format }; - my $date = $optargs->{ date }; - my $age = $optargs->{ age }; - my $status = $optargs->{ status }; - my $tid = $optargs->{ tid }; - my $articles = $optargs->{ articles }; - my $aid = (split(/\s+/, $articles))[0]; - - # do nothing if the $thread_id is unknown. - return unless $tid; - - #
..> - my $xtid = CGI::escape($tid); - $action = "${action}?ml_name=${ml_name}"; - $action .= "&thread_id=$xtid&article_id=$aid"; - - print "\n"; - print ""; - print ""; - print "[close]\n"; - print "
\n"; - print ""; - print "[see articles]\n"; - print "$date\n"; - print "$age\n"; - print "$status\n"; - print "$tid\n"; - print ""; - - $aid = (split(/\s+/, $articles))[0]; - my $buf = $self->_article_summary(File::Spec->catfile($spool_dir, $aid)); - print STR2EUC($buf); -} - - -=head2 C - -execute CGI. - -=cut - -sub run_cgi -{ - my ($self) = @_; - my $config = $self->{ _config }; - my $title = $config->{ thread_cgi_title } || 'thread system interface'; - my $color = $config->{ thread_cgi_bgcolor } || '#E6E6FA'; - - # XXX $ml_name may change by HTTP request - $config->{ ml_name } = param('ml_name') if param('ml_name'); - - # ensure the current mode - $self->mode('html'); - - # load standard CGI routines - use CGI qw/:standard/; - - # get action parameter via HTTP - my $action = param('action') || 'list'; - my $thread_id = param('thread_id'); - - # o.k start html - print start_html(-title=>$title,-BGCOLOR=>$color), "\n"; - - if ($action eq 'close') { - $self->set_status({ - thread_id => $thread_id, - status => 'closed', - }); - } - - if ($action eq 'show') { - Log("run.cgi.show_articles for $thread_id"); - $self->show_articles_for_thread($thread_id); - } - else { - # menu at the top of scrren - $self->cgi_top_menu(); - - # show summary - $self->show_summary(); - } - - # o.k. end of html - print end_html; - print "\n"; -} - - -1; diff --git a/fml/lib/Mail/ThreadTrack/Print/HTML.pm b/fml/lib/Mail/ThreadTrack/Print/HTML.pm new file mode 100644 index 00000000..243fdf90 --- /dev/null +++ b/fml/lib/Mail/ThreadTrack/Print/HTML.pm @@ -0,0 +1,201 @@ +package Mail::ThreadTrack::Print::HTML; + +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; +use Mail::ThreadTrack::Print::Utils qw(decode_mime_string STR2EUC); + + +sub STR2EUC +{ + my ($str) = @_; + + use Jcode; + &Jcode::convert(\$str, 'euc'); + return $str; +} + + +sub show_articles_for_thread +{ + my ($self, $thread_id) = @_; + my $mode = $self->get_mode || 'text'; + my $config = $self->{ _config }; + my $spool_dir = $config->{ spool_dir }; + + $self->db_open(); + + my $articles = $self->{ _hash_table }->{ _articles }->{ $thread_id }; + + print ""; + print "show contents related with thread_id=$thread_id\n"; + print ""; + print "
"; + print "
\n";
+
+    if (defined($articles) && defined($spool_dir) && -d $spool_dir) {
+	use FileHandle;
+
+	my $s = '';
+	for (split(/\s+/, $articles)) {
+	    my $file = File::Spec->catfile($spool_dir, $_);
+	    my $fh   = new FileHandle $file;
+	    while (defined($_ = $fh->getline())) {
+		next if 1 .. /^$/;
+
+		$s = STR2EUC($_);
+		$s =~ s/&/&/g;
+		$s =~ s//>/g;
+		$s =~ s/\"/"/g;
+		print $s;
+	    }
+	    $fh->close;
+	}
+    }
+
+    print "
"; + + $self->db_close(); +} + + +sub cgi_top_menu +{ + my ($self) = @_; + my $config = $self->{ _config }; + my $action = 'fmlthread.cgi'; + my $target = $config->{ thread_cgi_target_window } || 'ThreadCGIWindow'; + + use DirHandle; + my $dh = new DirHandle $config->{ ml_home_prefix }; + my @dirlist; + my $prefix = $config->{ ml_home_prefix }; + while ($_ = $dh->read()) { + next if /^\./; + next if /^\@/; + push(@dirlist, $_) if -f "$prefix/$_/config.cf"; + } + $dh->close; + + if ($self->get_mode eq 'html') { + require 'ctime.pl'; + my $time = ctime(time); + my $ml_name = $config->{ ml_name }; + print "[$time] the brief summary for \"$ml_name\" ML
"; + } + + use CGI qw/:standard/; + print start_form(-action=>$action, -target=>$target); + print "mailing list: ", + popup_menu(-name => 'ml_name', -values => \@dirlist), + submit(-name => 'go'), + end_form; +} + + + +# This shows summary on C<$thread_id> in HTML language. +# It is used in C. +sub _show_thread_by_html_table +{ + my ($self, $optargs) = @_; + my $config = $self->{ _config }; + my $ml_name = $config->{ ml_name }; + my $spool_dir = $config->{ spool_dir }; + my $action = 'fmlthread.cgi'; + my $target = $config->{ thread_cgi_target_window } || 'ThreadCGIWindow'; + + # printf($fd $format, + # $date, $age, $status, $tid, $rh->{ _articles }->{ $tid }); + my $format = $optargs->{ format }; + my $date = $optargs->{ date }; + my $age = $optargs->{ age }; + my $status = $optargs->{ status }; + my $tid = $optargs->{ tid }; + my $articles = $optargs->{ articles }; + my $aid = (split(/\s+/, $articles))[0]; + + # do nothing if the $thread_id is unknown. + return unless $tid; + + # ..> + my $xtid = CGI::escape($tid); + $action = "${action}?ml_name=${ml_name}"; + $action .= "&thread_id=$xtid&article_id=$aid"; + + print "\n"; + print ""; + print ""; + print "[close]\n"; + print "
\n"; + print ""; + print "[see articles]\n"; + print "$date\n"; + print "$age\n"; + print "$status\n"; + print "$tid\n"; + print ""; + + $aid = (split(/\s+/, $articles))[0]; + my $buf = $self->_article_summary(File::Spec->catfile($spool_dir, $aid)); + print STR2EUC($buf); +} + + +=head2 C + +execute CGI. + +=cut + +sub run_cgi +{ + my ($self) = @_; + my $config = $self->{ _config }; + my $title = $config->{ thread_cgi_title } || 'thread system interface'; + my $color = $config->{ thread_cgi_bgcolor } || '#E6E6FA'; + + # XXX $ml_name may change by HTTP request + $config->{ ml_name } = param('ml_name') if param('ml_name'); + + # ensure the current mode + $self->mode('html'); + + # load standard CGI routines + use CGI qw/:standard/; + + # get action parameter via HTTP + my $action = param('action') || 'list'; + my $thread_id = param('thread_id'); + + # o.k start html + print start_html(-title=>$title,-BGCOLOR=>$color), "\n"; + + if ($action eq 'close') { + $self->set_status({ + thread_id => $thread_id, + status => 'closed', + }); + } + + if ($action eq 'show') { + Log("run.cgi.show_articles for $thread_id"); + $self->show_articles_for_thread($thread_id); + } + else { + # menu at the top of scrren + $self->cgi_top_menu(); + + # show summary + $self->show_summary(); + } + + # o.k. end of html + print end_html; + print "\n"; +} + + +1; +1; diff --git a/fml/lib/Mail/ThreadTrack/Print/Sort.pm b/fml/lib/Mail/ThreadTrack/Print/Sort.pm index 062ead50..0b675206 100644 --- a/fml/lib/Mail/ThreadTrack/Print/Sort.pm +++ b/fml/lib/Mail/ThreadTrack/Print/Sort.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: Utils.pm,v 1.1 2001/11/09 10:37:06 fukachan Exp $ +# $FML: Sort.pm,v 1.1 2001/11/09 11:28:42 fukachan Exp $ # package Mail::ThreadTrack::Print::Sort; @@ -13,7 +13,7 @@ use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; -=head2 sort($thread_id_list) +=head2 sort_thread_id($thread_id_list) =cut @@ -22,7 +22,7 @@ use Carp; # Arguments: $self $args # Side Effects: # Return Value: none -sub sort +sub sort_thread_id { my ($self, $thread_id_list) = @_; diff --git a/fml/lib/Mail/ThreadTrack/Print/Text.pm b/fml/lib/Mail/ThreadTrack/Print/Text.pm index e69de29b..0afc6045 100644 --- a/fml/lib/Mail/ThreadTrack/Print/Text.pm +++ b/fml/lib/Mail/ThreadTrack/Print/Text.pm @@ -0,0 +1 @@ +1; -- cgit v1.2.1