Skip to content

Commit

Permalink
Item1055: make 'version' and 'installed version' uniform by only comp…
Browse files Browse the repository at this point in the history
…aring the svn revision number, so we do not confuse by using different notations; also show a message "up to date" if both versions are equal (with green background); use pink background for extensions that need upgrading

git-svn-id: http://svn.foswiki.org/trunk@2810 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Mar 1, 2009
1 parent e645bca commit 309277b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 41 deletions.
13 changes: 8 additions & 5 deletions core/lib/Foswiki/Configure/CSS.pm
Expand Up @@ -214,17 +214,20 @@ table.extensionsTable th {
}
table.extensionsTable th,
table.extensionsTable td {
padding-left:.5em;
padding-right:.5em;
padding:.5em;
line-height:1.2em;
}
table.extensionsTable .odd {
background:#f6fafc;
background:#fff; /*f6fafc*/
}
table.extensionsTable .even {
background:#fff;
}
table.extensionsTable .installed {
background:#D9F5D9;
table.extensionsTable .uptodate {
background:#e8f9e8;
}
table.extensionsTable .upgrade {
background:#fff0f2;
}
table.extensionsTable .installed a:link,
table.extensionsTable .installed a:visited {
Expand Down
79 changes: 43 additions & 36 deletions core/lib/Foswiki/Configure/UIs/EXTENSIONS.pm
Expand Up @@ -6,15 +6,14 @@ use strict;
use Foswiki::Configure::Type;

my @tableHeads =
qw(image topic description version installedVersion testedOn install );
qw( topic classification description version installedVersion compatibility install );
my %headNames = (
image => '',
topic => 'Extension',
classification => 'Classification',
description => 'Description',
version => 'Most Recent Version',
version => 'Most Recent Version',
installedVersion => 'Installed Version',
testedOn => 'Tested On Foswiki',
testedOnOS => 'Tested On OS',
compatibility => 'Compatible with',
install => 'Action',
);

Expand All @@ -33,6 +32,7 @@ sub _getListOfExtensions {
print CGI::div("Consulting $place->{name}...");
my $url =
$place->{data} . 'FastReport?skin=text';

my $response = $this->getUrl($url);
if ( !$response->is_error() ) {
my $page = $response->content();
Expand Down Expand Up @@ -92,8 +92,17 @@ sub ui {
foreach my $key ( sort keys %$exts ) {
my $ext = $exts->{$key};
my $row = '';
my $version = '';

foreach my $f (@tableHeads) {
my $text;

if ( $f eq 'version' && $ext->{$f} ) {
# strip out the date
$ext->{$f} =~ s/(\d+)\s\((.*)\)/$1/;
$version = $ext->{$f};
}

my $text;
if ( $f eq 'install' ) {
my @script = File::Spec->splitdir( $ENV{SCRIPT_NAME} );
my $scriptName = pop(@script);
Expand All @@ -106,21 +115,25 @@ sub ui {
. $ext->{repository}
. ';extension='
. $ext->{topic};
$text = 'Install';

if ( $ext->{installedVersion} ) {
$text = 'Upgrade';
if ($ext->{installedVersion} eq $version) {
$text = 'Up to date';
} else {
$text = 'Upgrade';
$text = CGI::a( { href => $link }, $text );
}
$installed++;
} else {
$text = 'Install';
$text = CGI::a( { href => $link }, $text );
}
$text = CGI::a( { href => $link }, $text );
}
else {
$text = $ext->{$f} || '-';
if ( $f eq 'topic' ) {
my $link = $ext->{data} . $ext->{topic};
$text = CGI::a( { href => $link }, $text );
} elsif ($f eq 'image' && $ext->{namespace} &&
$ext->{namespace} ne 'Foswiki') {
$text = "$text ($ext->{namespace})";
}
}
my %opts = ( valign => 'top' );
Expand All @@ -131,23 +144,26 @@ sub ui {
}
my @classes = ( $rows % 2 ? 'odd' : 'even' );
if ($ext->{installedVersion}) {
push @classes, qw( patternAccessKeyInfo installed );
if ($ext->{installedVersion} eq $version) {
push @classes, qw( patternAccessKeyInfo uptodate );
} else {
push @classes, qw( patternAccessKeyInfo upgrade );
}
push @classes, 'twikiExtension'
if $ext->{installedVersion} =~ /\(TWiki\)/;
}
$table .= CGI::Tr( { class => join( ' ', @classes ) }, $row );
$rows++;
}
$table .= CGI::Tr(
{ class => 'patternAccessKeyInfo' },
CGI::td(
{ colspan => "7" },
CGI::th(
{ colspan => scalar @tableHeads },
$installed
. ' extension'
. ( $installed == 1 ? '' : 's' )
. ' out of '
. $rows
. ' already installed'
. ' are installed'
)
);
my $page = <<INTRO;
Expand All @@ -172,34 +188,25 @@ sub _getInstalledVersion {
$lib = 'Contrib';
}

my $release;
my $version;
my $from;
foreach my $frm qw(Foswiki TWiki) {
my $path = $frm.'::'.$lib.'::'.$module;
eval "use $path";
next if $@;

$from = $frm;
$release = eval '$'.$path.'::RELEASE';

my $version;
$version = eval '$'.$path.'::VERSION';
if ($version) {
# tidy up the subversion rev number
$version =~ s/^\s*\$Rev:\s*(.*?)\s*\$$/$1/;
$version =~ s/(\d+)\s\((.*)\)/$1, $2/;
if ($release) {
$release .= " ($version)";
} else {
$release = $version;
}
}
$release ||= '';
$release =~ s/\$Date:\s*([^\$]*)\s*\$/$1/;
$version = eval '$'.$path.'::VERSION' || '';

# tidy up the subversion rev number
$version =~ s/^\s*\$Rev:\s*(.*?)\s*\$$/$1/;
# strip out the date, as it won't be published with all extensions
$version =~ s/(\d+)\s\((.*)\)/$1/;

last;
}

return ($release, $from);
return ($version, $from);
}

1;
Expand Down

0 comments on commit 309277b

Please sign in to comment.