Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
hello world for angular 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Dec 2, 2015
1 parent a97e25d commit cc57dc1
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 0.2.5
- Added `web-angular` template for an Angular2 (alpha) app.

## 0.2.4
- Migrated `server-appengine` to use `shelf`.
- Updated the template `.gitignore` files
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Kit and Yeoman.
* `package-simple` - A starting point for Dart libraries or applications.
* `server-appengine` - A simple App Engine application.
* `server-shelf` - A web server built using the shelf package.
* `web-angular` - A web app built using Angular 2.
* `web-polymer` - A web app built using polymer.dart.
* `web-simple` - An absolute bare-bones web app.

Expand Down
28 changes: 28 additions & 0 deletions lib/generators/web_angular.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2015, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

library stagehand.web.angular;

import '../stagehand.dart';
import '../src/common.dart';
import 'web_angular_data.dart';

/**
* A generator for an Angular 2 application.
*/
class WebAngularGenerator extends DefaultGenerator {
WebAngularGenerator()
: super('web-angular', 'Angular 2 Web Application',
'A web app built using Angular 2.',
categories: const ['dart', 'web']) {
for (TemplateFile file in decodeConcatenatedData(data)) {
addTemplateFile(file);
}

setEntrypoint(getFile('web/index.html'));
}

String getInstallInstructions() => "${super.getInstallInstructions()}\n"
"to run your app, use 'pub serve'";
}
46 changes: 46 additions & 0 deletions lib/generators/web_angular_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

const List<String> data = const [
".gitignore",
"text",
"""IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmJ1aWxkbG9nCi5wYWNrYWdl
cwoucHJvamVjdAoucHViLwpidWlsZC8KcGFja2FnZXMKcHVic3BlYy5sb2NrICMgKFJlbW92ZSB0
aGlzIHBhdHRlcm4gaWYgeW91IHdpc2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUpCgojIEZp
bGVzIGNyZWF0ZWQgYnkgZGFydDJqcwoqLmRhcnQuanMKKi5wYXJ0LmpzCiouanMuZGVwcwoqLmpz
Lm1hcAoqLmluZm8uanNvbgoKIyBEaXJlY3RvcnkgY3JlYXRlZCBieSBkYXJ0ZG9jCmRvYy9hcGkv
CgojIEpldEJyYWlucyBJREVzIChXZWJTdG9ybSBhbmQgSURFQSBhcmUgdGhlIHJlY29tZW5kZWQg
RGFydCBJREVzKSAKLmlkZWEvCiouaW1sCiouaXByCiouaXdzCg==""",
"lib/app_component.dart",
"text",
"""Ly8gQ29weXJpZ2h0IChjKSBfX3llYXJfXywgX19hdXRob3JfXy4gQWxsIHJpZ2h0cyByZXNlcnZl
ZC4gVXNlIG9mIHRoaXMgc291cmNlIGNvZGUKLy8gaXMgZ292ZXJuZWQgYnkgYSBCU0Qtc3R5bGUg
bGljZW5zZSB0aGF0IGNhbiBiZSBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlLgoKbGlicmFyeSBf
X3Byb2plY3ROYW1lX18uYXBwX2NvbXBvbmVudDsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyMi9h
bmd1bGFyMi5kYXJ0JzsKCkBDb21wb25lbnQoc2VsZWN0b3I6ICdteS1hcHAnLCB0ZW1wbGF0ZVVy
bDogJ2FwcF9jb21wb25lbnQuaHRtbCcpCmNsYXNzIEFwcENvbXBvbmVudCB7fQo=""",
"lib/app_component.html",
"text",
"PGgxPk15IEZpcnN0IEFuZ3VsYXI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K"""
];
2 changes: 2 additions & 0 deletions lib/stagehand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'generators/console_simple.dart';
import 'generators/package_simple.dart';
import 'generators/server_appengine.dart';
import 'generators/server_shelf.dart';
import 'generators/web_angular.dart';
import 'generators/web_polymer.dart';
import 'generators/web_simple.dart';
import 'src/common.dart';
Expand All @@ -42,6 +43,7 @@ final List<Generator> generators = [
new PackageSimpleGenerator(),
new ServerAppEngineGenerator(),
new ServerShelfGenerator(),
new WebAngularGenerator(),
new WebPolymerGenerator(),
new WebSimpleGenerator()
]..sort();
Expand Down
1 change: 1 addition & 0 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ <h1 id="usage">Usage</h1>
<li>package-simple - <em>A starting point for Dart libraries or applications.</em></li>
<li>server-appengine - <em>A simple App Engine application.</em></li>
<li>server-shelf - <em>A web server built using the shelf package.</em></li>
<li>web-angular - <em>A web app built using Angular 2.</em></li>
<li>web-polymer - <em>A web app built using polymer.dart.</em></li>
<li>web-simple - <em>An absolute bare-bones web app.</em></li>
</ul>
Expand Down
24 changes: 24 additions & 0 deletions templates/web-angular/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Files and directories created by pub
.buildlog
.packages
.project
.pub/
build/
packages
pubspec.lock # (Remove this pattern if you wish to check in your lock file)

# Files created by dart2js
*.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json

# Directory created by dartdoc
doc/api/

# JetBrains IDEs (WebStorm and IDEA are the recomended Dart IDEs)
.idea/
*.iml
*.ipr
*.iws
9 changes: 9 additions & 0 deletions templates/web-angular/lib/app_component.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) __year__, __author__. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library __projectName__.app_component;

import 'package:angular2/angular2.dart';

@Component(selector: 'my-app', templateUrl: 'app_component.html')
class AppComponent {}
1 change: 1 addition & 0 deletions templates/web-angular/lib/app_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>My First Angular 2 App</h1>
8 changes: 8 additions & 0 deletions templates/web-angular/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: __projectName__
version: 0.0.1
dependencies:
angular2: 2.0.0-alpha.47
browser: ^0.10.0
transformers:
- angular2:
entry_points: web/main.dart
12 changes: 12 additions & 0 deletions templates/web-angular/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>__projectName__</title>

<script defer src="main.dart" type="application/dart"></script>
<script defer src="packages/browser/dart.js"></script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
12 changes: 12 additions & 0 deletions templates/web-angular/web/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) __year__, __author__. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library __projectName__.web;

import 'package:angular2/bootstrap.dart';

import 'package:__projectName__/app_component.dart';

main() {
bootstrap(AppComponent);
}

0 comments on commit cc57dc1

Please sign in to comment.