diff --git a/.gitignore b/.gitignore index 31dc5a837fb..5324150c8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ nbproject/ *.log samples/highcharts/common-js/browserify/demo.js samples/highcharts/common-js/webpack/demo.js +/samples/cloud/charts diff --git a/cloud-downloader.js b/cloud-downloader.js index 1f6c73ab506..32740e3219f 100644 --- a/cloud-downloader.js +++ b/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 '' + + '' + + '' + + '
'; +} + 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'] @@ -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] + '/'; @@ -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 '' + - '' + - '' + - '
' -} diff --git a/utils/samples/compare-iframe.php b/utils/samples/compare-iframe.php index 0fcfd3f68ee..a3a60ae37ea 100644 --- a/utils/samples/compare-iframe.php +++ b/utils/samples/compare-iframe.php @@ -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"; } diff --git a/utils/settings.php b/utils/settings.php index 936aceef763..e6fb2b3319b 100644 --- a/utils/settings.php +++ b/utils/settings.php @@ -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"; }