mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
fix: urls in posts and announces
This commit is contained in:
@@ -25,6 +25,7 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
userAgentIcons,
|
||||
buildAvatar,
|
||||
increment,
|
||||
generatePostUrl,
|
||||
generateRepliedTo,
|
||||
generateWrote,
|
||||
isoTimeToLocaleString,
|
||||
@@ -329,18 +330,24 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
return String(value + parseInt(inc, 10));
|
||||
}
|
||||
|
||||
function generatePostUrl(post, property = 'pid') {
|
||||
return utils.isNumber(post[property]) ? `${relative_path}/post/${post[property]}` : post[property];
|
||||
}
|
||||
|
||||
function generateRepliedTo(post, timeagoCutoff) {
|
||||
const displayname = post.parent && post.parent.displayname ?
|
||||
post.parent.displayname : '[[global:guest]]';
|
||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
||||
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${post.toPid}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
|
||||
const url = generatePostUrl(post, 'toPid');
|
||||
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${url}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
|
||||
}
|
||||
|
||||
function generateWrote(post, timeagoCutoff) {
|
||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
||||
return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
|
||||
const url = generatePostUrl(post);
|
||||
return `[[topic:wrote-${langSuffix}, ${url}, ${post.timestampISO}]]`;
|
||||
}
|
||||
|
||||
function isoTimeToLocaleString(isoTime, locale = 'en-GB') {
|
||||
|
||||
Reference in New Issue
Block a user