Skip to content

Commit

Permalink
Item12798: add support for foswiki < 1.2.0
Browse files Browse the repository at this point in the history
... by providing a patch ;)



git-svn-id: http://svn.foswiki.org/trunk/PiwikPlugin@17399 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Mar 18, 2014
1 parent a8fd780 commit 79e5a5c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 20 deletions.
41 changes: 39 additions & 2 deletions data/System/PiwikPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1373970087" format="1.1" reprev="2" version="3"}%
%META:TOPICINFO{author="micha" comment="reprev" date="1391770950" format="1.1" reprev="4" version="4"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Expand Down Expand Up @@ -67,17 +67,54 @@ configuration setting. Foswiki itself will write to that directory while the
interim =piwik_daemon= has to be started which takes over responsibility
forwarding the records to the actual Piwik server.

---++ Foswiki < 1.2.0

To track rendering times on older Foswikis you need to apply below patch

%TWISTY%
<verbatim>
--- a/lib/Foswiki/Request.pm
+++ b/lib/Foswiki/Request.pm
@@ -37,6 +37,16 @@ use Error ();
use IO::File ();
use CGI::Util qw(rearrange);

+use Time::HiRes ();
+
+sub getTime {
+ my $this = shift;
+ my $endTime = [Time::HiRes::gettimeofday];
+ my $timeDiff = Time::HiRes::tv_interval( $this->{start_time}, $endTime );
+ return $timeDiff;
+}
+
+
=begin TML

---++ ClassMethod new([$initializer])
@@ -69,6 +79,7 @@ sub new {
remote_user => undef,
secure => 0,
server_port => undef,
+ start_time => [Time::HiRes::gettimeofday],
uploads => {},
uri => '',
};
</verbatim>
%ENDTWISTY%

---++ Info
<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

| Author(s): | Michael Daum|
| Copyright: | &copy; 2013 Michael Daum http://michaeldaumconsulting.com |
| Copyright: | &copy; 2013-2014 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 18 Mar 2014 | added support for foswiki engines < 1.2.0 |
| 01 Nov 2013 | final 2.0 release |
| 18 Jul 2013 | added tracking of outlinks and downloads |
| 16 Jul 2013 | added auto-start feature for the piwik comm server |
Expand Down
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/PiwikPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# PiwikPlugin is Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com
# PiwikPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -22,8 +22,8 @@ use Foswiki::Func ();
use Foswiki::Sandbox ();
use Error qw(:try);

our $VERSION = '2.00';
our $RELEASE = '2.00';
our $VERSION = '2.10';
our $RELEASE = '2.10';
our $SHORTDESCRIPTION = 'Server-side page tracking using Piwik';
our $NO_PREFS_IN_TOPIC = 1;
our $tracker;
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/PiwikPlugin/Daemon.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# PiwikPlugin is Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com
# PiwikPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/PiwikPlugin/Tracker.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# PiwikPlugin is Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com
# PiwikPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
27 changes: 14 additions & 13 deletions tools/piwik_daemon
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# PiwikPlugin is Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com
# PiwikPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -17,21 +17,22 @@
use strict;
use warnings;

BEGIN {
if (-e './setlib.cfg') {
unshift @INC, '.';
} elsif (-e '../bin/setlib.cfg') {
unshift @INC, '../bin';
} # otherwise rely on the user-set path
require 'setlib.cfg';
require 'LocalSite.cfg';
}

use Foswiki::Plugins::PiwikPlugin::Daemon ();
use FindBin;
use Getopt::Long;
use Pod::Usage;
use POSIX ();

$FindBin::Bin =~ /^(.*)$/;
chdir($1) or die "chdir $1 failed";

unshift @INC, '../bin';
require 'setlib.cfg';
require 'LocalSite.cfg';

$0 = 'piwik_daemon';

require Foswiki::Plugins::PiwikPlugin::Daemon;

my $debug = $Foswiki::cfg{PiwikPlugin}{Debug};
my $detach = 0;
my $dry = 0;
Expand Down

0 comments on commit 79e5a5c

Please sign in to comment.