Update of /cvsroot/sandweb/sandweb/bin
In directory usw-pr-cvs1:/tmp/cvs-serv28223/bin
Modified Files:
sandweb.cgi
Log Message:
implemented view and edit more correctly, now they let you view or
edit a non-Text file but you get a warning. Sweet.
Index: sandweb.cgi
===================================================================
RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v
retrieving revision 1.65
retrieving revision 1.66
diff -U2 -r1.65 -r1.66
--- sandweb.cgi 2001/11/22 00:31:35 1.65
+++ sandweb.cgi 2001/11/22 00:57:15 1.66
@@ -318,8 +318,6 @@
if (! -f "$location/$filename" ) {
- print header;
- print "File does not exist.\n";
- print "$location/$filename\n";
- exit 1;
+ set_error = "File does not exist!";
+ browse_menu();
}
@@ -339,38 +337,54 @@
elsif ( $command eq 'view' ) {
unless ( $file->get_file_type() eq "Text" ) {
- print header;
- print "This does not appear to be a text file.\n";
- exit 1;
+ $error = "This does not appear to be a text file.";
}
- print header;
+ my @tmp = ();
open (FILE, "$location/$filename");
- print "<pre>";
foreach my $line (<FILE>) {
- print "$line";
+ push @tmp, $line;
}
- print "</pre>";
+ my $content = $ui->view_file(
+ PROGNAME => $progname,
+ CONTENT => "@tmp",
+ );
+
+ print header( -cookie => $cookie );
+ $ui->print_screen(
+ TITLE=> 'SandWeb : View File',
+ MENU_TITLE => 'SandWeb',
+ SUBMENU_TITLE => 'view file',
+ FOOTER => '',
+ CONTENT => $content,
+ ERROR => $error,
+ );
+ exit 0;
}
elsif ( $command eq 'edit' ) {
unless ( $file->get_file_type() eq "Text" ) {
- print header;
- print "This does not appear to be a text file.\n";
- exit 1;
+ $error = "This does not appear to be a text file.";
}
- print header;
+ my @tmp = ();
open (FILE, "$location/$filename");
- print "<pre>";
- print "<textarea name=\"$filename\" rows=\"50\" cols=\"160\">";
foreach my $line (<FILE>) {
- print "$line";
+ push @tmp, $line;
}
- print '</textarea>';
- print "</pre>";
- print "<input type=\"button\" value=\"Save\" />";
- exit 1;
+ my $content = $ui->edit_file(
+ PROGNAME => $progname,
+ CONTENT => "@tmp",
+ );
+
+ print header( -cookie => $cookie );
+ $ui->print_screen(
+ TITLE=> 'SandWeb : Edit File',
+ MENU_TITLE => 'SandWeb',
+ SUBMENU_TITLE => 'edit file',
+ FOOTER => '',
+ CONTENT => $content,
+ ERROR => $error,
+ );
+ exit 0;
}
else {
- print header;
- print "hello\n";
- exit 1;
+ $error = "Invalid selection.";
}
}
|