Index: lib/Foswiki/Plugins/JQueryPlugin.pm =================================================================== --- lib/Foswiki/Plugins/JQueryPlugin.pm (revision 6641) +++ lib/Foswiki/Plugins/JQueryPlugin.pm (working copy) @@ -14,6 +14,7 @@ # package Foswiki::Plugins::JQueryPlugin; use strict; +use warnings; =begin TML @@ -44,6 +45,20 @@ sub initPlugin { my( $topic, $web, $user ) = @_; + + # BAD SMELL: This code, which provides a fake addToZone() should be + # removed, gone, eradicated by March 31 2010, by which time a consensus + # should be reached on http://foswiki.org/Development/ImprovePageLoadTime + # + # Instead, addToZone() should either be in core, or JQueryPlugin should make + # up its own wrapper to call addToZone() vs addToHEAD(). + # + # If there is no addToZONE as provided by ZonePlugin or the core, wrap + # addToHEAD to do it instead. + if (not exists &Foswiki::Func::addToZone) { + *Foswiki::Func::addToZone = \&Foswiki::Plugins::JQueryPlugin::_fakeaddToZone; + Foswiki::Func::registerTagHandler('ADDTOZONE', \&_fakeADDTOZONE ); + } # jquery.foswiki Foswiki::Func::registerTagHandler('JQTHEME', \&handleJQueryTheme ); @@ -79,8 +94,62 @@ return 1; } +############################################################################## =begin TML +---++ _fakeAddToZone($zone, $tag, $text, $requires) + +A wrapper to addToHEAD(), in case the real addToZone() is missing. + +=cut +sub _fakeaddToZone { + my ($zone, $tag, $text, $requires) = @_; + + Foswiki::Func::addToHEAD($tag, $text, $requires); + + return; +} + +############################################################################## +=begin TML + +---++ _fakeADDTOZONE +This is used to register a fake ADDTOZONE macro. It's a wrapper to our fake +addToZone() method, which in turn is a wrapper to addToHEAD, so zones are +ignored (everything is added to head). + +Copied from ZonePlugin.pm + +=cut +sub _fakeADDTOZONE { + my ($session, $params, $theTopic, $theWeb) = @_; + + my $zones = $params->{_DEFAULT} || $params->{zone} || 'head'; + my $tag = $params->{tag} || ''; + my $topic = $params->{topic} || ''; + my $section = $params->{section} || ''; + my $requires = $params->{requires} || '';; + my $text = $params->{text} || ''; + my $web = $theWeb; + + if ($topic) { + ($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $topic); + $text = '%INCLUDE{"' . $web . '.' . $topic . '"'; + $text .= ' section="' . $section . '"' if $section; + $text .= ' warn="off"}%'; + } + + foreach my $zone (split(/\s*,\s*/, $zones)) { + _fakeaddToZone($zone, $tag, $text, $requires); + } + + return ''; +} + + + +=begin TML + finish up the plugins container SMELL: I'd prefer a proper finishHandler, alas it does not exist @@ -89,6 +158,8 @@ sub modifyHeaderHandler { Foswiki::Plugins::JQueryPlugin::Plugins::finish(); + + return; } =begin TML Index: lib/Foswiki/Plugins/JQueryPlugin/DEPENDENCIES =================================================================== --- lib/Foswiki/Plugins/JQueryPlugin/DEPENDENCIES (revision 6641) +++ lib/Foswiki/Plugins/JQueryPlugin/DEPENDENCIES (working copy) @@ -1,2 +1,2 @@ -Foswiki::Plugins::ZonePlugin,>=1.0,perl,Required. +Foswiki::Plugins::ZonePlugin,>=1.0,perl,optional.