|
From: <jgr...@us...> - 2003-06-14 21:10:15
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv29263/UI
Modified Files:
HTML.pm HTTP.pm XMLRPC.pm
Log Message:
Added new message queuing engine for asynchronous message passing, use it for classification data and UI registrations, remove mcount and ecount global variables, add new access to all configuration options on Advanced page
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.168
retrieving revision 1.169
diff -C2 -d -r1.168 -r1.169
*** HTML.pm 9 Jun 2003 22:39:18 -0000 1.168
--- HTML.pm 14 Jun 2003 21:10:12 -0000 1.169
***************
*** 92,95 ****
--- 92,99 ----
$self->{languages__} = ();
+ # The last user to login via a proxy
+
+ $self->{last_login__} = '';
+
# Must call bless before attempting to call any methods
***************
*** 193,196 ****
--- 197,209 ----
$self->{url_handler_} = \&url_handler__;
+ # Finally register for the messages that we need to receive
+
+ $self->mq_register_( 'CLASS', $self );
+ $self->mq_register_( 'UIREG', $self );
+ $self->mq_register_( 'TICKD', $self );
+ $self->mq_register_( 'LOGIN', $self );
+
+ $self->calculate_today();
+
return 1;
}
***************
*** 207,215 ****
my ( $self ) = @_;
- # This needs to occur at launch, but after initialization
-
- $self->remove_mail_files();
- $self->calculate_today();
-
# Ensure that the messages subdirectory exists
--- 220,223 ----
***************
*** 232,235 ****
--- 240,245 ----
$self->sort_filter_history( '', '', '' );
+ $self->remove_mail_files();
+
return $self->SUPER::start();
}
***************
*** 237,252 ****
# ---------------------------------------------------------------------------------------------
#
! # service
#
! # Called to handle interface requests
#
# ---------------------------------------------------------------------------------------------
! sub service
{
! my ( $self ) = @_;
! $self->remove_mail_files();
! return $self->SUPER::service();
}
--- 247,286 ----
# ---------------------------------------------------------------------------------------------
#
! # deliver
#
! # Called by the message queue to deliver a message
! #
! # There is no return value from this method
#
# ---------------------------------------------------------------------------------------------
! sub deliver
{
! my ( $self, $type, $message, $parameter ) = @_;
! # Handle registration of UI components
! if ( $type eq 'UIREG' ) {
! $message =~ /(.*):(.*)/;
!
! $self->register_configuration_item__( $1, $2, $parameter );
! }
!
! # Invalidate the history cache if a classification occurs
!
! if ( $type eq 'CLASS' ) {
! $self->invalidate_history_cache();
! }
!
! # If a day has passed then clean up the history
!
! if ( $type eq 'TICKD' ) {
! $self->remove_mail_files();
! }
!
! # We keep track of the last username to login to show on the UI
!
! if ( $type eq 'LOGIN' ) {
! $self->{last_login__} = $message;
! }
}
***************
*** 369,374 ****
$redirect_url =~ s/&$//;
- $self->log_( "Correct password will redirect to $redirect_url" );
-
password_page( $self, $client, 0, $redirect_url );
--- 403,406 ----
***************
*** 424,438 ****
}
! my %url_table = ( '/security' => \&security_page,
! '/configuration' => \&configuration_page,
! '/buckets' => \&corpus_page,
! '/magnets' => \&magnet_page,
! '/advanced' => \&advanced_page,
! '/history' => \&history_page,
! '/view' => \&view_page,
! '/' => \&history_page );
# Any of the standard pages can be found in the url_table, the other pages are probably
# files on disk
if ( defined($url_table{$url}) ) {
&{$url_table{$url}}($self, $client);
--- 456,471 ----
}
! my %url_table = ( '/security' => \&security_page,
! '/configuration' => \&configuration_page,
! '/buckets' => \&corpus_page,
! '/magnets' => \&magnet_page,
! '/advanced' => \&advanced_page,
! '/history' => \&history_page,
! '/view' => \&view_page,
! '/' => \&history_page );
# Any of the standard pages can be found in the url_table, the other pages are probably
# files on disk
+
if ( defined($url_table{$url}) ) {
&{$url_table{$url}}($self, $client);
***************
*** 468,471 ****
--- 501,505 ----
# Check to see if we've checked for updates today. If we have not then insert a reference to an image
# that is generated through a CGI on UseTheSource. Also send stats to the same site if that is allowed
+
if ( $self->{today} ne $self->config_( 'last_update_check' ) ) {
calculate_today( $self );
***************
*** 480,484 ****
my @buckets = $self->{classifier__}->get_buckets();
my $bc = $#buckets + 1;
! $update_check .= "<img border=\"0\" alt=\"\" src=\"http://www.usethesource.com/cgi-bin/popfile_stats.pl?bc=$bc&mc=" . $self->global_config_( 'mcount' ) . "&ec=" . $self->global_config_( 'ecount' ) . "\" />\n";
}
--- 514,518 ----
my @buckets = $self->{classifier__}->get_buckets();
my $bc = $#buckets + 1;
! $update_check .= "<img border=\"0\" alt=\"\" src=\"http://www.usethesource.com/cgi-bin/popfile_stats.pl?bc=$bc&mc=" . $self->mcount__() . "&ec=" . $self->global_config_( 'ecount' ) . "\" />\n";
}
***************
*** 542,545 ****
--- 576,581 ----
}
+ $result .= "<link rel=\"icon\" href=\"popfile.ico\" type=\"image/ico\">\n";
+
$result .= "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n";
$result .= "<meta http-equiv=\"Expires\" content=\"0\">\n";
***************
*** 706,710 ****
$result .= "<a class=\"bottomLink\" href=\"http://sourceforge.net/docman/display_doc.php?docid=14421&group_id=63137\">FAQ</a><br>\n";
! $result .= "</td><td class=\"footerBody\">\n<a class=\"bottomLink\" href=\"http://popfile.sourceforge.net/\"><img src=\"otto.gif\" border=\"0\" alt=\"\"></a><br>$self->{version_}<br>($time)</td>\n";
$result .= "<td class=\"footerBody\"><a class=\"bottomLink\" href=\"http://sourceforge.net/tracker/index.php?group_id=63137&atid=502959\">$self->{language__}{Footer_RequestFeature}</a><br>\n";
--- 742,746 ----
$result .= "<a class=\"bottomLink\" href=\"http://sourceforge.net/docman/display_doc.php?docid=14421&group_id=63137\">FAQ</a><br>\n";
! $result .= "</td><td class=\"footerBody\">\n<a class=\"bottomLink\" href=\"http://popfile.sourceforge.net/\"><img src=\"otto.gif\" border=\"0\" alt=\"\"></a><br>$self->{version_}<br>($time - $self->{last_login__})</td>\n";
$result .= "<td class=\"footerBody\"><a class=\"bottomLink\" href=\"http://sourceforge.net/tracker/index.php?group_id=63137&atid=502959\">$self->{language__}{Footer_RequestFeature}</a><br>\n";
***************
*** 1223,1226 ****
--- 1259,1274 ----
my ( $self, $client ) = @_;
+ # Handle updating the parameter table
+
+ if ( defined( $self->{form_}{update_params} ) ) {
+ foreach my $param (sort keys %{$self->{form_}}) {
+ if ( $param =~ /parameter_(.*)/ ) {
+ $self->{configuration__}->parameter( $1, $self->{form_}{$param} );
+ }
+ }
+
+ $self->{configuration__}->save_configuration();
+ }
+
my $add_message = '';
my $deletemessage = '';
***************
*** 1233,1237 ****
if ( defined($self->{form_}{word}) ) {
- $self->log_($self->{form_}{word} );
my $result = $self->{classifier__}->remove_stopword( $self->{form_}{word} );
if ( $result == 0 ) {
--- 1281,1284 ----
***************
*** 1241,1245 ****
# title and heading
! my $body = "<h2 class=\"advanced\">$self->{language__}{Advanced_StopWords}</h2>\n";
$body .= "$self->{language__}{Advanced_Message1}\n<br /><br />\n<table summary=\"$self->{language__}{Advanced_MainTableSummary}\">\n";
--- 1288,1292 ----
# title and heading
! my $body = "<table cellpadding=\"10%\" cellspacing=\"0\" class=\"settingsTable\"><tr><td class=\"settingsPanel\" valign=\"top\"><h2 class=\"advanced\">$self->{language__}{Advanced_StopWords}</h2>\n";
$body .= "$self->{language__}{Advanced_Message1}\n<br /><br />\n<table summary=\"$self->{language__}{Advanced_MainTableSummary}\">\n";
***************
*** 1309,1313 ****
$body .= "</div>\n";
! http_ok($self, $client,$body,5);
}
--- 1356,1380 ----
$body .= "</div>\n";
! $body .= "</td><td class=\"settingsPanel\" width=\"50%\" valign=\"top\"><h2 class=\"advanced\">$self->{language__}{Advanced_AllParameters}</h2>\n<p>$self->{language__}{Advanced_Warning}";
!
! $body .= "<form action=\"/advanced\" method=\"POST\">\n";
! $body .= "<table width=\"100%\"><tr><th width=\"50%\">$self->{language__}{Advanced_Parameter}</th><th width=\"50%\">$self->{language__}{Advanced_Value}</th></tr>\n";
!
! my $last_module = '';
!
! foreach my $param ($self->{configuration__}->configuration_parameters()) {
! my $value = $self->{configuration__}->parameter( $param );
! $param =~ /^([^_]+)_/;
! if ( ( $last_module ne '' ) && ( $last_module ne $1 ) ) {
! $body .= "<tr><td colspan=\"2\"><hr></td></tr>";
! }
! $last_module = $1;
! $body .= "<tr><td>$param</td><td><input type=\"text\" name=\"parameter_$param\" value=\"$value\">";
! $body .= "<input type=\"hidden\" name=\"session\" value=\"$self->{session_key__}\" />\n</td></tr>\n";
! }
!
! $body .= "</table><p><input type=\"submit\" value=\"$self->{language__}{Update}\" name=\"update_params\"></form></td></tr></table>";
!
! $self->http_ok( $client, $body, 5 );
}
***************
*** 1586,1591 ****
my $percent = "0%";
if ( $self->{classifier__}->get_word_count() > 0 ) {
! $percent = int( 10000 * $bucket_count / $self->{classifier__}->get_word_count() ) / 100;
! $percent = "$percent%";
}
$body .= "</td>\n<td></td>\n</tr>\n<tr><td colspan=\"3\"><hr /></td></tr>\n";
--- 1653,1657 ----
my $percent = "0%";
if ( $self->{classifier__}->get_word_count() > 0 ) {
! $percent = sprintf( '%6.2f%%', int( 10000 * $bucket_count / $self->{classifier__}->get_word_count() ) / 100 );
}
$body .= "</td>\n<td></td>\n</tr>\n<tr><td colspan=\"3\"><hr /></td></tr>\n";
***************
*** 1681,1688 ****
if ( $s == 0 ) {
if ( $total_count == 0 ) {
! $percent = " (0%)";
} else {
! $percent = " ( " . int( $value * 10000 / $total_count ) / 100;
! $percent .= "%)";
}
}
--- 1747,1753 ----
if ( $s == 0 ) {
if ( $total_count == 0 ) {
! $percent = " ( 0.00%)";
} else {
! $percent = sprintf( ' (%.2f%%)', int( $value * 10000 / $total_count ) / 100 );
}
}
***************
*** 1735,1741 ****
if ( defined($self->{form_}{reset_stats}) ) {
! $self->global_config_( 'mcount', 0 );
! $self->global_config_( 'ecount', 0 );
! for my $bucket ($self->{classifier__}->get_buckets()) {
$self->{classifier__}->set_bucket_parameter( $bucket, 'count', 0 );
$self->{classifier__}->set_bucket_parameter( $bucket, 'fpcount', 0 );
--- 1800,1804 ----
if ( defined($self->{form_}{reset_stats}) ) {
! foreach my $bucket ($self->{classifier__}->get_buckets()) {
$self->{classifier__}->set_bucket_parameter( $bucket, 'count', 0 );
$self->{classifier__}->set_bucket_parameter( $bucket, 'fpcount', 0 );
***************
*** 1798,1802 ****
$self->{form_}{oname} = lc($self->{form_}{oname});
$self->{form_}{newname} = lc($self->{form_}{newname});
! $self->{classifier__}->rename_bucket( $self->{form_}{oname}, $self->{form_}{newname} );
$rename_message = "<blockquote><b>" . sprintf( $self->{language__}{Bucket_Error5}, $self->{form_}{oname}, $self->{form_}{newname} ) . "</b></blockquote>";
}
--- 1861,1865 ----
$self->{form_}{oname} = lc($self->{form_}{oname});
$self->{form_}{newname} = lc($self->{form_}{newname});
! $self->{classifier__}->rename_bucket( $self->{form_}{oname}, $self->{form_}{newname} );
$rename_message = "<blockquote><b>" . sprintf( $self->{language__}{Bucket_Error5}, $self->{form_}{oname}, $self->{form_}{newname} ) . "</b></blockquote>";
}
***************
*** 1904,1915 ****
my $number = pretty_number( $self, $self->{classifier__}->get_word_count() );
! my $pmcount = pretty_number( $self, $self->global_config_( 'mcount' ) );
! my $pecount = pretty_number( $self, $self->global_config_( 'ecount' ) );
my $accuracy = $self->{language__}{Bucket_NotEnoughData};
my $percent = 0;
! if ( $self->global_config_( 'mcount' ) > $self->global_config_( 'ecount' ) ) {
! $percent = int( 10000 * ( $self->global_config_( 'mcount' ) - $self->global_config_( 'ecount' ) ) / $self->global_config_( 'mcount' ) ) / 100;
$accuracy = "$percent%";
! }
# finish off Summary panel
--- 1967,1978 ----
my $number = pretty_number( $self, $self->{classifier__}->get_word_count() );
! my $pmcount = pretty_number( $self, $self->mcount__() );
! my $pecount = pretty_number( $self, $self->ecount__() );
my $accuracy = $self->{language__}{Bucket_NotEnoughData};
my $percent = 0;
! if ( $self->mcount__() > $self->ecount__() ) {
! $percent = int( 10000 * ( $self->mcount__() - $self->ecount__() ) / $self->mcount__() ) / 100;
$accuracy = "$percent%";
! }
# finish off Summary panel
***************
*** 2111,2115 ****
}
}
! }
foreach my $bucket (@buckets) {
--- 2174,2178 ----
}
}
! }
foreach my $bucket (@buckets) {
***************
*** 2227,2231 ****
if ( ( $filter eq '' ) ||
( $self->{history__}{$file}{bucket} eq $filter ) ||
! ( ( $filter eq '__filter__magnet' ) && ( $self->{history__}{$file}{magnet} ne '' ) ) ||
( ( $filter eq '__filter__no__magnet' ) && ( $self->{history__}{$file}{magnet} eq '' ) ) ) {
if ( ( $search eq '' ) ||
--- 2290,2294 ----
if ( ( $filter eq '' ) ||
( $self->{history__}{$file}{bucket} eq $filter ) ||
! ( ( $filter eq '__filter__magnet' ) && ( $self->{history__}{$file}{magnet} ne '' ) ) ||
( ( $filter eq '__filter__no__magnet' ) && ( $self->{history__}{$file}{magnet} eq '' ) ) ) {
if ( ( $search eq '' ) ||
***************
*** 2267,2270 ****
--- 2330,2335 ----
my ($a1,$b1) = ($self->{history__}{$a}{$sort},
$self->{history__}{$b}{$sort});
+ $a1 =~ s/&(l|g)t;//ig;
+ $b1 =~ s/&(l|g)t;//ig;
$a1 =~ s/[^A-Z0-9]//ig;
$b1 =~ s/[^A-Z0-9]//ig;
***************
*** 2559,2564 ****
#
# ---------------------------------------------------------------------------------------------
! sub history_write_class {
!
my ( $self, $filename, $reclassified, $bucket, $usedtobe, $magnet ) = @_;
--- 2624,2629 ----
#
# ---------------------------------------------------------------------------------------------
! sub history_write_class
! {
my ( $self, $filename, $reclassified, $bucket, $usedtobe, $magnet ) = @_;
***************
*** 2596,2602 ****
#
# ---------------------------------------------------------------------------------------------
! sub history_load_class {
!
my ( $self, $filename ) = @_;
$filename =~ s/msg$/cls/;
--- 2661,2668 ----
#
# ---------------------------------------------------------------------------------------------
! sub history_load_class
! {
my ( $self, $filename ) = @_;
+
$filename =~ s/msg$/cls/;
***************
*** 3063,3067 ****
$body .= "$short_subject</a></td>\n<td>";
if ( $reclassified ) {
! $body .= "<font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></td>\n<td>";
$body .= sprintf( $self->{language__}{History_Already}, ($self->{classifier__}->get_bucket_color($bucket) || ''), ($bucket || '') );
$body .= " <input type=\"submit\" class=\"undoButton\" name=\"undo_$i\" value=\"$self->{language__}{Undo}\">\n";
--- 3129,3133 ----
$body .= "$short_subject</a></td>\n<td>";
if ( $reclassified ) {
! $body .= "<a href=\"buckets?session=$self->{session_key__}&showbucket=$bucket\"><font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></a></td>\n<td>";
$body .= sprintf( $self->{language__}{History_Already}, ($self->{classifier__}->get_bucket_color($bucket) || ''), ($bucket || '') );
$body .= " <input type=\"submit\" class=\"undoButton\" name=\"undo_$i\" value=\"$self->{language__}{Undo}\">\n";
***************
*** 3070,3074 ****
$body .= "$bucket</td>\n<td>";
} else {
! $body .= "<font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></td>\n<td>";
}
--- 3136,3140 ----
$body .= "$bucket</td>\n<td>";
} else {
! $body .= "<a href=\"buckets?session=$self->{session_key__}&showbucket=$bucket\"><font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></a></td>\n<td>";
}
***************
*** 3149,3154 ****
my $bucket = $self->{history__}{$mail_file}{bucket};
my $color = $self->{classifier__}->get_bucket_color($bucket);
!
! my $page_size = $self->config_( 'page_size' );
$self->{form_}{sort} = '' if ( !defined( $self->{form_}{sort} ) );
--- 3215,3219 ----
my $bucket = $self->{history__}{$mail_file}{bucket};
my $color = $self->{classifier__}->get_bucket_color($bucket);
! my $page_size = $self->config_( 'page_size' );
$self->{form_}{sort} = '' if ( !defined( $self->{form_}{sort} ) );
***************
*** 3492,3516 ****
{
my ( $self ) = @_;
- my $yesterday = defined($self->{today})?$self->{today}:0;
- $self->calculate_today();
! if ( $self->{today} > $yesterday ) {
! my @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*=*.msg" );
! foreach my $mail_file (@mail_files) {
! my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($mail_file);
! if ( $ctime < (time - $self->config_( 'history_days' ) * $seconds_per_day) ) {
! $self->history_delete_file( $mail_file, $self->config_( 'archive' ) );
! }
}
! # Clean up old style msg/cls files
! @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*_*.???" );
! foreach my $mail_file (@mail_files) {
! unlink($mail_file);
! }
}
}
--- 3557,3577 ----
{
my ( $self ) = @_;
! my @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*=*.msg" );
! foreach my $mail_file (@mail_files) {
! my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($mail_file);
! if ( $ctime < (time - $self->config_( 'history_days' ) * $seconds_per_day) ) {
! $self->history_delete_file( $mail_file, $self->config_( 'archive' ) );
}
+ }
! # Clean up old style msg/cls files
! @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*_*.???" );
! foreach my $mail_file (@mail_files) {
! unlink($mail_file);
}
}
***************
*** 3657,3661 ****
# ---------------------------------------------------------------------------------------------
! # register_configuration_item
#
# $type The type of item (configuration, security or chain)
--- 3718,3722 ----
# ---------------------------------------------------------------------------------------------
! # register_configuration_item__
#
# $type The type of item (configuration, security or chain)
***************
*** 3712,3716 ****
#
# ---------------------------------------------------------------------------------------------
! sub register_configuration_item
{
my ( $self, $type, $name, $object ) = @_;
--- 3773,3777 ----
#
# ---------------------------------------------------------------------------------------------
! sub register_configuration_item__
{
my ( $self, $type, $name, $object ) = @_;
***************
*** 3746,3749 ****
--- 3807,3847 ----
return $line;
+ }
+
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # mcount__, ecount__ get the total message count, or the total error count
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub mcount__
+ {
+ my ( $self ) = @_;
+
+ my $count = 0;
+
+ my @buckets = $self->{classifier__}->get_buckets();
+
+ foreach my $bucket (@buckets) {
+ $count += $self->{classifier__}->get_bucket_parameter( $bucket, 'count' );
+ }
+
+ return $count;
+ }
+
+ sub ecount__
+ {
+ my ( $self ) = @_;
+
+ my $count = 0;
+
+ my @buckets = $self->{classifier__}->get_buckets();
+
+ foreach my $bucket (@buckets) {
+ $count += $self->{classifier__}->get_bucket_parameter( $bucket, 'fpcount' );
+ }
+
+ return $count;
}
Index: HTTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTTP.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** HTTP.pm 9 Jun 2003 18:34:36 -0000 1.6
--- HTTP.pm 14 Jun 2003 21:10:13 -0000 1.7
***************
*** 213,216 ****
--- 213,218 ----
my $arg = $1;
+ my $need_array = defined( $self->{form_}{$arg} );
+
$self->{form_}{$arg} = $2;
$self->{form_}{$arg} =~ s/\+/ /g;
***************
*** 222,226 ****
# Push the value onto an array to allow for multiple values of the same name
! push( @{ $self->{form_}{$arg . "_array"} }, $self->{form_}{$arg} );
}
}
--- 224,230 ----
# Push the value onto an array to allow for multiple values of the same name
! if ( $need_array ) {
! push( @{ $self->{form_}{$arg . "_array"} }, $self->{form_}{$arg} );
! }
}
}
Index: XMLRPC.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/XMLRPC.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLRPC.pm 26 Mar 2003 16:39:12 -0000 1.2
--- XMLRPC.pm 14 Jun 2003 21:10:13 -0000 1.3
***************
*** 65,75 ****
# item that needs a UI component
! $self->{ui__}->register_configuration_item( 'configuration',
! 'xmlrpc_port',
! $self );
! $self->{ui__}->register_configuration_item( 'security',
! 'xmlrpc_local',
! $self );
return 1;
--- 65,75 ----
# item that needs a UI component
! $self->register_configuration_item_( 'configuration',
! 'xmlrpc_port',
! $self );
! $self->register_configuration_item_( 'security',
! 'xmlrpc_local',
! $self );
return 1;
***************
*** 280,294 ****
return $self->{classifier__};
- }
-
- sub ui
- {
- my ( $self, $value ) = @_;
-
- if ( defined( $value ) ) {
- $self->{ui__} = $value;
- }
-
- return $self->{ui__};
}
--- 280,283 ----
|