Skip to content

Commit 2229090

Browse files
committed
fix(awesomeThings) Update awesomeThings server api to work with new bootstrap 3.0 template
1 parent d3326ff commit 2229090

File tree

4 files changed

+55
-37
lines changed

4 files changed

+55
-37
lines changed

templates/common/root/app/views/main.html

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<li><a href="#">About</a></li>
55
<li><a href="#">Contact</a></li>
66
</ul>
7-
<h3 class="text-muted"><%= appname %></h3>
7+
<h3 class="text-muted">angular fullstack update</h3>
88
</div>
99

1010
<div class="jumbotron">
@@ -14,14 +14,10 @@ <h1>'Allo, 'Allo!</h1>
1414
</div>
1515

1616
<div class="row marketing">
17-
<h4>HTML5 Boilerplate</h4>
18-
<p>HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.</p>
19-
20-
<h4>Angular</h4>
21-
<p>AngularJS is a toolset for building the framework most suited to your application development.</p>
22-
23-
<h4>Karma</h4>
24-
<p>Spectacular Test Runner for JavaScript.</p>
17+
<div ng-repeat="thing in awesomeThings">
18+
<h4>{{thing.name}}</h4>
19+
<p>{{thing.info}}</p>
20+
</div>
2521
</div>
2622

2723
<div class="footer">

templates/express/api.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,38 @@
22
<% if (!mongo) { %>
33
exports.awesomeThings = function(req, res) {
44
res.json([
5-
'HTML5 Boilerplate',
6-
'AngularJS',
7-
'Karma',
8-
'Express'
5+
{
6+
name : 'HTML5 Boilerplate',
7+
info : 'HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.',
8+
awesomeness: 10
9+
}, {
10+
name : 'AngularJS',
11+
info : 'AngularJS is a toolset for building the framework most suited to your application development.',
12+
awesomeness: 10
13+
}, {
14+
name : 'Karma',
15+
info : 'Spectacular Test Runner for JavaScript.',
16+
awesomeness: 10
17+
}, {
18+
name : 'Express',
19+
info : 'Flexible and minimalist web application framework for node.js.',
20+
awesomeness: 10
21+
}, {
22+
name : 'Mongoose',
23+
info : 'An excellent way to add validation and business logic to your mongoDB objects.',
24+
awesomeness: 10
25+
}
926
]);
1027
};
1128
<% } %><% if (mongo) { %>
1229
var mongoose = require('mongoose'),
1330
Thing = mongoose.model('Thing'),
1431
async = require('async');
1532

16-
// Return a list of thing 'names'
1733
exports.awesomeThings = function(req, res) {
1834
return Thing.find(function (err, things) {
1935
if (!err) {
20-
var thingNames = [];
21-
22-
async.each(things, function (thing, cb) {
23-
thingNames.push(thing.name);
24-
cb();
25-
}, function (err) {
26-
return res.send(thingNames);
27-
});
36+
return res.json(things);
2837
} else {
2938
return res.send(err);
3039
}

templates/express/mongo/dummydata.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,30 @@
33
var mongoose = require('mongoose'),
44
Thing = mongoose.model('Thing');
55

6-
// Create all of the dummy things if Thing is empty
7-
Thing.find(function (err, things) {
8-
if (things.length === 0) {
9-
console.log('populating database');
10-
Thing.create(
11-
{ name : 'HTML5 Boilerplate', awesomeness: 10},
12-
{ name : 'AngularJS', awesomeness: 10},
13-
{ name : 'Karma', awesomeness: 10},
14-
{ name : 'Express', awesomeness: 10},
15-
{ name : 'Mongoose', awesomeness: 10}, function(err) {
16-
console.log('finished populating');
17-
}
18-
);
19-
}
20-
});
6+
//Clear old things, then add things in
7+
Thing.find({}).remove(function() {
8+
Thing.create({
9+
name : 'HTML5 Boilerplate',
10+
info : 'HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.',
11+
awesomeness: 10
12+
}, {
13+
name : 'AngularJS',
14+
info : 'AngularJS is a toolset for building the framework most suited to your application development.',
15+
awesomeness: 10
16+
}, {
17+
name : 'Karma',
18+
info : 'Spectacular Test Runner for JavaScript.',
19+
awesomeness: 10
20+
}, {
21+
name : 'Express',
22+
info : 'Flexible and minimalist web application framework for node.js.',
23+
awesomeness: 10
24+
}, {
25+
name : 'Mongoose',
26+
info : 'An excellent way to add validation and business logic to your mongoDB objects.',
27+
awesomeness: 10
28+
}, function(err) {
29+
console.log('finished populating things');
30+
}
31+
);
32+
});

templates/express/mongo/thing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var mongoose = require('mongoose'),
66
// Schema
77
var ThingSchema = new Schema({
88
name: String,
9+
info: String,
910
awesomeness: Number
1011
});
1112

0 commit comments

Comments
 (0)