Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item14340: Add macro to extract foswiki version from the agent
Use on the FastReport to filter out incompatible extensions,
  • Loading branch information
gac410 committed Mar 12, 2017
1 parent 3f536de commit 771d5c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion data/System/FoswikiOrgPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1416784160" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489351300" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
<!--
One line description, required for extensions repository catalog.
Expand Down 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.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 |
| 1.0 (2014-08-20): | Initial version |
Expand Down
26 changes: 23 additions & 3 deletions lib/Foswiki/Plugins/FoswikiOrgPlugin.pm
Expand Up @@ -9,9 +9,10 @@ use Foswiki::Func;

use constant TRACE => 1;

our $VERSION = '1.03';
our $RELEASE = '1.03';
our $SHORTDESCRIPTION = 'Adds github WebHook to accept push notifications';
our $VERSION = '1.04';
our $RELEASE = '12 Mar 2017';
our $SHORTDESCRIPTION =
'Adds github WebHook and other utility functions for foswiki.org';
our $NO_PREFS_IN_TOPIC = 1;

# Plugin init method, used to initialise handlers
Expand All @@ -31,6 +32,10 @@ sub initPlugin {
);
}

# Register the _FoswikiAgentVersion function to handle %FOSWIKIREQUESTAGENT{}%
Foswiki::Func::registerTagHandler( 'FOSWIKIREQUESTAGENT',
\&_FoswikiAgentVersion );

return 1;
}

Expand All @@ -45,6 +50,21 @@ sub _RESTgithubpush {

}

sub _FoswikiAgentVersion {

# my($session, $params, $topic, $web, $topicObject) = @_;

my $request = Foswiki::Func::getRequestObject();
my $ua = $request->userAgent() || '';

if ( $ua =~ m#Foswiki::Net/V?([^\ _]+)#i ) {
return $1;
}
else {
return 'unknown';
}

}
###############################################################################
sub writeDebug {
return unless TRACE;
Expand Down

0 comments on commit 771d5c9

Please sign in to comment.