Skip to content

Commit

Permalink
Item14340: Add mappings for old svn versions
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Mar 12, 2017
1 parent 771d5c9 commit 96a047a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions data/System/FoswikiOrgPlugin.txt
Expand Up @@ -33,6 +33,7 @@ Configuration is done witin =bin/configure=. See configure for documentation.
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; |
| 1.05 (2017-03-13): | Item14340: Add mappings for old svn based releases. |
| 1.04 (2017-03-12): | Item14340: Add macro to extract the Foswiki version from the Foswiki::Net user agent string. |
| 1.03 (2015-07-24): | Item13554: encode_utf8 the data from github |
| 1.02 (2014-11-23): | Item13107: Add user map table |
Expand Down
39 changes: 32 additions & 7 deletions lib/Foswiki/Plugins/FoswikiOrgPlugin.pm
Expand Up @@ -9,12 +9,27 @@ use Foswiki::Func;

use constant TRACE => 1;

our $VERSION = '1.04';
our $RELEASE = '12 Mar 2017';
our $VERSION = '1.05';
our $RELEASE = '13 Mar 2017';
our $SHORTDESCRIPTION =
'Adds github WebHook and other utility functions for foswiki.org';
our $NO_PREFS_IN_TOPIC = 1;

my %revmap = (
'3705' => '1.0.5',
'4272' => '1.0.6',
'5061' => '1.0.7',
'5668' => '1.0.8',
'6075' => '1.0.9',
'8969' => '1.0.10',
'9498' => '1.1.0',
'9743' => '1.1.1',
'9940' => '1.1.2',
'11475' => '1.1.3',
'13483' => '1.1.4',
'14595' => '1.1.5',
);

# Plugin init method, used to initialise handlers
sub initPlugin {

Expand Down Expand Up @@ -57,12 +72,22 @@ sub _FoswikiAgentVersion {
my $request = Foswiki::Func::getRequestObject();
my $ua = $request->userAgent() || '';

if ( $ua =~ m#Foswiki::Net/V?([^\ _]+)#i ) {
return $1;
}
else {
return 'unknown';
$ua =~ m#Foswiki::Net/V?([^\ _]+)#i;
my $fwver = $1;
return 'unknown' unless $fwver; # Not a known agent format

# not dotted form, map from svn rev to version
if ( $fwver =~ m/^[0-9]{2,5}$/ ) {
return '1.0.0' if ( $fwver < 3705 ); # Give up, too old.
my $mapped = $revmap{$fwver};
unless ($mapped) {
return '1.0.5' if ( $fwver < 8969 );
return '1.1.0' if ( $fwver < 14595 );
return 'unknown';
}
return $mapped;
}
return $fwver;

}
###############################################################################
Expand Down

0 comments on commit 96a047a

Please sign in to comment.