Skip to content

Commit

Permalink
Release v0.2.27.
Browse files Browse the repository at this point in the history
Add Fnac.pt icon.

Add Spanish Amazon link.

Refactor the book links logic.

Update dependencies.

Bump the version to release.
  • Loading branch information
alessandrojean committed Jan 19, 2022
1 parent d2ca0e1 commit 12194df
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 311 deletions.
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toshokan",
"version": "0.2.26",
"version": "0.2.27",
"private": true,
"scripts": {
"dev": "vite",
Expand All @@ -10,27 +10,27 @@
"lint:fix": "eslint src --fix"
},
"dependencies": {
"@headlessui/vue": "^1.4.2",
"@headlessui/vue": "^1.4.3",
"@heroicons/vue": "^1.0.5",
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/typography": "^0.5.0",
"@vuelidate/core": "^2.0.0-alpha.32",
"@vuelidate/validators": "^2.0.0-alpha.25",
"apexcharts": "^3.32.1",
"axios": "^0.24.0",
"core-js": "^3.20.1",
"@vuelidate/core": "^2.0.0-alpha.34",
"@vuelidate/validators": "^2.0.0-alpha.26",
"apexcharts": "^3.33.0",
"axios": "^0.25.0",
"core-js": "^3.20.3",
"dedent": "^0.7.0",
"lodash.clonedeep": "^4.5.0",
"markdown-it": "^12.3.0",
"markdown-it": "^12.3.2",
"markdown-it-abbr": "^1.0.4",
"markdown-it-deflist": "^2.1.0",
"nanoid": "^3.1.30",
"nanoid": "^3.2.0",
"paginator": "^1.0.0",
"register-service-worker": "^1.7.2",
"search-query-parser": "^1.6.0",
"slugify": "^1.6.4",
"vue": "^3.2.26",
"slugify": "^1.6.5",
"vue": "^3.2.27",
"vue-i18n": "^9.1.9",
"vue-router": "^4.0.12",
"vue3-apexcharts": "^1.4.1",
Expand All @@ -39,20 +39,20 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.0.1",
"@vue/compiler-sfc": "^3.2.26",
"@vue/compiler-sfc": "^3.2.27",
"@vue/eslint-config-standard": "^6.1.0",
"autoprefixer": "^10.4.0",
"autoprefixer": "^10.4.2",
"babel-eslint": "^10.1.0",
"eslint": "^8.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint": "^8.7.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^8.2.0",
"eslint-plugin-vue": "^8.3.0",
"git-describe": "^4.1.0",
"postcss": "^8.4.5",
"postcss-loader": "^6.2.1",
"tailwindcss": "^3.0.7",
"vite": "^2.7.6"
"tailwindcss": "^3.0.15",
"vite": "^2.7.13"
}
}
84 changes: 9 additions & 75 deletions src/components/BookInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,12 @@
target="_blank"
:href="link.url"
>
<span aria-hidden="true">
<span aria-hidden="true" class="icon">
<component
v-if="link.icon"
:is="link.icon"
class="w-4 h-4"
/>
<GlobeAltIcon
v-else
class="w-4 h-4"
/>
<GlobeAltIcon v-else />
</span>
<span>{{ link.title }}</span>
<span aria-hidden="true">
Expand All @@ -241,6 +237,7 @@ import {
ExternalLinkIcon,
GlobeAltIcon,
PencilIcon,
ShoppingCartIcon,
StarIcon as StarSolidIcon
} from '@heroicons/vue/solid'
import {
Expand All @@ -251,33 +248,24 @@ import {
UserGroupIcon
} from '@heroicons/vue/outline'
import AmazonIcon from '@/components/icons/AmazonIcon.vue'
import Avatar from '@/components/Avatar.vue'
import BookBreadcrumb from '@/components/BookBreadcrumb.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'
import { convertIsbn13ToIsbn10, getIsbnCountry } from '@/util/isbn'
import getBookLinks from '@/services/links'
import { BookFavorite, BookStatus } from '@/model/Book'
export default {
components: {
AmazonIcon,
Avatar,
BookBreadcrumb,
BookmarkOutlineIcon,
BookmarkSolidIcon,
ClockIcon,
ExternalLinkIcon,
GlobeAltIcon,
GoodreadsIcon,
NewPopIcon,
PaniniIcon,
PencilIcon,
SkoobIcon,
StarOutlineIcon,
StarSolidIcon,
TrashIcon,
Expand Down Expand Up @@ -392,65 +380,7 @@ export default {
})
const externalLinks = computed(() => {
if (!book.value?.codeType?.includes('ISBN')) {
return []
}
const bookCode = book.value ? book.value.code.replaceAll('-', '') : ''
const links = [
{
title: 'Goodreads',
url: `https://goodreads.com/search?q=${bookCode}`,
icon: GoodreadsIcon
},
{
title: 'Open Library',
url: `https://openlibrary.org/isbn/${bookCode}`
}
]
const amazonLinks = {
BR: { title: 'Amazon.com.br', url: 'https://amazon.com.br' },
US: { title: 'Amazon', url: 'https://amazon.com' },
JP: { title: 'Amazon.co.jp', url: 'https://amazon.co.jp' }
}
if (amazonLinks[country.value?.countryCode]) {
const amazonData = amazonLinks[country.value.countryCode]
links.push({
title: amazonData.title,
url: `${amazonData.url}/dp/${isbn10.value}`,
icon: AmazonIcon
})
}
if (country.value?.countryCode === 'BR' && book.value?.publisher?.includes('Panini')) {
links.push({
title: 'Loja Panini',
url: `https://loja.panini.com.br/panini/solucoes/busca.aspx?t=${bookCode}`,
icon: PaniniIcon
})
}
if (book.value?.publisher?.includes('NewPOP')) {
links.push({
title: 'NewPOP SHOP',
url: `https://www.lojanewpop.com.br/buscar?q=${bookCode}`,
icon: NewPopIcon
})
}
if (country.value?.countryCode === 'BR') {
links.push({
title: 'Skoob',
url: `https://www.skoob.com.br/livro/lista/busca:${bookCode}/tipo:isbn`,
icon: SkoobIcon
})
}
return links.sort((a, b) => a.title.localeCompare(b.title, locale.value))
return getBookLinks(book.value, locale.value)
})
const separator = computed(() => {
Expand Down Expand Up @@ -571,6 +501,10 @@ export default {
@apply dark:ring-offset-gray-900;
}
.book-external-link .icon svg {
@apply w-4 h-4;
}
.book-external-link svg {
@apply text-gray-500 dark:text-gray-400;
}
Expand Down
12 changes: 12 additions & 0 deletions src/components/icons/FnacIcon.vue
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>
118 changes: 118 additions & 0 deletions src/services/links.js
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)
})
}
Loading

0 comments on commit 12194df

Please sign in to comment.