mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +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,
|
||||
generateRepliedTo,
|
||||
generateWrote,
|
||||
encodeURIComponent: _encodeURIComponent,
|
||||
isoTimeToLocaleString,
|
||||
shouldHideReplyContainer,
|
||||
humanReadableNumber,
|
||||
@@ -340,13 +341,17 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
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}]]`;
|
||||
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) {
|
||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||
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') {
|
||||
|
||||
@@ -154,7 +154,7 @@ inbox.announce = async (req) => {
|
||||
await topics.events.log(tid, {
|
||||
type: 'announce',
|
||||
uid: actor,
|
||||
href: `/post/${pid}`,
|
||||
href: `/post/${encodeURIComponent(pid)}`,
|
||||
pid,
|
||||
timestamp,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user