diff --git a/public/locales/ar/common.json b/public/locales/ar/common.json index 088ae2f0..8370883a 100644 --- a/public/locales/ar/common.json +++ b/public/locales/ar/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories", + "series": "Series" } } diff --git a/public/locales/bg/common.json b/public/locales/bg/common.json index 5a6ecc71..120ee063 100644 --- a/public/locales/bg/common.json +++ b/public/locales/bg/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/ca/common.json b/public/locales/ca/common.json index 525e533d..64f4d76d 100644 --- a/public/locales/ca/common.json +++ b/public/locales/ca/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/cs/common.json b/public/locales/cs/common.json index 1d48f636..b591dde2 100644 --- a/public/locales/cs/common.json +++ b/public/locales/cs/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/da/common.json b/public/locales/da/common.json index 9c6533f0..f71c12bd 100644 --- a/public/locales/da/common.json +++ b/public/locales/da/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/de/common.json b/public/locales/de/common.json index db017c20..8646b2dd 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/el/common.json b/public/locales/el/common.json index ba94bf9e..1599d066 100644 --- a/public/locales/el/common.json +++ b/public/locales/el/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 2cf3f1ba..373a9bea 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -579,6 +579,12 @@ "incident": "Incident", "m": "m" }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" + }, "komga": { "libraries": "Libraries", "series": "Series", @@ -661,6 +667,11 @@ "monitoring": "Monitoring", "updates": "Updates" }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, "jdownloader": { "downloadCount": "Queue", "downloadBytesRemaining": "Remaining", diff --git a/public/locales/eo/common.json b/public/locales/eo/common.json index aebc9dc2..efec21cc 100644 --- a/public/locales/eo/common.json +++ b/public/locales/eo/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 904aba10..027fb5ea 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -706,5 +706,16 @@ "users": "Usuarios", "categories": "Categorías", "tags": "Etiquetas" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/eu/common.json b/public/locales/eu/common.json index 4fa20c75..1c647c19 100644 --- a/public/locales/eu/common.json +++ b/public/locales/eu/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "authors": "Authors", + "books": "Books", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/fi/common.json b/public/locales/fi/common.json index 050db077..6f098f7f 100644 --- a/public/locales/fi/common.json +++ b/public/locales/fi/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories", + "series": "Series" } } diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 64512796..9405b390 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -706,5 +706,16 @@ "users": "Utilisateurs", "categories": "Catégories", "tags": "Étiquettes" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/he/common.json b/public/locales/he/common.json index 4690d1bc..199c5530 100644 --- a/public/locales/he/common.json +++ b/public/locales/he/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 99295197..98f3608a 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "chapters": "Chapters", + "categories": "Categories", + "series": "Series", + "archives": "Archives" } } diff --git a/public/locales/hr/common.json b/public/locales/hr/common.json index 5b0f7e4f..9fd3d809 100644 --- a/public/locales/hr/common.json +++ b/public/locales/hr/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/hu/common.json b/public/locales/hu/common.json index a2cff3ab..1edd712e 100644 --- a/public/locales/hu/common.json +++ b/public/locales/hu/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/id/common.json b/public/locales/id/common.json index 26c4e251..957d13f1 100644 --- a/public/locales/id/common.json +++ b/public/locales/id/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/it/common.json b/public/locales/it/common.json index 27a93aaf..85e6d192 100644 --- a/public/locales/it/common.json +++ b/public/locales/it/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index e8c607d7..3bcacf61 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/ko/common.json b/public/locales/ko/common.json index 0c2b6420..331e13c1 100644 --- a/public/locales/ko/common.json +++ b/public/locales/ko/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "chapters": "Chapters", + "categories": "Categories", + "series": "Series", + "archives": "Archives" } } diff --git a/public/locales/lv/common.json b/public/locales/lv/common.json index a968d4fa..21bc0bff 100644 --- a/public/locales/lv/common.json +++ b/public/locales/lv/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "chapters": "Chapters", + "series": "Series", + "archives": "Archives", + "categories": "Categories" } } diff --git a/public/locales/ms/common.json b/public/locales/ms/common.json index c1616367..38c5fde3 100644 --- a/public/locales/ms/common.json +++ b/public/locales/ms/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/nb-NO/common.json b/public/locales/nb-NO/common.json index 6b75aa23..46f8f048 100644 --- a/public/locales/nb-NO/common.json +++ b/public/locales/nb-NO/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index 9ce33db9..7a2b502a 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/pl/common.json b/public/locales/pl/common.json index 52d04e0f..cf21a545 100644 --- a/public/locales/pl/common.json +++ b/public/locales/pl/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/pt-BR/common.json b/public/locales/pt-BR/common.json index 1e188fda..27e339a8 100644 --- a/public/locales/pt-BR/common.json +++ b/public/locales/pt-BR/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/pt/common.json b/public/locales/pt/common.json index ac143fda..790290b6 100644 --- a/public/locales/pt/common.json +++ b/public/locales/pt/common.json @@ -715,5 +715,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/ro/common.json b/public/locales/ro/common.json index a52232e8..99a94592 100644 --- a/public/locales/ro/common.json +++ b/public/locales/ro/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 579f748f..d1415929 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/sk/common.json b/public/locales/sk/common.json index b46615b5..255ef944 100644 --- a/public/locales/sk/common.json +++ b/public/locales/sk/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/sl/common.json b/public/locales/sl/common.json index 258852c1..507259fd 100644 --- a/public/locales/sl/common.json +++ b/public/locales/sl/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/sr/common.json b/public/locales/sr/common.json index 32562c75..0bcd08dd 100644 --- a/public/locales/sr/common.json +++ b/public/locales/sr/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/sv/common.json b/public/locales/sv/common.json index 0a86dca6..4db3f9f8 100644 --- a/public/locales/sv/common.json +++ b/public/locales/sv/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/te/common.json b/public/locales/te/common.json index 4212b34d..4a76f97f 100644 --- a/public/locales/te/common.json +++ b/public/locales/te/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/th/common.json b/public/locales/th/common.json index 57a9ae62..f6c2a79a 100644 --- a/public/locales/th/common.json +++ b/public/locales/th/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/tr/common.json b/public/locales/tr/common.json index ac88b616..3496426e 100644 --- a/public/locales/tr/common.json +++ b/public/locales/tr/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/uk/common.json b/public/locales/uk/common.json index a7804865..bc57de81 100644 --- a/public/locales/uk/common.json +++ b/public/locales/uk/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/vi/common.json b/public/locales/vi/common.json index c3d393d0..862cd26c 100644 --- a/public/locales/vi/common.json +++ b/public/locales/vi/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/yue/common.json b/public/locales/yue/common.json index ed609cff..a91d652b 100644 --- a/public/locales/yue/common.json +++ b/public/locales/yue/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index d820aa96..70c4c93f 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/public/locales/zh-Hant/common.json b/public/locales/zh-Hant/common.json index c8ce9caf..17c217fd 100644 --- a/public/locales/zh-Hant/common.json +++ b/public/locales/zh-Hant/common.json @@ -706,5 +706,16 @@ "users": "Users", "categories": "Categories", "tags": "Tags" + }, + "calibreweb": { + "books": "Books", + "authors": "Authors", + "series": "Series" + }, + "atsumeru": { + "series": "Series", + "archives": "Archives", + "chapters": "Chapters", + "categories": "Categories" } } diff --git a/src/components/widgets/widget/container.jsx b/src/components/widgets/widget/container.jsx index 59ea5684..42d04948 100644 --- a/src/components/widgets/widget/container.jsx +++ b/src/components/widgets/widget/container.jsx @@ -7,6 +7,11 @@ import Raw from "./raw"; export function getAllClasses(options, additionalClassNames = '') { if (options?.style?.header === "boxedWidgets") { + if (options?.style?.cardBlur !== undefined) { + // eslint-disable-next-line no-param-reassign + additionalClassNames = additionalClassNames.concat(additionalClassNames, ` backdrop-blur${options.style.cardBlur.length ? '-' : ""}${options.style.cardBlur}`) + } + return classNames( "flex flex-col justify-center first:ml-0 ml-2 mr-2", "mt-2 m:mb-0 rounded-md shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-theme-100/20 dark:bg-white/5 p-2 pl-3 pr-3", diff --git a/src/pages/index.jsx b/src/pages/index.jsx index a2993b1a..9b9890e9 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -257,8 +257,9 @@ function Home({ initialSettings }) {
!rightAlignedWidgets.includes(widget.type)) .map((widget, i) => ( - + ))}
rightAlignedWidgets.includes(widget.type)) .map((widget, i) => ( - + ))}
diff --git a/src/widgets/atsumeru/component.jsx b/src/widgets/atsumeru/component.jsx new file mode 100644 index 00000000..85e78182 --- /dev/null +++ b/src/widgets/atsumeru/component.jsx @@ -0,0 +1,36 @@ +import { useTranslation } from "next-i18next"; + +import Container from "components/services/widget/container"; +import Block from "components/services/widget/block"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { t } = useTranslation(); + const { widget } = service; + + const { data: infoData, error: infoError } = useWidgetAPI(widget, "info"); + + if (infoError) { + return ; + } + + if (!infoData) { + return ( + + + + + + + ); + } + + return ( + + + + + + + ); +} diff --git a/src/widgets/atsumeru/widget.js b/src/widgets/atsumeru/widget.js new file mode 100644 index 00000000..3934f6f4 --- /dev/null +++ b/src/widgets/atsumeru/widget.js @@ -0,0 +1,14 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/server/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + info: { + endpoint: "info" + } + }, +}; + +export default widget; \ No newline at end of file diff --git a/src/widgets/calibreweb/component.jsx b/src/widgets/calibreweb/component.jsx new file mode 100644 index 00000000..450297af --- /dev/null +++ b/src/widgets/calibreweb/component.jsx @@ -0,0 +1,37 @@ +import { useTranslation } from "next-i18next"; + +import Container from "components/services/widget/container"; +import Block from "components/services/widget/block"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + const { data: booksData, error: booksError } = useWidgetAPI(widget, "books"); + const { data: authorsData, error: authorsError } = useWidgetAPI(widget, "authors"); + const { data: seriesData, error: seriesError } = useWidgetAPI(widget, "series"); + + if (booksError || authorsError || seriesError) { + const finalError = booksError ?? authorsError ?? seriesError; + return ; + } + + if (!booksData || !authorsData || !seriesData) { + return ( + + + + + + ); + } + + return ( + + + + + + ); +} diff --git a/src/widgets/calibreweb/proxy.js b/src/widgets/calibreweb/proxy.js new file mode 100644 index 00000000..4328e43c --- /dev/null +++ b/src/widgets/calibreweb/proxy.js @@ -0,0 +1,73 @@ +import { xml2json } from "xml-js"; + +import { formatApiCall } from "utils/proxy/api-helpers"; +import { httpProxy } from "utils/proxy/http"; +import getServiceWidget from "utils/config/service-helpers"; +import createLogger from "utils/logger"; +import widgets from "widgets/widgets"; + +const proxyName = "calibreWebProxyHandler"; +const logger = createLogger(proxyName); + +async function getWidget(req) { + const { group, service } = req.query; + + if (!group || !service) { + logger.debug("Invalid or missing service '%s' or group '%s'", service, group); + return null; + } + + const widget = await getServiceWidget(group, service); + + if (!widget) { + logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group); + return null; + } + + return widget; +} + +async function apiCall(widget, endpoint) { + const { api } = widgets[widget.type]; + const apiUrl = new URL(formatApiCall(api, { endpoint, ...widget })); + const headers = { + Authorization: `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}` + }; + + const [status, contentType, data] = await httpProxy(apiUrl, { + withCredentials: true, + credentials: "include", + headers, + }); + + if (status !== 200) { + logger.error("Error getting data from CalibreWeb: %s status %d. Data: %s", apiUrl, status, data); + return { status, contentType, data: null }; + } + + try { + const dataDecoded = xml2json(data.toString(), { compact: true }); + return {status, data: JSON.parse(dataDecoded), contentType}; + } catch (e) { + logger.error("Error decoding CalibreWeb API data. Data: %s", data.toString()); + return {status, data: null, contentType}; + } +} + +export default async function calibreWebProxyHandler(req, res) { + const widget = await getWidget(req); + + const { endpoint } = req.query; + + if (!widget) { + return res.status(400).json({ error: "Invalid proxy service type" }); + } + + const { status, data } = await apiCall(widget, endpoint); + + if (status !== 200) { + return res.status(status).json({error: {message: "HTTP error communicating with CalibreWeb API", data: Buffer.from(data).toString()}}); + } + + return res.status(status).json(data); +} diff --git a/src/widgets/calibreweb/widget.js b/src/widgets/calibreweb/widget.js new file mode 100644 index 00000000..ea898dd1 --- /dev/null +++ b/src/widgets/calibreweb/widget.js @@ -0,0 +1,20 @@ +import calibreWebProxyHandler from "./proxy"; + +const widget = { + api: "{url}/{endpoint}", + proxyHandler: calibreWebProxyHandler, + + mappings: { + books: { + endpoint: "opds/books/letter/00", + }, + authors: { + endpoint: "opds/author/letter/00", + }, + series: { + endpoint: "opds/series/letter/00", + }, + }, +}; + +export default widget; diff --git a/src/widgets/components.js b/src/widgets/components.js index f3242ce4..4662a8c3 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -2,12 +2,14 @@ import dynamic from "next/dynamic"; const components = { adguard: dynamic(() => import("./adguard/component")), + atsumeru: dynamic(() => import("./atsumeru/component")), audiobookshelf: dynamic(() => import("./audiobookshelf/component")), authentik: dynamic(() => import("./authentik/component")), autobrr: dynamic(() => import("./autobrr/component")), azuredevops: dynamic(() => import("./azuredevops/component")), bazarr: dynamic(() => import("./bazarr/component")), caddy: dynamic(() => import("./caddy/component")), + calibreweb: dynamic(() => import("./calibreweb/component")), changedetectionio: dynamic(() => import("./changedetectionio/component")), channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")), cloudflared: dynamic(() => import("./cloudflared/component")), diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 1b7d9f1b..f17a4767 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -1,10 +1,12 @@ import adguard from "./adguard/widget"; +import atsumeru from "./atsumeru/widget"; import audiobookshelf from "./audiobookshelf/widget"; import authentik from "./authentik/widget"; import autobrr from "./autobrr/widget"; import azuredevops from "./azuredevops/widget"; import bazarr from "./bazarr/widget"; import caddy from "./caddy/widget"; +import calibreweb from "./calibreweb/widget"; import changedetectionio from "./changedetectionio/widget"; import channelsdvrserver from "./channelsdvrserver/widget"; import cloudflared from "./cloudflared/widget"; @@ -95,12 +97,14 @@ import urbackup from "./urbackup/widget"; const widgets = { adguard, + atsumeru, audiobookshelf, authentik, autobrr, azuredevops, bazarr, caddy, + calibreweb, changedetectionio, channelsdvrserver, cloudflared,