Skip to content

Commit

Permalink
feat: setting to show signatures only once in topics, closes #10071
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Aug 16, 2022
1 parent 14c7976 commit aba420a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions install/data/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"reputation:disabled": 0,
"downvote:disabled": 0,
"disableSignatures": 0,
"signatures:hideDuplicates": 0,
"upvotesPerDay": 20,
"upvotesPerUserPerDay": 6,
"downvotesPerDay": 10,
Expand Down
1 change: 1 addition & 0 deletions public/language/en-GB/admin/settings/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"signature.disable": "Disable signatures",
"signature.no-links": "Disable links in signatures",
"signature.no-images": "Disable images in signatures",
"signature.hide-duplicates": "Hide duplicate signatures in topics",
"signature.max-length": "Maximum Signature Length",
"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.",
Expand Down
2 changes: 1 addition & 1 deletion public/src/client/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ define('forum/topic', [
app.enterRoom('topic_' + tid);

posts.onTopicPageLoad(components.get('post'));

posts.signaturesShown = {};
navigator.init('[component="post"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, utils.debounce(Topic.navigatorCallback, 500));

postTools.init(tid);
Expand Down
17 changes: 17 additions & 0 deletions public/src/client/topic/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ define('forum/topic/posts', [
], function (pagination, infinitescroll, postTools, images, navigator, components, translator, hooks, helpers) {
const Posts = { };

Posts.signaturesShown = {};

Posts.onNewPost = function (data) {
if (
!data ||
Expand Down Expand Up @@ -282,6 +284,7 @@ define('forum/topic/posts', [
Posts.onTopicPageLoad = function (posts) {
handlePrivateUploads(posts);
images.wrapImagesInLinks(posts);
hideDuplicateSignatures(posts);
Posts.showBottomPostBar();
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
Posts.addBlockquoteEllipses(posts);
Expand Down Expand Up @@ -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) {
removedPostEls.each((index, el) => {
$(`[data-necro-post-index="${$(el).attr('data-index')}"]`).remove();
Expand Down
1 change: 1 addition & 0 deletions src/controllers/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ topicsController.get = async function getTopic(req, res, next) {
topicData['reputation:disabled'] = meta.config['reputation:disabled'];
topicData['downvote:disabled'] = meta.config['downvote:disabled'];
topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
topicData['signatures:hideDuplicates'] = meta.config['signatures:hideDuplicates'];
topicData.bookmarkThreshold = meta.config.bookmarkThreshold;
topicData.necroThreshold = meta.config.necroThreshold;
topicData.postEditDuration = meta.config.postEditDuration;
Expand Down
6 changes: 6 additions & 0 deletions src/views/admin/settings/post.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@
<span class="mdl-switch__label"><strong>[[admin/settings/post:signature.no-images]]</strong></span>
</label>
</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">
<label for="maximumSignatureLength">[[admin/settings/post:signature.max-length]]</label>
<input id="maximumSignatureLength" type="text" class="form-control" value="255" data-field="maximumSignatureLength">
Expand Down

0 comments on commit aba420a

Please sign in to comment.