File tree Expand file tree Collapse file tree 13 files changed +18
-56
lines changed
Expand file tree Collapse file tree 13 files changed +18
-56
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11'use strict' ;
22
33const bcrypt = require ( 'bcryptjs' ) ;
4- const moment = require ( 'moment' ) ;
5-
6- moment . locale ( 'zh-cn' ) ; // 使用中文
7-
8- // 格式化时间
9- exports . formatDate = ( date , friendly ) => {
10- date = moment ( date ) ;
11-
12- if ( friendly ) {
13- return date . fromNow ( ) ;
14- }
15-
16- return date . format ( 'YYYY-MM-DD HH:mm' ) ;
17- } ;
184
195exports . validateId = str => {
206 return / ^ [ a - z A - Z 0 - 9 \- _ ] + $ / i. test ( str ) ;
Original file line number Diff line number Diff line change 33const util = require ( 'util' ) ;
44const qn = require ( 'qn' ) ;
55
6- exports = function qnUpload ( options ) {
6+ module . exports = function qnUpload ( options ) {
77 // 7牛 client
88 let qnClient ;
99 if ( options . qn_access && options . qn_access . secretKey !== 'your secret key' ) {
1010 qnClient = qn . create ( options . qn_access ) ;
1111 }
12- const qnUpload = util . promisify ( qnClient . upload ) ;
13- return qnUpload ;
12+ return util . promisify ( qnClient . upload ) ;
1413} ;
Original file line number Diff line number Diff line change 33const MarkdownIt = require ( 'markdown-it' ) ;
44const validator = require ( 'validator' ) ;
55const jsxss = require ( 'xss' ) ;
6+ const moment = require ( 'moment' ) ;
7+
8+ moment . locale ( 'zh-cn' ) ; // 使用中文
69
710// Set default options
811const md = new MarkdownIt ( ) ;
@@ -90,3 +93,9 @@ exports.proxy = function(url) {
9093 // 当 google 和 github 封锁严重时,则需要通过服务器代理访问它们的静态资源
9194 // return '/agent?url=' + encodeURIComponent(url);
9295} ;
96+
97+ exports . ago = function ( date ) {
98+ date = moment ( date ) ;
99+
100+ return date . fromNow ( ) ;
101+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const BaseModel = require ( '../common/base_model' ) ;
4-
53module . exports = app => {
64 const mongoose = app . mongoose ;
75 const Schema = mongoose . Schema ;
@@ -17,7 +15,6 @@ module.exports = app => {
1715 create_at : { type : Date , default : Date . now } ,
1816 } ) ;
1917
20- MessageSchema . plugin ( BaseModel ) ;
2118 MessageSchema . index ( { master_id : 1 , has_read : - 1 , create_at : - 1 } ) ;
2219
2320 return mongoose . model ( 'Message' , MessageSchema ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const BaseModel = require ( '../common/base_model' ) ;
4-
53module . exports = app => {
64 const mongoose = app . mongoose ;
75 const Schema = mongoose . Schema ;
@@ -21,7 +19,6 @@ module.exports = app => {
2119 usePushEach : true ,
2220 } ) ;
2321
24- ReplySchema . plugin ( BaseModel ) ;
2522 ReplySchema . index ( { topic_id : 1 } ) ;
2623 ReplySchema . index ( { author_id : 1 , create_at : - 1 } ) ;
2724
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const BaseModel = require ( '../common/base_model' ) ;
4-
53module . exports = app => {
64 const mongoose = app . mongoose ;
75 const Schema = mongoose . Schema ;
@@ -27,7 +25,6 @@ module.exports = app => {
2725 deleted : { type : Boolean , default : false } ,
2826 } ) ;
2927
30- TopicSchema . plugin ( BaseModel ) ;
3128 TopicSchema . index ( { create_at : - 1 } ) ;
3229 TopicSchema . index ( { top : - 1 , last_reply_at : - 1 } ) ;
3330 TopicSchema . index ( { author_id : 1 , create_at : - 1 } ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const BaseModel = require ( '../common/base_model' ) ;
4-
53module . exports = app => {
64 const mongoose = app . mongoose ;
75 const Schema = mongoose . Schema ;
@@ -13,7 +11,6 @@ module.exports = app => {
1311 create_at : { type : Date , default : Date . now } ,
1412 } ) ;
1513
16- TopicCollectSchema . plugin ( BaseModel ) ;
1714 TopicCollectSchema . index ( { user_id : 1 , topic_id : 1 } , { unique : true } ) ;
1815
1916 return mongoose . model ( 'TopicCollect' , TopicCollectSchema ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
33const utility = require ( 'utility' ) ;
4- const BaseModel = require ( '../common/base_model' ) ;
54
65module . exports = app => {
76 const mongoose = app . mongoose ;
@@ -47,8 +46,6 @@ module.exports = app => {
4746 accessToken : { type : String } ,
4847 } ) ;
4948
50- UserSchema . plugin ( BaseModel ) ;
51-
5249 UserSchema . index ( { loginname : 1 } , { unique : true } ) ;
5350 UserSchema . index ( { email : 1 } , { unique : true } ) ;
5451 UserSchema . index ( { score : - 1 } ) ;
Original file line number Diff line number Diff line change 77
88 < div class ='user_info '>
99 < a class ='dark reply_author ' href ="/user/<%= reply.author.loginname %> "> < %= reply.author.loginname %> </ a >
10- < a class ="reply_time " href ="#<%= reply._id %> "> < %= indexInCollection + 1 %> 楼•< %= reply.create_at_ago( )
10+ < a class ="reply_time " href ="#<%= reply._id %> "> < %= indexInCollection + 1 %> 楼•< %= helper.ago(reply.create_at )
1111 %> </ a >
1212 < % if (reply.author.loginname == topic.author.loginname) { %>
1313 < span class ="reply_by_author "> 作者</ span >
You can’t perform that action at this time.
0 commit comments