Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

Commit

Permalink
support nickname, update tpl
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Aug 28, 2014
1 parent a27dd7e commit 65d5650
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 56 deletions.
2 changes: 2 additions & 0 deletions api/user.js
Expand Up @@ -50,6 +50,7 @@ userCache.getP = function (Uid, convert) {
cont(jsGen.Err(msg.USER.UidNone));
}
}).then(function (cont, user) {
user.nickname = user.nickname || user.name;
if (!inCache) {
user = intersect(union(UserPrivateTpl), user);
that.put(Uid, user);
Expand Down Expand Up @@ -170,6 +171,7 @@ function adduser(userObj) {
}).then(function (cont) {
delete userObj._id;
userObj.email = userObj.email.toLowerCase();
userObj.nickname = userObj.nickname || userObj.name;
userObj.avatar = gravatar(userObj.email);
userObj.resetDate = Date.now();
userObj.role = jsGen.config.emailVerification ? 1 : 2;
Expand Down
32 changes: 17 additions & 15 deletions app.js
Expand Up @@ -181,21 +181,23 @@ serverDm.run(function () {

var path = req.path[0].toLowerCase();

if (jsGen.hooks.reqHooks(req, res) === false) return;
if (path === 'api' && jsGen.api[req.path[1]]) {
jsGen.api[req.path[1]][req.method](req, res); // 处理api请求
} else if (jsGen.robotReg.test(req.useragent)) {
jsGen.api.article.robot(req, res); // 处理搜索引擎请求
} else if (path === 'sitemap.xml') {
jsGen.api.article.sitemap(req, res); // 响应搜索引擎sitemap,动态生成
} else if (path === 'robots.txt') {
res.setHeader('Content-Type', 'text/plain');
res.send(jsGen.cache.robotsTxt);
} else {
jsGen.config.visitors = 1; // 访问次数+1
res.setHeader('Content-Type', 'text/html');
res.send(jsGen.cache.indexTpl); // 响应首页index.html
}
jsGen.hooks.reqHooks(req, res, function () {

if (path === 'api' && jsGen.api[req.path[1]]) {
jsGen.api[req.path[1]][req.method](req, res); // 处理api请求
} else if (jsGen.robotReg.test(req.useragent)) {
jsGen.api.article.robot(req, res); // 处理搜索引擎请求
} else if (path === 'sitemap.xml') {
jsGen.api.article.sitemap(req, res); // 响应搜索引擎sitemap,动态生成
} else if (path === 'robots.txt') {
res.setHeader('Content-Type', 'text/plain');
res.send(jsGen.cache.robotsTxt);
} else {
jsGen.config.visitors = 1; // 访问次数+1
res.setHeader('Content-Type', 'text/html');
res.send(jsGen.cache.indexTpl); // 响应首页index.html
}
});
}

function handler(req, res) {
Expand Down
3 changes: 2 additions & 1 deletion hooks/req-hooks.js
@@ -1,6 +1,7 @@
'use strict';
/*global require, module, Buffer, jsGen*/

module.exports = function (req, res) {
module.exports = function (req, res, next) {
//
next();
};
3 changes: 3 additions & 0 deletions lib/json.js
Expand Up @@ -12,6 +12,7 @@ exports.User = {
// 通过users的convertID方法相互转换。初始化时第一用户管理员Uid为‘Uadmin’,对应_id为61061
name: '',
// String,用户名,小写英文字母、数字、下划线_、或者汉字,5至15字节长(2至5汉字)
nickname: '',
email: '',
// String,用户邮箱,name 或 email 均可做为登录名
passwd: '',
Expand Down Expand Up @@ -93,6 +94,7 @@ exports.User = {
exports.UserPublicTpl = {
_id: 0,
name: '',
nickname: '',
locked: false,
sex: '',
role: 0,
Expand All @@ -116,6 +118,7 @@ exports.UserPublicTpl = {
exports.UserPrivateTpl = {
_id: 0,
name: '',
nickname: '',
email: '',
locked: false,
social: {
Expand Down
1 change: 1 addition & 0 deletions lib/redis.js
Expand Up @@ -282,6 +282,7 @@ userCache.update = function (userObj, callback) {
email: '',
avatar: '',
score: 0,
role: 0
};

callback = callback || callbackFn;
Expand Down
4 changes: 2 additions & 2 deletions static/dist/index.html
Expand Up @@ -9,7 +9,7 @@
<meta name="description" content="{{global.metadesc}}">
<meta name="keywords" content="{{global.keywords}}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico"/>
<link rel="shortcut icon" href="/static/favicon.ico"/>
<link rel="stylesheet" href="/static/css/app.css">
</head>
<!--[if lt IE 9]> <body class="ie pure-g-r"> <![endif]-->
Expand All @@ -32,7 +32,7 @@
</ul>
<ul class="right user" ng-if="global.isLogin">
<li><a class="pure-menu-img" href="/home"><img class="img-mini" src="http://cdn.angularjs.cn/img/avatar.png" gen-src="{{global.user.avatar}}"/></a></li>
<li ng-if="global.isDesktop"><a href="/home"><i class="fa fa-home"></i>{{global.user.name}}</a></li>
<li ng-if="global.isDesktop"><a href="/home"><i class="fa fa-home"></i>{{global.user.nickname}}</a></li>
<li ng-if="global.isEditor"><a href="/admin"><i class="fa fa-gear"></i>管理</a></li>
<li ng-if="global.isDesktop"><a ng-click="logout()"><i class="fa fa-signout"></i>退出</a></li>
</ul>
Expand Down
31 changes: 13 additions & 18 deletions static/dist/tpl/index.html
Expand Up @@ -10,10 +10,12 @@
<img src="http://cdn.angularjs.cn/img/angularjs.png" alt="AngularJS">
<div class="text-show text-left">使用超动感HTML &amp; JS开发WEB应用!</div>
<div class="text-show text-hot text-left">QQ交流群1 <strong class="hot">278252889(满)</strong></div>
<div class="text-show text-hot text-left">QQ交流群2 <strong class="hot">305739270</strong></div>
<div class="text-show text-hot text-left"><a class="hot" href="http://tburl.in/0hbn5nev" target="_blank">Teambition项目组,欢迎加入!</a></div>
<div class="text-show text-hot text-left">QQ交流群2 <strong class="hot">305739270(满)</strong></div>
<div class="text-show text-hot text-left">QQ交流群3 <strong class="hot">207542263</strong></div>
<div class="text-show text-hot text-left">QQ交流群4 <strong class="hot">240328422</strong></div>
<div class="text-show">
<a href="https://github.com/angular/angular.js" class="pure-button pure-button-link" target="_blank"><i class="fa fa-github fa-2x"></i>GitHub</a>
<a href="https://github.com/angular/angular.js" class="pure-button pure-button-link" target="_blank"><i class="fa fa-github fa-2x"></i>Git
Hub</a>
<a href="http://weibo.com/angularjs/" class="pure-button pure-button-link" target="_blank"><i class="fa fa-weibo fa-2x"></i>WeiBo</a>
</div>
</div>
Expand All @@ -30,28 +32,21 @@
</div>
</div>
</div>
<div class="panel pure-hidden-phone" ng-show="hotComments.length>0">
<div class="panel-heading muted"><i class="fa fa-fire"></i>热门评论</div>
<ul class="media-list comments">
<li class="media" ng-repeat="comment in hotComments">
<div class="media-body">
<div class="media-content list-content">
<em class="hot" title="热度">{{comment.hots}}</em>&nbsp;&nbsp;{{comment.content}}
</div>
<div class="media-footer">
<a ng-href="{{'/'+comment.author._id}}"><strong>{{comment.author.name}}</strong></a>&nbsp;<a ng-href="{{'/'+comment.refer._id}}">{{comment.title}}</a>
</div>
</div>
</li>
</ul>
<div class="panel pure-hidden-phone">
<div class="inner text-center">
<a href="http://www.lagou.com/?utm_source=CPA__angularjs_banner&utm_medium=front&utm_campaign=toufang" target="_blank">
<img src="http://cdn.angularjs.cn/img/lagou.jpg" alt="拉勾网">
</a>
</div>
</div>
<div class="panel pure-hidden-phone">
<div class="inner text-center">
<a href="https://www.upyun.com/" target="_blank">
<img src="http://cdn.angularjs.cn/img/upyun.png" alt="又拍云存储">
</a>
<div class="text-show text-left">帮助企业提供静态文件云存储、云处理、云分发的云服务平台。<a href="http://weibo.com/upaiyun" target="_blank"><i class="fa fa-weibo fa-lg"></i></a></div>
<div class="text-show"><a href="http://segmentfault.com/t/%E5%8F%88%E6%8B%8D%E4%BA%91%E5%AD%98%E5%82%A8" target="_blank"><strong>segmentfault又拍云存储问答专区</strong></a></div>
<div class="text-show"><a href="http://segmentfault.com/t/%E5%8F%88%E6%8B%8D%E4%BA%91%E5%AD%98%E5%82%A8" target="_blank"><strong>segmentfault
又拍云存储问答专区</strong></a></div>
</div>
</div>
<div class="panel">
Expand Down
4 changes: 2 additions & 2 deletions static/src/index.html
Expand Up @@ -9,7 +9,7 @@
<meta name="description" content="{{global.metadesc}}">
<meta name="keywords" content="{{global.keywords}}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico"/>
<link rel="shortcut icon" href="/static/favicon.ico"/>
<link rel="stylesheet" href="/static/css/app.css">
</head>
<!--[if lt IE 9]> <body class="ie pure-g-r"> <![endif]-->
Expand All @@ -32,7 +32,7 @@
</ul>
<ul class="right user" ng-if="global.isLogin">
<li><a class="pure-menu-img" href="/home"><img class="img-mini" src="http://cdn.angularjs.cn/img/avatar.png" gen-src="{{global.user.avatar}}"/></a></li>
<li ng-if="global.isDesktop"><a href="/home"><i class="fa fa-home"></i>{{global.user.name}}</a></li>
<li ng-if="global.isDesktop"><a href="/home"><i class="fa fa-home"></i>{{global.user.nickname}}</a></li>
<li ng-if="global.isEditor"><a href="/admin"><i class="fa fa-gear"></i>管理</a></li>
<li ng-if="global.isDesktop"><a ng-click="logout()"><i class="fa fa-signout"></i>退出</a></li>
</ul>
Expand Down
31 changes: 13 additions & 18 deletions static/src/tpl/index.html
Expand Up @@ -10,10 +10,12 @@
<img src="http://cdn.angularjs.cn/img/angularjs.png" alt="AngularJS">
<div class="text-show text-left">使用超动感HTML &amp; JS开发WEB应用!</div>
<div class="text-show text-hot text-left">QQ交流群1 <strong class="hot">278252889(满)</strong></div>
<div class="text-show text-hot text-left">QQ交流群2 <strong class="hot">305739270</strong></div>
<div class="text-show text-hot text-left"><a class="hot" href="http://tburl.in/0hbn5nev" target="_blank">Teambition项目组,欢迎加入!</a></div>
<div class="text-show text-hot text-left">QQ交流群2 <strong class="hot">305739270(满)</strong></div>
<div class="text-show text-hot text-left">QQ交流群3 <strong class="hot">207542263</strong></div>
<div class="text-show text-hot text-left">QQ交流群4 <strong class="hot">240328422</strong></div>
<div class="text-show">
<a href="https://github.com/angular/angular.js" class="pure-button pure-button-link" target="_blank"><i class="fa fa-github fa-2x"></i>GitHub</a>
<a href="https://github.com/angular/angular.js" class="pure-button pure-button-link" target="_blank"><i class="fa fa-github fa-2x"></i>Git
Hub</a>
<a href="http://weibo.com/angularjs/" class="pure-button pure-button-link" target="_blank"><i class="fa fa-weibo fa-2x"></i>WeiBo</a>
</div>
</div>
Expand All @@ -30,28 +32,21 @@
</div>
</div>
</div>
<div class="panel pure-hidden-phone" ng-show="hotComments.length>0">
<div class="panel-heading muted"><i class="fa fa-fire"></i>热门评论</div>
<ul class="media-list comments">
<li class="media" ng-repeat="comment in hotComments">
<div class="media-body">
<div class="media-content list-content">
<em class="hot" title="热度">{{comment.hots}}</em>&nbsp;&nbsp;{{comment.content}}
</div>
<div class="media-footer">
<a ng-href="{{'/'+comment.author._id}}"><strong>{{comment.author.name}}</strong></a>&nbsp;<a ng-href="{{'/'+comment.refer._id}}">{{comment.title}}</a>
</div>
</div>
</li>
</ul>
<div class="panel pure-hidden-phone">
<div class="inner text-center">
<a href="http://www.lagou.com/?utm_source=CPA__angularjs_banner&utm_medium=front&utm_campaign=toufang" target="_blank">
<img src="http://cdn.angularjs.cn/img/lagou.jpg" alt="拉勾网">
</a>
</div>
</div>
<div class="panel pure-hidden-phone">
<div class="inner text-center">
<a href="https://www.upyun.com/" target="_blank">
<img src="http://cdn.angularjs.cn/img/upyun.png" alt="又拍云存储">
</a>
<div class="text-show text-left">帮助企业提供静态文件云存储、云处理、云分发的云服务平台。<a href="http://weibo.com/upaiyun" target="_blank"><i class="fa fa-weibo fa-lg"></i></a></div>
<div class="text-show"><a href="http://segmentfault.com/t/%E5%8F%88%E6%8B%8D%E4%BA%91%E5%AD%98%E5%82%A8" target="_blank"><strong>segmentfault又拍云存储问答专区</strong></a></div>
<div class="text-show"><a href="http://segmentfault.com/t/%E5%8F%88%E6%8B%8D%E4%BA%91%E5%AD%98%E5%82%A8" target="_blank"><strong>segmentfault
又拍云存储问答专区</strong></a></div>
</div>
</div>
<div class="panel">
Expand Down

0 comments on commit 65d5650

Please sign in to comment.