mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client/comments: add global comment list
This commit is contained in:
@ -1,18 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
const api = require('../api.js');
|
||||
const page = require('page');
|
||||
const misc = require('../util/misc.js');
|
||||
const topNavController = require('../controllers/top_nav_controller.js');
|
||||
const pageController = require('../controllers/page_controller.js');
|
||||
const CommentsPageView = require('../views/comments_page_view.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class CommentsController {
|
||||
registerRoutes() {
|
||||
page('/comments', (ctx, next) => { this._listCommentsRoute(); });
|
||||
page('/comments/:query?',
|
||||
(ctx, next) => { misc.parseSearchQueryRoute(ctx, next); },
|
||||
(ctx, next) => { this._listCommentsRoute(ctx); });
|
||||
this._commentsPageView = new CommentsPageView();
|
||||
this._emptyView = new EmptyView();
|
||||
}
|
||||
|
||||
_listCommentsRoute() {
|
||||
_listCommentsRoute(ctx) {
|
||||
topNavController.activate('comments');
|
||||
this._emptyView.render();
|
||||
|
||||
pageController.run({
|
||||
searchQuery: ctx.searchQuery,
|
||||
clientUrl: '/comments/' + misc.formatSearchQuery({page: '{page}'}),
|
||||
requestPage: page => {
|
||||
return api.get(
|
||||
'/posts/?query=sort:comment-date+comment-count-min:1' +
|
||||
`&page=${page}&pageSize=10&fields=` +
|
||||
'id,comments,commentCount,thumbnailUrl');
|
||||
},
|
||||
pageRenderer: this._commentsPageView,
|
||||
pageContext: {
|
||||
canViewPosts: api.hasPrivilege('posts:view'),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user