prevent dup[licate backlinks and add (OP) label to op quotes

merge-requests/208/head
fatchan 5 years ago
parent f6e8565432
commit f8a88d7a23
  1. 4
      helpers/quotes.js
  2. 2
      models/forms/make-post.js

@ -77,7 +77,7 @@ module.exports = async (board, text) => {
const quotenum = +match.substring(2); const quotenum = +match.substring(2);
if (postThreadIdMap[board] && postThreadIdMap[board][quotenum]) { if (postThreadIdMap[board] && postThreadIdMap[board][quotenum]) {
threadQuotes.push(quotenum) threadQuotes.push(quotenum)
return `<a class='quote' href='/${board}/thread/${postThreadIdMap[board][quotenum]}.html#${quotenum}'>&gt;&gt;${quotenum}</a>`; return `<a class='quote' href='/${board}/thread/${postThreadIdMap[board][quotenum]}.html#${quotenum}'>&gt;&gt;${quotenum}</a>${postThreadIdMap[board][quotenum] === quotenum ? ' <small>(OP)</small> ' : ''}`;
} }
return match; return match;
}); });
@ -96,6 +96,6 @@ module.exports = async (board, text) => {
}); });
} }
return { quotedMessage: text, threadQuotes }; return { quotedMessage: text, threadQuotes: [...new Set(threadQuotes)] };
} }

@ -12,7 +12,7 @@ const path = require('path')
, simpleMarkdown = require(__dirname+'/../../helpers/markdown.js') , simpleMarkdown = require(__dirname+'/../../helpers/markdown.js')
, sanitize = require('sanitize-html') , sanitize = require('sanitize-html')
, sanitizeOptions = { , sanitizeOptions = {
allowedTags: [ 'span', 'a', 'em', 'strong' ], allowedTags: [ 'span', 'a', 'em', 'strong', 'small' ],
allowedAttributes: { allowedAttributes: {
'a': [ 'href', 'class' ], 'a': [ 'href', 'class' ],
'span': [ 'class' ] 'span': [ 'class' ]

Loading…
Cancel
Save