From 79e5a5c6a34c944e76f137a4953ba0893ee8427c Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Tue, 18 Mar 2014 14:00:22 +0000 Subject: [PATCH] Item12798: add support for foswiki < 1.2.0 ... by providing a patch ;) git-svn-id: http://svn.foswiki.org/trunk/PiwikPlugin@17399 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- data/System/PiwikPlugin.txt | 41 ++++++++++++++++++++-- lib/Foswiki/Plugins/PiwikPlugin.pm | 6 ++-- lib/Foswiki/Plugins/PiwikPlugin/Daemon.pm | 2 +- lib/Foswiki/Plugins/PiwikPlugin/Tracker.pm | 2 +- tools/piwik_daemon | 27 +++++++------- 5 files changed, 58 insertions(+), 20 deletions(-) diff --git a/data/System/PiwikPlugin.txt b/data/System/PiwikPlugin.txt index ebd0ac2..23d867f 100644 --- a/data/System/PiwikPlugin.txt +++ b/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% @@ -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% + +--- 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 => '', + }; + +%ENDTWISTY% + ---++ Info | Author(s): | Michael Daum| -| Copyright: | © 2013 Michael Daum http://michaeldaumconsulting.com | +| Copyright: | © 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: |   | +| 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 | diff --git a/lib/Foswiki/Plugins/PiwikPlugin.pm b/lib/Foswiki/Plugins/PiwikPlugin.pm index a1de3c0..42f7bc4 100644 --- a/lib/Foswiki/Plugins/PiwikPlugin.pm +++ b/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 @@ -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; diff --git a/lib/Foswiki/Plugins/PiwikPlugin/Daemon.pm b/lib/Foswiki/Plugins/PiwikPlugin/Daemon.pm index b43751d..17c25a0 100644 --- a/lib/Foswiki/Plugins/PiwikPlugin/Daemon.pm +++ b/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 diff --git a/lib/Foswiki/Plugins/PiwikPlugin/Tracker.pm b/lib/Foswiki/Plugins/PiwikPlugin/Tracker.pm index 2a84086..dbc18c7 100644 --- a/lib/Foswiki/Plugins/PiwikPlugin/Tracker.pm +++ b/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 diff --git a/tools/piwik_daemon b/tools/piwik_daemon index ddca1fb..360f77f 100755 --- a/tools/piwik_daemon +++ b/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 @@ -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;