Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit e8a062b

Browse files
authored
build: zipper revival (#3319)
1 parent 0f8b1df commit e8a062b

File tree

14 files changed

+222
-130
lines changed

14 files changed

+222
-130
lines changed

gulpfile.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var LIVE_EXAMPLES_PATH = path.join(RESOURCES_PATH, 'live-examples');
4646
var STYLES_SOURCE_PATH = path.join(TOOLS_PATH, 'styles-builder/less');
4747

4848
var docShredder = require(path.resolve(TOOLS_PATH, 'doc-shredder/doc-shredder'));
49-
var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZipper'));
49+
var ExampleZipper = require(path.resolve(TOOLS_PATH, 'example-zipper/exampleZipper'));
5050
var regularPlunker = require(path.resolve(TOOLS_PATH, 'plunker-builder/regularPlunker'));
5151
var embeddedPlunker = require(path.resolve(TOOLS_PATH, 'plunker-builder/embeddedPlunker'));
5252
var fsUtils = require(path.resolve(TOOLS_PATH, 'fs-utils/fsUtils'));
@@ -572,9 +572,7 @@ gulp.task('build-and-serve', ['build-docs'], function (cb) {
572572
watchAndSync({localFiles: true}, cb);
573573
});
574574

575-
gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers']);
576-
// Stop zipping examples Feb 28, 2016
577-
//gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers', '_zip-examples']);
575+
gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers', '_zip-examples']);
578576

579577
gulp.task('build-api-docs', ['build-js-api-docs', 'build-ts-api-docs']);
580578

@@ -787,8 +785,8 @@ gulp.task('_shred-clean-api', function(cb) {
787785
});
788786

789787
gulp.task('_zip-examples', function() {
790-
exampleZipper.zipExamples(_devguideShredOptions.examplesDir, _devguideShredOptions.zipDir);
791-
exampleZipper.zipExamples(_apiShredOptions.examplesDir, _apiShredOptions.zipDir);
788+
new ExampleZipper(_devguideShredOptions.examplesDir, _devguideShredOptions.zipDir);
789+
// exampleZipper.zipExamples(_apiShredOptions.examplesDir, _apiShredOptions.zipDir);
792790
});
793791

794792

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files":[
3+
"!**/*.d.ts",
4+
"!**/*.js",
5+
"!**/*.[0-9].*",
6+
".angular-cli.json",
7+
"protractor.conf.js"
8+
],
9+
"removeSystemJsConfig": true
10+
}

public/docs/_examples/package.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,31 @@
44
"private": true,
55
"description": "Master package.json, the superset of all dependencies for all of the _example package.json files. See _boilerplate/package.json for example npm scripts.",
66
"scripts": {
7-
"http-server": "http-server",
8-
"protractor": "protractor",
9-
"webdriver:update": "webdriver-manager update --standalone false --gecko false"
7+
"build": "tsc -p src/",
8+
"build:watch": "tsc -p src/ -w",
9+
"build:e2e": "tsc -p e2e/",
10+
"serve": "lite-server -c=bs-config.json",
11+
"prestart": "npm run build",
12+
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
13+
"protractor": "protractor protractor.config.js",
14+
"pretest": "npm run build",
15+
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
16+
"pretest:once": "npm run build",
17+
"test:once": "karma start karma.conf.js --single-run",
18+
"lint": "tslint ./src/**/*.ts -t verbose",
19+
20+
"build:upgrade": "tsc",
21+
"serve:upgrade": "http-server",
22+
"build:cli": "ng build --no-progress",
23+
"serve:cli": "http-server dist/",
24+
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
25+
"serve:aot": "lite-server -c bs-config.aot.json",
26+
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
27+
"test:webpack": "karma start karma.webpack.conf.js",
28+
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
29+
"build:babel": "babel src -d src --extensions \".es6\" --source-maps",
30+
"copy-dist-files": "node ./copy-dist-files.js",
31+
"i18n": "ng-xi18n"
1032
},
1133
"keywords": [],
1234
"author": "",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files":[
3+
"!**/*.d.ts",
4+
"!**/*.js",
5+
"!**/*.[0-9].*",
6+
"config/**/*",
7+
"webpack.config.js",
8+
"karma.webpack.conf.js"
9+
],
10+
"removeSystemJsConfig": true
11+
}

