mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-23 09:19:15 +02:00
Add:Server setting to ignore "The" infront of titles and series when sorting #361
This commit is contained in:
parent
e0a6631396
commit
f15be4c96e
6 changed files with 93 additions and 20 deletions
|
@ -144,10 +144,19 @@ class LibraryController {
|
|||
}
|
||||
|
||||
if (payload.sortBy) {
|
||||
var sortKey = payload.sortBy
|
||||
|
||||
// Handle server setting sortingIgnorePrefix
|
||||
if ((sortKey === 'book.series' || sortKey === 'book.title') && this.db.serverSettings.sortingIgnorePrefix) {
|
||||
// Book.js has seriesIgnorePrefix and titleIgnorePrefix getters
|
||||
sortKey += 'IgnorePrefix'
|
||||
}
|
||||
|
||||
var direction = payload.sortDesc ? 'desc' : 'asc'
|
||||
audiobooks = naturalSort(audiobooks)[direction]((ab) => {
|
||||
|
||||
// Supports dot notation strings i.e. "book.title"
|
||||
return payload.sortBy.split('.').reduce((a, b) => a[b], ab)
|
||||
return sortKey.split('.').reduce((a, b) => a[b], ab)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -202,7 +211,14 @@ class LibraryController {
|
|||
}
|
||||
|
||||
var series = libraryHelpers.getSeriesFromBooks(audiobooks, payload.minified)
|
||||
series = sort(series).asc(s => s.name)
|
||||
|
||||
var sortingIgnorePrefix = this.db.serverSettings.sortingIgnorePrefix
|
||||
series = sort(series).asc(s => {
|
||||
if (sortingIgnorePrefix && s.name.toLowerCase().startsWith('the')) {
|
||||
return s.name.substr(4)
|
||||
}
|
||||
return s.name
|
||||
})
|
||||
payload.total = series.length
|
||||
|
||||
if (payload.limit) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue