summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ivybanner395
-rw-r--r--ivybanner.conf5
2 files changed, 220 insertions, 180 deletions
diff --git a/ivybanner b/ivybanner
index af6a72f..5bfaccc 100644
--- a/ivybanner
+++ b/ivybanner
@@ -36,6 +36,8 @@ my $ivylaunch_command = "/usr/bin/ivylaunch";
my $default_domain;
my @ivyports = (2010, 3009, 3110, 3945);
my $default_port = 3110;
+my $demossortingpolicy = 'mtime';
+my $testssortingpolicy = 'mtime';
my %SIZES = ( "small" => {
"width" => 640,
@@ -146,19 +148,23 @@ for ($demosdir, $testsdir) {
#--------------------------
if (open S, $conffile) {
- while (<S>) {
- if (/^ivylaunch_command\s*:\s*([\w\/-]+)/) {
- $ivylaunch_command = $1;
- } elsif (/^default_domain\s*:\s*(.*)/) {
- $default_domain = $1;
- } elsif (/^4ports\s*:\s*(.*)/) {
- my $ports = $1;
- @ivyports = split(/\s*,\s*/, $ports);
- } elsif (/^default_port\s*:\s*([\w\/-]+)/) {
- $default_port = $1;
- }
- }
- close S;
+ while (<S>) {
+ if (/^ivylaunch_command\s*:\s*([\w\/-]+)/) {
+ $ivylaunch_command = $1;
+ } elsif (/^default_domain\s*:\s*(.*)/) {
+ $default_domain = $1;
+ } elsif (/^4ports\s*:\s*(.*)/) {
+ my $ports = $1;
+ @ivyports = split(/\s*,\s*/, $ports);
+ } elsif (/^default_port\s*:\s*([\w\/-]+)/) {
+ $default_port = $1;
+ } elsif (/^demos_sorting_policy\s*:\s*(\w+)/) {
+ $demossortingpolicy = $1 if $1 eq 'mtime' or $1 eq 'alphabetical';
+ } elsif (/^tests_sorting_policy\s*:\s*(\w+)/) {
+ $testssortingpolicy = $1 if $1 eq 'mtime' or $1 eq 'alphabetical';
+ }
+ }
+close S;
}
$ivylaunch_command .= " -override" if $opt{override};
@@ -228,13 +234,15 @@ print "--- Environment variables\n";
print "\$IVYCONFIGSDIR=",$ENV{'IVYCONFIGSDIR'},"\n";
print "\$IVYTESTSDIR=",$ENV{'IVYTESTSDIR'},"\n";
print "--- Parameters\n";
-print "configuration file : $conffile\n";
-print "declared ports : ",join(',', @ivyports),"\n";
-print "default domain : $default_domain\n";
-print "default port : $default_port \n";
-print "demos directory : $demosdir \n";
-print "tests directory : $testsdir \n";
-print "ivylaunch command : $ivylaunch_command \n";
+print "configuration file : $conffile\n";
+print "declared ports : ",join(',', @ivyports),"\n";
+print "default domain : $default_domain\n";
+print "default port : $default_port \n";
+print "demos directory : $demosdir \n";
+print "tests directory : $testsdir \n";
+print "demos sorting policy : $demossortingpolicy \n";
+print "tests sorting policy : $testssortingpolicy \n";
+print "ivylaunch command : $ivylaunch_command \n";
print "======================================================\n";
@@ -390,8 +398,9 @@ sub demosframe {
$en_ownport->configure(-state => 'normal',
-background => $fg)},
-text => "other\nport")->place(@placeattr);
-
- &subdirframe($fm2, $path, $x, $y, $dx, $dy);
+
+ my $policy = ($title eq 'tests') ? $testssortingpolicy : $demossortingpolicy;
+ &subdirframe($policy, $fm2, $path, $x, $y, $dx, $dy);
# control buttons bottom frame
#--------------------------------------------------
@@ -461,164 +470,190 @@ sub demosframe {
sub subdirframe {
-
- my $fm2 = shift;
- my $path = shift;
- my $x = shift;
- my $y = shift;
- my $dx = shift;
- my $dy = shift;
-
- for (@subdirbtn) {
- $_->destroy if Tk::Exists($_);
- }
- @subdirbtn = ();
-
- # demos frame
- #--------------------------------------------------
- my @bbox = (40*$coef, 160*$coef, $SIZES{$opt{size}}->{width}-40*$coef, 640*$coef);
- my $fmh = 90*$coef;
- my $fmw = 180*$coef;
- my $butw = 14*$coef;
- my $max_columns = int(($bbox[2]-$bbox[0])/$fmw);
- my $max_rows = int(($bbox[3]-$bbox[1])/$fmh);
- my $maxnb = $max_columns*$max_rows;
- my @placeattr = (-x => 10*$coef, '-y' => 5*$coef);
- my @frameattr = (-relief => 'flat',
- -highlightthickness => 3*$coef*$coef,
- -highlightbackground => $hlbg,
- -height => $fmh,
- -width => $fmw,
- -background => $bg);
- my @rbuttonattr = (-width => $butw, -height => 4*$coef,
- -borderwidth => 1,
- -font => $SIZES{$opt{size}}->{fontspec_medium},
- -relief => 'flat',
- -highlightthickness => 0,
- -background => $bg,
- -foreground => $fg,
- -activeforeground => $fg,
- -activebackground => $bg,
- -selectcolor => $selcolor,
- -indicatoron => 0,
- );
- my @buttonattr = (-width => $butw, -height => 4*$coef,
- -borderwidth => 1,
- -font => $SIZES{$opt{size}}->{fontspec_medium},
- -relief => 'flat',
- -highlightthickness => 3*$coef*$coef,
- -highlightbackground => $hlbg,
- -activebackground => $bg,
- -activeforeground => $fg,
- -background => $bg,
- -foreground => $fg);
-
- my $c = 1;
- my $r = 1;
- opendir PREFIX, $path;
- #my @file_liste = grep /:/, readdir PREFIX;
- my @file_liste = readdir PREFIX;
- closedir PREFIX;
- my @cleanfilelist = ();
- push(@cleanfilelist, ['..', 'd']) if $level > 1;
- @file_liste = sort { (stat("$path/$a"))[10] <=> (stat("$path/$b"))[10] } @file_liste;
- foreach my $file (@file_liste) {
- my $type;
- if (-f $path."/".$file) {
- #print "$file is a file\n";
- $type = 'f';
- } elsif (-d $path."/".$file) {
- #print "$file is a directory\n";
- $type = 'd';
- }
- #print "file=$file mtime=", (stat("$path/$file"))[10] ,"\n";
- next unless defined $type;
- next if ($type eq 'f' and $file !~ /:/);
- next if ($type eq 'f' and $file =~ /\~$/);
- next if ($type eq 'f' and $file =~ /^\./);
- next if ($type eq 'f' and $file =~ /\%$/);
- next if ($type eq 'd' and $file =~ /^\./);
- push(@cleanfilelist, [$file, $type]);
- }
- #print "\n";
- #print "maxnb=$maxnb cleanfilelist=", scalar @cleanfilelist, "\n";
- my $demosnb = @cleanfilelist;
- if ($demosnb > $maxnb) {
- splice(@cleanfilelist, $maxnb-1);
- }
- #print "apres cleanfilelist=", scalar @cleanfilelist, "\n";
- my $maxc = $max_columns;
- for my $i (1, 4, 9, 16, 25) {
- if ($demosnb <= $i) {
- $maxc = sqrt($i);
- last;
- }
- }
- $dx = ($bbox[2] - $bbox[0] - $maxc*$fmw)/($maxc+1);
- $dy = ($bbox[3] - $bbox[1] - $maxc*$fmh)/($maxc+1);
- $x = $bbox[0] + $dx;
- $y = $bbox[1] + $dy;
- #print "maxc=$maxc x=$x y=$y dx=$dx dy=$dy\n";
- my ($xi, $yi);
- for my $fileref (@cleanfilelist) {
- my ($file, $type) = @$fileref;
- my @fields = split(/:/, $file);
- my ($category, $extinfo);
- if (@fields == 1) {
- $category = $fields[0];
- } elsif (@fields > 1) {
- ($category, $extinfo) = ($fields[-2], $fields[-1]);
- }
- my $len = length($category);
- if ($len >= $butw) {
- $category = substr($category, 0, $butw)."\n".substr($category, $butw);
- }
- $len = length($extinfo);
- if ($len > $butw) {
- $extinfo = substr($extinfo, 0, $butw)."\n".substr($extinfo, $butw);
- }
- ($xi, $yi) = ($x + ($c-1)*($dx+$fmw), $y + ($r-1)*($dy+$fmh));
- my $b = $fm2->Button(@buttonattr)->place(-x => $xi, '-y' => $yi);
- if ($type eq 'f') {
- $b->configure(-text => "$category\n$extinfo",
- -command => sub {
- &off();
- &on($b, $path."/".$file);
- });
- } else {
- $b->configure(-bg => $darkbg,
- -activebackground => $darkbg,
- -text => ($file eq '..') ? "Up" : $file,
- -command => sub {
- &off;
- if ($file eq '..') {
- $level--;
- } else {
- $level++;
- }
- &subdirframe($fm2, $path."/".$file, $x, $y, $dx, $dy);
- });
- }
- push(@subdirbtn, $b);
- if ($c >= $maxc) {
- $c=1;
- $r++;
- } else {
- $c++;
- }
- }
- if ($demosnb > $maxnb) {
- #print "maxnb=$maxnb\n";
- my $many = $demosnb - $maxnb + 1;
- ($xi, $yi) = ($x + ($c-1)*($dx+$fmw), $y + ($r-1)*($dy+$fmh));
- my $disa = $fm2->Button(@buttonattr,
- -state => "disabled",
- -text => "and $many\nmore...",
- )->place(-x => $xi, '-y' => $yi);
- push(@subdirbtn, $disa);
-
- }
-
+
+ my $filesortingpolicy = shift;
+ my $fm2 = shift;
+ my $path = shift;
+ my $x = shift;
+ my $y = shift;
+ my $dx = shift;
+ my $dy = shift;
+
+ for (@subdirbtn) {
+ $_->destroy if Tk::Exists($_);
+ }
+ @subdirbtn = ();
+
+ # demos frame
+ #--------------------------------------------------
+ my @bbox = (40*$coef, 160*$coef, $SIZES{$opt{size}}->{width}-40*$coef, 640*$coef);
+ my $fmh = 90*$coef;
+ my $fmw = 180*$coef;
+ my $butw = 14*$coef;
+ my $max_columns = int(($bbox[2]-$bbox[0])/$fmw);
+ my $max_rows = int(($bbox[3]-$bbox[1])/$fmh);
+ my $maxnb = $max_columns*$max_rows;
+ my @placeattr = (-x => 10*$coef, '-y' => 5*$coef);
+ my @frameattr = (-relief => 'flat',
+ -highlightthickness => 3*$coef*$coef,
+ -highlightbackground => $hlbg,
+ -height => $fmh,
+ -width => $fmw,
+ -background => $bg);
+ my @rbuttonattr = (-width => $butw, -height => 4*$coef,
+ -borderwidth => 1,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
+ -relief => 'flat',
+ -highlightthickness => 0,
+ -background => $bg,
+ -foreground => $fg,
+ -activeforeground => $fg,
+ -activebackground => $bg,
+ -selectcolor => $selcolor,
+ -indicatoron => 0,
+ );
+ my @buttonattr = (-width => $butw, -height => 4*$coef,
+ -borderwidth => 1,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
+ -relief => 'flat',
+ -highlightthickness => 3*$coef*$coef,
+ -highlightbackground => $hlbg,
+ -activebackground => $bg,
+ -activeforeground => $fg,
+ -background => $bg,
+ -foreground => $fg);
+
+ my $c = 1;
+ my $r = 1;
+
+ # sélection du contenu du répertoire
+ # => création de la liste d'éléments [file, type, label]
+ #--------------------------------------------------
+ opendir PREFIX, $path;
+ #my @file_liste = grep /:/, readdir PREFIX;
+ my @file_liste = readdir PREFIX;
+ closedir PREFIX;
+ my @cleanfilelist = ();
+
+ foreach my $file (@file_liste) {
+ my $type;
+ if (-f $path."/".$file) {
+ $type = 'f';
+ } elsif (-d $path."/".$file) {
+ $type = 'd';
+ }
+ next unless defined $type;
+ next if ($type eq 'f' and $file !~ /:/);
+ next if ($type eq 'f' and $file =~ /\~$/);
+ next if ($type eq 'f' and $file =~ /^\./);
+ next if ($type eq 'f' and $file =~ /\%$/);
+ next if ($type eq 'd' and $file =~ /^\./);
+ next if ($type eq 'd' and $file eq 'CVS');
+
+ my $label;
+ if ($type eq 'd') {
+ $label = $file;
+ # cas des fichiers : seuls les 2 derniers champs séparés par des ':'
+ # seront affichés
+ } elsif ($type eq 'f') {
+ my @fields = split(/:/, $file);
+ my ($category, $extinfo);
+ if (@fields == 1) {
+ $category = $fields[0];
+ } elsif (@fields > 1) {
+ ($category, $extinfo) = ($fields[-2], $fields[-1]);
+ }
+ my $len = length($category);
+ if ($len >= $butw) {
+ $category = substr($category, 0, $butw).":".substr($category, $butw);
+ }
+ $len = length($extinfo);
+ if ($len > $butw) {
+ $extinfo = substr($extinfo, 0, $butw).":".substr($extinfo, $butw);
+ }
+ $label = $category.":".$extinfo;
+ }
+ push(@cleanfilelist, [$file, $type, $label]);
+ }
+
+ # règle de tri des fichiers
+ #--------------------------------------------------
+ if ($filesortingpolicy eq 'mtime') {
+ @cleanfilelist = sort { (stat("$path/$a->[0]"))[9] <=> (stat("$path/$b->[0]"))[9] } @cleanfilelist;
+ } else {
+ @cleanfilelist = sort { uc($a->[2]) cmp uc($b->[2]) } @cleanfilelist;
+ }
+ @cleanfilelist = (['..', 'd', 'Up'], @cleanfilelist) if $level > 1;
+
+ # calcul des limites
+ #--------------------------------------------------
+ my $demosnb = @cleanfilelist;
+ if ($demosnb > $maxnb) {
+ splice(@cleanfilelist, $maxnb-1);
+ }
+ my $maxc = $max_columns;
+ for my $i (1, 4, 9, 16, 25) {
+ if ($demosnb <= $i) {
+ $maxc = sqrt($i);
+ last;
+ }
+ }
+
+
+ # affichage
+ #--------------------------------------------------
+ $dx = ($bbox[2] - $bbox[0] - $maxc*$fmw)/($maxc+1);
+ $dy = ($bbox[3] - $bbox[1] - $maxc*$fmh)/($maxc+1);
+ $x = $bbox[0] + $dx;
+ $y = $bbox[1] + $dy;
+ #print "maxc=$maxc x=$x y=$y dx=$dx dy=$dy\n";
+ my ($xi, $yi);
+ for my $fileref (@cleanfilelist) {
+ my ($file, $type, $label) = @$fileref;
+ #print "file=$file label=$label mtime=",(stat("$path/$file"))[9],"\n";
+ ($xi, $yi) = ($x + ($c-1)*($dx+$fmw), $y + ($r-1)*($dy+$fmh));
+ my $b = $fm2->Button(@buttonattr)->place(-x => $xi, '-y' => $yi);
+ if ($type eq 'f') {
+ $label =~ s/:/\n/;
+ $b->configure(-text => $label,
+ -command => sub {
+ &off();
+ &on($b, $path."/".$file);
+ });
+ } else {
+ $b->configure(-bg => $darkbg,
+ -activebackground => $darkbg,
+ -text => $label,
+ -command => sub {
+ &off;
+ if ($file eq '..') {
+ $level--;
+ } else {
+ $level++;
+ }
+ &subdirframe($filesortingpolicy, $fm2, $path."/".$file, $x, $y, $dx, $dy);
+ });
+ }
+ push(@subdirbtn, $b);
+ if ($c >= $maxc) {
+ $c=1;
+ $r++;
+ } else {
+ $c++;
+ }
+ }
+ if ($demosnb > $maxnb) {
+ #print "maxnb=$maxnb\n";
+ my $many = $demosnb - $maxnb + 1;
+ ($xi, $yi) = ($x + ($c-1)*($dx+$fmw), $y + ($r-1)*($dy+$fmh));
+ my $disa = $fm2->Button(@buttonattr,
+ -state => "disabled",
+ -text => "and $many\nmore...",
+ )->place(-x => $xi, '-y' => $yi);
+ push(@subdirbtn, $disa);
+
+ }
+
} # end subdirframe
diff --git a/ivybanner.conf b/ivybanner.conf
index 9f33c70..7da15fe 100644
--- a/ivybanner.conf
+++ b/ivybanner.conf
@@ -9,3 +9,8 @@ default_port : 3110
# default domain; may be your broadcast address
#default_domain : 10.192.36.255
+
+# files display sorting policy : mtime or alphabetical
+demos_sorting_policy : mtime
+
+tests_sorting_policy : mtime \ No newline at end of file