From 2f8a90c21a4eea257dbdbb85e4cec6a5e76794ab Mon Sep 17 00:00:00 2001 From: ISO-B <3048685+ISO-B@users.noreply.github.com> Date: Tue, 4 Jan 2022 12:20:28 +0200 Subject: [PATCH 1/4] Added isbn search Search now also searches books using isbn. ISBN match has to be exact to prevent isbn matches to flood results. --- server/objects/Book.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/objects/Book.js b/server/objects/Book.js index 34109475..f8661eeb 100644 --- a/server/objects/Book.js +++ b/server/objects/Book.js @@ -278,8 +278,12 @@ class Book { // var authorMatch = this._author.toLowerCase().includes(search) var seriesMatch = this._series.toLowerCase().includes(search) + + // ISBN match has to be exact to prevent isbn matches to flood results. Remove dashes since isbn might have those + var isbnMatch = this.isbn.toLowerCase().replaceAll('-', '') === search.replaceAll('-', '') + + var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : false - var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : false var bookMatchText = bookMatchKey ? this[bookMatchKey] : '' return { book: bookMatchKey, From 01c8013309f2ea849f056dc8335d736cfbb6d57d Mon Sep 17 00:00:00 2001 From: ISO-B <3048685+ISO-B@users.noreply.github.com> Date: Tue, 4 Jan 2022 14:41:34 +0200 Subject: [PATCH 2/4] Changed replaceAll to replace since node12 doent' have it --- server/objects/Book.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/objects/Book.js b/server/objects/Book.js index f8661eeb..caef8a04 100644 --- a/server/objects/Book.js +++ b/server/objects/Book.js @@ -278,9 +278,9 @@ class Book { // var authorMatch = this._author.toLowerCase().includes(search) var seriesMatch = this._series.toLowerCase().includes(search) - + // ISBN match has to be exact to prevent isbn matches to flood results. Remove dashes since isbn might have those - var isbnMatch = this.isbn.toLowerCase().replaceAll('-', '') === search.replaceAll('-', '') + var isbnMatch = this.isbn.toLowerCase().replace(/-/g, '') === search.replace(/-/g, '') var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : false From 7607381ea43c2927d47622c21d1d85212d7af9b9 Mon Sep 17 00:00:00 2001 From: ISO-B <3048685+ISO-B@users.noreply.github.com> Date: Tue, 4 Jan 2022 14:46:40 +0200 Subject: [PATCH 3/4] Added _isbn to Book so it's always string --- server/objects/Book.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/objects/Book.js b/server/objects/Book.js index caef8a04..f60215bc 100644 --- a/server/objects/Book.js +++ b/server/objects/Book.js @@ -43,6 +43,7 @@ class Book { get _authorsList() { return this._author.split(', ') } get _narratorsList() { return this._narrator.split(', ') } get _genres() { return this.genres || [] } + get _isbn() { return this.isbn || '' } get shouldSearchForCover() { if (this.cover) return false @@ -280,7 +281,7 @@ class Book { var seriesMatch = this._series.toLowerCase().includes(search) // ISBN match has to be exact to prevent isbn matches to flood results. Remove dashes since isbn might have those - var isbnMatch = this.isbn.toLowerCase().replace(/-/g, '') === search.replace(/-/g, '') + var isbnMatch = this._isbn.toLowerCase().replace(/-/g, '') === search.replace(/-/g, '') var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : false From 47dbd90971b0470b475bb069e15ed1d0ef4b58f2 Mon Sep 17 00:00:00 2001 From: advplyr Date: Tue, 4 Jan 2022 07:36:52 -0600 Subject: [PATCH 4/4] Add:ISBN highlighting to book search card --- client/components/cards/AudiobookSearchCard.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/components/cards/AudiobookSearchCard.vue b/client/components/cards/AudiobookSearchCard.vue index be8420f0..159f02b0 100644 --- a/client/components/cards/AudiobookSearchCard.vue +++ b/client/components/cards/AudiobookSearchCard.vue @@ -1,5 +1,5 @@ @@ -70,6 +70,7 @@ export default { if (this.matchKey === 'tags') return `

Tags: ${html}

` if (this.matchKey === 'authorFL') return `by ${html}` + if (this.matchKey === 'isbn') return `

ISBN: ${html}

` if (this.matchKey === 'series') return `

Series: ${html}

` return `${html}` }