mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: async refactor
This commit is contained in:
@@ -1,46 +1,40 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const nconf = require('nconf');
|
||||||
var nconf = require('nconf');
|
|
||||||
|
|
||||||
var user = require('../user');
|
const user = require('../user');
|
||||||
var plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
var topics = require('../topics');
|
const topics = require('../topics');
|
||||||
var posts = require('../posts');
|
const posts = require('../posts');
|
||||||
var helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
|
|
||||||
exports.get = function (req, res, callback) {
|
exports.get = async function (req, res, callback) {
|
||||||
res.locals.metaTags = {
|
res.locals.metaTags = {
|
||||||
...res.locals.metaTags,
|
...res.locals.metaTags,
|
||||||
name: 'robots',
|
name: 'robots',
|
||||||
content: 'noindex',
|
content: 'noindex',
|
||||||
};
|
};
|
||||||
|
|
||||||
async.waterfall([
|
const data = await plugins.fireHook('filter:composer.build', {
|
||||||
function (next) {
|
req: req,
|
||||||
plugins.fireHook('filter:composer.build', {
|
res: res,
|
||||||
req: req,
|
next: callback,
|
||||||
res: res,
|
templateData: {},
|
||||||
next: callback,
|
});
|
||||||
templateData: {},
|
|
||||||
}, next);
|
if (data.templateData.disabled) {
|
||||||
},
|
res.render('', {
|
||||||
function (data) {
|
title: '[[modules:composer.compose]]',
|
||||||
if (data.templateData.disabled) {
|
});
|
||||||
res.render('', {
|
} else {
|
||||||
title: '[[modules:composer.compose]]',
|
data.templateData.title = '[[modules:composer.compose]]';
|
||||||
});
|
res.render('compose', data.templateData);
|
||||||
} else {
|
}
|
||||||
data.templateData.title = '[[modules:composer.compose]]';
|
|
||||||
res.render('compose', data.templateData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
], callback);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.post = function (req, res) {
|
exports.post = async function (req, res) {
|
||||||
var body = req.body;
|
const body = req.body;
|
||||||
var data = {
|
const data = {
|
||||||
uid: req.uid,
|
uid: req.uid,
|
||||||
req: req,
|
req: req,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
@@ -52,49 +46,37 @@ exports.post = function (req, res) {
|
|||||||
if (!data.content) {
|
if (!data.content) {
|
||||||
return helpers.noScriptErrors(req, res, '[[error:invalid-data]]', 400);
|
return helpers.noScriptErrors(req, res, '[[error:invalid-data]]', 400);
|
||||||
}
|
}
|
||||||
|
async function queueOrPost(postFn, data) {
|
||||||
async.waterfall([
|
const shouldQueue = await posts.shouldQueue(req.uid, data);
|
||||||
function (next) {
|
if (shouldQueue) {
|
||||||
function queueOrPost(postFn, data, next) {
|
delete data.req;
|
||||||
async.waterfall([
|
return await posts.addToQueue(data);
|
||||||
function (next) {
|
|
||||||
posts.shouldQueue(req.uid, data, next);
|
|
||||||
},
|
|
||||||
function (shouldQueue, next) {
|
|
||||||
if (shouldQueue) {
|
|
||||||
delete data.req;
|
|
||||||
posts.addToQueue(data, next);
|
|
||||||
} else {
|
|
||||||
postFn(data, next);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
], next);
|
|
||||||
}
|
|
||||||
if (body.tid) {
|
|
||||||
data.tid = body.tid;
|
|
||||||
queueOrPost(topics.reply, data, next);
|
|
||||||
} else if (body.cid) {
|
|
||||||
data.cid = body.cid;
|
|
||||||
data.title = body.title;
|
|
||||||
data.tags = [];
|
|
||||||
data.thumb = '';
|
|
||||||
queueOrPost(topics.post, data, next);
|
|
||||||
} else {
|
|
||||||
next(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (result, next) {
|
|
||||||
if (result.queued) {
|
|
||||||
return res.redirect((nconf.get('relative_path') || '/'));
|
|
||||||
}
|
|
||||||
var uid = result.uid ? result.uid : result.topicData.uid;
|
|
||||||
user.updateOnlineUsers(uid);
|
|
||||||
next(null, result.pid ? '/post/' + result.pid : '/topic/' + result.topicData.slug);
|
|
||||||
},
|
|
||||||
], function (err, path) {
|
|
||||||
if (err) {
|
|
||||||
return helpers.noScriptErrors(req, res, err.message, 400);
|
|
||||||
}
|
}
|
||||||
|
return await postFn(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let result;
|
||||||
|
if (body.tid) {
|
||||||
|
data.tid = body.tid;
|
||||||
|
result = await queueOrPost(topics.reply, data);
|
||||||
|
} else if (body.cid) {
|
||||||
|
data.cid = body.cid;
|
||||||
|
data.title = body.title;
|
||||||
|
data.tags = [];
|
||||||
|
data.thumb = '';
|
||||||
|
result = await queueOrPost(topics.post, data);
|
||||||
|
} else {
|
||||||
|
throw new Error('[[error:invalid-data]]');
|
||||||
|
}
|
||||||
|
if (result.queued) {
|
||||||
|
return res.redirect((nconf.get('relative_path') || '/'));
|
||||||
|
}
|
||||||
|
const uid = result.uid ? result.uid : result.topicData.uid;
|
||||||
|
user.updateOnlineUsers(uid);
|
||||||
|
const path = result.pid ? '/post/' + result.pid : '/topic/' + result.topicData.slug;
|
||||||
res.redirect(nconf.get('relative_path') + path);
|
res.redirect(nconf.get('relative_path') + path);
|
||||||
});
|
} catch (err) {
|
||||||
|
helpers.noScriptErrors(req, res, err.message, 400);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,66 +1,52 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const url = require('url');
|
||||||
var url = require('url');
|
|
||||||
|
|
||||||
var plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
var meta = require('../meta');
|
const meta = require('../meta');
|
||||||
var user = require('../user');
|
const user = require('../user');
|
||||||
|
|
||||||
function adminHomePageRoute() {
|
function adminHomePageRoute() {
|
||||||
return (meta.config.homePageRoute || meta.config.homePageCustom || '').replace(/^\/+/, '') || 'categories';
|
return (meta.config.homePageRoute || meta.config.homePageCustom || '').replace(/^\/+/, '') || 'categories';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserHomeRoute(uid, callback) {
|
async function getUserHomeRoute(uid) {
|
||||||
async.waterfall([
|
const settings = await user.getSettings(uid);
|
||||||
function (next) {
|
let route = adminHomePageRoute();
|
||||||
user.getSettings(uid, next);
|
|
||||||
},
|
|
||||||
function (settings, next) {
|
|
||||||
var route = adminHomePageRoute();
|
|
||||||
|
|
||||||
if (settings.homePageRoute !== 'undefined' && settings.homePageRoute !== 'none') {
|
if (settings.homePageRoute !== 'undefined' && settings.homePageRoute !== 'none') {
|
||||||
route = (settings.homePageRoute || route).replace(/^\/+/, '');
|
route = (settings.homePageRoute || route).replace(/^\/+/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
next(null, route);
|
return route;
|
||||||
},
|
|
||||||
], callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rewrite(req, res, next) {
|
async function rewrite(req, res, next) {
|
||||||
if (req.path !== '/' && req.path !== '/api/' && req.path !== '/api') {
|
if (req.path !== '/' && req.path !== '/api/' && req.path !== '/api') {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
let route = adminHomePageRoute();
|
||||||
|
if (meta.config.allowUserHomePage) {
|
||||||
|
route = await getUserHomeRoute(req.uid, next);
|
||||||
|
}
|
||||||
|
|
||||||
async.waterfall([
|
let parsedUrl;
|
||||||
function (next) {
|
try {
|
||||||
if (meta.config.allowUserHomePage) {
|
parsedUrl = url.parse(route, true);
|
||||||
getUserHomeRoute(req.uid, next);
|
} catch (err) {
|
||||||
} else {
|
return next(err);
|
||||||
next(null, adminHomePageRoute());
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
function (route, next) {
|
|
||||||
var parsedUrl;
|
|
||||||
try {
|
|
||||||
parsedUrl = url.parse(route, true);
|
|
||||||
} catch (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pathname = parsedUrl.pathname;
|
const pathname = parsedUrl.pathname;
|
||||||
var hook = 'action:homepage.get:' + pathname;
|
const hook = 'action:homepage.get:' + pathname;
|
||||||
if (!plugins.hasListeners(hook)) {
|
if (!plugins.hasListeners(hook)) {
|
||||||
req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + pathname;
|
req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + pathname;
|
||||||
} else {
|
} else {
|
||||||
res.locals.homePageRoute = pathname;
|
res.locals.homePageRoute = pathname;
|
||||||
}
|
}
|
||||||
req.query = Object.assign(parsedUrl.query, req.query);
|
req.query = Object.assign(parsedUrl.query, req.query);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
},
|
|
||||||
], next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.rewrite = rewrite;
|
exports.rewrite = rewrite;
|
||||||
|
|||||||
@@ -1,36 +1,30 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const nconf = require('nconf');
|
||||||
var nconf = require('nconf');
|
const validator = require('validator');
|
||||||
var validator = require('validator');
|
|
||||||
|
|
||||||
var helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
var recentController = require('./recent');
|
const recentController = require('./recent');
|
||||||
|
|
||||||
var popularController = module.exports;
|
const popularController = module.exports;
|
||||||
|
|
||||||
popularController.get = function (req, res, next) {
|
popularController.get = async function (req, res, next) {
|
||||||
async.waterfall([
|
const data = await recentController.getData(req, 'popular', 'posts');
|
||||||
function (next) {
|
if (!data) {
|
||||||
recentController.getData(req, 'popular', 'posts', next);
|
return next();
|
||||||
},
|
}
|
||||||
function (data, next) {
|
const term = helpers.terms[req.query.term] || 'alltime';
|
||||||
if (!data) {
|
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/popular') || req.originalUrl.startsWith(nconf.get('relative_path') + '/popular')) {
|
||||||
return next();
|
data.title = '[[pages:popular-' + term + ']]';
|
||||||
}
|
const breadcrumbs = [{ text: '[[global:header.popular]]' }];
|
||||||
var term = helpers.terms[req.query.term] || 'alltime';
|
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
|
||||||
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/popular') || req.originalUrl.startsWith(nconf.get('relative_path') + '/popular')) {
|
}
|
||||||
data.title = '[[pages:popular-' + term + ']]';
|
|
||||||
var breadcrumbs = [{ text: '[[global:header.popular]]' }];
|
const feedQs = data.rssFeedUrl.split('?')[1];
|
||||||
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
|
data.rssFeedUrl = nconf.get('relative_path') + '/popular/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
|
||||||
}
|
if (req.loggedIn) {
|
||||||
var feedQs = data.rssFeedUrl.split('?')[1];
|
data.rssFeedUrl += '?' + feedQs;
|
||||||
data.rssFeedUrl = nconf.get('relative_path') + '/popular/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
|
}
|
||||||
if (req.loggedIn) {
|
res.render('popular', data);
|
||||||
data.rssFeedUrl += '?' + feedQs;
|
|
||||||
}
|
|
||||||
res.render('popular', data);
|
|
||||||
},
|
|
||||||
], next);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,131 +1,93 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const nconf = require('nconf');
|
||||||
var nconf = require('nconf');
|
|
||||||
|
|
||||||
var user = require('../user');
|
const user = require('../user');
|
||||||
var categories = require('../categories');
|
const categories = require('../categories');
|
||||||
var topics = require('../topics');
|
const topics = require('../topics');
|
||||||
var meta = require('../meta');
|
const meta = require('../meta');
|
||||||
var helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
var pagination = require('../pagination');
|
const pagination = require('../pagination');
|
||||||
var privileges = require('../privileges');
|
const privileges = require('../privileges');
|
||||||
|
|
||||||
var recentController = module.exports;
|
const recentController = module.exports;
|
||||||
|
|
||||||
recentController.get = function (req, res, next) {
|
recentController.get = async function (req, res, next) {
|
||||||
async.waterfall([
|
const data = await recentController.getData(req, 'recent', 'recent');
|
||||||
function (next) {
|
if (!data) {
|
||||||
recentController.getData(req, 'recent', 'recent', next);
|
return next();
|
||||||
},
|
}
|
||||||
function (data, next) {
|
res.render('recent', data);
|
||||||
if (!data) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
res.render('recent', data);
|
|
||||||
},
|
|
||||||
], next);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
recentController.getData = function (req, url, sort, callback) {
|
recentController.getData = async function (req, url, sort) {
|
||||||
var page = parseInt(req.query.page, 10) || 1;
|
const page = parseInt(req.query.page, 10) || 1;
|
||||||
var stop = 0;
|
let term = helpers.terms[req.query.term];
|
||||||
var term = helpers.terms[req.query.term];
|
const cid = req.query.cid;
|
||||||
var settings;
|
const filter = req.query.filter || '';
|
||||||
var cid = req.query.cid;
|
|
||||||
var filter = req.query.filter || '';
|
|
||||||
var categoryData;
|
|
||||||
var rssToken;
|
|
||||||
var canPost;
|
|
||||||
|
|
||||||
if (!helpers.validFilters[filter] || (!term && req.query.term)) {
|
if (!helpers.validFilters[filter] || (!term && req.query.term)) {
|
||||||
return callback(null, null);
|
return null;
|
||||||
}
|
}
|
||||||
term = term || 'alltime';
|
term = term || 'alltime';
|
||||||
|
|
||||||
async.waterfall([
|
const states = [categories.watchStates.watching, categories.watchStates.notwatching];
|
||||||
function (next) {
|
if (filter === 'watched') {
|
||||||
async.parallel({
|
states.push(categories.watchStates.ignoring);
|
||||||
settings: function (next) {
|
}
|
||||||
user.getSettings(req.uid, next);
|
|
||||||
},
|
|
||||||
categories: function (next) {
|
|
||||||
const states = [categories.watchStates.watching, categories.watchStates.notwatching];
|
|
||||||
if (filter === 'watched') {
|
|
||||||
states.push(categories.watchStates.ignoring);
|
|
||||||
}
|
|
||||||
helpers.getCategoriesByStates(req.uid, cid, states, next);
|
|
||||||
},
|
|
||||||
rssToken: function (next) {
|
|
||||||
user.auth.getFeedToken(req.uid, next);
|
|
||||||
},
|
|
||||||
canPost: function (next) {
|
|
||||||
canPostTopic(req.uid, next);
|
|
||||||
},
|
|
||||||
}, next);
|
|
||||||
},
|
|
||||||
function (results, next) {
|
|
||||||
rssToken = results.rssToken;
|
|
||||||
settings = results.settings;
|
|
||||||
categoryData = results.categories;
|
|
||||||
canPost = results.canPost;
|
|
||||||
|
|
||||||
var start = Math.max(0, (page - 1) * settings.topicsPerPage);
|
const [settings, categoryData, rssToken, canPost] = await Promise.all([
|
||||||
stop = start + settings.topicsPerPage - 1;
|
user.getSettings(req.uid),
|
||||||
|
helpers.getCategoriesByStates(req.uid, cid, states),
|
||||||
|
user.auth.getFeedToken(req.uid),
|
||||||
|
canPostTopic(req.uid),
|
||||||
|
]);
|
||||||
|
|
||||||
topics.getSortedTopics({
|
const start = Math.max(0, (page - 1) * settings.topicsPerPage);
|
||||||
cids: cid,
|
const stop = start + settings.topicsPerPage - 1;
|
||||||
uid: req.uid,
|
|
||||||
start: start,
|
|
||||||
stop: stop,
|
|
||||||
filter: filter,
|
|
||||||
term: term,
|
|
||||||
sort: sort,
|
|
||||||
query: req.query,
|
|
||||||
}, next);
|
|
||||||
},
|
|
||||||
function (data, next) {
|
|
||||||
data.canPost = canPost;
|
|
||||||
data.categories = categoryData.categories;
|
|
||||||
data.allCategoriesUrl = url + helpers.buildQueryString('', filter, '');
|
|
||||||
data.selectedCategory = categoryData.selectedCategory;
|
|
||||||
data.selectedCids = categoryData.selectedCids;
|
|
||||||
data['feeds:disableRSS'] = meta.config['feeds:disableRSS'];
|
|
||||||
data.rssFeedUrl = nconf.get('relative_path') + '/' + url + '.rss';
|
|
||||||
if (req.loggedIn) {
|
|
||||||
data.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
|
||||||
}
|
|
||||||
data.title = meta.config.homePageTitle || '[[pages:home]]';
|
|
||||||
|
|
||||||
data.filters = helpers.buildFilters(url, filter, req.query);
|
const data = await topics.getSortedTopics({
|
||||||
data.selectedFilter = data.filters.find(filter => filter && filter.selected);
|
cids: cid,
|
||||||
data.terms = helpers.buildTerms(url, term, req.query);
|
uid: req.uid,
|
||||||
data.selectedTerm = data.terms.find(term => term && term.selected);
|
start: start,
|
||||||
|
stop: stop,
|
||||||
|
filter: filter,
|
||||||
|
term: term,
|
||||||
|
sort: sort,
|
||||||
|
query: req.query,
|
||||||
|
});
|
||||||
|
|
||||||
var pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage));
|
data.canPost = canPost;
|
||||||
data.pagination = pagination.create(page, pageCount, req.query);
|
data.categories = categoryData.categories;
|
||||||
|
data.allCategoriesUrl = url + helpers.buildQueryString('', filter, '');
|
||||||
|
data.selectedCategory = categoryData.selectedCategory;
|
||||||
|
data.selectedCids = categoryData.selectedCids;
|
||||||
|
data['feeds:disableRSS'] = meta.config['feeds:disableRSS'];
|
||||||
|
data.rssFeedUrl = nconf.get('relative_path') + '/' + url + '.rss';
|
||||||
|
if (req.loggedIn) {
|
||||||
|
data.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
||||||
|
}
|
||||||
|
data.title = meta.config.homePageTitle || '[[pages:home]]';
|
||||||
|
|
||||||
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/' + url) || req.originalUrl.startsWith(nconf.get('relative_path') + '/' + url)) {
|
data.filters = helpers.buildFilters(url, filter, req.query);
|
||||||
data.title = '[[pages:' + url + ']]';
|
data.selectedFilter = data.filters.find(filter => filter && filter.selected);
|
||||||
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[' + url + ':title]]' }]);
|
data.terms = helpers.buildTerms(url, term, req.query);
|
||||||
}
|
data.selectedTerm = data.terms.find(term => term && term.selected);
|
||||||
|
|
||||||
next(null, data);
|
var pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage));
|
||||||
},
|
data.pagination = pagination.create(page, pageCount, req.query);
|
||||||
], callback);
|
|
||||||
|
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/' + url) || req.originalUrl.startsWith(nconf.get('relative_path') + '/' + url)) {
|
||||||
|
data.title = '[[pages:' + url + ']]';
|
||||||
|
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[' + url + ':title]]' }]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
function canPostTopic(uid, callback) {
|
async function canPostTopic(uid) {
|
||||||
async.waterfall([
|
let cids = await categories.getAllCidsFromSet('categories:cid');
|
||||||
function (next) {
|
cids = await privileges.categories.filterCids('topics:create', cids, uid);
|
||||||
categories.getAllCidsFromSet('categories:cid', next);
|
return cids.length > 0;
|
||||||
},
|
|
||||||
function (cids, next) {
|
|
||||||
privileges.categories.filterCids('topics:create', cids, uid, next);
|
|
||||||
},
|
|
||||||
function (cids, next) {
|
|
||||||
next(null, cids.length > 0);
|
|
||||||
},
|
|
||||||
], callback);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const nconf = require('nconf');
|
||||||
var nconf = require('nconf');
|
const validator = require('validator');
|
||||||
var validator = require('validator');
|
|
||||||
|
|
||||||
var helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
var recentController = require('./recent');
|
const recentController = require('./recent');
|
||||||
|
|
||||||
var topController = module.exports;
|
const topController = module.exports;
|
||||||
|
|
||||||
topController.get = function (req, res, next) {
|
topController.get = async function (req, res, next) {
|
||||||
async.waterfall([
|
const data = await recentController.getData(req, 'top', 'votes');
|
||||||
function (next) {
|
if (!data) {
|
||||||
recentController.getData(req, 'top', 'votes', next);
|
return next();
|
||||||
},
|
}
|
||||||
function (data, next) {
|
const term = helpers.terms[req.query.term] || 'alltime';
|
||||||
if (!data) {
|
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/top') || req.originalUrl.startsWith(nconf.get('relative_path') + '/top')) {
|
||||||
return next();
|
data.title = '[[pages:top-' + term + ']]';
|
||||||
}
|
}
|
||||||
var term = helpers.terms[req.query.term] || 'alltime';
|
|
||||||
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/top') || req.originalUrl.startsWith(nconf.get('relative_path') + '/top')) {
|
|
||||||
data.title = '[[pages:top-' + term + ']]';
|
|
||||||
}
|
|
||||||
|
|
||||||
var feedQs = data.rssFeedUrl.split('?')[1];
|
const feedQs = data.rssFeedUrl.split('?')[1];
|
||||||
data.rssFeedUrl = nconf.get('relative_path') + '/top/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
|
data.rssFeedUrl = nconf.get('relative_path') + '/top/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
|
||||||
if (req.loggedIn) {
|
if (req.loggedIn) {
|
||||||
data.rssFeedUrl += '?' + feedQs;
|
data.rssFeedUrl += '?' + feedQs;
|
||||||
}
|
}
|
||||||
res.render('top', data);
|
res.render('top', data);
|
||||||
},
|
|
||||||
], next);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user