diff --git a/.gitignore b/.gitignore index f90fe7f26f..adffdb8aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,5 @@ pubspec.lock public/docs/xref-*.* _zip-output www -*.plnkr.html -plnkr.html \ No newline at end of file +*plnkr.html +*plnkr.no-link.html \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 0b6fe49a7c..0d16f518db 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -28,6 +28,7 @@ var DOCS_PATH = path.join(PUBLIC_PATH, 'docs'); var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples'); var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*'); var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources'); +var LIVE_EXAMPLES_PATH = path.join(RESOURCES_PATH, 'live-examples'); var docShredder = require(path.resolve(TOOLS_PATH, 'doc-shredder/doc-shredder')); var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZipper')); @@ -51,9 +52,6 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){ return new Minimatch(excludePattern) }); -gulp.task('build-plunkers', function() { - return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, gutil.log); -}); // Public tasks @@ -83,7 +81,7 @@ gulp.task('build-and-serve', ['build-docs'], function (cb) { watchAndSync({localFiles: true}, cb); }); -gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', '_zip-examples']); +gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers', '_zip-examples']); gulp.task('build-api-docs', ['build-js-api-docs', 'build-ts-api-docs']); @@ -99,6 +97,10 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() { return buildApiDocs('js'); }); +gulp.task('build-plunkers', function() { + return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log }); +}); + gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){ var after, sha, messageSuffix; if (argv.after) { diff --git a/public/docs/_examples/displaying-data/ts/src/plnkr.config b/public/docs/_examples/displaying-data/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/displaying-data/ts/src/plnkr.config rename to public/docs/_examples/displaying-data/ts/src/plnkr.json diff --git a/public/docs/_examples/forms/ts/src/plnkr.config b/public/docs/_examples/forms/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/forms/ts/src/plnkr.config rename to public/docs/_examples/forms/ts/src/plnkr.json diff --git a/public/docs/_examples/pipes/ts/src/plnkr.config b/public/docs/_examples/pipes/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/pipes/ts/src/plnkr.config rename to public/docs/_examples/pipes/ts/src/plnkr.json diff --git a/public/docs/_examples/quickstart/ts/src/plnkr.config b/public/docs/_examples/quickstart/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/quickstart/ts/src/plnkr.config rename to public/docs/_examples/quickstart/ts/src/plnkr.json diff --git a/public/docs/_examples/quickstart/ts/src/test.plnkr.config b/public/docs/_examples/quickstart/ts/src/test.plnkr.json similarity index 100% rename from public/docs/_examples/quickstart/ts/src/test.plnkr.config rename to public/docs/_examples/quickstart/ts/src/test.plnkr.json diff --git a/public/docs/_examples/template-syntax/ts/src/plnkr.config b/public/docs/_examples/template-syntax/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/template-syntax/ts/src/plnkr.config rename to public/docs/_examples/template-syntax/ts/src/plnkr.json diff --git a/public/docs/_examples/user-input/ts/src/plnkr.config b/public/docs/_examples/user-input/ts/src/plnkr.json similarity index 100% rename from public/docs/_examples/user-input/ts/src/plnkr.config rename to public/docs/_examples/user-input/ts/src/plnkr.json diff --git a/public/docs/ts/latest/guide/pipes.jade b/public/docs/ts/latest/guide/pipes.jade index 0215ee6aa6..c4ccc5626a 100644 --- a/public/docs/ts/latest/guide/pipes.jade +++ b/public/docs/ts/latest/guide/pipes.jade @@ -17,7 +17,7 @@ include ../../../../_includes/_util-fns Welcome, Angular pipes, the simple display-value transformations that we can declare in our HTML! - [Live Example](/docs/_examples/pipes/ts/src/plnkr.html) + [Live Example](/resources/live-examples/pipes/ts/src/plnkr.html) .l-main-section :marked diff --git a/public/docs/ts/latest/guide/template-syntax.jade b/public/docs/ts/latest/guide/template-syntax.jade index 90f609678c..5666aea0d4 100644 --- a/public/docs/ts/latest/guide/template-syntax.jade +++ b/public/docs/ts/latest/guide/template-syntax.jade @@ -36,7 +36,7 @@ include ../../../../_includes/_util-fns >[Template Expression Operators](#expression-operators) - [Live Example](/docs/_examples/template-syntax/ts/src/plnkr.html) + [Live Example](/resources/live-examples/template-syntax/ts/src/plnkr.html) .l-main-section :marked diff --git a/tools/plunker-builder/indexHtmlTranslator.js b/tools/plunker-builder/indexHtmlTranslator.js index 5f91bf0062..cbb8e43b55 100644 --- a/tools/plunker-builder/indexHtmlTranslator.js +++ b/tools/plunker-builder/indexHtmlTranslator.js @@ -53,7 +53,7 @@ var _rxData = [ { pattern: 'link', from: 'node_modules/bootstrap/dist/css/bootstrap.min.css', - to: 'https://cdnjs.com/libraries/twitter-bootstrap/3.3.5' + to: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap-theme.min.css' // to: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css' }, { diff --git a/tools/plunker-builder/plunkerBuilder.js b/tools/plunker-builder/plunkerBuilder.js index 4643f55a2f..f1aa79f47e 100644 --- a/tools/plunker-builder/plunkerBuilder.js +++ b/tools/plunker-builder/plunkerBuilder.js @@ -5,6 +5,7 @@ var _ = require('lodash'); var jsdom = require("jsdom"); var fs = require("fs"); var globule = require('globule'); +var mkdirp = require('mkdirp'); var indexHtmlTranslator = require('./indexHtmlTranslator'); var regionExtractor = require('../doc-shredder/regionExtractor'); @@ -13,16 +14,16 @@ module.exports = { buildPlunkers: buildPlunkers }; -function buildPlunkers(basePath, errFn) { - errFn = errFn || function(e) { console.log(e); }; - var configExtns = ['plnkr.config', '*.plnkr.config']; +function buildPlunkers(basePath, destPath, options) { + var errFn = options.errFn || function(e) { console.log(e); }; + var configExtns = ['plnkr.json', '*plnkr.json']; var gpaths = configExtns.map(function(extn) { return path.join(basePath, '**/' + extn); }); var fileNames = globule.find(gpaths); fileNames.forEach(function(configFileName) { try { - buildPlunkerFrom(configFileName); + buildPlunkerFrom(configFileName, basePath, destPath); } catch (e) { errFn(e); } @@ -34,19 +35,34 @@ function buildPlunkers(basePath, errFn) { // description: optional string - description of this plunker - defaults to the title in the index.html page. // tags: [] - optional array of strings // main: string - filename of what will become index.html in the plunker - defaults to index.html -function buildPlunkerFrom(configFileName ) { - // replace ending 'plnkr.config' with 'plnkr.html' to create output file name; - var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.config'.length) + 'plnkr.html'; +function buildPlunkerFrom(configFileName, basePath, destPath ) { + // replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name; + var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + 'plnkr.no-link.html'; + var altFileName; + if (destPath && destPath.length > 0) { + var partPath = path.dirname(path.relative(basePath, outputFileName)); + var altFileName = path.join(destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.'); + } try { var config = initConfigAndCollectFileNames(configFileName); var postData = createPostData(config); var html = createPlunkerHtml(postData); fs.writeFileSync(outputFileName, html, 'utf-8'); + if (altFileName) { + var altDirName = path.dirname(altFileName); + if (!fs.existsSync(altDirName)) { + mkdirp.sync(altDirName); + } + fs.writeFileSync(altFileName, html, 'utf-8'); + } } catch (e) { // if we fail delete the outputFile if it exists because it is an old one. if (existsSync(outputFileName)) { fs.unlinkSync(outputFileName); } + if (altFileName && existsSync(altFileName)) { + fs.unlinkSync(altFileName); + } throw e; } } @@ -78,7 +94,7 @@ function initConfigAndCollectFileNames(configFileName) { return path.join(basePath, fileName); } }); - var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/plnkr.html', '!**/*.plnkr.html' ]; + var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ]; Array.prototype.push.apply(gpaths, defaultExcludes); config.fileNames = globule.find(gpaths); diff --git a/tools/plunker-builder/tmp.plunker.example.jade b/tools/plunker-builder/tmp.plunker.example.jade index 5bbe6b7584..69316aa642 100644 --- a/tools/plunker-builder/tmp.plunker.example.jade +++ b/tools/plunker-builder/tmp.plunker.example.jade @@ -1,6 +1,6 @@ .l-main-section - a(href='/docs/_examples/template-syntax/ts/src/plnkr.html') Live Example 0 + a(href='/resources/live-examples/template-syntax/ts/src/plnkr.html') Live Example 0 :marked - [Live Example 1](/docs/_examples/template-syntax/ts/src/plnkr.html) - Live Example 2 + [Live Example 1](/resources/live-examples/template-syntax/ts/src/plnkr.html) +