Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vasttian committed May 22, 2017
2 parents 1773411 + 2dcc445 commit 51d00bb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ app.use(session({
},
store: new mongoStore({
url: dbUrl,
collection: 'sessions'
collection: 'sessions',
}),
resave: true,
saveUninitialized: true
saveUninitialized: true,
}));


Expand Down
6 changes: 4 additions & 2 deletions app/schemas/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var UserSchema = new mongoose.Schema({

UserSchema.pre('save', function(next) {
var user = this;

if (this.isNew) {
this.meta.createdAt = this.meta.updateAt = Date.now();
} else {
Expand All @@ -84,6 +85,7 @@ UserSchema.pre('save', function(next) {


// 实例方法
// 密码验证
UserSchema.methods = {
comparePassword: function(pass, cb) {
bcrypt.compare(pass, this.password, function(err, isMatch) {
Expand All @@ -105,8 +107,8 @@ UserSchema.statics = {
.exec(cb);
},

findById: function(id, cb){
return this.findOne({_id:id}).exec(cb);
findById: function(id, cb) {
return this.findOne({ _id: id }).exec(cb);
},
};

Expand Down
8 changes: 4 additions & 4 deletions app/views/includes/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title> <%= title %> </title>
<%- include head %>

</head>

<body>
Expand All @@ -29,7 +29,7 @@
<li class="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">友情链接 <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="https://www.douban.com/" target="_blank">豆瓣</a></li>
<li><a href="https://movie.douban.com/tag/" target="_blank">豆瓣</a></li>
<li><a href="http://www.youku.com/" target="_blank">优酷</a></li>
<li><a href="http://www.mtime.com/" target="_blank">时光网</a></li>
<li><a href="https://developers.douban.com/wiki/?title=book_v2" target="_blank">豆瓣开发者</a></li>
Expand All @@ -55,7 +55,7 @@
<ul class="nav navbar-nav navbar-right">
<% if (user) { %>
<li class = "dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">欢迎您:<%= user.nickname %>
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">欢迎您:<%= user.nickname %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
Expand Down Expand Up @@ -109,7 +109,7 @@
<div class="checkbox">
<div class="pull-right">
<a href="/forgot/password" id="forgot_passwd"> 忘记密码?</a>
</div>
</div>
<label>
<input type="checkbox" name="savePassword">记住密码
</label>
Expand Down
24 changes: 12 additions & 12 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ var multipartMiddleware = multipart();

module.exports = function (app) {

//在所有请求之前把当前登录用户设置为本地变量。
// 在所有请求之前把当前登录用户设置为本地变量。
app.use(function (req, res, next) {
var _user = req.session.user;

//本地变量
// 本地变量
app.locals.user = _user;
next();
});

//首页
// 首页
app.get('/', Index.index);

//用户
// 用户
app.get('/signup', User.showSignup);
app.get('/signin', User.showSignin);
app.get('/logout', User.logout);
Expand All @@ -37,7 +37,7 @@ module.exports = function (app) {
app.post('/user/signin', User.signin);
app.post('/user/simple/signin', User.simpleSignin);

//管理员
// 管理员
app.get('/admin', User.signinRequired, User.movieAdminRequired, User.showAdmin);
app.get('/admin/user', User.signinRequired, User.movieAdminRequired, User.sendUser);
app.get('/admin/user/list', User.signinRequired, User.userAdminRequired, User.list);
Expand All @@ -46,7 +46,7 @@ module.exports = function (app) {
app.post('/admin/del/user', User.signinRequired, User.userAdminRequired, User.del);
app.post('/admin/update/role', User.signinRequired, User.userAdminRequired, User.updateRole);

//电影
// 电影
app.get("/movie-pv/ranking", User.signinRequired, Movie.pvRanking);
app.get("/movie-time/ranking", User.signinRequired, Movie.movieTimeRanking);
app.get("/movie-date/ranking", User.signinRequired, Movie.dateRanking);
Expand All @@ -59,27 +59,27 @@ module.exports = function (app) {
app.post("/admin/movie", multipartMiddleware, User.signinRequired, User.movieAdminRequired, Movie.savePoster, Movie.save);
app.delete("/admin/movie/list", User.signinRequired, User.movieAdminRequired, Movie.del);

//电影类别
// 电影类别
app.get("/admin/movie/category/add", User.signinRequired, User.movieAdminRequired, Category.add);
app.get("/admin/movie/category/list", User.signinRequired, User.movieAdminRequired, Category.list);
app.get("/admin/category/update/:id", User.signinRequired, User.movieAdminRequired, Category.update);
app.post("/admin/movie/category", User.signinRequired, User.movieAdminRequired, Category.save);
app.delete("/admin/movie/category/list", User.signinRequired, User.movieAdminRequired, Category.del);

//评论
// 评论
app.post("/user/comment", User.signinRequired, Comment.save);

//评分
// 评分
app.post("/movie/grade", User.signinRequired, Movie.grade);

//找回密码
// 找回密码
app.get("/forgot/password", User.sendForgotPage);
app.post("/forgot/password", User.setNewPassword);

//搜索
// 搜索
app.get('/results', Index.search);

//ECharts
// ECharts
app.get('/active/view/categories/count', User.signinRequired, Movie.categoriesCount);
app.get('/active/view/categories/count/data', User.signinRequired, Category.categoriesCountData);
app.get('/active/view/categories/click', User.signinRequired, Movie.categoriesClick);
Expand Down
2 changes: 1 addition & 1 deletion public/js/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ $(function() {
}
});
});
});
});

0 comments on commit 51d00bb

Please sign in to comment.