Skip to content

Commit db9d953

Browse files
committed
basic view for tutorial.
1 parent bfd26d0 commit db9d953

File tree

5 files changed

+75
-23
lines changed

5 files changed

+75
-23
lines changed

app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ passport.use(new LocalStrategy(
5555
));
5656

5757
app.get('/', routes.index);
58-
app.get('/users', user.list);
5958
app.get('/login', routes.login);
6059
app.get('/path', routes.login);
60+
app.get('/learnpath/:lid', routes.learnpath);
61+
app.get('/tutorial/:tid', routes.tutorial);
62+
app.get('/profile/:uid', user.profile);
6163

6264
app.get('/auth',
6365
passport.authenticate('local', {failureRedirect: '/login'}),

public/stylesheets/style.css

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
body {
22
padding-top:60px;
33
padding-bottom:40px;
4-
background:url(../images/background.png);
54
overflow-y:scroll;
65
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
76
}
@@ -20,26 +19,25 @@ a {
2019
object-position: top center;
2120
}
2221

23-
.im:hover
24-
{
25-
opacity:0.5;
26-
filter:alpha(opacity=100); /* For IE8 and earlier */
22+
.im:hover {
23+
opacity:0.5;
24+
filter:alpha(opacity=100); /* For IE8 and earlier */
2725
}
2826

2927
.atext{
30-
height: 40px;
31-
overflow: hidden;
32-
text-overflow: ellipsis;
28+
height: 40px;
29+
overflow: hidden;
30+
text-overflow: ellipsis;
3331
}
3432

3533
.tut-sub-by-wrap {
36-
padding-top: 4px;
37-
border-top: 1px solid #E2E2E2;
38-
margin-top: 4px;
39-
height:14px;
40-
line-height: 14px;
41-
overflow: hidden;
42-
text-overflow: ellipsis;
34+
padding-top: 4px;
35+
border-top: 1px solid #E2E2E2;
36+
margin-top: 4px;
37+
height:14px;
38+
line-height: 14px;
39+
overflow: hidden;
40+
text-overflow: ellipsis;
4341
}
4442

4543

@@ -51,7 +49,7 @@ filter:alpha(opacity=100); /* For IE8 and earlier */
5149
box-shadow: 1px 1px 1px black;
5250
color: white;
5351
font: bold 24px/20px Helvetica, Verdana, Tahoma;
54-
height: 30px;
52+
height: 30px;
5553
line-height: 30px;
5654
width: 30px;
5755
padding: 1px 1px 1px 1px;
@@ -61,7 +59,7 @@ filter:alpha(opacity=100); /* For IE8 and earlier */
6159
.path-node-title {
6260
display: block;
6361
font: bold 24px/20px Helvetica, Verdana, Tahoma;
64-
height: 30px;
62+
height: 30px;
6563
line-height: 30px;
6664
padding: 10px 10px 10px 10px;
6765
margin: 10px 10px 10px 10px;
@@ -70,3 +68,11 @@ filter:alpha(opacity=100); /* For IE8 and earlier */
7068

7169
}
7270

71+
.externtut {
72+
display: block;
73+
text-align: center;
74+
}
75+
76+
.label {
77+
margin-right: 5px;
78+
}

routes/index.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,55 @@ exports.index = function(req, res) {
1111
}
1212
};
1313

14+
exports.tutorial = function(req, res) {
15+
console.log(req.params);
16+
var tutorialId = req.params.tid;
17+
if (!tutorialId) {
18+
res.send("response with a resource");
19+
} else {
20+
// fetch tutorial based on id
21+
var tut = {
22+
title: 'NodeJS web basic',
23+
createdBy: 'Hung Doan',
24+
star: 5,
25+
desc: "In this tutorial I will run you through the process setting up an Express.js app and making it do what a basic website might do. You will learn the basics of routes, views, Jade templates, Stylus CSS engine, handling POST and GET requests.",
26+
url: 'http://www.hacksparrow.com/express-js-tutorial.html',
27+
stat: {
28+
likes: 103,
29+
shares: 50,
30+
views: 1042
31+
},
32+
requires: [
33+
'javascript-basic',
34+
'nodejs-basic',
35+
'javascript',
36+
'nodejs',
37+
],
38+
acquires: [
39+
'nodejs-intermediate',
40+
'expressjs-basic',
41+
'nodejs-basic',
42+
'javascript',
43+
]
44+
};
45+
res.render('tutorial', {
46+
title: tut.title,
47+
tut: tut
48+
});
49+
}
50+
}
51+
52+
exports.learnpath = function(req, res) {
53+
console.log(req.params);
54+
res.send("respond with a resource");
55+
}
56+
1457
/*
1558
* GET login page.
1659
*/
1760
exports.login = function(req, res){
1861
console.log('login');
19-
res.render('login',{ title: 'Login' });
62+
res.render('login', { title: 'Login' });
2063
};
2164

2265
/*

routes/user.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* GET users listing.
44
*/
55

6-
exports.list = function(req, res){
6+
exports.profile = function(req, res){
7+
console.log(req.params);
78
res.send("respond with a resource");
8-
};
9+
};

views/layout.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
doctype 5
22
html
33
head
4-
title= title
4+
title = title
55
link(rel='stylesheet', href='/stylesheets/bootstrap.min.css')
66
link(rel='stylesheet', href='/stylesheets/style.css')
7-
include bit/scripts
7+
include bit/scripts
88
body
99
include bit/topbar
1010
div.container

0 commit comments

Comments
 (0)