Permalink
Browse files

Item14448: fixed reporting outdated plugins

  • Loading branch information...
1 parent a53885c commit 92328fa30d8dbb9271ccd4ec6c2312f6432c555c MichaelDaum committed Jul 28, 2017
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="ProjectContributor" comment="" date="1493865930" format="1.1" version="1"}%
+%META:TOPICINFO{author="ProjectContributor" comment="" date="1505301509" format="1.1" version="1"}%
---+!! %TOPIC%
<img class="foswikiRight" src="%ATTACHURL%/logo.png">
%$SHORTDESCRIPTION%
@@ -66,6 +66,7 @@ to prevent disclosing them to the outside world.
This plugin was initially developed during a collaborative design and coding session at the 2011 Foswiki Camp.
| Change History: | <!-- versions below in reverse order -->&nbsp; |
+| 1.04 (28 Jul 2017) | Foswikitask:Item14448: fixed broken outdated plugins report |
| 1.03 (03 May 2017) | Foswikitask:Item13907: Report list of extensions needing update. |
| 1.02 (23 Jan 2017) | Foswikitask:Item14281: Cookie related changes. Inconsistent use of the domain and secure flags. |
| 1.01 (24 Jul 2015) | Foswikitask:Item13555: Compare VERSION not RELEASE strings.<br/>\
@@ -80,10 +81,6 @@ This plugin was initially developed during a collaborative design and coding ses
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/distro"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; Foswiki Contributors 2011-2017"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
-%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
+%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25$ROOTMODULE%25"}%
-%META:FILEATTACHMENT{name="logo.png" attr="h" comment="" date="1493865930" size="53676" user="ProjectContributor" version="1"}%
-%META:FILEATTACHMENT{name="jquery.updates.js" attr="h" comment="" date="1493865930" size="2322" user="ProjectContributor" version="1"}%
-%META:FILEATTACHMENT{name="jquery.updates.js.gz" attr="h" comment="" date="1493865930" size="786" user="ProjectContributor" version="1"}%
-%META:FILEATTACHMENT{name="jquery.updates.uncompressed.js" attr="h" comment="" date="1493865930" size="4313" user="ProjectContributor" version="1"}%
-%META:FILEATTACHMENT{name="Makefile" attr="h" comment="" date="1493865930" size="127" user="ProjectContributor" version="1"}%
+%META:FILEATTACHMENT{name="logo.png" attr="h" comment="" date="1505301509" size="53676" user="ProjectContributor" version="1"}%
@@ -20,8 +20,8 @@ use warnings;
use Foswiki::Func ();
-our $VERSION = '1.03';
-our $RELEASE = '03 May 2017';
+our $VERSION = '1.04';
+our $RELEASE = '28 Jul 2017';
our $SHORTDESCRIPTION = 'Checks Foswiki.org for updates';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
# Standard preamble
use strict;
@@ -1,11 +1,12 @@
/*
- * jquery.updates plugin 0.30
+ * jquery.updates plugin 1.04
*
- * Copyright (c) 2011-2015 Foswiki Contributors http://foswiki.org
+ * Copyright (c) 2011-2017 Foswiki Contributors http://foswiki.org
*
* http://www.gnu.org/licenses/gpl.html
*
*/
+"use strict";
(function($) {
// global defaults
@@ -28,14 +29,14 @@
self.options = $.extend({}, defaults, options);
if (self.options.debug) {
- console.log("called new FoswikiUpdates");
+ console.log("called new FoswikiUpdates"); // eslint-disable-line no-console
}
self.init();
self.loadPluginInfo(0);
return self;
- };
+ }
// init method
FoswikiUpdates.prototype.init = function() {
@@ -51,15 +52,15 @@
}
self.options.cookieDomain = foswiki.getPreference('COOKIEREALM'); // Allow domain override
- self.options.cookieSecure = foswiki.getPreference('URLHOST').startsWith('https://');
+ self.options.cookieSecure = foswiki.getPreference('URLHOST').indexOf('https://') === 0;
// events
- $(document).bind("refresh.foswikiUpdates", function() {
+ $(document).on("refresh.foswikiUpdates", function() {
//console.log("BIND refresh.foswikiUpdates calling loadPluginInfo.");
self.loadPluginInfo(0);
});
- $(document).bind("forceRefresh.foswikiUpdates", function() {
+ $(document).on("forceRefresh.foswikiUpdates", function() {
//console.log("BIND forceRefresh.foswikiUpdates calling loadPluginInfo.");
$.cookie(self.options.cookieName, null, {
expires: -1,
@@ -70,15 +71,15 @@
self.loadPluginInfo(1);
});
- $(document).bind("display.foswikiUpdates", function() {
+ $(document).on("display.foswikiUpdates", function() {
//console.log("BIND display.foswikiUpdates calling loadPluginInfo.");
- self.displayPluginInfo(0);
+ self.displayPluginInfo();
});
$(document).on("click", "#foswikiUpdatesIgnore", function() {
// setting the cookie to zero...means ignore and don't search again
//console.log("BIND click entered ");
- $.cookie(self.options.cookieName, 0, {
+ $.cookie(self.options.cookieName, [], {
expires: self.options.cookieExpires,
path: "/",
domain:self.options.cookieDomain,
@@ -91,12 +92,12 @@
// pull info from f.o and refresh internal state
FoswikiUpdates.prototype.loadPluginInfo = function(forced) {
- var self = this, key, version;
+ var self = this;
//console.log("called loadPluginInfo forced: " + forced );
- self.numberOutdatedPlugins = $.cookie(self.options.cookieName);
+ self.outdatedPlugins = $.cookie(self.options.cookieName);
- if (typeof(self.numberOutdatedPlugins) === 'undefined') {
+ if (typeof(self.outdatedPlugins) === 'undefined') {
// collect remote info
window.setTimeout(function() {
@@ -106,25 +107,24 @@
url: self.options.endpointUrl,
dataType: "json",
timeout: self.options.timeout,
- success: function(data, status, xhr) {
+ success: function(data) {
//console.log("success: data=",data);
- self.numberOutdatedPlugins = data.length;
- self.pluginList = data.sort();
+ self.outdatedPlugins = data;
// remember findings: sets cookie to the number of outdated plugins. setting it to
// zero explicitly can either mean: everything up-to-date or ignore pending updates
- $.cookie(self.options.cookieName, self.numberOutdatedPlugins, {
+ $.cookie(self.options.cookieName, self.outdatedPlugins, {
expires: self.options.cookieExpires,
path: "/",
domain:self.options.cookieDomain,
secure:self.options.cookieSecure
});
//console.log("Forced: " + forced);
- if (self.numberOutdatedPlugins > 0 || forced) {
+ if (self.outdatedPlugins.length > 0 || forced) {
$(document).trigger("display.foswikiUpdates");
}
},
- error: function(xhr, msg, status) {
+ error: function() {
//console.log("got an error: status=",status,"msg=",msg)
// remember the error state
$.cookie(self.options.cookieName, -1, {
@@ -136,22 +136,27 @@
}
});
}, self.options.delay);
- } else if (self.numberOutdatedPlugins > 0) {
- // we already know. so only trigger the display again
- $(document).trigger("display.foswikiUpdates");
- }
+ } else {
+ if (typeof(self.outdatedPlugins) === 'string' && self.outdatedPlugins.length > 0) {
+ self.outdatedPlugins = self.outdatedPlugins.split(/\s*,\s*/);
+ }
+ if (self.outdatedPlugins.length > 0) {
+ // we already know. so only trigger the display again
+ $(document).trigger("display.foswikiUpdates");
+ }
+ }
};
// displays internal state using a nice info box at the top of the page
FoswikiUpdates.prototype.displayPluginInfo = function() {
var self = this, elem;
- $(".foswikiUpdateMessage").remove(); // ... the old one if there
+ $(".foswikiUpdatesMessage").remove(); // ... the old one if there
// ... and add a new one
elem = $("#foswikiUpdatesTmpl").render([{
- nrPlugins:self.numberOutdatedPlugins,
- pluginList:self.pluginList,
+ nrPlugins:self.outdatedPlugins.length,
+ outdatedPlugins:self.outdatedPlugins.sort().join(", "),
cookieExpires:self.options.cookieExpires,
configureUrl:self.options.configureUrl
}]);
@@ -1,16 +1,16 @@
%TMPL:DEF{"messagetmpl"}%<script id="foswikiUpdatesTmpl" type="text/x-jsrender">
<div class="foswikiBroadcastMessage foswikiUpdatesMessage">
-%JQICON{"error"}%
+%TMPL:P{"messagetmpl::icon"}%
%TMPL:P{"messagetmpl::text"}%
-<a href="%SCRIPTURL{configure}%">%JQICON{"tick"}% %MAKETEXT{"Upgrade"}%</a>
-<a href="#" id="foswikiUpdatesIgnore">%JQICON{"cross"}% %MAKETEXT{"Ignore for 7 days"}%</a><br/>
-%TMPL:P{"messagetmpl::list"}%
+%TMPL:P{"messagetmpl::buttons"}%
%CLEAR%
</div>
</script>%TMPL:END%
-%TMPL:DEF{"messagetmpl::text"}%%MAKETEXT{"Warning: Updates found for [_1] extension(s)." args="{{:nrPlugins}}"}%%TMPL:END%
-%TMPL:DEF{"messagetmpl::list"}%({{:pluginList}})%TMPL:END%
+%TMPL:DEF{"messagetmpl::icon"}%%JQICON{"error"}%%TMPL:END%
+%TMPL:DEF{"messagetmpl::text"}%%MAKETEXT{"Warning: Updates found for [_1] extension(s): [_2]" arg1="{{:nrPlugins}}" arg2="{{:outdatedPlugins}}"}%%TMPL:END%
+%TMPL:DEF{"messagetmpl::buttons"}%<a href="%SCRIPTURLPATH{configure}%">%JQICON{"tick"}% %MAKETEXT{"Upgrade"}%</a>
+<a href="#" id="foswikiUpdatesIgnore">%JQICON{"cross"}% %MAKETEXT{"Ignore for 7 days"}%</a>%TMPL:END%
%TMPL:DEF{"css"}%<style type="text/css">
.foswikiBroadcastMessage.foswikiUpdatesMessage {

0 comments on commit 92328fa

Please sign in to comment.