Update of /cvsroot/sandweb/sandweb/bin
In directory usw-pr-cvs1:/tmp/cvs-serv15485/bin
Modified Files:
sandweb.cgi
Log Message:
implemented the File object in place of raw open/close statements
in more places, and made edit_file go to view_file after a file
is saved ( rather than making it go back to the last known
browse location )
Index: sandweb.cgi
===================================================================
RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v
retrieving revision 1.104
retrieving revision 1.105
diff -U2 -r1.104 -r1.105
--- sandweb.cgi 2001/12/21 01:12:47 1.104
+++ sandweb.cgi 2001/12/21 02:40:16 1.105
@@ -302,5 +302,6 @@
if ( $repo_type eq 'CVS' ) {
- $log->debug("repo type is CVS, setting up CVSROOT");
+ $log->debug("repo_type is CVS");
+
if ( $connection eq 'local' ) {
$vcsroot = "$root";
@@ -310,4 +311,10 @@
}
+ if ( $vcsroot ) {
+ $log->debug("setting up vcsroot $vcsroot");
+ } else {
+ $log->debug("no vcsroot set!");
+ }
+
$log->debug("creating Repository object");
my $repository = SandWeb::Repository->new(
@@ -457,18 +464,17 @@
$log->debug("viewing file : $filename");
- my @tmp = $file->file_read();
+ my $content = $file->file_read();
if ( $file->get_file_type() ne "Text" ) {
$log->debug("User wants to view non-text file : $filename");
set_error("This does not appear to be a text file.");
- @tmp = ();
+ $content = "";
}
-
my $content = $ui->get_menu(
MENU => 'view_file',
PROGNAME => $progname,
FILENAME => "$filename",
- CONTENT => "@tmp",
+ CONTENT => "$content",
);
@@ -491,64 +497,39 @@
$log->debug("saving edited file : $filename");
- $log->debug("opening $users_dir/$username$location/$filename");
- unless (open ( FILE, "> $users_dir/$username$location/$filename" )) {
- $log->error("could not open $users_dir/$username$location/$filename for writing : $!");
- browse_menu(
- cookie => $cookie,
- path => $location,
- );
- }
- print FILE "$data";
- unless (close FILE) {
- my $error = "could not save $users_dir/$username$location/$filename : $!";
- $log->error("$error");
- set_error("$error");
- browse_menu(
- cookie => $cookie,
- path => $location,
- );
- }
-
- browse_menu(
- cookie => $cookie,
- path => $location,
+ $log->debug("editing $users_dir/$username$location/$filename");
+ $file->file_write(
+ 'location' => "$location",
+ 'filename' => "$filename",
+ 'contents' => $data,
);
+
+ my @filename = $filename;
+
+ file(
+ cookie => $cookie,
+ file_command => "view",
+ filename => \@filename,
+ location => $location,
+ );
}
if ( $file->get_file_type() ne "Text" ) {
$log->debug("User wants to edit non-text file : $filename");
set_error("This does not appear to be a text file.");
- browse_menu(
- cookie => $cookie,
- path => $location,
- );
- }
- my @tmp;
- $log->debug("opening $users_dir/$username/$location/$filename");
- unless (open (FILE, "< $users_dir/$username/$location/$filename") ) {
- my $error = "could not open $users_dir/$username/$location/$filename for reading : $!";
- $log->error("$error");
- set_error("$error");
- browse_menu(
- cookie => $cookie,
- path => $location,
+ file(
+ cookie => $cookie,
+ file_command => "view",
+ filename => $filename,
+ location => $location,
);
}
- foreach my $line (<FILE>) {
- push @tmp, $line;
- }
- unless (close FILE) {
- my $error = "could not close $users_dir/$username/$location/$filename : $!";
- $log->error("$error");
- set_error("$error");
- browse_menu(
- cookie => $cookie,
- path => $location,
- );
- }
+ $log->debug("reading $users_dir/$username/$location/$filename");
+
+ my $content = $file->file_read();
+
$log->debug("closing $users_dir/$username/$location/$filename");
my $content = $ui->get_menu(
MENU => 'edit_file',
PROGNAME => $progname,
- CONTENT => "@tmp",
+ CONTENT => "$content",
FILENAME => $filename,
LOCATION => $location,
|