diff --git a/api/src/models/utils/filters/parser.ts b/api/src/models/utils/filters/parser.ts index 84a0f272..ec845d55 100644 --- a/api/src/models/utils/filters/parser.ts +++ b/api/src/models/utils/filters/parser.ts @@ -1,5 +1,7 @@ +import { isLetter } from "char-info"; import { anyStringOf, + charWhere, digit, float, int, @@ -43,7 +45,17 @@ function t(parser: Parjser): Parjser { return parser.pipe(thenq(string(" ").pipe(many()))); } -const enumP = t(letter().pipe(many1(), stringify()).expects("an enum value")); +const enumP = t( + charWhere( + (x) => + isLetter(x) || + x === "-" || { + reason: "Expected a letter or a `-`", + }, + ) + .pipe(many1(), stringify()) + .expects("an enum value"), +); const property = t(letter().pipe(many1(), stringify())).expects("a property"); diff --git a/front/src/ui/home/genre.tsx b/front/src/ui/home/genre.tsx index be3e0656..7e9314d1 100644 --- a/front/src/ui/home/genre.tsx +++ b/front/src/ui/home/genre.tsx @@ -1,31 +1,12 @@ -/* - * Kyoo - A portable and vast media library solution. - * Copyright (c) Kyoo. - * - * See AUTHORS.md and LICENSE file in the project root for full license information. - * - * Kyoo is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * Kyoo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kyoo. If not, see . - */ - import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { View } from "react-native"; import { useYoshiki } from "yoshiki/native"; import { ItemGrid, itemMap } from "~/components/items"; -import type { Genre, Show } from "~/models"; +import { type Genre, Show } from "~/models"; import { H3, ts } from "~/primitives"; import { InfiniteFetch, type QueryIdentifier } from "~/query"; +import { EmptyView } from "../errors"; export const Header = ({ title }: { title: string }) => { const { css } = useYoshiki(); @@ -56,7 +37,11 @@ export const GenreGrid = ({ genre }: { genre: Genre }) => { query={GenreGrid.query(genre)} layout={{ ...ItemGrid.layout, layout: "horizontal" }} placeholderCount={2} - empty={displayEmpty.current ? t("home.none") : undefined} + Empty={ + displayEmpty.current ? ( + + ) : undefined + } Render={({ item }) => } Loader={ItemGrid.Loader} /> @@ -69,7 +54,6 @@ GenreGrid.query = (genre: Genre): QueryIdentifier => ({ infinite: true, path: ["api", "shows"], params: { - fields: ["watchStatus"], filter: `genres has ${genre}`, sort: "random", // Limit the initial numbers of items diff --git a/front/src/ui/home/news.tsx b/front/src/ui/home/news.tsx index 70109118..ed049552 100644 --- a/front/src/ui/home/news.tsx +++ b/front/src/ui/home/news.tsx @@ -1,34 +1,13 @@ -/* - * Kyoo - A portable and vast media library solution. - * Copyright (c) Kyoo. - * - * See AUTHORS.md and LICENSE file in the project root for full license information. - * - * Kyoo is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * Kyoo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kyoo. If not, see . - */ - import { useTranslation } from "react-i18next"; -import { useYoshiki } from "yoshiki/native"; import { EntryBox, entryDisplayNumber } from "~/components/entries"; import { ItemGrid } from "~/components/items"; -import type { Entry } from "~/models"; +import { Entry } from "~/models"; import { InfiniteFetch, type QueryIdentifier } from "~/query"; +import { EmptyView } from "../errors"; import { Header } from "./genre"; export const NewsList = () => { const { t } = useTranslation(); - const { css } = useYoshiki(); return ( <> @@ -36,41 +15,46 @@ export const NewsList = () => { (x?.kind === "movie" || (!x && i % 2) ? "movie" : "episode")} - getItemSize={(kind) => (kind === "episode" ? 2 : 1)} - empty={t("home.none")} + // getItemType={(x, i) => + // x?.kind === "movie" || (!x && i % 2) ? "movie" : "episode" + // } + // getItemSizeMult={(_, __, kind) => (kind === "episode" ? 2 : 1)} + Empty={} Render={({ item }) => { - if (item.kind === "episode" || item.kind === "special") { - return ( - - ); - } + // if (item.kind === "episode" || item.kind === "special") { return ( - ); + // } + // return ( + // + // ); }} - Loader={({ index }) => (index % 2 ? : )} + Loader={({ index }) => + index % 2 ? : + } /> ); @@ -81,8 +65,6 @@ NewsList.query = (): QueryIdentifier => ({ infinite: true, path: ["api", "news"], params: { - // Limit the initial numbers of items limit: 10, - fields: ["serie", "watchStatus"], }, }); diff --git a/front/src/ui/home/recommended.tsx b/front/src/ui/home/recommended.tsx index 7615c926..b9af0111 100644 --- a/front/src/ui/home/recommended.tsx +++ b/front/src/ui/home/recommended.tsx @@ -1,34 +1,15 @@ -/* - * Kyoo - A portable and vast media library solution. - * Copyright (c) Kyoo. - * - * See AUTHORS.md and LICENSE file in the project root for full license information. - * - * Kyoo is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * Kyoo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kyoo. If not, see . - */ - import PlayArrow from "@material-symbols/svg-400/rounded/play_arrow-fill.svg"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { ScrollView, View } from "react-native"; import { type Theme, calc, percent, px, rem, useYoshiki } from "yoshiki/native"; -import { ItemGrid, ItemWatchStatus } from "~/components/items"; +import { ItemGrid } from "~/components/items"; import { ItemContext } from "~/components/items/context-menus"; -import type { Genre, KImage, Show, WatchStatusV } from "~/models"; +import { type Genre, type KImage, Show, type WatchStatusV } from "~/models"; import { getDisplayDate } from "~/utils"; import { Chip, + focusReset, H3, IconFab, Link, @@ -40,12 +21,7 @@ import { ts, } from "~/primitives"; import { InfiniteFetch, type Layout, type QueryIdentifier } from "~/query"; - -const imageBorderRadius = 6; -const focusReset = { - boxShadow: "unset", - outline: "none", -}; +import { ItemWatchStatus } from "~/components/items/item-helpers"; export const ItemDetails = ({ slug, @@ -99,7 +75,7 @@ export const ItemDetails = ({ bottom: 0, flexDirection: "row", bg: (theme) => theme.variant.background, - borderRadius: calc(px(imageBorderRadius), "+", ts(0.25)), + borderRadius: px(12), overflow: "hidden", borderColor: (theme) => theme.background, borderWidth: ts(0.25), @@ -132,13 +108,28 @@ export const ItemDetails = ({ p: ts(1), })} > -

theme.colors.white }, "title"])}>{name}

- {subtitle && {subtitle}} +

theme.colors.white }, + "title", + ])} + > + {name} +

