From 1d6bcbebde1632499fd35dce377f28d7dd7ff19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 16 Nov 2020 21:31:55 -0500 Subject: [PATCH] feat: https://github.com/NodeBB/NodeBB/issues/8147 --- install/data/defaults.json | 3 ++- public/language/en-GB/admin/settings/user.json | 1 + public/language/en-GB/user.json | 2 +- public/openapi/components/schemas/SettingsObj.yaml | 3 +++ public/openapi/read/topic/topic_id/slug/post_index.yaml | 2 ++ public/src/client/topic.js | 2 +- src/controllers/topics.js | 1 + src/user/settings.js | 2 ++ src/views/admin/settings/user.tpl | 7 +++++++ 9 files changed, 20 insertions(+), 3 deletions(-) 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 @@ +
+ +
+