mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-19 06:50:21 +01:00
fix: renderOverride to not clobber url if already set in template data
This commit is contained in:
@@ -151,7 +151,7 @@ categoryController.get = async function (req, res, next) {
|
|||||||
categoryData.selectedTags = tagData.selectedTags;
|
categoryData.selectedTags = tagData.selectedTags;
|
||||||
categoryData.sortOptionLabel = `[[topic:${validator.escape(String(sort)).replace(/_/g, '-')}]]`;
|
categoryData.sortOptionLabel = `[[topic:${validator.escape(String(sort)).replace(/_/g, '-')}]]`;
|
||||||
|
|
||||||
if (!meta.config['feeds:disableRSS']) {
|
if (utils.isNumber(categoryData.cid) && !meta.config['feeds:disableRSS']) {
|
||||||
categoryData.rssFeedUrl = `${url}/category/${categoryData.cid}.rss`;
|
categoryData.rssFeedUrl = `${url}/category/${categoryData.cid}.rss`;
|
||||||
if (req.loggedIn) {
|
if (req.loggedIn) {
|
||||||
categoryData.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`;
|
categoryData.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`;
|
||||||
@@ -175,10 +175,15 @@ categoryController.get = async function (req, res, next) {
|
|||||||
res.set('Link', `<${nconf.get('url')}/category/${cid}>; rel="alternate"; type="application/activity+json"`);
|
res.set('Link', `<${nconf.get('url')}/category/${cid}>; rel="alternate"; type="application/activity+json"`);
|
||||||
|
|
||||||
// Category accessible
|
// Category accessible
|
||||||
const remoteOk = await privileges.categories.can('read', cid, activitypub._constants.uid);
|
const federating = await privileges.categories.can('read', cid, activitypub._constants.uid);
|
||||||
if (remoteOk) {
|
if (federating) {
|
||||||
categoryData.handleFull = `${categoryData.handle}@${nconf.get('url_parsed').host}`;
|
categoryData.handleFull = `${categoryData.handle}@${nconf.get('url_parsed').host}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some remote categories don't have `url`, assume same as id
|
||||||
|
if (!utils.isNumber(categoryData.cid) && !categoryData.hasOwnProperty('url')) {
|
||||||
|
categoryData.url = categoryData.cid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('category', categoryData);
|
res.render('category', categoryData);
|
||||||
@@ -247,7 +252,7 @@ function addTags(categoryData, res, currentPage) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!categoryData['feeds:disableRSS']) {
|
if (categoryData.rssFeedUrl && !categoryData['feeds:disableRSS']) {
|
||||||
res.locals.linkTags.push({
|
res.locals.linkTags.push({
|
||||||
rel: 'alternate',
|
rel: 'alternate',
|
||||||
type: 'application/rss+xml',
|
type: 'application/rss+xml',
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ module.exports = function (middleware) {
|
|||||||
options.loggedInUser = await getLoggedInUser(req);
|
options.loggedInUser = await getLoggedInUser(req);
|
||||||
options.relative_path = relative_path;
|
options.relative_path = relative_path;
|
||||||
options.template = { name: template, [template]: true };
|
options.template = { name: template, [template]: true };
|
||||||
options.url = (req.baseUrl + req.path.replace(/^\/api/, ''));
|
options.url = options.url || (req.baseUrl + req.path.replace(/^\/api/, ''));
|
||||||
options.bodyClass = helpers.buildBodyClass(req, res, options);
|
options.bodyClass = helpers.buildBodyClass(req, res, options);
|
||||||
|
|
||||||
if (req.loggedIn) {
|
if (req.loggedIn) {
|
||||||
|
|||||||
Reference in New Issue
Block a user