* Updated CGI DirHistory: added colors, added explanatory text.
authorcbarratt <cbarratt>
Mon, 7 Jul 2003 03:09:23 +0000 (03:09 +0000)
committercbarratt <cbarratt>
Mon, 7 Jul 2003 03:09:23 +0000 (03:09 +0000)
ChangeLog
lib/BackupPC/CGI/DirHistory.pm
lib/BackupPC/CGI/Restore.pm
lib/BackupPC/Lang/de.pm
lib/BackupPC/Lang/en.pm
lib/BackupPC/Lang/es.pm
lib/BackupPC/Lang/fr.pm
lib/BackupPC/View.pm

index ab0bfbf..86a98cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,9 @@
 * Added directory history display to BackupPC_Admin, allowing the
   user to quickly see which files changed between backups.
 
+* Browsing and directory history now sort the files in a
+  case-insensitive manner.
+
 * Swapped the Server and Hosts sections on the Nav bar.  Moved the
   host search text box to the top of the hosts section.  This was
   done to move the variable-length part of the Nav bar (when all
index 45bb01d..a1b2d2d 100644 (file)
@@ -85,7 +85,7 @@ sub action
        my $nameCnt = 0;
        (my $fDisp  = "${EscHTML($f)}") =~ s/ /&nbsp;/g;
        $fileStr   .= "<tr><td align=left>$fDisp</td>";
-       my($colSpan, $url, $inode, $type);
+       my($colSpan, $url, $inode, $type, $tdColor);
        for ( $i = 0 ; $i < @Backups ; $i++ ) {
            my($path);
            if ( $colSpan > 0 ) {
@@ -102,11 +102,23 @@ sub action
                    $colSpan++;
                    next;
                }
-               $fileStr .= "<td align=center colspan=$colSpan>$url</td>";
+               #
+               # Also handle the case of a sequence of missing files
+               #
+               if ( !defined($hist->{$f}[$i]) && $inode == -3 ) {
+                   $colSpan++;
+                   next;
+               }
+               $fileStr .= "<td align=center colspan=$colSpan$tdColor>"
+                         . "$url</td>";
                $colSpan = 0;
+               $tdColor = "";
            }
            if ( !defined($hist->{$f}[$i]) ) {
-               $fileStr .= "<td></td>";
+               $colSpan = 1;
+               $url     = "&nbsp;";
+               $inode   = -3;                  # special value for missing
+               $tdColor = ' bgcolor="#ffffaa"';
                next;
            }
             if ( $dir eq "" ) {
@@ -118,17 +130,21 @@ sub action
            $path =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
            my $num = $hist->{$f}[$i]{backupNum};
            if ( $hist->{$f}[$i]{type} == BPC_FTYPE_DIR ) {
-               $inode = -2;
+               $inode = -2;                    # special value for dir
                $type  = $hist->{$f}[$i]{type};
                $url   = <<EOF;
-<a href="$MyURL?action=dirHistory&host=${EscURI($host)}&num=$num&share=$shareURI&dir=$path">dir</a>
+<a href="$MyURL?action=dirHistory&host=${EscURI($host)}&num=$num&share=$shareURI&dir=$path">$Lang->{DirHistory_dirLink}</a>
 EOF
            } else {
                $inode = $hist->{$f}[$i]{inode};
                $type  = $hist->{$f}[$i]{type};
+               #
+               # special value for empty file
+               #
                $inode = -1 if ( $hist->{$f}[$i]{size} == 0 );
                if ( !defined($inode2name{$inode}) ) {
-                   $inode2name{$inode} = "v$nameCnt";
+                   $inode2name{$inode}
+                               = "$Lang->{DirHistory_fileLink}$nameCnt";
                    $nameCnt++;
                }
                $url = <<EOF;
@@ -138,7 +154,7 @@ EOF
            $colSpan = 1;
        }
        if ( $colSpan > 0 ) {
-           $fileStr .= "<td align=center colspan=$colSpan>$url</td>";
+           $fileStr .= "<td align=center colspan=$colSpan$tdColor>$url</td>";
            $colSpan = 0;
        }
        $fileStr .= "</tr>\n";
index 8e2022e..f236e1e 100644 (file)
@@ -38,6 +38,7 @@ package BackupPC::CGI::Restore;
 
 use strict;
 use BackupPC::CGI::Lib qw(:all);
+use Data::Dumper;
 
 sub action
 {
index 23fc3a1..7136c52 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/perl -T
+#!/bin/perl
 #
 # by Manfred Herrmann (V1.1) (some typo errors + 3 new strings)
 # CVS-> Revision ???
@@ -618,24 +618,39 @@ EOF
 # ------------------------------
 $Lang{DirHistory_backup_for__host} = "(ENGLISH) BackupPC: Directory backup history for \$host";
 
+#
+# These two strings are used to build the links for directories and
+# file versions.  Files are appended with a version number.
+#
+$Lang{DirHistory_dirLink}  = "(ENGLISH) dir";
+$Lang{DirHistory_fileLink} = "(ENGLISH) v";
+
 $Lang{DirHistory_for__host} = <<EOF;
+\${h1("Directory backup history for \$host")}
 (ENGLISH)
-\${h1("Backup history for \$host")}
-
+<p>
 This display shows each unique version of files across all
 the backups:
 <ul>
 <li> Click on a backup number to return to the backup browser,
-<li> Click on a directory link to navigate into that directory,
-<li> Click on a file version link to download that file.
+<li> Click on a directory link (\$Lang->{DirHistory_dirLink}) to navigate
+     into that directory,
+<li> Click on a file version link (\$Lang->{DirHistory_fileLink}0,
+     \$Lang->{DirHistory_fileLink}1, ...) to download that file,
+<li> Files with the same contents between different backups have the same
+     version number,
+<li> Files or directories not present in a particular backup have an
+     empty box.
+<li> Files shown with the same version might have different attributes.
+     Select the backup number to see the file attributes.
 </ul>
 
 \${h2("History of \${EscHTML(\$dirDisplay)}")}
 
 <br>
-<table border>
-<tr><td>Backup number</td>\$backupNumStr</tr>
-<tr><td>Backup time</td>\$backupTimeStr</tr>
+<table border bgcolor="#ffffcc">
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup number</td>\$backupNumStr</tr>
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup time</td>\$backupTimeStr</tr>
 \$fileStr
 </table>
 EOF
index 099bfab..a6b27d0 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/perl -T
+#!/bin/perl
 
 #my %lang;
 
@@ -615,23 +615,38 @@ EOF
 # ------------------------------
 $Lang{DirHistory_backup_for__host} = "BackupPC: Directory backup history for \$host";
 
-$Lang{DirHistory_for__host} = <<EOF;
-\${h1("Backup history for \$host")}
+#
+# These two strings are used to build the links for directories and
+# file versions.  Files are appended with a version number.
+#
+$Lang{DirHistory_dirLink}  = "dir";
+$Lang{DirHistory_fileLink} = "v";
 
+$Lang{DirHistory_for__host} = <<EOF;
+\${h1("Directory backup history for \$host")}
+<p>
 This display shows each unique version of files across all
 the backups:
 <ul>
 <li> Click on a backup number to return to the backup browser,
-<li> Click on a directory link to navigate into that directory,
-<li> Click on a file version link to download that file.
+<li> Click on a directory link (\$Lang->{DirHistory_dirLink}) to navigate
+     into that directory,
+<li> Click on a file version link (\$Lang->{DirHistory_fileLink}0,
+     \$Lang->{DirHistory_fileLink}1, ...) to download that file,
+<li> Files with the same contents between different backups have the same
+     version number,
+<li> Files or directories not present in a particular backup have an
+     empty box.
+<li> Files shown with the same version might have different attributes.
+     Select the backup number to see the file attributes.
 </ul>
 
 \${h2("History of \${EscHTML(\$dirDisplay)}")}
 
 <br>
-<table border>
-<tr><td>Backup number</td>\$backupNumStr</tr>
-<tr><td>Backup time</td>\$backupTimeStr</tr>
+<table border bgcolor="#ffffcc">
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup number</td>\$backupNumStr</tr>
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup time</td>\$backupTimeStr</tr>
 \$fileStr
 </table>
 EOF
index 7454817..b5fd657 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/perl -T
+#!/bin/perl
 
 #my %lang;
 
@@ -617,24 +617,39 @@ EOF
 # ------------------------------
 $Lang{DirHistory_backup_for__host} = "(ENGLISH) BackupPC: Directory backup history for \$host";
 
+#
+# These two strings are used to build the links for directories and
+# file versions.  Files are appended with a version number.
+#
+$Lang{DirHistory_dirLink}  = "(ENGLISH) dir";
+$Lang{DirHistory_fileLink} = "(ENGLISH) v";
+
 $Lang{DirHistory_for__host} = <<EOF;
+\${h1("Directory backup history for \$host")}
 (ENGLISH)
-\${h1("Backup history for \$host")}
-
+<p>
 This display shows each unique version of files across all
 the backups:
 <ul>
 <li> Click on a backup number to return to the backup browser,
-<li> Click on a directory link to navigate into that directory,
-<li> Click on a file version link to download that file.
+<li> Click on a directory link (\$Lang->{DirHistory_dirLink}) to navigate
+     into that directory,
+<li> Click on a file version link (\$Lang->{DirHistory_fileLink}0,
+     \$Lang->{DirHistory_fileLink}1, ...) to download that file,
+<li> Files with the same contents between different backups have the same
+     version number,
+<li> Files or directories not present in a particular backup have an
+     empty box.
+<li> Files shown with the same version might have different attributes.
+     Select the backup number to see the file attributes.
 </ul>
 
 \${h2("History of \${EscHTML(\$dirDisplay)}")}
 
 <br>
-<table border>
-<tr><td>Backup number</td>\$backupNumStr</tr>
-<tr><td>Backup time</td>\$backupTimeStr</tr>
+<table border bgcolor="#ffffcc">
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup number</td>\$backupNumStr</tr>
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Backup time</td>\$backupTimeStr</tr>
 \$fileStr
 </table>
 EOF
index 70d0d6a..690c832 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/perl -T
+#!/bin/perl
 
 #my %lang;
 #use strict;
@@ -614,22 +614,37 @@ EOF
 # ------------------------------
 $Lang{DirHistory_backup_for__host} = "BackupPC: Historique de sauvegarde des répertoires de \$host";
 
-$Lang{DirHistory_for__host} = <<EOF;
-\${h1("Historique de sauvegarde pour \$host")}
+#
+# These two strings are used to build the links for directories and
+# file versions.  Files are appended with a version number.
+#
+$Lang{DirHistory_dirLink}  = "(ENGLISH) dir";
+$Lang{DirHistory_fileLink} = "(ENGLISH) v";
 
+$Lang{DirHistory_for__host} = <<EOF;
+\${h1("Historique de sauvegarde des répertoires de \$host")}
+<p>
 Voici les versions des fichiers pour toutes les sauvegardes:
 <ul>
 <li> Cliquez sur un numéro de sauvegarde pour revenir à la navigation de sauvegarde,
-<li> Cliquez sur un répertoire pour naviguer dans celui-ci,
-<li> Cliquez sur une version d'un fichier pour la télécharger.
+<li> Cliquez sur un répertoire (\$Lang->{DirHistory_dirLink}) pour naviguer
+     dans celui-ci,
+<li> Cliquez sur une version d'un fichier (\$Lang->{DirHistory_fileLink}0,
+     \$Lang->{DirHistory_fileLink}1, ...) pour la télécharger.
+<li> (ENGLISH) Files with the same contents between different backups have the same
+     version number,
+<li> (ENGLISH) Files or directories not present in a particular backup have an
+     empty box.
+<li> (ENGLISH) Files shown with the same version might have different attributes.
+     Select the backup number to see the file attributes.
 </ul>
 
 \${h2("Historique de \${EscHTML(\$dirDisplay)}")}
 
 <br>
-<table border>
-<tr><td>No. de sauvegarde</td>\$backupNumStr</tr>
-<tr><td>Date</td>\$backupTimeStr</tr>
+<table border bgcolor="#ffffcc">
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>No. de sauvegarde</td>\$backupNumStr</tr>
+<tr bgcolor="\$Conf{CgiHeaderBgColor}"><td>Date</td>\$backupTimeStr</tr>
 \$fileStr
 </table>
 EOF
index 357c9e3..5974a8b 100644 (file)
@@ -428,7 +428,7 @@ sub dirHistory
            my $a = $attr->get;
            foreach my $fileUM ( keys(%$a) ) {
                next if ( $a->{$fileUM}{type} != BPC_FTYPE_DELETED );
-               $files->{$fileUM}[$i] = undef;
+               $files->{$fileUM}[$i] = undef if ( defined($files->{$fileUM}) );
            }
        }
     }