Skip to content

Commit

Permalink
Dictionary page setup and icon added
Browse files Browse the repository at this point in the history
  • Loading branch information
githubalexliu committed Mar 26, 2018
1 parent 1bb2652 commit c7043c7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 35 deletions.
61 changes: 28 additions & 33 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ module.exports = function(app, passport) {
});
});

app.get('/profile', function(req, res) {
if (req.isAuthenticated()) {
res.render('profile', {
title: 'Profile',
messageSuccess: req.flash('messageSuccess'),
messageFail: req.flash('messageFail'),
user: req.user
});
} else {
res.redirect('/');
}
app.get('/profile', isLoggedIn, function(req, res) {
res.render('profile', {
title: 'Profile',
messageSuccess: req.flash('messageSuccess'),
messageFail: req.flash('messageFail'),
user: req.user
});
});

app.post('/changename', function(req, res) {
Expand Down Expand Up @@ -91,18 +87,14 @@ module.exports = function(app, passport) {
});
});

app.get('/word-list', function(req, res) {
if (req.isAuthenticated()) {
getWordList(req.user.id, function(err, data) {
res.render('word-list', {
title: 'Word List',
user: req.user,
wordlist: data
});
app.get('/word-list', isLoggedIn, function(req, res) {
getWordList(req.user.id, function(err, data) {
res.render('word-list', {
title: 'Word List',
user: req.user,
wordlist: data
});
} else {
res.redirect('/');
}
});
});

app.post('/addword', function(req, res) {
Expand All @@ -121,24 +113,27 @@ module.exports = function(app, passport) {
res.redirect('back');
});

app.get('/review', function(req, res) {
if (req.isAuthenticated()) {
getRevWordList(req.user.id, function(err, data) {
res.render('review', {
title: 'Review',
user: req.user,
wordlist: data
});
app.get('/review', isLoggedIn, function(req, res) {
getRevWordList(req.user.id, function(err, data) {
res.render('review', {
title: 'Review',
user: req.user,
wordlist: data
});
} else {
res.redirect('/');
}
});
});

app.post('/remword', function(req, res) {
remword2(req.user.id, req.body);
});

app.get('/dictionary', isLoggedIn, function(req, res) {
res.render('dictionary', {
title: 'Dictionary',
user: req.user
});
});

app.get('/logout', function(req, res) {
req.logout();
res.redirect('/');
Expand Down
Binary file added public/img/favicon.ico
Binary file not shown.
34 changes: 34 additions & 0 deletions views/dictionary.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>

<head>
<% include partials/head %>
</head>

<body>
<% include partials/nav %>
<div class="container-fluid text-center top-buffer-50">
<div class="row">
<div class="col-md-6 offset-md-3">
<form class="" method="post" action="/searchword">
<div class="input-group">
<input type="text" class="form-control" id="word" name="word"
placeholder="Search for a word">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary ml-2">Search</button>
</span>
</div>
<!-- <button type="submit" class="btn btn-primary">Search</button> -->
</form>
</div>
</div>
<div class="row">
<div class="col-12">
<table id="results" class="display" cellspacing="0" width="100%">
</table>
</div>
</div>
</div>
</body>

</html>
3 changes: 2 additions & 1 deletion views/partials/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="public/css/styles.css">
<link rel="shortcut icon" type="image/ico" href="public/img/favicon.ico">
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<title>Vocabuilder |
<%= title %>
</title>
</title>
8 changes: 7 additions & 1 deletion views/partials/nav.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
<a class="nav-link" href="word-list">Word List</a>
</li>
<% } %>
<% if (title === 'Dictionary') { %>
<li class="nav-item active">
<a class="nav-link" href="dictionary">Dictionary</a>
</li>
<% } else { %>
<li class="nav-item">
<a class="nav-link" href="#">Dictionary</a>
<a class="nav-link" href="dictionary">Dictionary</a>
</li>
<% } %>
<% if (title === 'Review') { %>
<li class="nav-item active">
<a class="nav-link" href="review">Review</a>
Expand Down

0 comments on commit c7043c7

Please sign in to comment.