1
1
const
2
2
Router = require ( 'koa-router' ) ,
3
3
{ ObjectID } = require ( 'bson' ) ,
4
- { PermissionError } = require ( 'hydro' ) . errors ,
5
- { PERM_THREAD_CREATE , PERM_THREAD_REPLY , PERM_THREAD_DELETE , PERM_REPLY_DELETE } = require ( '../constants .js' ) ;
4
+ { PermissionError } = require ( 'hydro-framework ' ) . errors ,
5
+ { PERM_THREAD_CREATE , PERM_THREAD_REPLY , PERM_THREAD_DELETE , PERM_REPLY_DELETE } = require ( '../../permission .js' ) ;
6
6
7
- module . exports = class HANDLER_MAIN {
7
+ exports . handler = class {
8
8
constructor ( i ) {
9
9
this . db = i . db ;
10
10
this . lib = i . lib ;
@@ -25,7 +25,7 @@ module.exports = class HANDLER_MAIN {
25
25
this . router
26
26
. get ( '/' , async ctx => {
27
27
let categories = await this . lib . conf . get ( 'categories' ) ;
28
- await ctx . render ( 'index ' , { categories } ) ;
28
+ await ctx . render ( 'bbs_index ' , { categories } ) ;
29
29
} )
30
30
. get ( '/c/:category' , async ( ctx , next ) => {
31
31
let page = ctx . query . page || 1 , category ;
@@ -39,7 +39,7 @@ module.exports = class HANDLER_MAIN {
39
39
else {
40
40
let threads = await this . db . collection ( 'thread' ) . find ( { category : category . id } )
41
41
. skip ( ( page - 1 ) * 50 ) . limit ( 50 ) . sort ( { time : - 1 } ) . toArray ( ) ;
42
- await ctx . render ( 'list ' , { category, threads } ) ;
42
+ await ctx . render ( 'bbs_list ' , { category, threads } ) ;
43
43
}
44
44
} )
45
45
. get ( '/c/:category/create' , async ( ctx , next ) => {
@@ -50,7 +50,7 @@ module.exports = class HANDLER_MAIN {
50
50
break ;
51
51
}
52
52
if ( ! category ) await next ( ) ;
53
- else await ctx . render ( 'create ' , { category } ) ;
53
+ else await ctx . render ( 'bbs_create ' , { category } ) ;
54
54
} )
55
55
. post ( '/c/:category/create' , async ( ctx , next ) => {
56
56
if ( ! ctx . state . user . hasPerm ( PERM_THREAD_CREATE ) ) throw new PermissionError ( ) ;
@@ -92,7 +92,7 @@ module.exports = class HANDLER_MAIN {
92
92
for ( let i in comments ) queue . push ( await this . formatComment ( comments [ i ] ) ) ;
93
93
await Promise . all ( queue ) ;
94
94
thread . author = author ;
95
- await ctx . render ( 'thread ' , { thread, comments, category } ) ;
95
+ await ctx . render ( 'bbs_thread ' , { thread, comments, category } ) ;
96
96
}
97
97
} )
98
98
. all ( '/t/:id/delete' , async ( ctx , next ) => {
0 commit comments