-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Fnac.pt icon. Add Spanish Amazon link. Refactor the book links logic. Update dependencies. Bump the version to release.
- Loading branch information
1 parent
d2ca0e1
commit 12194df
Showing
5 changed files
with
376 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1000 1000"> | ||
<path | ||
d="M187.513 0H812.51C916.377 0 1000 83.625 1000 187.501v624.997C1000 916.375 916.377 1000 812.51 1000H187.513C83.623 1000 0 916.375 0 812.499V187.501C0 83.625 83.623 0 187.513 0z" | ||
fill="#e1a925" | ||
/> | ||
<path | ||
fill="#fff" | ||
d="M319.135 442.372c-30.945 8.343-43.164 20.413-47.897 27.661v-26.567H110.565c-4.556-51.802 48.518-50.708 48.518-50.708 51.95-1.538 54.051 32.158 54.051 32.158h58.104c0-60.648-83.487-67.571-83.487-67.571-81.771-6.538-109.936 21.212-109.936 21.212-25.709 22.129-25.028 56.98-24.525 64.908H26.664l.562 39.761h26.212v156.531h58.074V483.228l101.711.03v156.502h58.045V529.823c3.018-18.786 15.561-44.377 60.589-48.193 0 0 65.825-10.828 74.464 48.341v109.758h58.045V507.398c-13.283-94.078-145.23-65.027-145.23-65.027zm393.857 79.316c4.97-68.162-66.861-77.866-66.861-77.866-64.021-10.71-100.794.118-101.386.296-62.63 14.408-62.837 64.494-62.837 64.494h59.406s.533-39.051 64.021-34.022c0 0 45.797 2.012 48.489 22.81 0 0 14.911 24.792-48.489 28.46-63.784 3.757-139.638 2.722-131.591 62.364 0 0-1.509 57.275 102.747 55.382 0 0 55.648 1.716 78.458-26.833v.888l1.923 22.07h57.63l-1.479-118.042zm-65.648 65.115c-14.556 17.751-32.04 23.194-52.424 24.023-18.046.74-56.625 4.053-57.423-25.561-.769-27.898 46.507-26.478 78.251-28.608 0 0 31.833-.118 38.164-8.787 0 0 .414-.888.473 0 .059.917 5.621 23.49-7.041 38.933zM913.9 573.786c-8.846 18.668-23.934 29.407-61.151 29.762-15.976.148-67.571-5.503-70.145-60.855l-.029-2.012c1.627-55.323 54.347-61.033 71.446-61.417 31.685-.651 49.909 9.378 59.287 27.987l59.435-.533c-.533-7.219-1.538-11.005-5.355-18.786-11.923-22.188-42.01-49.702-116.859-47.483-21.123.621-45.826 3.787-61.21 9.852-25.827 10.207-70.056 37.365-67.186 95.055l-.059-.03c3.018 60.352 44.732 78.073 68.577 88.043 15.739 6.597 36.123 8.55 61.713 9.023 75.47 1.45 104.433-27.809 115.941-50.234 3.668-7.869 4.615-11.656 5.029-18.904z" | ||
/> | ||
</svg> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { convertIsbn13ToIsbn10, getIsbnCountry } from '@/util/isbn' | ||
|
||
import AmazonIcon from '@/components/icons/AmazonIcon.vue' | ||
import FnacIcon from '@/components/icons/FnacIcon.vue' | ||
import GoodreadsIcon from '@/components/icons/GoodreadsIcon.vue' | ||
import NewPopIcon from '@/components/icons/NewPopIcon.vue' | ||
import PaniniIcon from '@/components/icons/PaniniIcon.vue' | ||
import SkoobIcon from '@/components/icons/SkoobIcon.vue' | ||
|
||
const Categories = { | ||
DATABASE: 0, | ||
STORE: 1 | ||
} | ||
|
||
const ALL_COUNTRIES = 'ALL' | ||
|
||
const WEBSITES = [ | ||
// Database websites. | ||
{ | ||
title: 'Goodreads', | ||
url: 'https://goodreads.com/search?q={isbn}', | ||
country: ALL_COUNTRIES, | ||
category: Categories.DATABASE, | ||
icon: GoodreadsIcon | ||
}, | ||
{ | ||
title: 'Open Library', | ||
url: 'https://openlibrary.org/isbn/{isbn}', | ||
country: ALL_COUNTRIES, | ||
category: Categories.DATABASE | ||
}, | ||
{ | ||
title: 'Skoob', | ||
url: 'https://www.skoob.com.br/livro/lista/busca:{isbn}/tipo:isbn', | ||
country: 'BR', | ||
category: Categories.DATABASE, | ||
icon: SkoobIcon | ||
}, | ||
// Stores | ||
{ | ||
title: 'Amazon', | ||
url: 'https://amazon.com/dp/{isbn10}', | ||
coutry: 'US', | ||
category: Categories.STORE, | ||
icon: AmazonIcon | ||
}, | ||
{ | ||
title: 'Amazon.co.jp', | ||
url: 'https://amazon.co.jp/dp/{isbn10}', | ||
coutry: 'JP', | ||
category: Categories.STORE, | ||
icon: AmazonIcon | ||
}, | ||
{ | ||
title: 'Amazon.com.br', | ||
url: 'https://amazon.com.br/dp/{isbn10}', | ||
coutry: 'BR', | ||
category: Categories.STORE, | ||
icon: AmazonIcon | ||
}, | ||
{ | ||
title: 'Amazon.es', | ||
url: 'https://amazon.es/dp/{isbn10}', | ||
coutry: 'ES', | ||
category: Categories.STORE, | ||
icon: AmazonIcon | ||
}, | ||
{ | ||
title: 'Loja Panini', | ||
url: 'https://loja.panini.com.br/panini/solucoes/busca.aspx?t={isbn}', | ||
country: 'BR', | ||
category: Categories.STORE, | ||
check: book => book.publisher.includes('Panini'), | ||
icon: PaniniIcon | ||
}, | ||
{ | ||
title: 'NewPOP SHOP', | ||
url: 'https://www.lojanewpop.com.br/buscar?q={isbn}', | ||
country: 'BR', | ||
category: Categories.STORE, | ||
check: book => book.publisher.includes('NewPOP'), | ||
icon: NewPopIcon | ||
}, | ||
{ | ||
title: 'Fnac.pt', | ||
url: 'https://fnac.pt/SearchResult/ResultList.aspx?Search={isbn}', | ||
country: 'PT', | ||
category: Categories.STORE, | ||
icon: FnacIcon | ||
} | ||
] | ||
|
||
export default function getBookLinks (book, locale) { | ||
if (!book || !book.codeType.includes('ISBN')) { | ||
return [] | ||
} | ||
|
||
const isbn = book.code.replaceAll('-', '') | ||
const isbn10 = isbn.length === 10 ? isbn : convertIsbn13ToIsbn10(isbn) | ||
|
||
const { countryCode: country } = getIsbnCountry(isbn) | ||
|
||
return WEBSITES | ||
.filter(website => { | ||
return website.country === country || website.country === ALL_COUNTRIES | ||
}) | ||
.filter(website => website.check ? website.check(book) : true) | ||
.map(website => ({ | ||
...website, | ||
url: website.url | ||
.replaceAll('{isbn}', isbn) | ||
.replaceAll('{isbn10}', isbn10) | ||
})) | ||
.sort((a, b) => { | ||
return (a.category - b.category) || | ||
a.title.localeCompare(b.title, locale) | ||
}) | ||
} |
Oops, something went wrong.