Skip to content

Commit 717575b

Browse files
committed
Fixed compiling cached AngularJS templates.
Added UI Bootstrap's Collapse plugin into example app's navbar. Updated gulp plugins.
1 parent a940fdc commit 717575b

6 files changed

Lines changed: 49 additions & 32 deletions

File tree

bower.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "ng-devstack",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"devDependencies": {
5-
"angular": "~1.2.12",
5+
"angular": "~1.2.14",
66
"angular-bootstrap": "~0.10.0",
7-
"angular-mocks": "~1.2.12",
7+
"angular-mocks": "~1.2.14",
88
"angular-ui-router": "0.2.8-bowratic-tedium",
9-
"angular-ui-utils": "~0.1.1",
109
"bootstrap-sass-official": "latest"
1110
},
1211
"dependencies": {}

gulpfile.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,29 @@ gulp.task('vendor:assets', function () {
6565
// ==================
6666

6767
// Cache AngularJS templates
68-
var fnHtml2Js = function (path) {
68+
var fnCacheTpls = function (path) {
6969
return gulp.src(path)
7070
.pipe(plugins.minifyHtml({
7171
empty: true,
7272
spare: true,
7373
quotes: true
7474
}))
75-
.pipe(plugins.ngHtml2js({
76-
moduleName: 'templates'
75+
.pipe(plugins.angularTemplatecache({
76+
module: 'ngDevstack.templates',
77+
standalone: true
7778
}))
78-
.pipe(plugins.concat('app-templates.js'))
79+
.pipe(plugins.concat('templates.js'))
7980
.pipe(gulp.dest(config.build + '/app'));
8081
};
81-
gulp.task('scripts:html2js', function () {
82-
return fnHtml2Js(config.paths.templates);
82+
gulp.task('scripts:cacheTpls', function () {
83+
return fnCacheTpls(config.paths.templates);
8384
});
8485

8586
// Check JavaScript code quality with JSHint
8687
var fnLint = function (path) {
8788
return gulp.src(path, { base: config.app })
8889
.pipe(plugins.plumber())
89-
.pipe(plugins.jshint('.jshintrc'))
90+
.pipe(plugins.jshint())
9091
.pipe(plugins.jshint.reporter('default'))
9192
.pipe(gulp.dest(config.build));
9293
};
@@ -95,14 +96,14 @@ gulp.task('scripts:lint', function () {
9596
});
9697

9798
// Concat and minify JavaScript
98-
gulp.task('scripts', ['scripts:lint', 'scripts:html2js', 'vendor:js'], function () {
99-
var arr = (config.vendor_files.js).concat(config.paths.scripts);
99+
gulp.task('scripts', ['scripts:lint', 'scripts:cacheTpls', 'vendor:js'], function () {
100+
var arr = (config.vendor_files.js).concat(config.paths.scripts, config.build + '/app/templates.js');
100101
return gulp.src(arr)
101102
.pipe(plugins.concat('main.js'))
102103
.pipe(plugins.bytediff.start())
103104
.pipe(plugins.ngmin())
104-
.pipe(plugins.uglify())
105105
.pipe(plugins.removelogs())
106+
.pipe(plugins.uglify())
106107
.pipe(plugins.rename({ suffix: '.min' }))
107108
.pipe(plugins.bytediff.stop())
108109
.pipe(gulp.dest(config.dist + '/assets'));
@@ -153,7 +154,7 @@ var fnInject = function (path) {
153154
}))
154155
.pipe(gulp.dest(config.build));
155156
};
156-
gulp.task('html:inject', ['styles:sass', 'scripts:lint', 'scripts:html2js'], function () {
157+
gulp.task('html:inject', ['styles:sass', 'scripts:lint', 'scripts:cacheTpls'], function () {
157158
return fnInject(config.paths.html);
158159
});
159160

@@ -209,7 +210,7 @@ gulp.task('test:watch', ['vendor:assets'], function() {
209210
// ============
210211

211212
// Add files to Watch
212-
gulp.task('watch', ['styles:sass', 'scripts:lint', 'scripts:html2js', 'assets:img', 'vendor:js', 'vendor:assets', 'test:watch', 'html:inject'], function () {
213+
gulp.task('watch', ['styles:sass', 'scripts:lint', 'scripts:cacheTpls', 'assets:img', 'vendor:js', 'vendor:assets', 'test:watch', 'html:inject'], function () {
213214
require('./server.js')(server);
214215

215216
// watch for JS changes
@@ -235,7 +236,7 @@ gulp.task('watch', ['styles:sass', 'scripts:lint', 'scripts:html2js', 'assets:im
235236
// watch AngularJS templates to cache
236237
gulp.watch(config.app + '/+(app|common)/**', function (event) {
237238
if (event.path.lastIndexOf('.tpl.html') === event.path.length - 9) {
238-
return fnHtml2Js(config.paths.templates).pipe(plugins.livereload(server));
239+
return fnCacheTpls(config.paths.templates).pipe(plugins.livereload(server));
239240
}
240241
});
241242

@@ -281,7 +282,7 @@ gulp.task('clean', function () {
281282
// ===============
282283

283284
gulp.task('build', ['clean'], function () {
284-
gulp.start('styles:sass', 'scripts:lint', 'scripts:html2js', 'vendor:js', 'vendor:assets', 'test:run', 'assets:img', 'html:inject');
285+
gulp.start('styles:sass', 'scripts:lint', 'scripts:cacheTpls', 'vendor:js', 'vendor:assets', 'test:run', 'assets:img', 'html:inject');
285286
});
286287

287288
gulp.task('compile', ['build'], function () {

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
{
22
"author": "Mariusz Michalski",
33
"name": "ng-devstack",
4-
"version": "0.2.1",
4+
"version": "0.2.2",
55
"licenses": {
66
"type": "MIT",
77
"url": "https://raw2.github.com/mariuszm/ng-devstack/master/LICENSE.md"
88
},
99
"devDependencies": {
1010
"express": "~3.4.8",
11-
"connect": "~2.12.0",
11+
"connect": "~2.13.0",
1212
"connect-livereload": "~0.3.2",
1313
"connect-modrewrite": "~0.5.11",
1414
"open": "0.0.4",
1515
"tiny-lr": "0.0.5",
16-
"gulp": "~3.5.1",
16+
"gulp": "~3.5.5",
17+
"gulp-angular-templatecache": "~1.1.0",
1718
"gulp-autoprefixer": "0.0.6",
1819
"gulp-bytediff": "~0.1.8",
1920
"gulp-concat": "~2.1.7",
2021
"gulp-filesize": "0.0.6",
2122
"gulp-html-replace": "~0.2.0",
2223
"gulp-imagemin": "~0.1.4",
2324
"gulp-inject": "~0.2.2",
24-
"gulp-jshint": "~1.3.4",
25+
"gulp-jshint": "~1.5.0",
2526
"gulp-livereload": "~0.3.2",
2627
"gulp-load-plugins": "~0.3.0",
2728
"gulp-minify-css": "~0.2.0",
28-
"gulp-minify-html": "~0.1.0",
29+
"gulp-minify-html": "~0.1.2",
2930
"gulp-newer": "~0.2.1",
30-
"gulp-ng-html2js": "~0.1.4",
3131
"gulp-ngmin": "~0.1.2",
3232
"gulp-plumber": "~0.5.6",
3333
"gulp-removelogs": "0.0.2",
3434
"gulp-rename": "~0.2.2",
3535
"gulp-rimraf": "0.0.8",
36-
"gulp-ruby-sass": "~0.3.0",
36+
"gulp-ruby-sass": "~0.3.1",
3737
"gulp-size": "~0.1.2",
3838
"gulp-uglify": "~0.2.0",
3939
"gulp-util": "~2.2.14",

src/app/app.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
'use strict';
22

33
angular.module('ngDevstack', [
4-
'templates',
4+
'ngDevstack.templates',
55
'ngDevstack.conf',
66
'ngDevstack.home',
77
'ngDevstack.about',
8+
'ui.bootstrap',
89
'ui.router'
910
])
1011

11-
.config(function ($urlRouterProvider, $locationProvider, $stateProvider) {
12+
.config(function ($urlRouterProvider) {
1213

1314
$urlRouterProvider.otherwise('/');
1415
// Please enable mod rewrite in server.js when html5Mode is enabled.
16+
// Don't forget to inject $locationProvider.
1517
// $locationProvider.html5Mode(true);
1618

1719

@@ -42,6 +44,9 @@ angular.module('ngDevstack', [
4244

4345
.controller('AppCtrl', function ($rootScope, $scope) {
4446

47+
// handling UI Bootstrap Collapse plugin
48+
$scope.isCollapsed = true;
49+
4550
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
4651
if (angular.isDefined(toState.data.pageTitle)) {
4752
$scope.pageTitle = toState.data.pageTitle + ' | ng-devstack';

src/app/home/home.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ <h1>This is ng-devstack!</h1>
44
<p>Everything a front-end developer needs to simplify building AngularJS applications.</p>
55
<br>
66
<p>
7-
<a class="btn btn-primary btn-lg" role="button">
7+
<a class="btn btn-primary btn-lg" role="button" href="https://github.com/mariuszm/ng-devstack">
88
<span class="glyphicon glyphicon-download-alt"></span> Download
99
</a>
1010
</p>

src/index.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@
1717
<div class="col-md-10 col-md-offset-1">
1818
<nav class="navbar navbar-inverse" role="navigation">
1919
<div class="container-fluid">
20-
<ul class="nav navbar-nav">
21-
<li ui-sref-active="active"><a ui-sref="home">Home</a></li>
22-
<li ui-sref-active="active"><a ui-sref="about">About</a></li>
23-
</ul>
20+
21+
<div class="navbar-header">
22+
<button type="button" class="navbar-toggle" ng-click="isCollapsed = !isCollapsed">
23+
<span class="icon-bar"></span>
24+
<span class="icon-bar"></span>
25+
<span class="icon-bar"></span>
26+
</button>
27+
</div>
28+
29+
<div class="collapse navbar-collapse" collapse="isCollapsed">
30+
<ul class="nav navbar-nav">
31+
<li ui-sref-active="active"><a ui-sref="home">Home</a></li>
32+
<li ui-sref-active="active"><a ui-sref="about">About</a></li>
33+
</ul>
34+
</div>
35+
2436
</div>
2537
</nav>
2638
<div ui-view="main"></div>

0 commit comments

Comments
 (0)