v1.18.x
barisusakli 8 years ago
parent 8a0a74d95e
commit 387110fecc

@ -26,5 +26,6 @@
"touch-icon.upload": "Upload",
"touch-icon.help": "Recommended size and format: 192x192, PNG format only. If no touch icon is specified, NodeBB will fall back to using the favicon.",
"outgoing-links": "Outgoing Links",
"outgoing-links.warning-page": "Use Outgoing Links Warning Page"
"outgoing-links.warning-page": "Use Outgoing Links Warning Page",
"search-default-sort-by": "Search default sort by"
}

@ -12,6 +12,7 @@
"reply-count": "Reply Count",
"at-least": "At least",
"at-most": "At most",
"relevance": "Relevance",
"post-time": "Post time",
"newer-than": "Newer than",
"older-than": "Older than",

@ -105,8 +105,8 @@ define('forum/search', ['search', 'autocomplete'], function (searchModule, autoc
$('#post-time-filter').val(formData.timeFilter);
}
if (formData.sortBy) {
$('#post-sort-by').val(formData.sortBy);
if (formData.sortBy || ajaxify.data.searchDefaultSortBy) {
$('#post-sort-by').val(formData.sortBy || ajaxify.data.searchDefaultSortBy);
$('#post-sort-direction').val(formData.sortDirection);
}

@ -38,7 +38,7 @@ searchController.search = function (req, res, next) {
repliesFilter: req.query.repliesFilter,
timeRange: req.query.timeRange,
timeFilter: req.query.timeFilter,
sortBy: req.query.sortBy,
sortBy: req.query.sortBy || meta.config.searchDefaultSortBy || '',
sortDirection: req.query.sortDirection,
page: page,
uid: req.uid,
@ -67,6 +67,7 @@ searchController.search = function (req, res, next) {
searchData.title = '[[global:header.search]]';
searchData.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
searchData.expandSearch = !req.query.term;
searchData.searchDefaultSortBy = meta.config.searchDefaultSortBy || '';
res.render('search', searchData);
});

@ -147,7 +147,7 @@ function getMatchedPosts(pids, data, callback) {
topicFields.push('postcount');
}
if (data.sortBy) {
if (data.sortBy && data.sortBy !== 'relevance') {
if (data.sortBy.startsWith('category')) {
topicFields.push('cid');
} else if (data.sortBy.startsWith('topic.')) {
@ -328,7 +328,7 @@ function filterByTags(posts, hasTags) {
}
function sortPosts(posts, data) {
if (!posts.length || !data.sortBy) {
if (!posts.length || !data.sortBy || data.sortBy === 'relevance') {
return;
}

@ -113,6 +113,23 @@
</div>
</div>
<div class="row">
<div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/general:search-default-sort-by]]</div>
<div class="col-sm-10 col-xs-12">
<select id="post-sort-by" class="form-control" data-field="searchDefaultSortBy">
<option value="relevance">[[search:relevance]]</option>
<option value="timestamp">[[search:post-time]]</option>
<option value="teaser.timestamp">[[search:last-reply-time]]</option>
<option value="topic.title">[[search:topic-title]]</option>
<option value="topic.postcount">[[search:number-of-replies]]</option>
<option value="topic.viewcount">[[search:number-of-views]]</option>
<option value="topic.timestamp">[[search:topic-start-date]]</option>
<option value="user.username">[[search:username]]</option>
<option value="category.name">[[search:category]]</option>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/general:outgoing-links]]</div>
<div class="col-sm-10 col-xs-12">

Loading…
Cancel
Save