mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
fix: post urls to use prefix instead of linking out directly to origin server, exposed encodeURIComponent as a template helper for themes
This commit is contained in:
@@ -27,6 +27,7 @@ module.exports = function (utils, Benchpress, relative_path) {
|
|||||||
increment,
|
increment,
|
||||||
generateRepliedTo,
|
generateRepliedTo,
|
||||||
generateWrote,
|
generateWrote,
|
||||||
|
encodeURIComponent: _encodeURIComponent,
|
||||||
isoTimeToLocaleString,
|
isoTimeToLocaleString,
|
||||||
shouldHideReplyContainer,
|
shouldHideReplyContainer,
|
||||||
humanReadableNumber,
|
humanReadableNumber,
|
||||||
@@ -340,13 +341,17 @@ module.exports = function (utils, Benchpress, relative_path) {
|
|||||||
post.parent.displayname : '[[global:guest]]';
|
post.parent.displayname : '[[global:guest]]';
|
||||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
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}]]`;
|
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${encodeURIComponent(post.toPid)}, ${displayname}, ${relative_path}/post/${encodeURIComponent(post.pid)}, ${post.timestampISO}]]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWrote(post, timeagoCutoff) {
|
function generateWrote(post, timeagoCutoff) {
|
||||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
||||||
return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
|
return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${encodeURIComponent(post.pid)}, ${post.timestampISO}]]`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _encodeURIComponent(value) {
|
||||||
|
return encodeURIComponent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isoTimeToLocaleString(isoTime, locale = 'en-GB') {
|
function isoTimeToLocaleString(isoTime, locale = 'en-GB') {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ inbox.announce = async (req) => {
|
|||||||
await topics.events.log(tid, {
|
await topics.events.log(tid, {
|
||||||
type: 'announce',
|
type: 'announce',
|
||||||
uid: actor,
|
uid: actor,
|
||||||
href: `/post/${pid}`,
|
href: `/post/${encodeURIComponent(pid)}`,
|
||||||
pid,
|
pid,
|
||||||
timestamp,
|
timestamp,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user