diff --git a/install/data/defaults.json b/install/data/defaults.json index fb0bf761ed..acd8e9cf17 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -107,6 +107,9 @@ "postsPerPage": 20, "categoriesPerPage": 50, "userSearchResultsPerPage": 50, + "searchDefaultSortBy": "relevance", + "searchDefaultIn": "titlesposts", + "searchDefaultInQuick": "titles", "maximumGroupNameLength": 255, "maximumGroupTitleLength": 40, "preventTopicDeleteAfterReplies": 0, diff --git a/public/language/en-GB/admin/settings/general.json b/public/language/en-GB/admin/settings/general.json index 147384d94b..be7df90870 100644 --- a/public/language/en-GB/admin/settings/general.json +++ b/public/language/en-GB/admin/settings/general.json @@ -35,7 +35,10 @@ "maskable-icon.help": "Recommended size and format: 512x512, PNG format only. If no maskable icon is specified, NodeBB will fall back to the Touch Icon.", "outgoing-links": "Outgoing Links", "outgoing-links.warning-page": "Use Outgoing Links Warning Page", - "search-default-sort-by": "Search default sort by", + "search": "Search", + "search-default-in": "Search In", + "search-default-in-quick": "Quick Search In", + "search-default-sort-by": "Sort by", "outgoing-links.whitelist": "Domains to whitelist for bypassing the warning page", "site-colors": "Site Color Metadata", "theme-color": "Theme Color", diff --git a/public/src/app.js b/public/src/app.js index 290dd52c6d..a76d4b7f1a 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -483,7 +483,7 @@ app.cacheBuster = null; return; } /* eslint-disable-next-line */ - var searchOptions = Object.assign({ in: 'titles' }, options.searchOptions); + var searchOptions = Object.assign({ in: config.searchDefaultInQuick || 'titles' }, options.searchOptions); var quickSearchResults = options.searchElements.resultEl; var inputEl = options.searchElements.inputEl; var searchTimeoutId = 0; @@ -608,7 +608,7 @@ app.cacheBuster = null; }; app.handleSearch = function (searchOptions) { - searchOptions = searchOptions || { in: 'titles' }; + searchOptions = searchOptions || { in: config.searchDefaultInQuick || 'titles' }; var searchButton = $('#search-button'); var searchFields = $('#search-fields'); var searchInput = $('#search-fields input'); diff --git a/public/src/client/search.js b/public/src/client/search.js index d722099cb6..9412acc6d8 100644 --- a/public/src/client/search.js +++ b/public/src/client/search.js @@ -81,7 +81,7 @@ define('forum/search', [ if (ajaxify.data.term) { $('#search-input').val(ajaxify.data.term); } - formData.in = formData.in || 'posts'; + formData.in = formData.in || ajaxify.data.searchDefaultIn; $('#search-in').val(formData.in); updateFormItemVisiblity(formData.in); diff --git a/src/controllers/api.js b/src/controllers/api.js index 44f3726f72..3e4e2fa216 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -64,6 +64,7 @@ apiController.loadConfig = async function (req) { categoryTopicSort: meta.config.categoryTopicSort || 'newest_to_oldest', csrf_token: req.uid >= 0 && req.csrfToken && req.csrfToken(), searchEnabled: plugins.hooks.hasListeners('filter:search.query'), + searchDefaultInQuick: meta.config.searchDefaultInQuick || 'titles', bootswatchSkin: meta.config.bootswatchSkin || '', enablePostHistory: meta.config.enablePostHistory === 1, timeagoCutoff: meta.config.timeagoCutoff !== '' ? Math.max(0, parseInt(meta.config.timeagoCutoff, 10)) : meta.config.timeagoCutoff, diff --git a/src/controllers/search.js b/src/controllers/search.js index 9386f3eeff..0dbdff2dd0 100644 --- a/src/controllers/search.js +++ b/src/controllers/search.js @@ -27,7 +27,7 @@ searchController.search = async function (req, res, next) { 'search:content': privileges.global.can('search:content', req.uid), 'search:tags': privileges.global.can('search:tags', req.uid), }); - req.query.in = req.query.in || 'posts'; + req.query.in = req.query.in || meta.config.searchDefaultIn || 'titlesposts'; const allowed = (req.query.in === 'users' && userPrivileges['search:users']) || (req.query.in === 'tags' && userPrivileges['search:tags']) || (req.query.in === 'categories') || @@ -89,6 +89,7 @@ searchController.search = async function (req, res, next) { searchData.title = '[[global:header.search]]'; searchData.searchDefaultSortBy = meta.config.searchDefaultSortBy || ''; + searchData.searchDefaultIn = meta.config.searchDefaultIn || 'titlesposts'; searchData.privileges = userPrivileges; res.render('search', searchData); diff --git a/src/views/admin/settings/general.tpl b/src/views/admin/settings/general.tpl index a792e48142..f2ece80c61 100644 --- a/src/views/admin/settings/general.tpl +++ b/src/views/admin/settings/general.tpl @@ -136,21 +136,43 @@
-
[[admin/settings/general:search-default-sort-by]]
+
[[admin/settings/general:search]]
- +
+ + +
+
+ + +
+
+ + +