Replace JS with links

This commit is contained in:
Peter Badida 2016-08-06 15:23:51 +02:00
parent e31299a5e7
commit ab375864d6
2 changed files with 13 additions and 111 deletions

View File

@ -298,110 +298,3 @@ $(document).ready(function () {
}
});
// get url for nightly wheel
// ajax from https://github.com/padolsey-archive/jquery.fn/tree/master/cross-domain-ajax
// <button onclick="getNightly('cp27','win32');">Get wheel!</button>
// leading zeros for date
function addZeros(num, size) {
var s = num + '';
while (s.length < size) s = '0' + s;
return s;
}
function wheelUrl(fromAjax, pyVer, arch) {
var prefixUrl = 'https://docs.google.com/uc?id=';
var fileID = 'entry-([a-zA-Z0-9\\-]*?)';
var htmlGarbage = '(?:" role="link" tabindex="0">\
<div class="flip-entry-info"><div class="flip-entry-visual">\
<div class="flip-entry-visual-card"><div class="flip-entry-icon">\
<img alt="Compressed Archive" src="https:\\/\\/ssl.gstatic.com\\/do\
cs\\/doclist\\/images\\/icon_9_archive_xl128\\.png"\\/><\\/div>\
<\\/div><\\/div><div class="flip-entry-list-icon"><img alt="" src="\
https:\\/\\/ssl\\.gstatic\\.com\\/docs\\/doclist\\/images\\/icon_9_\
archive_list\\.png"\\/><\\/div><div class="flip-entry-title">)';
var wheel = '(Kivy-\\d\\.\\d\\.\\d)(\\.\\w{4}_$date$_git\\_?\\w\
{7}-$pyVer$)(-none|_\\d{8}_git_\\w{7}-$pyVer$m)(-$arch$.whl)';
var date = new Date();
var yesterday = addZeros(date.getDate() - 1, 2);
var month = addZeros(date.getMonth() + 1, 2);
var year = date.getFullYear();
date = yesterday + month + year;
wheel = wheel.replace("$date$", date).replace("$pyVer$", pyVer);
wheel = wheel.replace("$pyVer$", pyVer).replace("$arch$", arch);
var regex = fileID + htmlGarbage + wheel;
var text = fromAjax.responseText;
try {
whlUrl = prefixUrl + text.match(new RegExp(regex))[1];
var win = window.open(whlUrl, '_blank');
if (win) {
win.focus();
}
else {
alert('Please allow pop-ups for this page!');
}
}
catch (e) {
alert('No nightly wheel is available yet!');
}
}
// getNightly('cp27', 'win32'); for cpXY and win32, win_amd64
function getNightly(pyVer, arch) {
var whlURL;
var driveUrl = 'https://drive.google.com/folderview?id=0B1_HB9J8\
mZepOV81UHpDbmg5SWM&usp=sharing#list';
jQuery.ajax = (function(_ajax) {
var protocol = location.protocol,
hostname = location.hostname,
exRegex = RegExp(protocol + '//' + hostname),
YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query\
.yahooapis.com/v1/public/yql?callback=?',
query = 'select * from html where url="{URL}" and xpath="*"';
function isExternal(url) {
return !exRegex.test(url) && /:\/\//.test(url);
}
return function(o) {
var url = o.url;
if (/get/i.test(o.type) && !/json/i.test(o.dataType) &&
isExternal(url)) {
o.url = YQL;
o.dataType = 'json';
o.data = {
q: query.replace(
'{URL}',
url + (o.data ?
(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
: '')
),
format: 'xml'
};
if (!o.success && o.complete) {
o.success = o.complete;
delete o.complete;
}
o.success = (function(_success) {
return function(data) {
var rx = /<script[^>]+?\/>|<script(.|\s)*?\/script>/gi;
if (_success) {
_success.call(this, {
responseText: data.results[0]
.replace(rx, '')
}, 'success');
}
};
})(o.success);
}
return _ajax.apply(this, arguments);
};
})(jQuery.ajax);
$.ajax({
url: driveUrl,
type: 'GET',
async: false,
success: function(res) {
wheelUrl(res, pyVer, arch);
}
});
}

View File

@ -69,10 +69,19 @@ Snapshot wheels of current Kivy master are created every night. They can be foun
To use them, instead of doing `python -m pip install kivy` we'll install one of
these wheels as follows.
- `Python 2.7, 32bit <javascript:getNightly('cp27','win32');>`_
- `Python 3.4, 32bit <javascript:getNightly('cp34','win32');>`_
- `Python 2.7, 64bit <javascript:getNightly('cp27','win_amd64');>`_
- `Python 3.4, 64bit <javascript:getNightly('cp34','win_amd64');>`_
.. |cp27_win32| replace:: Python 2.7, 32bit
.. _cp27_win32: https://drive.google.com/uc?id=0B-080DPVLKs2amMxY3o1cHNzRjQ
.. |cp34_win32| replace:: Python 3.4, 32bit
.. _cp34_win32: https://drive.google.com/uc?id=0B-080DPVLKs2TnpLb25lcUh3d0U
.. |cp27_amd64| replace:: Python 2.7, 64bit
.. _cp27_amd64: https://drive.google.com/uc?id=0B-080DPVLKs2TmRrMExqLVJ1M28
.. |cp34_amd64| replace:: Python 3.4, 64bit
.. _cp34_amd64: https://drive.google.com/uc?id=0B-080DPVLKs2eDlqQlJCRldkNE0
- |cp27_win32|_
- |cp34_win32|_
- |cp27_amd64|_
- |cp34_amd64|_
#. Perform steps 1 and 2 of the above Installation section.
#. Download the appropriate wheel for your system.