Skip to content

Commit

Permalink
Utils: Prepared cloud samples downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed May 23, 2016
1 parent b8a934d commit 9e64b1e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -51,3 +51,4 @@ nbproject/
*.log
samples/highcharts/common-js/browserify/demo.js
samples/highcharts/common-js/webpack/demo.js
/samples/cloud/charts
45 changes: 28 additions & 17 deletions cloud-downloader.js
@@ -1,20 +1,42 @@
"use strict";
/* eslint-env node, es6 */
/* eslint no-console: 0, require-jsdoc: 0 */

/**
* This script retrieves the n most popular charts from cloud.highcharts.com, downloads
* the configurations and prepare them for side-by-side testing in
* http://utils.highcharts.local/samples.
* The downloaded charts can be viewed under the "cloud" heading.
*/

'use strict';

let co = require('co');
let fs = require('co-fs-extra');
let request = require('co-request');
let properties = require('properties');


function wrap(script) {
return 'window.addEventListener("DOMContentLoaded", function () {' + script + '});\n';
}

function html(hash) {
return '<script src="https://code.highcharts.com/stock/highstock.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/data.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>' +
'<div id="highcharts-' + hash + '"></div>';
}

co(function* () {
let props = yield new Promise((resolve, reject) => {
properties.parse ("git-ignore-me.properties", { path: true }, function (error, props){
return error ? reject(error) : resolve(props);
properties.parse('git-ignore-me.properties', { path: true }, function (error, obj) {
return error ? reject(error) : resolve(obj);
});
});

let result = yield request({
uri: props['cloud.uri'] + "/api/charts/popular/",
method: "POST",
uri: props['cloud.uri'] + '/api/charts/popular/',
method: 'POST',
json: {
authentication: props['cloud.authentication'],
limit: props['cloud.limit']
Expand All @@ -31,7 +53,7 @@ co(function* () {

for (let i = 0; i < hashes.length; i++) {
console.log('Downloading script: ' + hashes[i] + ' (' + (i + 1) + '/' + hashes.length + ')');
let scriptResult = yield request.get(props['cloud.uri'] + "/inject/" + hashes[i]);
let scriptResult = yield request.get(props['cloud.uri'] + '/inject/' + hashes[i]);
let script = scriptResult.body;

let path = targetDir + hashes[i] + '/';
Expand All @@ -46,14 +68,3 @@ co(function* () {
}).catch(function (err) {
console.log(err);
});

function wrap(script) {
return "window.addEventListener('DOMContentLoaded', function () {" + script + "});\n";
}

function html(hash) {
return '<script src="https://code.highcharts.com/stock/highstock.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/data.js"></script>' +
'<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>' +
'<div id="highcharts-' + hash + '"></div>'
}
7 changes: 4 additions & 3 deletions utils/samples/compare-iframe.php
Expand Up @@ -22,11 +22,12 @@
$rightPath = vsprintf(isset($_SESSION['rightPath']) ? $_SESSION['rightPath'] : Settings::$rightPath, $topDomain);
}

// A commit is given, insert the full path
if (preg_match('/^[a-z0-9]+$/', $leftPath)) {
// A commit or tag is given, insert the full path
$commitOrTag = '/^[a-z0-9]+$/';
if (preg_match($commitOrTag, $leftPath)) {
$leftPath = "cache.php?file=http://github.highcharts.com/$leftPath";
}
if (preg_match('/^[a-z0-9]+$/', $rightPath)) {
if (preg_match($commitOrTag, $rightPath)) {
$rightPath = "cache.php?file=http://github.highcharts.com/$rightPath";
}

Expand Down
7 changes: 6 additions & 1 deletion utils/settings.php
Expand Up @@ -5,8 +5,13 @@ class Settings {
//static $git = "C:\Git\bin\git"; // Typical Windows path
static $git = '/usr/local/git/bin/git';

// Set it to commit id to test against a certain commit. To test against
// a certain version, use the version's commit id.
static $leftPath = "http://code.highcharts.com";
static $rightPath = "http://code.highcharts.%s"; // inserts top domain from utils.highcharts.{whatever}/samples
// Inserts top domain from utils.highcharts.{whatever}/samples.
// Set it to commit id to test against a certain commit.
static $rightPath = "http://code.highcharts.%s";

static $exportServer = "http://export.highcharts.com";
static $jQueryVersion = "1.8.3";
}
Expand Down

0 comments on commit 9e64b1e

Please sign in to comment.