public/docs/ts/latest/cli-quickstart.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ include _util-fns
2323
3. [Serve](#serve) the application
2424
4. [Edit](#first-component) the application
2525

26+
And you can also <a href="/resources/zips/cli-quickstart/cli-quickstart.zip">download the example.</a>
2627

2728
.l-main-section
2829
h2#devenv Step 1. Set up the Development Environment

public/docs/ts/latest/guide/change-log.jade

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ block includes
55
The Angular documentation is a living document with continuous improvements.
66
This log calls attention to recent significant changes.
77

8+
## NEW: Downloadable examples for each guide (2017-02-28)
9+
Now you can download the sample code for any guide and run it locally.
10+
Look for the new download links next to the "live example" links.
11+
812
## Template Syntax/Structural Directives: refreshed (2017-02-06)
913
The [_Template-Syntax_](template-syntax.html) and [_Structural Directives_](structural-directives.html)
1014
guides were significantly revised for clarity, accuracy, and current recommended practices.

public/docs/ts/latest/guide/index.jade

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ table(width="100%")
7272
You can reuse these snippets in your applications.
7373

7474
Look for a link to a running version of that sample, often near the top of the page,
75-
such as this <live-example name="architecture"></live-example> from the [Architecture](architecture.html) page.
75+
such as this <live-example nodownload name="architecture"></live-example> from the [Architecture](architecture.html) page.
7676
<span if-docs="ts">
7777
The link launches a browser-based, code editor where you can inspect, modify, save, and download the code.
7878
</span>
7979

80+
Alternatively, you can run the example locally, next to those `live-example` links you have a <a href="/resources/zips/architecture/architecture.zip">download link</a>.
81+
Just download, unzip, run `npm install` to install the dependencies and run it with `npm start`.
82+
8083
## Reference pages
8184

8285
* The [Cheat Sheet](cheatsheet.html) lists Angular syntax for common scenarios.

public/docs/ts/latest/guide/webpack.jade

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ style.
3232
[Trying it out](#try)
3333

3434
[Conclusions](#conclusions)
35-
35+
36+
You can also <a href="/resources/zips/webpack/webpack.zip">download the final result.</a>
37+
3638
.l-main-section
3739
<a id="what-is-webpack"></a>
3840
:marked

public/docs/ts/latest/quickstart.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ block includes
1010
block qs-src-online-and-local
1111
.l-sub-section
1212
:marked
13-
Try this **<live-example>QuickStart example on Plunker</live-example>** without installing anything.
13+
Try this **<live-example noDownload>QuickStart example on Plunker</live-example>** without installing anything.
1414
Try it locally with the [***QuickStart seed***](guide/setup.html "Setup for local development with the QuickStart seed")
1515
and prepare for development of a real Angular application.
1616

public/resources/js/directives/live-example.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ angularIO.directive('liveExample', ['$location', function ($location) {
5656

5757
function span(text) { return '<span>' + text + '</span>'; }
5858

59-
function embeddedTemplate(src, img) {
59+
function embeddedTemplate(src, img, zipHref) {
6060
return '<div ng-if="embeddedShow">' +
6161
'<iframe frameborder="0" width="100%" height="100%" src="' + src + '"></iframe>' +
6262
'</div>' +
63-
'<img ng-click="toggleEmbedded()" ng-if="!embeddedShow" src="' + img + '" alt="plunker">';
63+
'<img ng-click="toggleEmbedded()" ng-if="!embeddedShow" src="' + img + '" alt="plunker">' +
64+
'<p>You can also <a href="' + zipHref +'">download this example.</p>';
6465
}
6566

6667
return {
@@ -72,24 +73,29 @@ angularIO.directive('liveExample', ['$location', function ($location) {
7273
if (attrs['title'] == undefined) { tElement[0].setAttribute('title', text); } // set default title (tooltip)
7374
var ex = attrs.name || NgIoUtil.getExampleName($location);
7475
var embedded = attrs.hasOwnProperty('embedded');
76+
var noDownload = attrs.hasOwnProperty('nodownload') || attrs.hasOwnProperty('noDownload');
7577
var flatStyle = attrs.hasOwnProperty('flatstyle') || attrs.hasOwnProperty('flatStyle');
7678
var embeddedStyle = embedded || attrs.hasOwnProperty('embeddedstyle') || attrs.hasOwnProperty('embeddedStyle');
7779
var plnkr = (embeddedStyle || !flatStyle) ? 'eplnkr' : 'plnkr';
80+
var zipHref = ex;
7881
var imageBase = '/resources/images/';
7982
var defaultImg = 'plunker/placeholder.png';
8083

8184
if (attrs.plnkr) {
8285
plnkr = attrs.plnkr + '.' + plnkr;
86+
zipHref = attrs.plnkr + '.' + zipHref;
8387
}
8488

8589
var isForDart = attrs.lang === 'dart' || NgIoUtil.isDoc($location, 'dart');
8690
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
8791
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';
8892

93+
zipHref = '/resources/zips/' + ex + '/' + zipHref + '.zip';
94+
8995
if (embedded && !isForDart) {
9096
href = '/resources/live-examples/' + ex + '/' + exLang + '/' + plnkr + '.html';
9197
img = imageBase + (attrs.img || defaultImg);
92-
template = embeddedTemplate(href, img);
98+
template = embeddedTemplate(href, img, zipHref);
9399
} else {
94100
var href = isForDart
95101
? 'http://angular-examples.github.io/' + ex
@@ -98,6 +104,10 @@ angularIO.directive('liveExample', ['$location', function ($location) {
98104
// Link to live example.
99105
var template = a(text, { href: href, target: '_blank' });
100106

107+
if (!noDownload) {
108+
template += ' / ' + a('downloadable example', { href: zipHref, target: '_blank' });
109+
}
110+
101111
// The hosted example and sources are in different locations for Dart.
102112
// Also show link to sources for Dart, unless noSource is specified.
103113
if (isForDart && !attrs.hasOwnProperty('nosource')) {

0 commit comments

Comments
 (0)