mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
41 lines
1014 B
JavaScript
41 lines
1014 B
JavaScript
// 'url' is assigned to in a statement before this.
|
|
var page = require('webpage').create();
|
|
|
|
var isReady = function () {
|
|
return page.evaluate(function () {
|
|
if (typeof Meteor === 'undefined'
|
|
|| Meteor.status === undefined
|
|
|| !Meteor.status().connected) {
|
|
return false;
|
|
}
|
|
if (typeof Package === 'undefined'
|
|
|| Package.spiderable === undefined
|
|
|| Package.spiderable.Spiderable === undefined
|
|
|| !Package.spiderable.Spiderable._initialSubscriptionsStarted) {
|
|
return false;
|
|
}
|
|
Tracker.flush();
|
|
return DDP._allSubscriptionsReady();
|
|
});
|
|
};
|
|
|
|
var dumpPageContent = function () {
|
|
var out = page.content;
|
|
out = out.replace(/<script[^>]+>(.|\n|\r)*?<\/script\s*>/ig, '');
|
|
out = out.replace('<meta name="fragment" content="!">', '');
|
|
console.log(out);
|
|
};
|
|
|
|
page.open(url, function(status) {
|
|
if (status === 'fail')
|
|
phantom.exit();
|
|
});
|
|
|
|
setInterval(function() {
|
|
if (isReady()) {
|
|
dumpPageContent();
|
|
phantom.exit();
|
|
}
|
|
}, 100);
|
|
|