Skip to content

Node.js based forum software built for the modern web

feat: https://github.com/NodeBB/NodeBB/issues/8147

Barış Soner Uşaklı1d6bcbebde16
diff --git a/install/data/defaults.json b/install/data/defaults.json
index b6d4fa1907..24e1a4f9fb 100644
--- a/install/data/defaults.json
+++ b/install/data/defaults.json
@@ -139,5 +139,6 @@
"showAverageApprovalTime": true,
"autoApproveTime": 0,
"maxUserSessions": 10,
- "useCompression": 0
+ "useCompression": 0,
+ "updateUrlWithPostIndex": 1
}
\ No newline at end of file
diff --git a/public/language/en-GB/admin/settings/user.json b/public/language/en-GB/admin/settings/user.json
index 88f00aefc8..e05aa5e3ed 100644
--- a/public/language/en-GB/admin/settings/user.json
+++ b/public/language/en-GB/admin/settings/user.json
@@ -65,6 +65,7 @@
"restrict-chat": "Only allow chat messages from users I follow",
"outgoing-new-tab": "Open outgoing links in new tab",
"topic-search": "Enable In-Topic Searching",
+ "update-url-with-post-index": "Update url with post index while browsing topics",
"digest-freq": "Subscribe to Digest",
"digest-freq.off": "Off",
"digest-freq.daily": "Daily",
diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json
index bbf2f2ba5f..cddce941c6 100644
--- a/public/language/en-GB/user.json
+++ b/public/language/en-GB/user.json
@@ -133,7 +133,7 @@
"enable_topic_searching": "Enable In-Topic Searching",
"topic_search_help": "If enabled, in-topic searching will override the browser's default page search behaviour and allow you to search through the entire topic, instead of what is only shown on screen",
-
+ "update_url_with_post_index": "Update url with post index while browsing topics",
"scroll_to_my_post": "After posting a reply, show the new post",
"follow_topics_you_reply_to": "Watch topics that you reply to",
diff --git a/public/openapi/components/schemas/SettingsObj.yaml b/public/openapi/components/schemas/SettingsObj.yaml
index 3b674996aa..9e95fb675c 100644
--- a/public/openapi/components/schemas/SettingsObj.yaml
+++ b/public/openapi/components/schemas/SettingsObj.yaml
@@ -37,6 +37,9 @@ Settings:
topicSearchEnabled:
type: boolean
description: Enable keyword searching within topics
+ updateUrlWithPostIndex:
+ type: boolean
+ description: Update url with post index while browsing topics
categoryTopicSort:
type: string
description: Default sorting strategy of the topics in a category
diff --git a/public/openapi/read/topic/topic_id/slug/post_index.yaml b/public/openapi/read/topic/topic_id/slug/post_index.yaml
index 514f3065e5..47e0a60d2e 100644
--- a/public/openapi/read/topic/topic_id/slug/post_index.yaml
+++ b/public/openapi/read/topic/topic_id/slug/post_index.yaml
@@ -388,6 +388,8 @@ get:
type: number
scrollToMyPost:
type: boolean
+ updateUrlWithPostIndex:
+ type: boolean
allowMultipleBadges:
type: boolean
privateUploads:
diff --git a/public/src/client/topic.js b/public/src/client/topic.js
index b193b8cc9e..c54c631c5a 100644
--- a/public/src/client/topic.js
+++ b/public/src/client/topic.js
@@ -227,7 +227,7 @@ define('forum/topic', [
updateUserBookmark(index);
Topic.replaceURLTimeout = 0;
- if (history.replaceState) {
+ if (ajaxify.data.updateUrlWithPostIndex && history.replaceState) {
var search = window.location.search || '';
if (!config.usePagination) {
search = (search && !/^\?page=\d+$/.test(search) ? search : '');
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index 2b40f4595b..72fe28e5f6 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -81,6 +81,7 @@ topicsController.get = async function getTopic(req, res, callback) {
topicData.postEditDuration = meta.config.postEditDuration;
topicData.postDeleteDuration = meta.config.postDeleteDuration;
topicData.scrollToMyPost = settings.scrollToMyPost;
+ topicData.updateUrlWithPostIndex = settings.updateUrlWithPostIndex;
topicData.allowMultipleBadges = meta.config.allowMultipleBadges === 1;
topicData.privateUploads = meta.config.privateUploads === 1;
topicData.rssFeedUrl = relative_path + '/topic/' + topicData.tid + '.rss';
diff --git a/src/user/settings.js b/src/user/settings.js
index 0f9494a1ce..ebb153852f 100644
--- a/src/user/settings.js
+++ b/src/user/settings.js
@@ -58,6 +58,7 @@ module.exports = function (User) {
settings.upvoteNotifFreq = getSetting(settings, 'upvoteNotifFreq', 'all');
settings.restrictChat = parseInt(getSetting(settings, 'restrictChat', 0), 10) === 1;
settings.topicSearchEnabled = parseInt(getSetting(settings, 'topicSearchEnabled', 0), 10) === 1;
+ settings.updateUrlWithPostIndex = parseInt(getSetting(settings, 'updateUrlWithPostIndex', 1), 10) === 1;
settings.bootswatchSkin = validator.escape(String(settings.bootswatchSkin || ''));
settings.homePageRoute = validator.escape(String(settings.homePageRoute || '')).replace(///g, '/');
settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1;
@@ -116,6 +117,7 @@ module.exports = function (User) {
followTopicsOnReply: data.followTopicsOnReply,
restrictChat: data.restrictChat,
topicSearchEnabled: data.topicSearchEnabled,
+ updateUrlWithPostIndex: data.updateUrlWithPostIndex,
homePageRoute: ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
scrollToMyPost: data.scrollToMyPost,
upvoteNotifFreq: data.upvoteNotifFreq,
diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl
index c6f0db9062..f9f56e2eee 100644
--- a/src/views/admin/settings/user.tpl
+++ b/src/views/admin/settings/user.tpl
@@ -299,6 +299,13 @@
</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="updateUrlWithPostIndex">
+ <span class="mdl-switch__label"><strong>[[admin/settings/user:update-url-with-post-index]]</strong></span>
+ </label>
+ </div>
+
<div class="form-group">
<label>[[admin/settings/user:digest-freq]]</label>
<select class="form-control" data-field="dailyDigestFreq">