Merge branch 'master' of ssh://bitbucket.org/yackob03/quay
This commit is contained in:
commit
77532dff33
3 changed files with 49 additions and 24 deletions
|
@ -3789,6 +3789,8 @@ quayApp.directive('setupTriggerDialog', function () {
|
||||||
var modalSetup = false;
|
var modalSetup = false;
|
||||||
|
|
||||||
$scope.show = function() {
|
$scope.show = function() {
|
||||||
|
if (!$scope.trigger || !$scope.repository) { return; }
|
||||||
|
|
||||||
$scope.activating = false;
|
$scope.activating = false;
|
||||||
$scope.pullEntity = null;
|
$scope.pullEntity = null;
|
||||||
$scope.publicPull = true;
|
$scope.publicPull = true;
|
||||||
|
@ -3798,7 +3800,7 @@ quayApp.directive('setupTriggerDialog', function () {
|
||||||
|
|
||||||
if (!modalSetup) {
|
if (!modalSetup) {
|
||||||
$('#setupTriggerModal').on('hidden.bs.modal', function () {
|
$('#setupTriggerModal').on('hidden.bs.modal', function () {
|
||||||
if ($scope.trigger['is_active']) { return; }
|
if (!$scope.trigger || $scope.trigger['is_active']) { return; }
|
||||||
|
|
||||||
$scope.$apply(function() {
|
$scope.$apply(function() {
|
||||||
$scope.cancelSetupTrigger();
|
$scope.cancelSetupTrigger();
|
||||||
|
|
|
@ -1,37 +1,55 @@
|
||||||
var system = require('system');
|
var system = require('system');
|
||||||
var url = system.args[1] || '';
|
var url = system.args[1] || '';
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
if(url.length > 0) {
|
if(url.length > 0) {
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
page.open(url, function (status) {
|
page.open(url, function (status) {
|
||||||
if (status == 'success') {
|
try {
|
||||||
var delay, checker = (function() {
|
if (status == 'success') {
|
||||||
var html = page.evaluate(function () {
|
var delay;
|
||||||
var found = document.getElementsByTagName('html')[0].outerHTML || '';
|
var checker = (function() {
|
||||||
if (window.__isLoading && !window.__isLoading()) {
|
count++;
|
||||||
return found;
|
|
||||||
}
|
|
||||||
if (found.indexOf('404 Not Found') > 0) {
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (html) {
|
if (count > 100) {
|
||||||
if (html.indexOf('404 Not Found') > 0) {
|
|
||||||
console.log('Not Found');
|
console.log('Not Found');
|
||||||
phantom.exit();
|
phantom.exit();
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(delay);
|
var html = page.evaluate(function () {
|
||||||
console.log(html);
|
var found = document.getElementsByTagName('html')[0].outerHTML || '';
|
||||||
phantom.exit();
|
if (window.__isLoading && !window.__isLoading()) {
|
||||||
}
|
return found;
|
||||||
});
|
}
|
||||||
delay = setInterval(checker, 100);
|
if (found.indexOf('404 Not Found') > 0) {
|
||||||
} else {
|
return found;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (html) {
|
||||||
|
if (html.indexOf('404 Not Found') > 0) {
|
||||||
|
console.log('Not Found');
|
||||||
|
phantom.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearTimeout(delay);
|
||||||
|
console.log(html);
|
||||||
|
phantom.exit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
delay = setInterval(checker, 100);
|
||||||
|
} else {
|
||||||
|
console.log('Not Found');
|
||||||
|
phantom.exit();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
console.log('Not Found');
|
console.log('Not Found');
|
||||||
phantom.exit();
|
phantom.exit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
phantom.exit();
|
||||||
}
|
}
|
|
@ -3,22 +3,27 @@ import logging
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def render_snapshot(url):
|
def render_snapshot(url):
|
||||||
logger.info('Snapshotting url: %s' % url)
|
logger.info('Snapshotting url: %s' % url)
|
||||||
|
|
||||||
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
|
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
|
||||||
|
'--disk-cache=yes',
|
||||||
'util/phantomjs-runner.js', url])
|
'util/phantomjs-runner.js', url])
|
||||||
|
|
||||||
if not out_html or out_html.strip() == 'Not Found':
|
if not out_html or out_html.strip() == 'Not Found':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Remove script tags
|
# Remove script tags
|
||||||
|
logger.info('Removing script tags: %s' % url)
|
||||||
|
|
||||||
soup = BeautifulSoup(out_html.decode('utf8'))
|
soup = BeautifulSoup(out_html.decode('utf8'))
|
||||||
to_extract = soup.findAll('script')
|
to_extract = soup.findAll('script')
|
||||||
for item in to_extract:
|
for item in to_extract:
|
||||||
item.extract()
|
item.extract()
|
||||||
|
|
||||||
|
logger.info('Snapshotted url: %s' % url)
|
||||||
|
|
||||||
return str(soup)
|
return str(soup)
|
||||||
|
|
Reference in a new issue