From: Rob H. <for...@us...> - 2001-11-30 21:08:11
|
Update of /cvsroot/sandweb/sandweb/bin In directory usw-pr-cvs1:/tmp/cvs-serv25991/bin Modified Files: sandweb.cgi Log Message: remove present tense/past tense form submit/subroutine style Index: sandweb.cgi =================================================================== RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v retrieving revision 1.79 retrieving revision 1.80 diff -U2 -r1.79 -r1.80 --- sandweb.cgi 2001/11/27 02:40:35 1.79 +++ sandweb.cgi 2001/11/30 20:42:04 1.80 @@ -121,5 +121,5 @@ } elsif ( param('action') eq 'logout' ) { - # calle gout + # called logout logout(); } @@ -135,5 +135,4 @@ file( cookie => $cookie, - filename => param('filename'), command => param('command'), location => param('location'), @@ -315,6 +314,7 @@ my $command = $args{'command'}; - my $filename = $args{'filename'}; my $location = $args{'location'}; + my $filename = param('filename'); + my $save = param('save'); my $username = $auth->get_userinfo('username'); my $template_dir = $config->{'paths'}->{'template_dir'}; @@ -333,17 +333,14 @@ my $permissions; my $file_type; + my $file; + if ($filename) { + $file = SandWeb::File->new( + 'filename' => $filename, + 'location' => "$users_dir/$username$location", + ); + } - my $file = SandWeb::File->new( - 'filename' => $filename, - 'location' => "$users_dir/$username$location", - ); if ( $command eq 'info' ) { - if ($filename) { - if (! -f "$users_dir/$username/$filename" ) { - set_error("File does not exist!"); - browse_menu(); - } - } # can't give the leading / to the VCS $filename =~ s/\///; @@ -351,14 +348,14 @@ my %return = $repository->log( file => "$filename" ); my $content = $ui->file_info( - PROGNAME => $progname, - LOCATION => $location, - FULLPATH => "$users_dir/$username/$location", + PROGNAME => $progname, + LOCATION => $location, + FULLPATH => "$users_dir/$username/$location", VCS_OUTPUT => $return{'output'}, - VCS_ERROR => $return{'error'}, + VCS_ERROR => $return{'error'}, ); - print header( -cookie => $cookie ); - $ui->print_screen( - TITLE=> 'SandWeb : File Info', + print header( -cookie => $cookie ); + $ui->print_screen( + TITLE=> 'SandWeb : File Info', MENU_TITLE => 'SandWeb', SUBMENU_TITLE => 'file info', @@ -366,15 +363,8 @@ CONTENT => $content, ERROR => $error, - ); - exit 0; + ); + exit 0; } elsif ( $command eq 'view' ) { - if ($filename) { - if (! -f "$users_dir/$username/$filename" ) { - set_error("File does not exist!"); - browse_menu(); - } - } - if ( "$file->get_file_type()" eq "Binary" ) { set_error("This does not appear to be a text file."); @@ -402,9 +392,16 @@ } elsif ( $command eq 'edit' ) { - if ($filename) { - if (! -f "$users_dir/$username/$filename" ) { - set_error("File does not exist!"); - browse_menu(); - } + if ($save) { + my $data = param('data'), + my $filename = $file->get_filename(); + + open ( FILE, "> $users_dir/$username$filename" ); + print FILE "$data"; + close FILE; + + browse_menu( + cookie => $cookie, + path => $location, + ); } if ( $file->get_file_type() eq "Binary" ) { @@ -435,18 +432,13 @@ exit 0; } - elsif ( $command eq 'edited_file' ) { - my $data = param('data'), - my $filename = $file->get_filename(); - - open ( FILE, "> $users_dir/$username$filename" ); - print FILE "$data"; - close FILE; - - browse_menu( - cookie => $cookie, - path => $location, - ); - } elsif ( $command eq 'create_file' ) { + if ($file) { + $file->create_file(); + browse_menu( + cookie => $cookie, + path => $location, + ); + exit 0; + } my $content = $ui->create_file( PROGNAME => $progname, @@ -467,4 +459,12 @@ } elsif ( $command eq 'create_folder' ) { + if ($file) { + $file->create_folder(); + browse_menu( + cookie => $cookie, + path => $location, + ); + exit 0; + } my $content = $ui->create_folder( @@ -473,5 +473,4 @@ FULLPATH => "$users_dir/$username/$location", ); - print header( -cookie => $cookie ); $ui->print_screen( @@ -485,18 +484,4 @@ exit 0; } - elsif ( $command eq 'created_file' ) { - $file->create_file(); - browse_menu( - cookie => $cookie, - path => $location, - ); - } - elsif ( $command eq 'created_folder' ) { - $file->create_folder(); - browse_menu( - cookie => $cookie, - path => $location, - ); - } elsif ( $command eq 'upload' ) { my $content = $ui->upload_file( @@ -562,4 +547,5 @@ my $filename = $args{'filename'}; my $location = $args{'location'}; + my $message = param('message'); my $username = $auth->get_userinfo('username'); my $template_dir = $config->{'paths'}->{'template_dir'}; @@ -576,4 +562,29 @@ ); if ( $command eq 'commit' ) { + if ($message) { + # can't give the leading / to the VCS + $location =~ s/\///; + %return = $repository->commit( + file => "$location/$filename", + message => "$message", + ); + my $content = $ui->get_vcs_output( + LOCATION => $location, + PROGNAME => $progname, + FULLPATH => "$users_dir/$username/$location", + VCS_OUTPUT => $return{'output'}, + VCS_ERROR => $return{'error'}, + ); + print header( -cookie => $cookie ); + $ui->print_screen( + TITLE=> "SandWeb : VCS $command", + MENU_TITLE => 'SandWeb', + SUBMENU_TITLE => "VCS $command", + FOOTER => '', + CONTENT => $content, + ERROR => $error, + ); + exit 0; + } my $content = $ui->get_commit( LOCATION => $location, @@ -592,12 +603,4 @@ ); exit 0; - } - elsif ($command eq "committed") { - # can't give the leading / to the VCS - $location =~ s/\///; - %return = $repository->commit( - file => "$location/$filename", - message => param('message'), - ); } else { |