+ {subtitle && {subtitle}} - + setMoreOpened(v)} - force /> )} {tagline &&

{tagline}

}
- {description ?? t("show.noOverview")} + + {description ?? t("show.noOverview")} +
@@ -174,10 +166,10 @@ export const ItemDetails = ({ right: ts(0.25), borderWidth: ts(0.25), borderColor: "transparent", - borderBottomEndRadius: px(imageBorderRadius), + borderBottomEndRadius: px(6), overflow: "hidden", // Calculate the size of the poster - left: calc(ItemDetails.layout.size, "*", 2 / 3), + left: calc(px(ItemDetails.layout.size), "*", 2 / 3), bg: (theme) => theme.themeOverlay, flexDirection: "row", pX: 4, @@ -186,9 +178,18 @@ export const ItemDetails = ({ })} > {genres && ( - + {genres.map((x, i) => ( - + ))} )} @@ -199,7 +200,9 @@ export const ItemDetails = ({ as={Link} href={playHref} {...tooltip(t("show.play"))} - {...css({ fover: { self: { transform: "scale(1.2)" as any, mX: ts(0.5) } } })} + {...css({ + fover: { self: { transform: "scale(1.2)" as any, mX: ts(0.5) } }, + })} /> )} @@ -217,7 +220,7 @@ ItemDetails.Loader = (props: object) => { height: ItemDetails.layout.size, flexDirection: "row", bg: (theme) => theme.variant.background, - borderRadius: calc(px(imageBorderRadius), "+", ts(0.25)), + borderRadius: px(12), overflow: "hidden", borderColor: (theme) => theme.background, borderWidth: ts(0.25), @@ -281,31 +284,42 @@ export const Recommended = () => { const { css } = useYoshiki(); return ( - +

{t("home.recommended")}

( @@ -323,6 +337,6 @@ Recommended.query = (): QueryIdentifier => ({ params: { sort: "random", limit: 6, - fields: ["firstEntry", "watchStatus"], + with: ["firstEntry"], }, }); diff --git a/front/src/ui/home/vertical.tsx b/front/src/ui/home/vertical.tsx index 5b27abf5..6a9a6c39 100644 --- a/front/src/ui/home/vertical.tsx +++ b/front/src/ui/home/vertical.tsx @@ -1,28 +1,8 @@ -/* - * Kyoo - A portable and vast media library solution. - * Copyright (c) Kyoo. - * - * See AUTHORS.md and LICENSE file in the project root for full license information. - * - * Kyoo is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * Kyoo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kyoo. If not, see . - */ - import { useTranslation } from "react-i18next"; import { View } from "react-native"; import { useYoshiki } from "yoshiki/native"; import { ItemGrid, ItemList, itemMap } from "~/components/items"; -import type { Show } from "~/models"; +import { Show } from "~/models"; import { H3 } from "~/primitives"; import { InfiniteFetch, type QueryIdentifier } from "~/query"; @@ -38,7 +18,6 @@ export const VerticalRecommended = () => { placeholderCount={3} layout={{ ...ItemList.layout, layout: "vertical" }} fetchMore={false} - nested Render={({ item }) => } Loader={() => } /> @@ -51,7 +30,6 @@ VerticalRecommended.query = (): QueryIdentifier => ({ infinite: true, path: ["api", "shows"], params: { - fields: ["watchStatus"], sort: "random", limit: 3, },