|
From: <jgr...@us...> - 2003-11-10 19:55:40
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv311/UI
Modified Files:
HTML.pm
Log Message:
Multi-user Phase #1
-------------------
Make POPFile work relative to two special environment variables:
POPFILE_ROOT The location where popfile.pl is installed
POPFILE_USER The location where this user's config is kept
POPFile/Module.pm:
Add two methods
get_root_path_
get_user_path_
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER. This two helpers simply
call the relevant public interface in POPFile/Configuration.pm.
POPFile/Configuration.pm:
Add two methods
get_root_path
get_user_path
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER.
Classifer/WordMangle.pm:
Make this a PLM (with name 'wordmangle') so that it can get access
to the POPFILE_USER variable so that stopwords are per user.
Classifier/Bayes.pm:
Remove unused Classifier::WordMangle object.
Change all path usage to call get_user_path_ to set the path
correctly relative to the current user.
UI/HTML.pm:
Change path usage to call get_root_path_ or get_user_path_ to get
the path relative to the current root or user. The root is used to
access skins, manual and language files. Everything else is in the
user directory.
POPFile/Module.pm:
Use the POPFILE_ROOT to control the loading of modules.
popfile.pl:
If POPFILE_ROOT is defined the add it to @INC so that we can load
the POPFile::Loader module.
tests/TestWordMangle.tst:
Since Classifier::WordMangle is now a PLM the tests need to be
updated to load the mangler correctly and link it in with the
other POPFile modules that is depends on.
tests/TestPOP3.tst
tests/TestMailParse.tst
tests/TestBayes.tst:
Since Classifier::WordMangle is now a PLM test suites that relied
upon Classifier::MailParse creating the mangler needed updating to
actually create and pass in the mangler object.
tests/TestHTTP.tst:
Make tests work on non-Windows systems. One test was relying on
\n being \r\n.
TODO
Write tests for get_user_path and get_root_path, is_absolute_path,
root_path and path_join
Write tests for POPFILE_ROOT and POPFILE_USER
Make HTML test suite run on Linux
Debug MailParse test suite, fix Japanese handling (026).
Debug POP3 suite/TOP handling
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.220
retrieving revision 1.221
diff -C2 -d -r1.220 -r1.221
*** HTML.pm 30 Oct 2003 14:42:33 -0000 1.220
--- HTML.pm 10 Nov 2003 19:55:35 -0000 1.221
***************
*** 399,423 ****
if ( $url =~ /\/(.+\.gif)/ ) {
! $self->http_file_( $client, $1, 'image/gif' );
return 1;
}
if ( $url =~ /\/(.+\.png)/ ) {
! $self->http_file_( $client, $1, 'image/png' );
return 1;
}
if ( $url =~ /\/(.+\.ico)/ ) {
! $self->http_file_( $client, $1, 'image/x-icon' );
return 1;
}
if ( $url =~ /(skins\/.+\.css)/ ) {
! $self->http_file_( $client, $1, 'text/css' );
return 1;
}
if ( $url =~ /(manual\/.+\.html)/ ) {
! $self->http_file_( $client, $1, 'text/html' );
return 1;
}
--- 399,423 ----
if ( $url =~ /\/(.+\.gif)/ ) {
! $self->http_file_( $client, $self->get_root_path_( $1 ), 'image/gif' );
return 1;
}
if ( $url =~ /\/(.+\.png)/ ) {
! $self->http_file_( $client, $self->get_root_path_( $1 ), 'image/png' );
return 1;
}
if ( $url =~ /\/(.+\.ico)/ ) {
! $self->http_file_( $client, $self->get_root_path_( $1 ), 'image/x-icon' );
return 1;
}
if ( $url =~ /(skins\/.+\.css)/ ) {
! $self->http_file_( $client, $self->get_root_path_( $1 ), 'text/css' );
return 1;
}
if ( $url =~ /(manual\/.+\.html)/ ) {
! $self->http_file_( $client, $self->get_root_path_( $1 ), 'text/html' );
return 1;
}
***************
*** 645,649 ****
if ( $selected == -1 ) {
$result .= "<style type=\"text/css\">\n";
! if ( open FILE, '<skins/' . $self->config_( 'skin' ) . '.css' ) {
while (<FILE>) {
$result .= $_;
--- 645,649 ----
if ( $selected == -1 ) {
$result .= "<style type=\"text/css\">\n";
! if ( open FILE, '<' . $self->get_root_path_( 'skins/' . $self->config_( 'skin' ) . '.css' ) ) {
while (<FILE>) {
$result .= $_;
***************
*** 1892,1896 ****
if ( ( defined($self->{form_}{color}) ) && ( defined($self->{form_}{bucket}) ) ) {
! open COLOR, '>' . $self->module_config_( 'bayes', 'corpus' ) . "/$self->{form_}{bucket}/color";
print COLOR "$self->{form_}{color}\n";
close COLOR;
--- 1892,1896 ----
if ( ( defined($self->{form_}{color}) ) && ( defined($self->{form_}{bucket}) ) ) {
! open COLOR, '>' . $self->get_user_path_( $self->module_config_( 'bayes', 'corpus' ) . "/$self->{form_}{bucket}/color" );
print COLOR "$self->{form_}{color}\n";
close COLOR;
***************
*** 2440,2444 ****
my ( $self ) = @_;
! my $cache_file = $self->global_config_( 'msgdir' ) . 'history_cache';
if ( !(-e $cache_file) ) {
return;
--- 2440,2444 ----
my ( $self ) = @_;
! my $cache_file = $self->get_user_path_( $self->global_config_( 'msgdir' ) . 'history_cache' );
if ( !(-e $cache_file) ) {
return;
***************
*** 2498,2502 ****
}
! open CACHE, '>' . $self->global_config_( 'msgdir' ) . 'history_cache';
print CACHE "___HISTORY__ __ VERSION__ 1\n";
foreach my $key (keys %{$self->{history__}}) {
--- 2498,2502 ----
}
! open CACHE, '>' . $self->get_user_path_( $self->global_config_( 'msgdir' ) . 'history_cache' );
print CACHE "___HISTORY__ __ VERSION__ 1\n";
foreach my $key (keys %{$self->{history__}}) {
***************
*** 2550,2554 ****
# for non-culling and new entries that need to be added to the end
! opendir MESSAGES, $self->global_config_( 'msgdir' );
my @history_files;
--- 2550,2554 ----
# for non-culling and new entries that need to be added to the end
! opendir MESSAGES, $self->get_user_path_( $self->global_config_( 'msgdir' ) );
my @history_files;
***************
*** 2620,2624 ****
my $long_header = '';
! if ( open MAIL, '<'. $self->global_config_( 'msgdir' ) . $file ) {
while ( <MAIL> ) {
last if ( /^(\r\n|\r|\n)/ );
--- 2620,2624 ----
my $long_header = '';
! if ( open MAIL, '<'. $self->get_user_path_( $self->global_config_( 'msgdir' ) . $file ) ) {
while ( <MAIL> ) {
last if ( /^(\r\n|\r|\n)/ );
***************
*** 3493,3497 ****
if ( $self->{history__}{$mail_file}{magnet} eq '' ) {
! $body .= $self->{classifier__}->get_html_colored_message($self->global_config_( 'msgdir' ) . $mail_file);
# We want to insert a link to change the output format at the start of the word
--- 3493,3497 ----
if ( $self->{history__}{$mail_file}{magnet} eq '' ) {
! $body .= $self->{classifier__}->get_html_colored_message( $self->get_user_path_( $self->global_config_( 'msgdir' ) . $mail_file ) );
# We want to insert a link to change the output format at the start of the word
***************
*** 3553,3557 ****
$body .= "<tt>";
! open MESSAGE, '<' . $self->global_config_( 'msgdir' ) . $mail_file;
my $line;
# process each line of the message
--- 3553,3557 ----
$body .= "<tt>";
! open MESSAGE, '<' . $self->get_user_path_( $self->global_config_( 'msgdir' ) . $mail_file );
my $line;
# process each line of the message
***************
*** 3663,3667 ****
my ( $self ) = @_;
! @{$self->{skins__}} = glob 'skins/*.css';
for my $i (0..$#{$self->{skins__}}) {
--- 3663,3667 ----
my ( $self ) = @_;
! @{$self->{skins__}} = glob $self->get_root_path_( 'skins/*.css' );
for my $i (0..$#{$self->{skins__}}) {
***************
*** 3681,3685 ****
my ( $self ) = @_;
! @{$self->{languages__}} = glob 'languages/*.msg';
for my $i (0..$#{$self->{languages__}}) {
--- 3681,3685 ----
my ( $self ) = @_;
! @{$self->{languages__}} = glob $self->get_root_path_( 'languages/*.msg' );
for my $i (0..$#{$self->{languages__}}) {
***************
*** 3740,3744 ****
my ( $self, $lang ) = @_;
! if ( open LANG, "<languages/$lang.msg" ) {
while ( <LANG> ) {
next if ( /[ \t]*#/ );
--- 3740,3744 ----
my ( $self, $lang ) = @_;
! if ( open LANG, '<' . $self->get_root_path_( "languages/$lang.msg" ) ) {
while ( <LANG> ) {
next if ( /[ \t]*#/ );
***************
*** 3796,3800 ****
my ( $self ) = @_;
! opendir MESSAGES, $self->global_config_( 'msgdir' );
while ( my $mail_file = readdir MESSAGES ) {
--- 3796,3800 ----
my ( $self ) = @_;
! opendir MESSAGES, $self->get_user_path_( $self->global_config_( 'msgdir' ) );
while ( my $mail_file = readdir MESSAGES ) {
|