resources: Make jquery.cookie a multi-file resource with changelog, licence
authorJames D. Forrester <jforrester@wikimedia.org>
Mon, 24 Sep 2018 17:14:31 +0000 (10:14 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Mon, 24 Sep 2018 17:14:31 +0000 (10:14 -0700)
Change-Id: I47e25b1a7ac7d53932dfdfd37a47a38141f91be4

maintenance/resources/foreign-resources.yaml
resources/Resources.php
resources/lib/jquery.cookie.js [deleted file]
resources/lib/jquery.cookie/CHANGELOG.md [new file with mode: 0644]
resources/lib/jquery.cookie/MIT-LICENSE.txt [new file with mode: 0644]
resources/lib/jquery.cookie/jquery.cookie.js [new file with mode: 0644]

index ae45ab8..6316219 100644 (file)
@@ -68,9 +68,17 @@ jquery:
   dest: jquery.js
 
 jquery.cookie:
-  type: file
-  src: https://raw.githubusercontent.com/carhartl/jquery-cookie/v1.3.1/jquery.cookie.js
-  integrity: sha384-Xxq63E9KDgzUJ6WPNPqVeOtRIwZyx6y9DzEwY2u6LYKSnWrjSoGtWSKmTindYBf2
+  type: multi-file
+  files:
+    jquery.cookie.js:
+      src: https://raw.githubusercontent.com/carhartl/jquery-cookie/v1.3.1/jquery.cookie.js
+      integrity: sha384-Xxq63E9KDgzUJ6WPNPqVeOtRIwZyx6y9DzEwY2u6LYKSnWrjSoGtWSKmTindYBf2
+    MIT-LICENSE.txt:
+      src: https://raw.githubusercontent.com/carhartl/jquery-cookie/v1.3.1/MIT-LICENSE.txt
+      integrity: sha384-zYsGf3KJ7S0AhOICjcoh0kkn7aGZlzYUXXX5xz8dwR9KjLMM+/JPR2g/jVOGGeId
+    CHANGELOG.md:
+      src: https://raw.githubusercontent.com/carhartl/jquery-cookie/v1.3.1/CHANGELOG.md
+      integrity: sha384-SQOHhLc7PHxHDQpGE/zv9XfXKL0A7OBu8kuyVDnHVp+zSoWyRw4xUJ+LSm5ql4kS
 
 mustache:
   type: multi-file
index e57fce9..9c832dc 100644 (file)
@@ -221,7 +221,7 @@ return [
                'dependencies' => 'mediawiki.jqueryMsg',
        ],
        'jquery.cookie' => [
-               'scripts' => 'resources/lib/jquery.cookie.js',
+               'scripts' => 'resources/lib/jquery.cookie/jquery.cookie.js',
                'targets' => [ 'desktop', 'mobile' ],
        ],
        'jquery.form' => [
diff --git a/resources/lib/jquery.cookie.js b/resources/lib/jquery.cookie.js
deleted file mode 100644 (file)
index 3fb201c..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*!
- * jQuery Cookie Plugin v1.3.1
- * https://github.com/carhartl/jquery-cookie
- *
- * Copyright 2013 Klaus Hartl
- * Released under the MIT license
- */
-(function ($, document, undefined) {
-
-       var pluses = /\+/g;
-
-       function raw(s) {
-               return s;
-       }
-
-       function decoded(s) {
-               return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
-       }
-
-       function unRfc2068(value) {
-               if (value.indexOf('"') === 0) {
-                       // This is a quoted cookie as according to RFC2068, unescape
-                       value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
-               }
-               return value;
-       }
-
-       function fromJSON(value) {
-               return config.json ? JSON.parse(value) : value;
-       }
-
-       var config = $.cookie = function (key, value, options) {
-
-               // write
-               if (value !== undefined) {
-                       options = $.extend({}, config.defaults, options);
-
-                       if (value === null) {
-                               options.expires = -1;
-                       }
-
-                       if (typeof options.expires === 'number') {
-                               var days = options.expires, t = options.expires = new Date();
-                               t.setDate(t.getDate() + days);
-                       }
-
-                       value = config.json ? JSON.stringify(value) : String(value);
-
-                       return (document.cookie = [
-                               encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
-                               options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
-                               options.path    ? '; path=' + options.path : '',
-                               options.domain  ? '; domain=' + options.domain : '',
-                               options.secure  ? '; secure' : ''
-                       ].join(''));
-               }
-
-               // read
-               var decode = config.raw ? raw : decoded;
-               var cookies = document.cookie.split('; ');
-               var result = key ? null : {};
-               for (var i = 0, l = cookies.length; i < l; i++) {
-                       var parts = cookies[i].split('=');
-                       var name = decode(parts.shift());
-                       var cookie = decode(parts.join('='));
-
-                       if (key && key === name) {
-                               result = fromJSON(cookie);
-                               break;
-                       }
-
-                       if (!key) {
-                               result[name] = fromJSON(cookie);
-                       }
-               }
-
-               return result;
-       };
-
-       config.defaults = {};
-
-       $.removeCookie = function (key, options) {
-               if ($.cookie(key) !== null) {
-                       $.cookie(key, null, options);
-                       return true;
-               }
-               return false;
-       };
-
-})(jQuery, document);
diff --git a/resources/lib/jquery.cookie/CHANGELOG.md b/resources/lib/jquery.cookie/CHANGELOG.md
new file mode 100644 (file)
index 0000000..f3ac692
--- /dev/null
@@ -0,0 +1,34 @@
+1.3.1
+-----
+- Fixing issue where it was no longer possible to check for an arbitrary cookie,
+  while json is set to true, there was a SyntaxError thrown from JSON.parse.
+
+1.3.0
+-----
+- Configuration options: `raw`, `json`. Replaces raw option, becomes config:
+
+  ```javascript
+  $.cookie.raw = true; // bypass encoding/decoding the cookie value
+  $.cookie.json = true; // automatically JSON stringify/parse value
+  ```
+  
+  Thus the default options now cleanly contain cookie attributes only.
+
+- Removing licensing under GPL Version 2, the plugin is now released under MIT License only
+(keeping it simple and following the jQuery library itself here).
+
+- Bugfix: Properly handle RFC 2068 quoted cookie values.
+
+- Added component.json for bower.
+
+- Added jQuery plugin package manifest.
+
+- `$.cookie()` returns all available cookies.
+
+1.2.0
+-----
+- Adding `$.removeCookie('foo')` for deleting a cookie, using `$.cookie('foo', null)` is now deprecated.
+
+1.1
+---
+- Adding default options.
diff --git a/resources/lib/jquery.cookie/MIT-LICENSE.txt b/resources/lib/jquery.cookie/MIT-LICENSE.txt
new file mode 100644 (file)
index 0000000..8ae647b
--- /dev/null
@@ -0,0 +1,20 @@
+Copyright 2013 Klaus Hartl
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/resources/lib/jquery.cookie/jquery.cookie.js b/resources/lib/jquery.cookie/jquery.cookie.js
new file mode 100644 (file)
index 0000000..3fb201c
--- /dev/null
@@ -0,0 +1,90 @@
+/*!
+ * jQuery Cookie Plugin v1.3.1
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2013 Klaus Hartl
+ * Released under the MIT license
+ */
+(function ($, document, undefined) {
+
+       var pluses = /\+/g;
+
+       function raw(s) {
+               return s;
+       }
+
+       function decoded(s) {
+               return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
+       }
+
+       function unRfc2068(value) {
+               if (value.indexOf('"') === 0) {
+                       // This is a quoted cookie as according to RFC2068, unescape
+                       value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+               }
+               return value;
+       }
+
+       function fromJSON(value) {
+               return config.json ? JSON.parse(value) : value;
+       }
+
+       var config = $.cookie = function (key, value, options) {
+
+               // write
+               if (value !== undefined) {
+                       options = $.extend({}, config.defaults, options);
+
+                       if (value === null) {
+                               options.expires = -1;
+                       }
+
+                       if (typeof options.expires === 'number') {
+                               var days = options.expires, t = options.expires = new Date();
+                               t.setDate(t.getDate() + days);
+                       }
+
+                       value = config.json ? JSON.stringify(value) : String(value);
+
+                       return (document.cookie = [
+                               encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
+                               options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+                               options.path    ? '; path=' + options.path : '',
+                               options.domain  ? '; domain=' + options.domain : '',
+                               options.secure  ? '; secure' : ''
+                       ].join(''));
+               }
+
+               // read
+               var decode = config.raw ? raw : decoded;
+               var cookies = document.cookie.split('; ');
+               var result = key ? null : {};
+               for (var i = 0, l = cookies.length; i < l; i++) {
+                       var parts = cookies[i].split('=');
+                       var name = decode(parts.shift());
+                       var cookie = decode(parts.join('='));
+
+                       if (key && key === name) {
+                               result = fromJSON(cookie);
+                               break;
+                       }
+
+                       if (!key) {
+                               result[name] = fromJSON(cookie);
+                       }
+               }
+
+               return result;
+       };
+
+       config.defaults = {};
+
+       $.removeCookie = function (key, options) {
+               if ($.cookie(key) !== null) {
+                       $.cookie(key, null, options);
+                       return true;
+               }
+               return false;
+       };
+
+})(jQuery, document);