From dcb0f64ea2d180a3e69fb5c8ff37ecf4df06ff69 Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Fri, 13 Jan 2023 11:52:44 -0500 Subject: [PATCH 01/36] implement collection list --- CHANGELOG.md | 1 + config/appConfig.ts | 1 + .../CollectionCard/CollectionCard.tsx | 72 +++++++++ .../CollectionList/CollectionList.tsx | 31 ++++ src/components/Landing/Landing.tsx | 20 +-- src/lib/api/CollectionApi.ts | 26 ++++ src/pages/index.tsx | 20 ++- src/types/CollectionQuery.ts | 10 ++ src/types/OpdsModel.ts | 137 ++++++++++++++++++ src/util/CollectionUtils.tsx | 25 ++++ 10 files changed, 329 insertions(+), 14 deletions(-) create mode 100644 src/components/CollectionCard/CollectionCard.tsx create mode 100644 src/components/CollectionList/CollectionList.tsx create mode 100644 src/lib/api/CollectionApi.ts create mode 100644 src/types/CollectionQuery.ts create mode 100644 src/types/OpdsModel.ts create mode 100644 src/util/CollectionUtils.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d02646f..3fd8ea60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - add features and tests for publication year filter - add features and tests for language filter - Upgrade dgx-header-component to v2.8.0-r16-rc-3 +- Replace Search Examples with Recently Added Collections to landing page ## [0.16.0] diff --git a/config/appConfig.ts b/config/appConfig.ts index e5082e3d..7107c1b4 100644 --- a/config/appConfig.ts +++ b/config/appConfig.ts @@ -17,6 +17,7 @@ export default { editionPath: "/edition", readPath: "/link", languagesPath: "/utils/languages", + collectionPath: "/collection", }, booksCount: { apiUrl: "/utils/counts", diff --git a/src/components/CollectionCard/CollectionCard.tsx b/src/components/CollectionCard/CollectionCard.tsx new file mode 100644 index 00000000..632fd24e --- /dev/null +++ b/src/components/CollectionCard/CollectionCard.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { + Card, + CardContent, + CardHeading, + Box, + Heading, + Text, +} from "@nypl/design-system-react-components"; +import Link from "../Link/Link"; +import { PLACEHOLDER_COVER_LINK } from "~/src/constants/editioncard"; +import { Opds2Feed } from "~/src/types/OpdsModel"; +import CollectionUtils from "~/src/util/CollectionUtils"; + +export const CollectionCard: React.FC<{ collection: Opds2Feed }> = ({ + collection, +}) => { + const collectionTitleElem = (collection: Opds2Feed) => { + const collectionElem = collection ? ( + + {collection.metadata.title} + + ) : ( + <>{collection.metadata.title} + ); + return collectionElem; + }; + + const coverUrl = CollectionUtils.getCover(collection); + const collectionId = CollectionUtils.getId(collection.links); + + return ( + + + + Collection + + {collectionTitleElem(collection)} + + + + + {collection.metadata.numberOfItems + " Items"} + + {collection.metadata.description} + + + + ); +}; + +export default CollectionCard; diff --git a/src/components/CollectionList/CollectionList.tsx b/src/components/CollectionList/CollectionList.tsx new file mode 100644 index 00000000..7cf679ec --- /dev/null +++ b/src/components/CollectionList/CollectionList.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import { Box, Flex, Link } from "@nypl/design-system-react-components"; +import CollectionCard from "../CollectionCard/CollectionCard"; +import { Opds2Feed } from "~/src/types/OpdsModel"; + +export const CollectionList: React.FC<{ collections: Opds2Feed }> = ({ + collections, +}) => { + return ( + + + {collections.groups.map((collection, index) => { + if (index < 8) + return ; + })} + {collections.groups.length > 8 && ( + + View All Collections + + )} + + + ); +}; + +export default CollectionList; diff --git a/src/components/Landing/Landing.tsx b/src/components/Landing/Landing.tsx index 6e3cc3f4..62881ef3 100644 --- a/src/components/Landing/Landing.tsx +++ b/src/components/Landing/Landing.tsx @@ -1,11 +1,11 @@ import React from "react"; import { + Box, Breadcrumbs, Footer, Heading, Hero, Link, - List, Template, TemplateBreakout, TemplateContent, @@ -14,10 +14,11 @@ import { TemplateFooter, } from "@nypl/design-system-react-components"; import SearchForm from "~/src/components/SearchForm/SearchForm"; -import Subjects from "~/config/subjectListConfig"; import { defaultBreadcrumbs } from "~/src/constants/labels"; +import CollectionList from "../CollectionList/CollectionList"; +import { Opds2Feed } from "~/src/types/OpdsModel"; -const LandingPage: React.FC = () => { +const LandingPage: React.FC<{ collections: Opds2Feed }> = ({ collections }) => { const subHeader = ( Find millions of digital books for research from multiple sources @@ -55,15 +56,10 @@ const LandingPage: React.FC = () => { - Search Examples - - - {Subjects.map((sub: any) => ( -
  • - {sub.text} -
  • - ))} -
    + + Recently Added Collections + +
    diff --git a/src/lib/api/CollectionApi.ts b/src/lib/api/CollectionApi.ts new file mode 100644 index 00000000..30b91ed1 --- /dev/null +++ b/src/lib/api/CollectionApi.ts @@ -0,0 +1,26 @@ +import appConfig from "~/config/appConfig"; +import { CollectionQuery, CollectionResult } from "~/src/types/CollectionQuery"; + +const apiEnv = process.env["APP_ENV"]; +const apiUrl = process.env["API_URL"] || appConfig.api.url[apiEnv]; + +const { collectionPath } = appConfig.api; +const collectionUrl = apiUrl + collectionPath; +export const collectionFetcher = async (query: CollectionQuery) => { + const collectionApiQuery = { + ...query, + }; + + const url = new URL(collectionUrl + "/" + query.identifier); + url.search = new URLSearchParams(collectionApiQuery.toString()).toString(); + const res = await fetch(url.toString()); + + if (res.ok) { + const collectionResult: CollectionResult = await res.json(); + return collectionResult; + } else { + throw new Error( + `cannot find collection with identifier ${query.identifier}` + ); + } +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0e14e346..9d4db35d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -2,11 +2,27 @@ import React from "react"; import Layout from "~/src/components/Layout/Layout"; import Landing from "../components/Landing/Landing"; +import { collectionFetcher } from "../lib/api/CollectionApi"; +import { CollectionResult } from "../types/CollectionQuery"; -const LandingPage: React.FC = () => { +export async function getServerSideProps() { + // Fetch all collections + const collectionResult: CollectionResult = await collectionFetcher({ + identifier: "list", + perPage: 8, + }); + + return { + props: { + collections: collectionResult, + }, + }; +} + +const LandingPage: React.FC = (props) => { return ( - + ); }; diff --git a/src/types/CollectionQuery.ts b/src/types/CollectionQuery.ts new file mode 100644 index 00000000..398e9f24 --- /dev/null +++ b/src/types/CollectionQuery.ts @@ -0,0 +1,10 @@ +import { Opds2Feed } from "./OpdsModel"; + +export type CollectionQuery = { + identifier: string; + page?: number; + perPage?: number; + sort?: string; +}; + +export type CollectionResult = Opds2Feed; diff --git a/src/types/OpdsModel.ts b/src/types/OpdsModel.ts new file mode 100644 index 00000000..4381e89b --- /dev/null +++ b/src/types/OpdsModel.ts @@ -0,0 +1,137 @@ +export type Opds2Feed = { + facets: OpdsFacet[]; + groups: Opds2Feed[]; + images: OpdsImage[]; + links: OpdsLink[]; + metadata: OpdsMetadata; + navigation: OpdsNavigation[]; + publications: OpdsPublication[]; +}; + +export type OpdsFacet = { + links: OpdsLink[]; + metadata: OpdsMetadata; +}; + +export type OpdsLink = { + alternate: string; + bitrate: number; + children: any[]; + duration: number; + height: number; + href: string; + language: string; + properties: any; + rel: string; + templated: boolean; + title: string; + type: string; + width: number; +}; + +export type OpdsMetadata = { + abridged: string; + alternate: number; + artist: string; + author: string; + belongsTo: string; + bitrate: number; + collection: string; + colorist: string; + contributor: string; + description: string; + duration: number; + editor: string; + height: number; + href: string; + identifier: string; + illustrator: string; + imprint: string; + inker: string; + language: string; + letterer: string; + links: OpdsLink[]; + modified: string; + name: string; + narrator: string; + numberOfPages: number; + numberOfItems: number; + penciler: string; + position: string; + published: number; + publisher: string; + readingOrder: ReadingOrder[]; + rel: string; + resources: Resource[]; + series: string; + sortAs: string; + subject: string; + subtitle: string; + title: string; + translator: string; + type: string; + width: number; +}; + +export type ReadingOrder = { + alternate: string; + bitrate: number; + children: any[]; + duration: number; + height: number; + href: string; + language: string; + properties: any; + rel: string; + templated: boolean; + title: string; + type: string; + width: number; +}; + +export type Resource = { + alternate: string; + bitrate: number; + children: any[]; + duration: number; + height: number; + href: string; + language: string; + properties: any; + rel: string; + templated: boolean; + title: string; + type: string; + width: number; +}; + +export type OpdsNavigation = { + href: string; + rel: string; + title: string; + type: string; +}; + +export type OpdsPublication = { + editions: any[]; + images: OpdsImage[]; + links: OpdsLink[]; + metadata: OpdsMetadata; + type: string; +}; + +export type OpdsImage = { + alternate: string; + bitrate: number; + children: any[]; + duration: number; + height: number; + href: string; + language: string; + properties: any; + rel: string; + templated: boolean; + title: string; + type: string; + width: number; +}; diff --git a/src/util/CollectionUtils.tsx b/src/util/CollectionUtils.tsx new file mode 100644 index 00000000..950beeda --- /dev/null +++ b/src/util/CollectionUtils.tsx @@ -0,0 +1,25 @@ +import { formatUrl } from "./Util"; +import { PLACEHOLDER_COVER_LINK } from "../constants/editioncard"; +import { MediaTypes } from "../constants/mediaTypes"; +import { Opds2Feed, OpdsLink } from "../types/OpdsModel"; + +export default class CollectionUtils { + /** Get Cover Image + * @param covers - The list of covers + * @returns The URL of the cover that should be displayed. + */ + static getCover(collection: Opds2Feed): string { + if (!collection.publications || collection.publications.length === 0) + return PLACEHOLDER_COVER_LINK; + const coverLink = collection.publications[0].images.find((link) => { + return MediaTypes.display.includes(link.type); + }); + return coverLink ? formatUrl(coverLink.href) : PLACEHOLDER_COVER_LINK; + } + + static getId(links: OpdsLink[]): string { + if (!links || links.length === 0) return ""; + const id = links[0].href.match(/.*\/(.*)\?/g); + return id[0] ?? ""; + } +} From a7ce39be38c9bbf9bac0193ffccd9bdd64062d23 Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Tue, 17 Jan 2023 14:11:36 -0500 Subject: [PATCH 02/36] add tests --- src/__tests__/fixtures/CollectionFixture.ts | 1924 +++++++++++++++++ .../CollectionCard/CollectionCard.test.tsx | 35 + .../CollectionCard/CollectionCard.tsx | 25 +- .../CollectionList/CollectionList.test.tsx | 39 + .../CollectionList/CollectionList.tsx | 36 +- src/components/Landing/Landing.test.tsx | 19 +- src/components/Landing/Landing.tsx | 4 +- src/types/OpdsModel.ts | 88 +- src/util/CollectionUtils.tsx | 6 +- 9 files changed, 2062 insertions(+), 114 deletions(-) create mode 100644 src/__tests__/fixtures/CollectionFixture.ts create mode 100644 src/components/CollectionCard/CollectionCard.test.tsx create mode 100644 src/components/CollectionList/CollectionList.test.tsx diff --git a/src/__tests__/fixtures/CollectionFixture.ts b/src/__tests__/fixtures/CollectionFixture.ts new file mode 100644 index 00000000..cb588983 --- /dev/null +++ b/src/__tests__/fixtures/CollectionFixture.ts @@ -0,0 +1,1924 @@ +import { CollectionResult } from "~/src/types/CollectionQuery"; +import { Opds2Feed } from "~/src/types/OpdsModel"; + +export const collections = [ + { + title: "Baseball: A Collection by Mike Benowitz", + href: "/collection/978ea0e0-8ecc-4de2-bfe8-032fea641d8e", + }, + { + title: "Error Test Collection 1", + href: "/collection/42ba2f91-6802-45e2-8863-7afafec8cc2c", + }, + { + title: "Error Test Collection 2", + href: "/collection/d292ac5b-18dd-472f-a422-9d32cfa33659", + }, + { + title: "Historical Resources on Marblehead 1", + href: "/collection/0104a1ec-8e03-4ee8-9149-92516c119b40", + }, + { + title: "Historical Resources on Marblehead 2", + href: "/collection/b1e7f7d4-6822-4cc6-a82b-ee111252ac08", + }, + { + title: "Historical Resources on Marblehead 3", + href: "/collection/d505f3b3-8efa-49cb-b478-309ab629128e", + }, + { + title: "Historical Resources on Marblehead 4", + href: "/collection/53307b1c-64a1-449f-967c-f6d84d952e85", + }, + { + title: "Historical Resources on Marblehead 5", + href: "/collection/8cf9a31e-3097-458c-84c9-5fb1b1cac25b", + }, +]; + +export const oneCollectionListData: CollectionResult = { + groups: [ + { + links: [ + { + href: "/collection/978ea0e0-8ecc-4de2-bfe8-032fea641d8e?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A history of the sport of baseball", + itemsPerPage: 5, + numberOfItems: 3, + title: "Baseball: A Collection by Mike Benowitz", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/bib/b14514889", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+catalog", + }, + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/hold/request/b14514889-i38116343", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+edd", + }, + { + href: "https://drb-qa.nypl.org/edition/4267756", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + alternate: [], + created: "Tue, 18 May 2021 10:00:41 GMT", + creator: "Wray, J. E. (J. Edward)", + description: '{"Master microform held by: NN."}', + language: "eng", + locationCreated: "New York (State)", + modified: "Tue, 18 May 2021 10:00:41 GMT", + published: 1900, + publisher: "American Sports Publishing,", + sortAs: + "how to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + subtitle: null, + title: + "How to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "catalog.hathitrust.org/api/volumes/oclc/67612618.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/2422118", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + ["@type"]: "http://schema.org/Book", + alternate: [], + created: "Thu, 22 Apr 2021 10:00:39 GMT", + creator: " Committee on Energy and Natural Resources.", + description: null, + language: "eng", + locationCreated: null, + modified: "Thu, 22 Apr 2021 10:00:39 GMT", + published: 2006, + publisher: "[U.S. G.P.O.],", + sortAs: "negro leagues baseball museum", + subtitle: null, + title: "Negro Leagues Baseball Museum", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "drb-files-qa.s3.amazonaws.com/covers/hathi/mdp.39015047482628.jpeg", + type: "image/jpeg", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047482628", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/275274.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/2192781.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/894734", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Tue, 30 Mar 2021 19:29:20 GMT", + creator: "Spink, J. G. Taylor b. 1888.", + description: null, + language: "eng,und", + locationCreated: null, + modified: "Tue, 30 Mar 2021 19:29:20 GMT", + published: 1947, + publisher: + "Thomas Y. Crowell,, T. Y. Crowell Co., Crowell, New York", + sortAs: "judge landis and twenty-five years of baseball", + subtitle: null, + title: "Judge Landis and twenty-five years of baseball", + }, + type: "application/opds-publication+json", + }, + ], + }, + ], + links: [ + { + href: "/collection/list?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + currentPage: 1, + itemsPerPage: 10, + numberOfItems: 1, + title: "Digital Research Books Collections", + }, +}; + +export const collectionData: Opds2Feed = { + links: [ + { + href: "/collection/978ea0e0-8ecc-4de2-bfe8-032fea641d8e?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A history of the sport of baseball", + itemsPerPage: 5, + numberOfItems: 3, + title: "Baseball: A Collection by Mike Benowitz", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/bib/b14514889", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+catalog", + }, + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/hold/request/b14514889-i38116343", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+edd", + }, + { + href: "https://drb-qa.nypl.org/edition/4267756", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + alternate: [], + created: "Tue, 18 May 2021 10:00:41 GMT", + creator: "Wray, J. E. (J. Edward)", + description: '{"Master microform held by: NN."}', + language: "eng", + locationCreated: "New York (State)", + modified: "Tue, 18 May 2021 10:00:41 GMT", + published: 1900, + publisher: "American Sports Publishing,", + sortAs: + "how to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + subtitle: null, + title: + "How to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "catalog.hathitrust.org/api/volumes/oclc/67612618.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/2422118", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + ["@type"]: "http://schema.org/Book", + alternate: [], + created: "Thu, 22 Apr 2021 10:00:39 GMT", + creator: " Committee on Energy and Natural Resources.", + description: null, + language: "eng", + locationCreated: null, + modified: "Thu, 22 Apr 2021 10:00:39 GMT", + published: 2006, + publisher: "[U.S. G.P.O.],", + sortAs: "negro leagues baseball museum", + subtitle: null, + title: "Negro Leagues Baseball Museum", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "drb-files-qa.s3.amazonaws.com/covers/hathi/mdp.39015047482628.jpeg", + type: "image/jpeg", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047482628", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/275274.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/2192781.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/894734", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Tue, 30 Mar 2021 19:29:20 GMT", + creator: "Spink, J. G. Taylor b. 1888.", + description: null, + language: "eng,und", + locationCreated: null, + modified: "Tue, 30 Mar 2021 19:29:20 GMT", + published: 1947, + publisher: "Thomas Y. Crowell,, T. Y. Crowell Co., Crowell, New York", + sortAs: "judge landis and twenty-five years of baseball", + subtitle: null, + title: "Judge Landis and twenty-five years of baseball", + }, + type: "application/opds-publication+json", + }, + ], +}; + +export const collectionListData: CollectionResult = { + groups: [ + { + links: [ + { + href: "/collection/978ea0e0-8ecc-4de2-bfe8-032fea641d8e?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A history of the sport of baseball", + itemsPerPage: 5, + numberOfItems: 3, + title: "Baseball: A Collection by Mike Benowitz", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/bib/b14514889", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+catalog", + }, + { + href: + "www.nypl.org/research/collections/shared-collection-catalog/hold/request/b14514889-i38116343", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/html+edd", + }, + { + href: "https://drb-qa.nypl.org/edition/4267756", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + alternate: [], + created: "Tue, 18 May 2021 10:00:41 GMT", + creator: "Wray, J. E. (J. Edward)", + description: '{"Master microform held by: NN."}', + language: "eng", + locationCreated: "New York (State)", + modified: "Tue, 18 May 2021 10:00:41 GMT", + published: 1900, + publisher: "American Sports Publishing,", + sortAs: + "how to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + subtitle: null, + title: + "How to organize a league, manage a team, captain a team, coach a team, score a game, arrange signals [microform] including how to lay out a league diamond, and technical terms of base ball,", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "catalog.hathitrust.org/api/volumes/oclc/67612618.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/2422118", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + ["@type"]: "http://schema.org/Book", + alternate: [], + created: "Thu, 22 Apr 2021 10:00:39 GMT", + creator: " Committee on Energy and Natural Resources.", + description: null, + language: "eng", + locationCreated: null, + modified: "Thu, 22 Apr 2021 10:00:39 GMT", + published: 2006, + publisher: "[U.S. G.P.O.],", + sortAs: "negro leagues baseball museum", + subtitle: null, + title: "Negro Leagues Baseball Museum", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "drb-files-qa.s3.amazonaws.com/covers/hathi/mdp.39015047482628.jpeg", + type: "image/jpeg", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047482628", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/275274.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/2192781.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/894734", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Tue, 30 Mar 2021 19:29:20 GMT", + creator: "Spink, J. G. Taylor b. 1888.", + description: null, + language: "eng,und", + locationCreated: null, + modified: "Tue, 30 Mar 2021 19:29:20 GMT", + published: 1947, + publisher: + "Thomas Y. Crowell,, T. Y. Crowell Co., Crowell, New York", + sortAs: "judge landis and twenty-five years of baseball", + subtitle: null, + title: "Judge Landis and twenty-five years of baseball", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/42ba2f91-6802-45e2-8863-7afafec8cc2c?page=1", + rel: ["self", "first", "previous"], + type: "application/opds+json", + }, + { + href: "/collection/42ba2f91-6802-45e2-8863-7afafec8cc2c?page=0", + rel: ["next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "Testing Sean's error report", + itemsPerPage: 5, + numberOfItems: 0, + title: "Error Test Collection 1", + }, + }, + { + links: [ + { + href: "/collection/d292ac5b-18dd-472f-a422-9d32cfa33659?page=1", + rel: ["self", "first", "previous"], + type: "application/opds+json", + }, + { + href: "/collection/d292ac5b-18dd-472f-a422-9d32cfa33659?page=0", + rel: ["next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "Testing Sean's error report", + itemsPerPage: 5, + numberOfItems: 0, + title: "Error Test Collection 2", + }, + }, + { + links: [ + { + href: "/collection/0104a1ec-8e03-4ee8-9149-92516c119b40?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 1", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/b1e7f7d4-6822-4cc6-a82b-ee111252ac08?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 2", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/d505f3b3-8efa-49cb-b478-309ab629128e?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 3", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/53307b1c-64a1-449f-967c-f6d84d952e85?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 4", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/8cf9a31e-3097-458c-84c9-5fb1b1cac25b?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 5", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/d902fd44-7cbe-4401-b50c-5b1bda8b1059?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 6", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + { + links: [ + { + href: "/collection/37a7e91d-31cd-444c-8e97-7f17426de7ec?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + creator: "Mike Benowitz", + currentPage: 1, + description: "A town in Massachussetts", + itemsPerPage: 5, + numberOfItems: 3, + title: "Historical Resources on Marblehead 7", + }, + publications: [ + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=coo1.ark:/13960/t2t448c98", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=wu.89077236636", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829537", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/3486873.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662693", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, (1853-1904.)", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1880, + publisher: "Houghton, Osgood", + sortAs: "the history and traditions of marblehead. by samuel roads", + subtitle: null, + title: "The history and traditions of Marblehead. By Samuel Roads", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t08w3k590", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: + "babel.hathitrust.org/cgi/imgsrv/download/pdf?id=loc.ark:/13960/t3417498d", + rel: "http://opds-spec.org/acquisition/open-access", + type: "application/pdf", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=mdp.39015047402535", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=hvd.32044013685672", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081829529", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/1273431", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Sun, 04 Apr 2021 10:00:40 GMT", + creator: "Marblehead historical society.", + description: null, + language: "eng", + locationCreated: "Massachusetts", + modified: "Sun, 04 Apr 2021 10:00:40 GMT", + published: 1915, + publisher: "", + sortAs: + "old marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the marblehead historical society by benjamin j. lindsey, treasurer", + subtitle: null, + title: + "Old Marblehead sea captains and the ships in which they sailed ... comp. and pub. for the benefit of the Marblehead historical society by Benjamin J. Lindsey, treasurer", + }, + type: "application/opds-publication+json", + }, + { + editions: [], + images: [ + { + href: + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png", + type: "image/png", + }, + ], + links: [ + { + href: "babel.hathitrust.org/cgi/pt?id=nyp.33433081828323", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "catalog.hathitrust.org/api/volumes/oclc/35897189.html", + rel: "http://opds-spec.org/acquisition/open-access", + type: "text/html", + }, + { + href: "https://drb-qa.nypl.org/edition/4662646", + rel: "alternate", + type: "text/html", + }, + ], + metadata: { + "@type": "http://schema.org/Book", + alternate: [], + created: "Fri, 04 Jun 2021 10:00:41 GMT", + creator: "Roads, Samuel, Jr.", + description: null, + language: "eng", + locationCreated: null, + modified: "Fri, 04 Jun 2021 10:00:41 GMT", + published: 1881, + publisher: "M.H. Graves [cop, Merrill H. Graves,, C.H. Litchman,", + sortAs: "a guide to marblehead", + subtitle: null, + title: "A guide to Marblehead", + }, + type: "application/opds-publication+json", + }, + ], + }, + ], + links: [ + { + href: "/collection/list?page=1", + rel: ["self", "first", "previous", "next", "last"], + type: "application/opds+json", + }, + ], + metadata: { + currentPage: 1, + itemsPerPage: 10, + numberOfItems: 10, + title: "Digital Research Books Collections", + }, +}; diff --git a/src/components/CollectionCard/CollectionCard.test.tsx b/src/components/CollectionCard/CollectionCard.test.tsx new file mode 100644 index 00000000..ae43f28e --- /dev/null +++ b/src/components/CollectionCard/CollectionCard.test.tsx @@ -0,0 +1,35 @@ +import React from "react"; +import CollectionCard from "./CollectionCard"; +import "@testing-library/jest-dom/extend-expect"; +import { screen, render } from "@testing-library/react"; +import { collectionData } from "~/src/__tests__/fixtures/CollectionFixture"; + +describe("Collection list", () => { + beforeEach(() => { + render(); + }); + test("shows Title as heading", () => { + expect( + screen.getByRole("heading", { + name: "Baseball: A Collection by Mike Benowitz", + }) + ).toBeInTheDocument(); + }); + test("shows Description", () => { + expect( + screen.getByText("A history of the sport of baseball") + ).toBeInTheDocument(); + }); + test("Shows cover", () => { + expect( + screen + .getByAltText("Cover for Baseball: A Collection by Mike Benowitz") + .closest("img").src + ).toEqual( + "https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png" + ); + }); + test("Shows number of items", () => { + expect(screen.getByText("3 Items")).toBeInTheDocument(); + }); +}); diff --git a/src/components/CollectionCard/CollectionCard.tsx b/src/components/CollectionCard/CollectionCard.tsx index 632fd24e..494dfdef 100644 --- a/src/components/CollectionCard/CollectionCard.tsx +++ b/src/components/CollectionCard/CollectionCard.tsx @@ -7,7 +7,6 @@ import { Heading, Text, } from "@nypl/design-system-react-components"; -import Link from "../Link/Link"; import { PLACEHOLDER_COVER_LINK } from "~/src/constants/editioncard"; import { Opds2Feed } from "~/src/types/OpdsModel"; import CollectionUtils from "~/src/util/CollectionUtils"; @@ -15,21 +14,6 @@ import CollectionUtils from "~/src/util/CollectionUtils"; export const CollectionCard: React.FC<{ collection: Opds2Feed }> = ({ collection, }) => { - const collectionTitleElem = (collection: Opds2Feed) => { - const collectionElem = collection ? ( - - {collection.metadata.title} - - ) : ( - <>{collection.metadata.title} - ); - return collectionElem; - }; - const coverUrl = CollectionUtils.getCover(collection); const collectionId = CollectionUtils.getId(collection.links); @@ -43,19 +27,20 @@ export const CollectionCard: React.FC<{ collection: Opds2Feed }> = ({ coverUrl === PLACEHOLDER_COVER_LINK ? "Placeholder Cover" : `Cover for ${collection.metadata.title}`, - size: "xsmall", aspectRatio: "twoByOne", }} - mainActionLink={"/collection/" + collectionId} + mainActionLink={collection.links[0].href} isBordered width="264px" minHeight="405px" > - + Collection - {collectionTitleElem(collection)} + + {collection.metadata.title} + diff --git a/src/components/CollectionList/CollectionList.test.tsx b/src/components/CollectionList/CollectionList.test.tsx new file mode 100644 index 00000000..a7e5e46d --- /dev/null +++ b/src/components/CollectionList/CollectionList.test.tsx @@ -0,0 +1,39 @@ +import React from "react"; +import CollectionList from "./CollectionList"; +import "@testing-library/jest-dom/extend-expect"; +import { screen, render } from "@testing-library/react"; +import { + collectionListData, + oneCollectionListData, +} from "~/src/__tests__/fixtures/CollectionFixture"; + +describe("Collection list", () => { + beforeEach(() => { + render(); + }); + test("shows View All Collections link", () => { + expect( + screen.getByRole("link", { name: "View All Collections" }) + ).toBeInTheDocument(); + }); +}); + +describe("Collection list with one item", () => { + beforeEach(() => { + render(); + }); + test("does not show View All Collections link", () => { + expect( + screen.queryByRole("link", { name: "View All Collections" }) + ).not.toBeInTheDocument(); + }); +}); + +describe("Collection list with no data", () => { + beforeEach(() => { + render(); + }); + test("shows No collections available", () => { + expect(screen.getByText("No collections available")).toBeInTheDocument(); + }); +}); diff --git a/src/components/CollectionList/CollectionList.tsx b/src/components/CollectionList/CollectionList.tsx index 7cf679ec..718f0c86 100644 --- a/src/components/CollectionList/CollectionList.tsx +++ b/src/components/CollectionList/CollectionList.tsx @@ -8,22 +8,26 @@ export const CollectionList: React.FC<{ collections: Opds2Feed }> = ({ }) => { return ( - - {collections.groups.map((collection, index) => { - if (index < 8) - return ; - })} - {collections.groups.length > 8 && ( - - View All Collections - - )} - + {collections ? ( + + {collections.groups.map((collection, index) => { + if (index < 8) + return ; + })} + {collections.groups.length > 8 && ( + + View All Collections + + )} + + ) : ( + "No collections available" + )} ); }; diff --git a/src/components/Landing/Landing.test.tsx b/src/components/Landing/Landing.test.tsx index 290d57d9..3183ea71 100644 --- a/src/components/Landing/Landing.test.tsx +++ b/src/components/Landing/Landing.test.tsx @@ -1,6 +1,5 @@ import React from "react"; import { render, screen } from "@testing-library/react"; -import Subjects from "~/config/subjectListConfig"; import LandingPage from "./Landing"; import { searchFormRenderTests, @@ -9,10 +8,14 @@ import { jest.mock("next/router", () => require("next-router-mock")); import mockRouter from "next-router-mock"; +import { + collectionListData, + collections, +} from "~/src/__tests__/fixtures/CollectionFixture"; describe("Renders Index Page", () => { beforeEach(async () => { - render(); + render(); // Wait for page to be loaded await screen.findByRole("heading", { @@ -34,12 +37,12 @@ describe("Renders Index Page", () => { searchFormRenderTests(); }); - test("Shows Search Examples", () => { - expect(screen.getByText("Search Examples")).toBeInTheDocument(); - Subjects.forEach((sub) => { - expect(screen.getByText(sub.text)).toBeInTheDocument(); - expect(screen.getByText(sub.text).closest("a").href).toContain( - "/search?query=" + test("Shows Recently Added Collections", () => { + expect(screen.getByText("Recently Added Collections")).toBeInTheDocument(); + collections.forEach((collection) => { + expect(screen.getByText(collection.title)).toBeInTheDocument(); + expect(screen.getByText(collection.title).closest("a").href).toContain( + collection.href ); }); }); diff --git a/src/components/Landing/Landing.tsx b/src/components/Landing/Landing.tsx index 62881ef3..8721324e 100644 --- a/src/components/Landing/Landing.tsx +++ b/src/components/Landing/Landing.tsx @@ -18,7 +18,9 @@ import { defaultBreadcrumbs } from "~/src/constants/labels"; import CollectionList from "../CollectionList/CollectionList"; import { Opds2Feed } from "~/src/types/OpdsModel"; -const LandingPage: React.FC<{ collections: Opds2Feed }> = ({ collections }) => { +const LandingPage: React.FC<{ collections?: Opds2Feed }> = ({ + collections, +}) => { const subHeader = ( Find millions of digital books for research from multiple sources diff --git a/src/types/OpdsModel.ts b/src/types/OpdsModel.ts index 4381e89b..758fb930 100644 --- a/src/types/OpdsModel.ts +++ b/src/types/OpdsModel.ts @@ -1,11 +1,11 @@ export type Opds2Feed = { - facets: OpdsFacet[]; - groups: Opds2Feed[]; - images: OpdsImage[]; + facets?: OpdsFacet[]; + groups?: Opds2Feed[]; + images?: OpdsImage[]; links: OpdsLink[]; metadata: OpdsMetadata; - navigation: OpdsNavigation[]; - publications: OpdsPublication[]; + navigation?: OpdsNavigation[]; + publications?: OpdsPublication[]; }; export type OpdsFacet = { @@ -14,63 +14,28 @@ export type OpdsFacet = { }; export type OpdsLink = { - alternate: string; - bitrate: number; - children: any[]; - duration: number; - height: number; href: string; - language: string; - properties: any; - rel: string; - templated: boolean; - title: string; + rel: string | string[]; type: string; - width: number; }; export type OpdsMetadata = { - abridged: string; - alternate: number; - artist: string; - author: string; - belongsTo: string; - bitrate: number; - collection: string; - colorist: string; - contributor: string; - description: string; - duration: number; - editor: string; - height: number; - href: string; - identifier: string; - illustrator: string; - imprint: string; - inker: string; - language: string; - letterer: string; - links: OpdsLink[]; - modified: string; - name: string; - narrator: string; - numberOfPages: number; - numberOfItems: number; - penciler: string; - position: string; - published: number; - publisher: string; - readingOrder: ReadingOrder[]; - rel: string; - resources: Resource[]; - series: string; - sortAs: string; - subject: string; - subtitle: string; + "@type"?: string; + alternate?: string | string[]; + created?: string; + creator?: string; + currentPage?: number; + description?: string; + itemsPerPage?: number; + language?: string; + locationCreated?: string; + modified?: string; + numberOfItems?: number; + published?: number; + publisher?: string; + sortAs?: string; + subtitle?: string; title: string; - translator: string; - type: string; - width: number; }; export type ReadingOrder = { @@ -121,17 +86,6 @@ export type OpdsPublication = { }; export type OpdsImage = { - alternate: string; - bitrate: number; - children: any[]; - duration: number; - height: number; href: string; - language: string; - properties: any; - rel: string; - templated: boolean; - title: string; type: string; - width: number; }; diff --git a/src/util/CollectionUtils.tsx b/src/util/CollectionUtils.tsx index 950beeda..5bbe6584 100644 --- a/src/util/CollectionUtils.tsx +++ b/src/util/CollectionUtils.tsx @@ -5,7 +5,7 @@ import { Opds2Feed, OpdsLink } from "../types/OpdsModel"; export default class CollectionUtils { /** Get Cover Image - * @param covers - The list of covers + * @param collection - The collection * @returns The URL of the cover that should be displayed. */ static getCover(collection: Opds2Feed): string { @@ -17,9 +17,11 @@ export default class CollectionUtils { return coverLink ? formatUrl(coverLink.href) : PLACEHOLDER_COVER_LINK; } + // TODO: replace with collection_id property that will be added on backend response static getId(links: OpdsLink[]): string { if (!links || links.length === 0) return ""; - const id = links[0].href.match(/.*\/(.*)\?/g); + const link = links[0].href; + const id = link.substring(link.lastIndexOf("/") + 1, link.indexOf("?")); return id[0] ?? ""; } } From f2187b485c4815b8d428180a64021c852e5c7c25 Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Fri, 20 Jan 2023 13:35:13 -0500 Subject: [PATCH 03/36] update based on feedback --- .../CollectionCard/CollectionCard.tsx | 17 ++++++++++++++--- src/lib/api/CollectionApi.ts | 8 ++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/CollectionCard/CollectionCard.tsx b/src/components/CollectionCard/CollectionCard.tsx index 494dfdef..3764dabf 100644 --- a/src/components/CollectionCard/CollectionCard.tsx +++ b/src/components/CollectionCard/CollectionCard.tsx @@ -33,14 +33,25 @@ export const CollectionCard: React.FC<{ collection: Opds2Feed }> = ({ isBordered width="264px" minHeight="405px" + sx={{ + "a > h2": { + color: "ui.link.primary", + textDecoration: "underline", + }, + "h1 > a": { + textDecoration: "none", + _hover: { + p: { color: "initial" }, + h2: { color: "ui.link.secondary" }, + }, + }, + }} > Collection - - {collection.metadata.title} - + {collection.metadata.title} diff --git a/src/lib/api/CollectionApi.ts b/src/lib/api/CollectionApi.ts index 30b91ed1..8060d339 100644 --- a/src/lib/api/CollectionApi.ts +++ b/src/lib/api/CollectionApi.ts @@ -16,8 +16,12 @@ export const collectionFetcher = async (query: CollectionQuery) => { const res = await fetch(url.toString()); if (res.ok) { - const collectionResult: CollectionResult = await res.json(); - return collectionResult; + try { + const collectionResult: CollectionResult = await res.json(); + return collectionResult; + } catch (e) { + throw new Error(e.error); + } } else { throw new Error( `cannot find collection with identifier ${query.identifier}` From 545bec8987721edc93a6233b766082bf84357fee Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Fri, 20 Jan 2023 14:05:28 -0500 Subject: [PATCH 04/36] minor ui changes --- src/components/CollectionCard/CollectionCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CollectionCard/CollectionCard.tsx b/src/components/CollectionCard/CollectionCard.tsx index 3764dabf..2eba0b17 100644 --- a/src/components/CollectionCard/CollectionCard.tsx +++ b/src/components/CollectionCard/CollectionCard.tsx @@ -48,7 +48,7 @@ export const CollectionCard: React.FC<{ collection: Opds2Feed }> = ({ }} > - + Collection {collection.metadata.title} From cf6eac0411794f4fdf204943f0ec4bdedab5b7c2 Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Tue, 24 Jan 2023 15:49:31 -0500 Subject: [PATCH 05/36] add landing hero and clean up page --- .../CollectionList/CollectionList.tsx | 18 ++-- src/components/Landing/Landing.tsx | 85 ++++++++++++------- src/components/Layout/Layout.tsx | 18 ++-- src/components/SearchForm/SearchForm.tsx | 5 +- 4 files changed, 76 insertions(+), 50 deletions(-) diff --git a/src/components/CollectionList/CollectionList.tsx b/src/components/CollectionList/CollectionList.tsx index 718f0c86..1279b150 100644 --- a/src/components/CollectionList/CollectionList.tsx +++ b/src/components/CollectionList/CollectionList.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Box, Flex, Link } from "@nypl/design-system-react-components"; +import { Box, Link, SimpleGrid } from "@nypl/design-system-react-components"; import CollectionCard from "../CollectionCard/CollectionCard"; import { Opds2Feed } from "~/src/types/OpdsModel"; @@ -9,22 +9,24 @@ export const CollectionList: React.FC<{ collections: Opds2Feed }> = ({ return ( {collections ? ( - - {collections.groups.map((collection, index) => { - if (index < 8) - return ; - })} + <> + + {collections.groups.map((collection, index) => { + if (index < 8) + return ; + })} + {collections.groups.length > 8 && ( View All Collections )} - + ) : ( "No collections available" )} diff --git a/src/components/Landing/Landing.tsx b/src/components/Landing/Landing.tsx index 8721324e..1bc3814e 100644 --- a/src/components/Landing/Landing.tsx +++ b/src/components/Landing/Landing.tsx @@ -7,11 +7,12 @@ import { Hero, Link, Template, + TemplateAboveHeader, TemplateBreakout, TemplateContent, TemplateContentPrimary, - TemplateContentTop, TemplateFooter, + TemplateHeader, } from "@nypl/design-system-react-components"; import SearchForm from "~/src/components/SearchForm/SearchForm"; import { defaultBreadcrumbs } from "~/src/constants/labels"; @@ -22,41 +23,65 @@ const LandingPage: React.FC<{ collections?: Opds2Feed }> = ({ collections, }) => { const subHeader = ( - - Find millions of digital books for research from multiple sources - world-wide--all free to read, download, and keep. No library card - required. This is an early beta test, so we want your feedback!{" "} - - Read more about the project - - . - + + + Find millions of digital books for research from multiple sources + world-wide--all free to read, download, and keep. No library card + required. This is an early beta test, so we want your feedback!{" "} + + Read more about the project + + . + + + Search the World's Research Collections + + + ); return (