diff --git a/versionwarning/_static/js/versionwarning.js b/versionwarning/_static/js/versionwarning.js index 8730da3..76c5244 100644 --- a/versionwarning/_static/js/versionwarning.js +++ b/versionwarning/_static/js/versionwarning.js @@ -1 +1 @@ -!function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){const n=t(1);function o(e){console.debug("checkVersion");var r=e.version;console.debug("Running version: "+r.slug);var t={project__slug:e.project.slug,active:"true"};$.ajax({url:e.meta.api_url+"version/",data:t,success:function(t){highest_version=function(e){var r;return console.debug("getHighestVersion"),$.each(e,function(e,t){n.valid(coerce(t.slug))&&(r?n.valid(coerce(t.slug))&&n.valid(coerce(r.slug))&&n.gt(coerce(t.slug),coerce(r.slug))&&(r=t):r=t)}),r}(t.results),n.valid(coerce(r.slug))&&n.valid(coerce(highest_version.slug))&&n.lt(coerce(r.slug),coerce(highest_version.slug))&&(console.debug("Highest version: "+highest_version.slug),function(e,r,t){console.debug("injectVersionWarningBanner");var n=window.location.pathname.replace(e.slug,r.slug),o=$(t.banner.html);o.find("a").attr("href",n).text(r.slug),$(t.banner.body_selector).prepend(o)}(r,highest_version,e))},error:function(){console.error("Error loading Read the Docs active versions.")}})}function i(){console.debug("init"),$.ajax({url:"_static/data/versionwarning-data.json",success:function(e){document.getElementById(e.banner.id_div)?console.debug("There is already a banner added. No checking versions."):e.banner.custom?function(e){console.debug("injectCustomWarningBanner");var r=$(e.banner.html);$(e.banner.body_selector).prepend(r)}(e):o(e)},error:function(){console.error("Error loading versionwarning-data.json")}})}$(document).ready(function(){i()})},function(e,r,t){(function(t){var n;r=e.exports=W,n="object"==typeof t&&t.env&&t.env.NODE_DEBUG&&/\bsemver\b/i.test(t.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},r.SEMVER_SPEC_VERSION="2.0.0";var o=256,i=Number.MAX_SAFE_INTEGER||9007199254740991,s=r.re=[],a=r.src=[],u=0,c=u++;a[c]="0|[1-9]\\d*";var l=u++;a[l]="[0-9]+";var p=u++;a[p]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var h=u++;a[h]="("+a[c]+")\\.("+a[c]+")\\.("+a[c]+")";var f=u++;a[f]="("+a[l]+")\\.("+a[l]+")\\.("+a[l]+")";var v=u++;a[v]="(?:"+a[c]+"|"+a[p]+")";var m=u++;a[m]="(?:"+a[l]+"|"+a[p]+")";var g=u++;a[g]="(?:-("+a[v]+"(?:\\."+a[v]+")*))";var d=u++;a[d]="(?:-?("+a[m]+"(?:\\."+a[m]+")*))";var w=u++;a[w]="[0-9A-Za-z-]+";var y=u++;a[y]="(?:\\+("+a[w]+"(?:\\."+a[w]+")*))";var b=u++,j="v?"+a[h]+a[g]+"?"+a[y]+"?";a[b]="^"+j+"$";var E="[v=\\s]*"+a[f]+a[d]+"?"+a[y]+"?",T=u++;a[T]="^"+E+"$";var $=u++;a[$]="((?:<|>)?=?)";var _=u++;a[_]=a[l]+"|x|X|\\*";var k=u++;a[k]=a[c]+"|x|X|\\*";var x=u++;a[x]="[v=\\s]*("+a[k]+")(?:\\.("+a[k]+")(?:\\.("+a[k]+")(?:"+a[g]+")?"+a[y]+"?)?)?";var S=u++;a[S]="[v=\\s]*("+a[_]+")(?:\\.("+a[_]+")(?:\\.("+a[_]+")(?:"+a[d]+")?"+a[y]+"?)?)?";var R=u++;a[R]="^"+a[$]+"\\s*"+a[x]+"$";var I=u++;a[I]="^"+a[$]+"\\s*"+a[S]+"$";var V=u++;a[V]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var O=u++;a[O]="(?:~>?)";var A=u++;a[A]="(\\s*)"+a[O]+"\\s+",s[A]=new RegExp(a[A],"g");var M=u++;a[M]="^"+a[O]+a[x]+"$";var C=u++;a[C]="^"+a[O]+a[S]+"$";var N=u++;a[N]="(?:\\^)";var P=u++;a[P]="(\\s*)"+a[N]+"\\s+",s[P]=new RegExp(a[P],"g");var L=u++;a[L]="^"+a[N]+a[x]+"$";var B=u++;a[B]="^"+a[N]+a[S]+"$";var D=u++;a[D]="^"+a[$]+"\\s*("+E+")$|^$";var q=u++;a[q]="^"+a[$]+"\\s*("+j+")$|^$";var X=u++;a[X]="(\\s*)"+a[$]+"\\s*("+E+"|"+a[x]+")",s[X]=new RegExp(a[X],"g");var z=u++;a[z]="^\\s*("+a[x]+")\\s+-\\s+("+a[x]+")\\s*$";var G=u++;a[G]="^\\s*("+a[S]+")\\s+-\\s+("+a[S]+")\\s*$";var Z=u++;a[Z]="(<|>)?=?\\s*\\*";for(var H=0;Ho)return null;if(!(r?s[T]:s[b]).test(e))return null;try{return new W(e,r)}catch(e){return null}}function W(e,r){if(e instanceof W){if(e.loose===r)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>o)throw new TypeError("version is longer than "+o+" characters");if(!(this instanceof W))return new W(e,r);n("SemVer",e,r),this.loose=r;var t=e.trim().match(r?s[T]:s[b]);if(!t)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+t[1],this.minor=+t[2],this.patch=+t[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");t[4]?this.prerelease=t[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var r=+e;if(r>=0&&r=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},r.inc=function(e,r,t,n){"string"==typeof t&&(n=t,t=void 0);try{return new W(e,t).inc(r,n).version}catch(e){return null}},r.diff=function(e,r){if(ee(e,r))return null;var t=U(e),n=U(r);if(t.prerelease.length||n.prerelease.length){for(var o in t)if(("major"===o||"minor"===o||"patch"===o)&&t[o]!==n[o])return"pre"+o;return"prerelease"}for(var o in t)if(("major"===o||"minor"===o||"patch"===o)&&t[o]!==n[o])return o},r.compareIdentifiers=J;var F=/^[0-9]+$/;function J(e,r){var t=F.test(e),n=F.test(r);return t&&n&&(e=+e,r=+r),t&&!n?-1:n&&!t?1:er?1:0}function K(e,r,t){return new W(e,t).compare(new W(r,t))}function Q(e,r,t){return K(e,r,t)>0}function Y(e,r,t){return K(e,r,t)<0}function ee(e,r,t){return 0===K(e,r,t)}function re(e,r,t){return 0!==K(e,r,t)}function te(e,r,t){return K(e,r,t)>=0}function ne(e,r,t){return K(e,r,t)<=0}function oe(e,r,t,n){var o;switch(r){case"===":"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),o=e===t;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),o=e!==t;break;case"":case"=":case"==":o=ee(e,t,n);break;case"!=":o=re(e,t,n);break;case">":o=Q(e,t,n);break;case">=":o=te(e,t,n);break;case"<":o=Y(e,t,n);break;case"<=":o=ne(e,t,n);break;default:throw new TypeError("Invalid operator: "+r)}return o}function ie(e,r){if(e instanceof ie){if(e.loose===r)return e;e=e.value}if(!(this instanceof ie))return new ie(e,r);n("comparator",e,r),this.loose=r,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,n("comp",this)}r.rcompareIdentifiers=function(e,r){return J(r,e)},r.major=function(e,r){return new W(e,r).major},r.minor=function(e,r){return new W(e,r).minor},r.patch=function(e,r){return new W(e,r).patch},r.compare=K,r.compareLoose=function(e,r){return K(e,r,!0)},r.rcompare=function(e,r,t){return K(r,e,t)},r.sort=function(e,t){return e.sort(function(e,n){return r.compare(e,n,t)})},r.rsort=function(e,t){return e.sort(function(e,n){return r.rcompare(e,n,t)})},r.gt=Q,r.lt=Y,r.eq=ee,r.neq=re,r.gte=te,r.lte=ne,r.cmp=oe,r.Comparator=ie;var se={};function ae(e,r){if(e instanceof ae)return e.loose===r?e:new ae(e.raw,r);if(e instanceof ie)return new ae(e.value,r);if(!(this instanceof ae))return new ae(e,r);if(this.loose=r,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function ue(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,r,t,n,o,i,s,a,u,c,l,p,h){return((r=ue(t)?"":ue(n)?">="+t+".0.0":ue(o)?">="+t+"."+n+".0":">="+r)+" "+(a=ue(u)?"":ue(c)?"<"+(+u+1)+".0.0":ue(l)?"<"+u+"."+(+c+1)+".0":p?"<="+u+"."+c+"."+l+"-"+p:"<="+a)).trim()}function le(e,r){for(var t=0;t0){var o=e[t].semver;if(o.major===r.major&&o.minor===r.minor&&o.patch===r.patch)return!0}return!1}return!0}function pe(e,r,t){try{r=new ae(r,t)}catch(e){return!1}return r.test(e)}function he(e,r,t,n){var o,i,s,a,u;switch(e=new W(e,n),r=new ae(r,n),t){case">":o=Q,i=ne,s=Y,a=">",u=">=";break;case"<":o=Y,i=te,s=Q,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(pe(e,r,n))return!1;for(var c=0;c=0.0.0")),l=l||e,p=p||e,o(e.semver,l.semver,n)?l=e:s(e.semver,p.semver,n)&&(p=e)}),l.operator===a||l.operator===u)return!1;if((!p.operator||p.operator===a)&&i(e,p.semver))return!1;if(p.operator===u&&s(e,p.semver))return!1}return!0}ie.prototype.parse=function(e){var r=this.loose?s[D]:s[q],t=e.match(r);if(!t)throw new TypeError("Invalid comparator: "+e);this.operator=t[1],"="===this.operator&&(this.operator=""),t[2]?this.semver=new W(t[2],this.loose):this.semver=se},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return n("Comparator.test",e,this.loose),this.semver===se||("string"==typeof e&&(e=new W(e,this.loose)),oe(e,this.operator,this.semver,this.loose))},ie.prototype.intersects=function(e,r){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var t;if(""===this.operator)return t=new ae(e.value,r),pe(this.value,t,r);if(""===e.operator)return t=new ae(this.value,r),pe(e.semver,t,r);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),o=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),i=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=oe(this.semver,"<",e.semver,r)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=oe(this.semver,">",e.semver,r)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||o||i&&s||a||u},r.Range=ae,ae.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},ae.prototype.toString=function(){return this.range},ae.prototype.parseRange=function(e){var r=this.loose;e=e.trim(),n("range",e,r);var t=r?s[G]:s[z];e=e.replace(t,ce),n("hyphen replace",e),e=e.replace(s[X],"$1$2$3"),n("comparator trim",e,s[X]),e=(e=(e=e.replace(s[A],"$1~")).replace(s[P],"$1^")).split(/\s+/).join(" ");var o=r?s[D]:s[q],i=e.split(" ").map(function(e){return function(e,r){return n("comp",e),e=function(e,r){return e.trim().split(/\s+/).map(function(e){return function(e,r){n("caret",e,r);var t=r?s[B]:s[L];return e.replace(t,function(r,t,o,i,s){var a;return n("caret",e,r,t,o,i,s),ue(t)?a="":ue(o)?a=">="+t+".0.0 <"+(+t+1)+".0.0":ue(i)?a="0"===t?">="+t+"."+o+".0 <"+t+"."+(+o+1)+".0":">="+t+"."+o+".0 <"+(+t+1)+".0.0":s?(n("replaceCaret pr",s),"-"!==s.charAt(0)&&(s="-"+s),a="0"===t?"0"===o?">="+t+"."+o+"."+i+s+" <"+t+"."+o+"."+(+i+1):">="+t+"."+o+"."+i+s+" <"+t+"."+(+o+1)+".0":">="+t+"."+o+"."+i+s+" <"+(+t+1)+".0.0"):(n("no pr"),a="0"===t?"0"===o?">="+t+"."+o+"."+i+" <"+t+"."+o+"."+(+i+1):">="+t+"."+o+"."+i+" <"+t+"."+(+o+1)+".0":">="+t+"."+o+"."+i+" <"+(+t+1)+".0.0"),n("caret return",a),a})}(e,r)}).join(" ")}(e,r),n("caret",e),e=function(e,r){return e.trim().split(/\s+/).map(function(e){return function(e,r){var t=r?s[C]:s[M];return e.replace(t,function(r,t,o,i,s){var a;return n("tilde",e,r,t,o,i,s),ue(t)?a="":ue(o)?a=">="+t+".0.0 <"+(+t+1)+".0.0":ue(i)?a=">="+t+"."+o+".0 <"+t+"."+(+o+1)+".0":s?(n("replaceTilde pr",s),"-"!==s.charAt(0)&&(s="-"+s),a=">="+t+"."+o+"."+i+s+" <"+t+"."+(+o+1)+".0"):a=">="+t+"."+o+"."+i+" <"+t+"."+(+o+1)+".0",n("tilde return",a),a})}(e,r)}).join(" ")}(e,r),n("tildes",e),e=function(e,r){return n("replaceXRanges",e,r),e.split(/\s+/).map(function(e){return function(e,r){e=e.trim();var t=r?s[I]:s[R];return e.replace(t,function(r,t,o,i,s,a){n("xRange",e,r,t,o,i,s,a);var u=ue(o),c=u||ue(i),l=c||ue(s),p=l;return"="===t&&p&&(t=""),u?r=">"===t||"<"===t?"<0.0.0":"*":t&&p?(c&&(i=0),l&&(s=0),">"===t?(t=">=",c?(o=+o+1,i=0,s=0):l&&(i=+i+1,s=0)):"<="===t&&(t="<",c?o=+o+1:i=+i+1),r=t+o+"."+i+"."+s):c?r=">="+o+".0.0 <"+(+o+1)+".0.0":l&&(r=">="+o+"."+i+".0 <"+o+"."+(+i+1)+".0"),n("xRange return",r),r})}(e,r)}).join(" ")}(e,r),n("xrange",e),e=function(e,r){return n("replaceStars",e,r),e.trim().replace(s[Z],"")}(e,r),n("stars",e),e}(e,r)}).join(" ").split(/\s+/);return this.loose&&(i=i.filter(function(e){return!!e.match(o)})),i=i.map(function(e){return new ie(e,r)})},ae.prototype.intersects=function(e,r){if(!(e instanceof ae))throw new TypeError("a Range is required");return this.set.some(function(t){return t.every(function(t){return e.set.some(function(e){return e.every(function(e){return t.intersects(e,r)})})})})},r.toComparators=function(e,r){return new ae(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},ae.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new W(e,this.loose));for(var r=0;r",t)},r.outside=he,r.prerelease=function(e,r){var t=U(e,r);return t&&t.prerelease.length?t.prerelease:null},r.intersects=function(e,r,t){return e=new ae(e,t),r=new ae(r,t),e.intersects(r)},r.coerce=function(e){if(e instanceof W)return e;if("string"!=typeof e)return null;var r=e.match(s[V]);return null==r?null:U((r[1]||"0")+"."+(r[2]||"0")+"."+(r[3]||"0"))}}).call(this,t(2))},function(e,r){var t,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],l=!1,p=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&f())}function f(){if(!l){var e=a(h);l=!0;for(var r=c.length;r;){for(u=c,c=[];++p1)for(var t=1;t)?=?)";var $=u++;a[$]=a[l]+"|x|X|\\*";var x=u++;a[x]=a[c]+"|x|X|\\*";var k=u++;a[k]="[v=\\s]*("+a[x]+")(?:\\.("+a[x]+")(?:\\.("+a[x]+")(?:"+a[g]+")?"+a[w]+"?)?)?";var P=u++;a[P]="[v=\\s]*("+a[$]+")(?:\\.("+a[$]+")(?:\\.("+a[$]+")(?:"+a[d]+")?"+a[w]+"?)?)?";var S=u++;a[S]="^"+a[_]+"\\s*"+a[k]+"$";var R=u++;a[R]="^"+a[_]+"\\s*"+a[P]+"$";var I=u++;a[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var O=u++;a[O]="(?:~>?)";var V=u++;a[V]="(\\s*)"+a[O]+"\\s+",s[V]=new RegExp(a[V],"g");var A=u++;a[A]="^"+a[O]+a[k]+"$";var M=u++;a[M]="^"+a[O]+a[P]+"$";var N=u++;a[N]="(?:\\^)";var C=u++;a[C]="(\\s*)"+a[N]+"\\s+",s[C]=new RegExp(a[C],"g");var L=u++;a[L]="^"+a[N]+a[k]+"$";var B=u++;a[B]="^"+a[N]+a[P]+"$";var D=u++;a[D]="^"+a[_]+"\\s*("+E+")$|^$";var q=u++;a[q]="^"+a[_]+"\\s*("+j+")$|^$";var X=u++;a[X]="(\\s*)"+a[_]+"\\s*("+E+"|"+a[k]+")",s[X]=new RegExp(a[X],"g");var z=u++;a[z]="^\\s*("+a[k]+")\\s+-\\s+("+a[k]+")\\s*$";var G=u++;a[G]="^\\s*("+a[P]+")\\s+-\\s+("+a[P]+")\\s*$";var Z=u++;a[Z]="(<|>)?=?\\s*\\*";for(var H=0;Ho)return null;if(!(r.loose?s[T]:s[b]).test(e))return null;try{return new W(e,r)}catch(e){return null}}function W(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof W){if(e.loose===r.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>o)throw new TypeError("version is longer than "+o+" characters");if(!(this instanceof W))return new W(e,r);n("SemVer",e,r),this.options=r,this.loose=!!r.loose;var t=e.trim().match(r.loose?s[T]:s[b]);if(!t)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+t[1],this.minor=+t[2],this.patch=+t[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");t[4]?this.prerelease=t[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var r=+e;if(r>=0&&r=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},r.inc=function(e,r,t,n){"string"==typeof t&&(n=t,t=void 0);try{return new W(e,t).inc(r,n).version}catch(e){return null}},r.diff=function(e,r){if(ee(e,r))return null;var t=U(e),n=U(r);if(t.prerelease.length||n.prerelease.length){for(var o in t)if(("major"===o||"minor"===o||"patch"===o)&&t[o]!==n[o])return"pre"+o;return"prerelease"}for(var o in t)if(("major"===o||"minor"===o||"patch"===o)&&t[o]!==n[o])return o},r.compareIdentifiers=J;var F=/^[0-9]+$/;function J(e,r){var t=F.test(e),n=F.test(r);return t&&n&&(e=+e,r=+r),t&&!n?-1:n&&!t?1:er?1:0}function K(e,r,t){return new W(e,t).compare(new W(r,t))}function Q(e,r,t){return K(e,r,t)>0}function Y(e,r,t){return K(e,r,t)<0}function ee(e,r,t){return 0===K(e,r,t)}function re(e,r,t){return 0!==K(e,r,t)}function te(e,r,t){return K(e,r,t)>=0}function ne(e,r,t){return K(e,r,t)<=0}function oe(e,r,t,n){var o;switch(r){case"===":"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),o=e===t;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),o=e!==t;break;case"":case"=":case"==":o=ee(e,t,n);break;case"!=":o=re(e,t,n);break;case">":o=Q(e,t,n);break;case">=":o=te(e,t,n);break;case"<":o=Y(e,t,n);break;case"<=":o=ne(e,t,n);break;default:throw new TypeError("Invalid operator: "+r)}return o}function ie(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof ie){if(e.loose===!!r.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,r);n("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,n("comp",this)}r.rcompareIdentifiers=function(e,r){return J(r,e)},r.major=function(e,r){return new W(e,r).major},r.minor=function(e,r){return new W(e,r).minor},r.patch=function(e,r){return new W(e,r).patch},r.compare=K,r.compareLoose=function(e,r){return K(e,r,!0)},r.rcompare=function(e,r,t){return K(r,e,t)},r.sort=function(e,t){return e.sort(function(e,n){return r.compare(e,n,t)})},r.rsort=function(e,t){return e.sort(function(e,n){return r.rcompare(e,n,t)})},r.gt=Q,r.lt=Y,r.eq=ee,r.neq=re,r.gte=te,r.lte=ne,r.cmp=oe,r.Comparator=ie;var se={};function ae(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof ae)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new ae(e.raw,r);if(e instanceof ie)return new ae(e.value,r);if(!(this instanceof ae))return new ae(e,r);if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function ue(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,r,t,n,o,i,s,a,u,c,l,p,h){return((r=ue(t)?"":ue(n)?">="+t+".0.0":ue(o)?">="+t+"."+n+".0":">="+r)+" "+(a=ue(u)?"":ue(c)?"<"+(+u+1)+".0.0":ue(l)?"<"+u+"."+(+c+1)+".0":p?"<="+u+"."+c+"."+l+"-"+p:"<="+a)).trim()}function le(e,r,t){for(var o=0;o0){var i=e[o].semver;if(i.major===r.major&&i.minor===r.minor&&i.patch===r.patch)return!0}return!1}return!0}function pe(e,r,t){try{r=new ae(r,t)}catch(e){return!1}return r.test(e)}function he(e,r,t,n){var o,i,s,a,u;switch(e=new W(e,n),r=new ae(r,n),t){case">":o=Q,i=ne,s=Y,a=">",u=">=";break;case"<":o=Y,i=te,s=Q,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(pe(e,r,n))return!1;for(var c=0;c=0.0.0")),l=l||e,p=p||e,o(e.semver,l.semver,n)?l=e:s(e.semver,p.semver,n)&&(p=e)}),l.operator===a||l.operator===u)return!1;if((!p.operator||p.operator===a)&&i(e,p.semver))return!1;if(p.operator===u&&s(e,p.semver))return!1}return!0}ie.prototype.parse=function(e){var r=this.options.loose?s[D]:s[q],t=e.match(r);if(!t)throw new TypeError("Invalid comparator: "+e);this.operator=t[1],"="===this.operator&&(this.operator=""),t[2]?this.semver=new W(t[2],this.options.loose):this.semver=se},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return n("Comparator.test",e,this.options.loose),this.semver===se||("string"==typeof e&&(e=new W(e,this.options)),oe(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,r){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var t;if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),""===this.operator)return t=new ae(e.value,r),pe(this.value,t,r);if(""===e.operator)return t=new ae(this.value,r),pe(e.semver,t,r);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),o=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),i=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=oe(this.semver,"<",e.semver,r)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=oe(this.semver,">",e.semver,r)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||o||i&&s||a||u},r.Range=ae,ae.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},ae.prototype.toString=function(){return this.range},ae.prototype.parseRange=function(e){var r=this.options.loose;e=e.trim();var t=r?s[G]:s[z];e=e.replace(t,ce),n("hyphen replace",e),e=e.replace(s[X],"$1$2$3"),n("comparator trim",e,s[X]),e=(e=(e=e.replace(s[V],"$1~")).replace(s[C],"$1^")).split(/\s+/).join(" ");var o=r?s[D]:s[q],i=e.split(" ").map(function(e){return function(e,r){return n("comp",e,r),e=function(e,r){return e.trim().split(/\s+/).map(function(e){return function(e,r){n("caret",e,r),r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1});var t=r.loose?s[B]:s[L];return e.replace(t,function(r,t,o,i,s){var a;return n("caret",e,r,t,o,i,s),ue(t)?a="":ue(o)?a=">="+t+".0.0 <"+(+t+1)+".0.0":ue(i)?a="0"===t?">="+t+"."+o+".0 <"+t+"."+(+o+1)+".0":">="+t+"."+o+".0 <"+(+t+1)+".0.0":s?(n("replaceCaret pr",s),"-"!==s.charAt(0)&&(s="-"+s),a="0"===t?"0"===o?">="+t+"."+o+"."+i+s+" <"+t+"."+o+"."+(+i+1):">="+t+"."+o+"."+i+s+" <"+t+"."+(+o+1)+".0":">="+t+"."+o+"."+i+s+" <"+(+t+1)+".0.0"):(n("no pr"),a="0"===t?"0"===o?">="+t+"."+o+"."+i+" <"+t+"."+o+"."+(+i+1):">="+t+"."+o+"."+i+" <"+t+"."+(+o+1)+".0":">="+t+"."+o+"."+i+" <"+(+t+1)+".0.0"),n("caret return",a),a})}(e,r)}).join(" ")}(e,r),n("caret",e),e=function(e,r){return e.trim().split(/\s+/).map(function(e){return function(e,r){r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1});var t=r.loose?s[M]:s[A];return e.replace(t,function(r,t,o,i,s){var a;return n("tilde",e,r,t,o,i,s),ue(t)?a="":ue(o)?a=">="+t+".0.0 <"+(+t+1)+".0.0":ue(i)?a=">="+t+"."+o+".0 <"+t+"."+(+o+1)+".0":s?(n("replaceTilde pr",s),"-"!==s.charAt(0)&&(s="-"+s),a=">="+t+"."+o+"."+i+s+" <"+t+"."+(+o+1)+".0"):a=">="+t+"."+o+"."+i+" <"+t+"."+(+o+1)+".0",n("tilde return",a),a})}(e,r)}).join(" ")}(e,r),n("tildes",e),e=function(e,r){return n("replaceXRanges",e,r),e.split(/\s+/).map(function(e){return function(e,r){e=e.trim(),r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1});var t=r.loose?s[R]:s[S];return e.replace(t,function(r,t,o,i,s,a){n("xRange",e,r,t,o,i,s,a);var u=ue(o),c=u||ue(i),l=c||ue(s),p=l;return"="===t&&p&&(t=""),u?r=">"===t||"<"===t?"<0.0.0":"*":t&&p?(c&&(i=0),l&&(s=0),">"===t?(t=">=",c?(o=+o+1,i=0,s=0):l&&(i=+i+1,s=0)):"<="===t&&(t="<",c?o=+o+1:i=+i+1),r=t+o+"."+i+"."+s):c?r=">="+o+".0.0 <"+(+o+1)+".0.0":l&&(r=">="+o+"."+i+".0 <"+o+"."+(+i+1)+".0"),n("xRange return",r),r})}(e,r)}).join(" ")}(e,r),n("xrange",e),e=function(e,r){return n("replaceStars",e,r),e.trim().replace(s[Z],"")}(e,r),n("stars",e),e}(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(i=i.filter(function(e){return!!e.match(o)})),i=i.map(function(e){return new ie(e,this.options)},this)},ae.prototype.intersects=function(e,r){if(!(e instanceof ae))throw new TypeError("a Range is required");return this.set.some(function(t){return t.every(function(t){return e.set.some(function(e){return e.every(function(e){return t.intersects(e,r)})})})})},r.toComparators=function(e,r){return new ae(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},ae.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new W(e,this.options));for(var r=0;r",t)},r.outside=he,r.prerelease=function(e,r){var t=U(e,r);return t&&t.prerelease.length?t.prerelease:null},r.intersects=function(e,r,t){return e=new ae(e,t),r=new ae(r,t),e.intersects(r)},r.coerce=function(e){if(e instanceof W)return e;if("string"!=typeof e)return null;var r=e.match(s[I]);return null==r?null:U((r[1]||"0")+"."+(r[2]||"0")+"."+(r[3]||"0"))}}).call(this,t(2))},function(e,r){var t,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],l=!1,p=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&f())}function f(){if(!l){var e=a(h);l=!0;for(var r=c.length;r;){for(u=c,c=[];++p1)for(var t=1;t= (1, 8): # ``config-initied`` requires Sphinx >= 1.8 app.connect('config-inited', generate_versionwarning_data_json) diff --git a/versionwarning/signals.py b/versionwarning/signals.py index d80da4c..53fbe6b 100644 --- a/versionwarning/signals.py +++ b/versionwarning/signals.py @@ -3,6 +3,8 @@ import json import os +from versionwarning.exceptions import ConfigError + STATIC_PATH = os.path.join(os.path.dirname(__file__), '_static') JSON_DATA_FILENAME = 'versionwarning-data.json' @@ -27,6 +29,9 @@ def generate_versionwarning_data_json(app, config=None, **kwargs): if config is None: config = app.config + if not config.versionwarning_retrieve_data_from_api and not config.versionwarning_json_url: + raise ConfigError(ConfigError.NO_JSON_URL) + if config.versionwarning_project_version in config.versionwarning_messages: custom = True message = config.versionwarning_messages.get(config.versionwarning_project_version) @@ -43,15 +48,14 @@ def generate_versionwarning_data_json(app, config=None, **kwargs): admonition_type=config.versionwarning_admonition_type, ) - data = json.dumps({ - 'meta': { - 'api_url': config.versionwarning_api_url, - }, + data = { 'banner': { - 'html': banner_html, - 'id_div': config.versionwarning_banner_id_div, - 'body_selector': config.versionwarning_body_selector, - 'custom': custom, + config.versionwarning_project_version: { + 'html': banner_html, + 'id_div': config.versionwarning_banner_id_div, + 'body_selector': config.versionwarning_body_selector, + 'custom': custom, + }, }, 'project': { 'slug': config.versionwarning_project_slug, @@ -59,14 +63,29 @@ def generate_versionwarning_data_json(app, config=None, **kwargs): 'version': { 'slug': config.versionwarning_project_version, }, - }, indent=4) + } + + if config.versionwarning_retrieve_data_from_api: + url_key = 'api_url' + url = config.versionwarning_api_url + else: + url_key = 'json_url' + url = config.versionwarning_json_url + + data.update({ + 'meta': { + url_key: url, + 'retrieve_data_from_api': config.versionwarning_retrieve_data_from_api, + 'only_override_banner': config.versionwarning_only_override_banner, + }, + }) data_path = os.path.join(STATIC_PATH, 'data') if not os.path.exists(data_path): os.mkdir(data_path) with open(os.path.join(data_path, JSON_DATA_FILENAME), 'w') as f: - f.write(data) + f.write(json.dumps(data, indent=4)) # Add the path where ``versionwarning-data.json`` file and # ``versionwarning.js`` are saved