mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-15 22:11:17 +02:00
closes #11218, 🚋
This commit is contained in:
@@ -43,6 +43,11 @@
|
||||
"ban-ip": "Ban IP",
|
||||
"view-history": "Edit History",
|
||||
|
||||
"wrote-ago": "wrote <span class=\"timeago\" title=\"%1\"></span>",
|
||||
"wrote-on": "wrote on <span class=\"timeago\" title=\"%1\"></span>",
|
||||
"replied-to-user-ago": "replied to <a component=\"post/parent\" data-topid=\"%1\" href=\"%2\">%3</a> <span class=\"timeago\" title=\"%4\"></span>",
|
||||
"replied-to-user-on": "replied to <a component=\"post/parent\" data-topid=\"%1\" href=\"%2\">%3</a> on <span class=\"timeago\" title=\"%4\"></span>",
|
||||
|
||||
"user-locked-topic-ago": "%1 locked this topic %2",
|
||||
"user-locked-topic-on": "%1 locked this topic on %2",
|
||||
"user-unlocked-topic-ago": "%1 unlocked this topic %2",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
module.exports = function (utils, Benchpress, relative_path) {
|
||||
Benchpress.setGlobal('true', true);
|
||||
Benchpress.setGlobal('false', false);
|
||||
const oneDayInMs = 24 * 60 * 60 * 1000;
|
||||
|
||||
const helpers = {
|
||||
displayMenuItem,
|
||||
@@ -24,6 +25,8 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
userAgentIcons,
|
||||
buildAvatar,
|
||||
increment,
|
||||
generateRepliedTo,
|
||||
generateWrote,
|
||||
register,
|
||||
__escape: identity,
|
||||
};
|
||||
@@ -320,6 +323,20 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
return value + parseInt(inc, 10);
|
||||
}
|
||||
|
||||
function generateRepliedTo(post, timeagoCutoff) {
|
||||
const username = post.parent && post.parent.username ?
|
||||
post.parent.username : '[[global:guest]]';
|
||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
||||
return `[[topic:replied-to-user-${langSuffix}, ${post.pid}, ${relative_path}/post/${post.pid}, ${username}, ${post.timestampISO}]]`;
|
||||
}
|
||||
|
||||
function generateWrote(post, timeagoCutoff) {
|
||||
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
|
||||
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
|
||||
return `[[topic:wrote-${langSuffix}, ${post.timestampISO}]]`;
|
||||
}
|
||||
|
||||
function register() {
|
||||
Object.keys(helpers).forEach(function (helperName) {
|
||||
Benchpress.registerHelper(helperName, helpers[helperName]);
|
||||
|
||||
Reference in New Issue
Block a user