feat: setting to show signatures only once in topics, closes #10071

isekai-main
Barış Soner Uşaklı 2 years ago
parent 14c79763dd
commit aba420a3f3

@ -78,6 +78,7 @@
"reputation:disabled": 0, "reputation:disabled": 0,
"downvote:disabled": 0, "downvote:disabled": 0,
"disableSignatures": 0, "disableSignatures": 0,
"signatures:hideDuplicates": 0,
"upvotesPerDay": 20, "upvotesPerDay": 20,
"upvotesPerUserPerDay": 6, "upvotesPerUserPerDay": 6,
"downvotesPerDay": 10, "downvotesPerDay": 10,

@ -51,6 +51,7 @@
"signature.disable": "Disable signatures", "signature.disable": "Disable signatures",
"signature.no-links": "Disable links in signatures", "signature.no-links": "Disable links in signatures",
"signature.no-images": "Disable images in signatures", "signature.no-images": "Disable images in signatures",
"signature.hide-duplicates": "Hide duplicate signatures in topics",
"signature.max-length": "Maximum Signature Length", "signature.max-length": "Maximum Signature Length",
"composer": "Composer Settings", "composer": "Composer Settings",
"composer-help": "The following settings govern the functionality and/or appearance of the post composer shown\n\t\t\t\tto users when they create new topics, or reply to existing topics.", "composer-help": "The following settings govern the functionality and/or appearance of the post composer shown\n\t\t\t\tto users when they create new topics, or reply to existing topics.",

@ -40,7 +40,7 @@ define('forum/topic', [
app.enterRoom('topic_' + tid); app.enterRoom('topic_' + tid);
posts.onTopicPageLoad(components.get('post')); posts.onTopicPageLoad(components.get('post'));
posts.signaturesShown = {};
navigator.init('[component="post"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, utils.debounce(Topic.navigatorCallback, 500)); navigator.init('[component="post"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, utils.debounce(Topic.navigatorCallback, 500));
postTools.init(tid); postTools.init(tid);

@ -14,6 +14,8 @@ define('forum/topic/posts', [
], function (pagination, infinitescroll, postTools, images, navigator, components, translator, hooks, helpers) { ], function (pagination, infinitescroll, postTools, images, navigator, components, translator, hooks, helpers) {
const Posts = { }; const Posts = { };
Posts.signaturesShown = {};
Posts.onNewPost = function (data) { Posts.onNewPost = function (data) {
if ( if (
!data || !data ||
@ -282,6 +284,7 @@ define('forum/topic/posts', [
Posts.onTopicPageLoad = function (posts) { Posts.onTopicPageLoad = function (posts) {
handlePrivateUploads(posts); handlePrivateUploads(posts);
images.wrapImagesInLinks(posts); images.wrapImagesInLinks(posts);
hideDuplicateSignatures(posts);
Posts.showBottomPostBar(); Posts.showBottomPostBar();
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive'); posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
Posts.addBlockquoteEllipses(posts); Posts.addBlockquoteEllipses(posts);
@ -353,6 +356,20 @@ define('forum/topic/posts', [
}); });
} }
function hideDuplicateSignatures(posts) {
if (ajaxify.data['signatures:hideDuplicates']) {
posts.each((index, el) => {
const signatureEl = $(el).find('[component="post/signature"]');
const uid = signatureEl.attr('data-uid');
if (Posts.signaturesShown[uid]) {
signatureEl.addClass('hidden');
} else {
Posts.signaturesShown[uid] = true;
}
});
}
}
function removeNecroPostMessages(removedPostEls) { function removeNecroPostMessages(removedPostEls) {
removedPostEls.each((index, el) => { removedPostEls.each((index, el) => {
$(`[data-necro-post-index="${$(el).attr('data-index')}"]`).remove(); $(`[data-necro-post-index="${$(el).attr('data-index')}"]`).remove();

@ -88,6 +88,7 @@ topicsController.get = async function getTopic(req, res, next) {
topicData['reputation:disabled'] = meta.config['reputation:disabled']; topicData['reputation:disabled'] = meta.config['reputation:disabled'];
topicData['downvote:disabled'] = meta.config['downvote:disabled']; topicData['downvote:disabled'] = meta.config['downvote:disabled'];
topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0; topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
topicData['signatures:hideDuplicates'] = meta.config['signatures:hideDuplicates'];
topicData.bookmarkThreshold = meta.config.bookmarkThreshold; topicData.bookmarkThreshold = meta.config.bookmarkThreshold;
topicData.necroThreshold = meta.config.necroThreshold; topicData.necroThreshold = meta.config.necroThreshold;
topicData.postEditDuration = meta.config.postEditDuration; topicData.postEditDuration = meta.config.postEditDuration;

@ -259,6 +259,12 @@
<span class="mdl-switch__label"><strong>[[admin/settings/post:signature.no-images]]</strong></span> <span class="mdl-switch__label"><strong>[[admin/settings/post:signature.no-images]]</strong></span>
</label> </label>
</div> </div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="signatures:hideDuplicates">
<span class="mdl-switch__label"><strong>[[admin/settings/post:signature.hide-duplicates]]</strong></span>
</label>
</div>
<div class="form-group"> <div class="form-group">
<label for="maximumSignatureLength">[[admin/settings/post:signature.max-length]]</label> <label for="maximumSignatureLength">[[admin/settings/post:signature.max-length]]</label>
<input id="maximumSignatureLength" type="text" class="form-control" value="255" data-field="maximumSignatureLength"> <input id="maximumSignatureLength" type="text" class="form-control" value="255" data-field="maximumSignatureLength">

Loading…
Cancel
Save