diff --git a/app/.eslintrc.js b/app/.eslintrc.js index a0680bf99..5c42ced70 100644 --- a/app/.eslintrc.js +++ b/app/.eslintrc.js @@ -8,6 +8,7 @@ module.exports = { 'react/react-in-jsx-scope': 'off', // Next.js magically includes 'react/jsx-one-expression-per-line': 'off', // too vertical 'jsx-a11y/anchor-is-valid': 'off', // next/link breaks this rule + 'react-hooks/exhaustive-deps': 'off', // exhaustive is excessive }, env: { jest: true, diff --git a/app/__tests__/view/[gallery]/all.test.jsx b/app/__tests__/view/[gallery]/all.test.jsx index b060fbb4a..772456591 100644 --- a/app/__tests__/view/[gallery]/all.test.jsx +++ b/app/__tests__/view/[gallery]/all.test.jsx @@ -5,7 +5,7 @@ const { getByText } = screen test('0 results', async () => { const { render } = await getPage({ - route: '/view/demo/all?keyword=fake', + route: '/demo/all?keyword=fake', }) render() const h3 = getByText(/fake results 0 of 6 found/) @@ -14,7 +14,7 @@ test('0 results', async () => { test('1 result', async () => { const { render } = await getPage({ - route: '/view/demo/all?keyword=gingerbread', + route: '/demo/all?keyword=gingerbread', }) render() const h3 = getByText(/gingerbread results 1 of 6 found/) @@ -23,7 +23,7 @@ test('1 result', async () => { test('Mixed case', async () => { const { render } = await getPage({ - route: '/view/demo/all?keyword=Gingerbread', + route: '/demo/all?keyword=Gingerbread', }) render() const h3 = getByText(/Gingerbread results 1 of 6 found/) diff --git a/app/package-lock.json b/app/package-lock.json index 8fda2d0ce..91e293107 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -11276,20 +11276,21 @@ } }, "next-test-api-route-handler": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/next-test-api-route-handler/-/next-test-api-route-handler-2.0.2.tgz", - "integrity": "sha512-K0+VvPCvf3U5BWrTWBN8B8MktNT/iMSiTnYHaESFcQQ1QvhZ/HMSWxSpOWOIW73DmY6+aIfSc29ztMQo9L5WDw==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/next-test-api-route-handler/-/next-test-api-route-handler-2.3.4.tgz", + "integrity": "sha512-hr92BcHjvRBlNnnCrqobvSiztOh1L5nn0TNKim00wecxxsCX2OM2QAxvmxr+vPsWr7VwrKfRNttfENmjKYsiCA==", "dev": true, "requires": { + "cookie": "^0.4.1", "debug": "^4.3.2", "isomorphic-unfetch": "^3.1.0", "test-listen": "^1.1.0" }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" diff --git a/app/package.json b/app/package.json index a34b7c257..023964737 100644 --- a/app/package.json +++ b/app/package.json @@ -42,7 +42,7 @@ "jest": "^27.0.6", "jest-styled-components": "^7.0.5", "next-page-tester": "^0.30.0", - "next-test-api-route-handler": "^2.0.2", + "next-test-api-route-handler": "^2.3.4", "node-fetch": "^2.6.1", "react-test-renderer": "^17.0.2", "standard-version": "^9.3.1" diff --git a/app/pages/view/[gallery]/albums.jsx b/app/pages/[gallery].jsx similarity index 85% rename from app/pages/view/[gallery]/albums.jsx rename to app/pages/[gallery].jsx index a2f0b967f..860d4d4d5 100644 --- a/app/pages/view/[gallery]/albums.jsx +++ b/app/pages/[gallery].jsx @@ -1,10 +1,10 @@ import Head from 'next/head' import styled, { css } from 'styled-components' -import { get as getAlbums } from '../../../src/lib/albums' -import { get as getGalleries } from '../../../src/lib/galleries' +import { get as getAlbums } from '../src/lib/albums' +import { get as getGalleries } from '../src/lib/galleries' -import Link from '../../../src/components/Link' +import Link from '../src/components/Link' export async function getStaticProps({ params: { gallery } }) { const { IMAGE_BASE_URL = '/' } = process.env @@ -60,7 +60,7 @@ const AlbumsPage = ({ gallery, albums }) => { key={album.name} odd={i % 2 === 0} > - {album.name} + {album.name} {album.h1} {album.h2} {album.year} diff --git a/app/pages/view/[gallery]/[album].jsx b/app/pages/[gallery]/[album].jsx similarity index 88% rename from app/pages/view/[gallery]/[album].jsx rename to app/pages/[gallery]/[album].jsx index 5734c4c59..c061b1e6b 100644 --- a/app/pages/view/[gallery]/[album].jsx +++ b/app/pages/[gallery]/[album].jsx @@ -1,8 +1,8 @@ import Head from 'next/head' -import { get as getAlbum } from '../../../src/lib/album' -import { get as getAlbums } from '../../../src/lib/albums' -import { get as getGalleries } from '../../../src/lib/galleries' +import { get as getAlbum } from '../../src/lib/album' +import { get as getAlbums } from '../../src/lib/albums' +import { get as getGalleries } from '../../src/lib/galleries' async function buildStaticPaths() { const { galleries } = await getGalleries() diff --git a/app/pages/view/[gallery]/all.jsx b/app/pages/[gallery]/all.jsx similarity index 87% rename from app/pages/view/[gallery]/all.jsx rename to app/pages/[gallery]/all.jsx index 077656013..cca366334 100644 --- a/app/pages/view/[gallery]/all.jsx +++ b/app/pages/[gallery]/all.jsx @@ -2,11 +2,11 @@ import Head from 'next/head' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' -import { get as getAlbum } from '../../../src/lib/album' -import { get as getAlbums } from '../../../src/lib/albums' -import { get as getGalleries } from '../../../src/lib/galleries' +import { get as getAlbum } from '../../src/lib/album' +import { get as getAlbums } from '../../src/lib/albums' +import { get as getGalleries } from '../../src/lib/galleries' -import Link from '../../../src/components/Link' +import Link from '../../src/components/Link' async function buildStaticPaths() { const { galleries } = await getGalleries() @@ -60,7 +60,6 @@ const AllPage = ({ items = [] }) => { return null } return null - /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [keyword]) if (!router.isReady) { @@ -91,7 +90,7 @@ const AllPage = ({ items = [] }) => { {item.album} {item.content} {checkKeyword(keyword) ? {item.caption} : item.caption} - {item.caption} + {item.caption} ))} diff --git a/app/pages/index.jsx b/app/pages/index.jsx index e68e41158..be347a2c7 100644 --- a/app/pages/index.jsx +++ b/app/pages/index.jsx @@ -18,8 +18,8 @@ export async function getStaticProps() { const ListComponent = ({ item }) => ( - {item.gallery} - Search album + {item.gallery} + Search album )} /> diff --git a/app/pages/view/galleries.jsx b/app/pages/view/galleries.jsx deleted file mode 100644 index 3d596e9b7..000000000 --- a/app/pages/view/galleries.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import Head from 'next/head' - -import { get as getGalleries } from '../../src/lib/galleries' -import GenericList from '../../src/components/GenericList' -import ListItem from '../../src/components/ListItem' -import Link from '../../src/components/Link' - -export async function getStaticProps() { - const { galleries } = await getGalleries() - - return { - props: { - galleries: galleries.map((gallery) => ({ id: gallery, gallery })), - }, - } -} - -const ListComponent = ({ item }) => ( - {item.gallery}} /> -) - -const Home = ({ galleries }) => ( -
- - History App - List Galleries - - - -
-

List of Galleries

- -
-
-) - -export default Home diff --git a/app/src/lib/__tests__/album.test.js b/app/src/lib/__tests__/album.test.js index aa6fb3c22..3b6054bee 100644 --- a/app/src/lib/__tests__/album.test.js +++ b/app/src/lib/__tests__/album.test.js @@ -5,13 +5,13 @@ describe('Album library', () => { describe('getVideoPath', () => { test('Just filename', () => { const item = { filename: '2016-12-31-01.mp4' } - const expectedPath = `/view/video?sources=${item.filename}&w=&h=&gallery=${gallery}` + const expectedPath = `/video?sources=${item.filename}&w=&h=&gallery=${gallery}` expect(lib.getVideoPath(item, gallery)).toBe(expectedPath) }) test('All', () => { const item = { filename: '2016-12-31-01.mp4', size: { w: 1, h: 2 } } - const expectedPath = `/view/video?sources=${item.filename}&w=${item.size.w}&h=${item.size.h}&gallery=${gallery}` + const expectedPath = `/video?sources=${item.filename}&w=${item.size.w}&h=${item.size.h}&gallery=${gallery}` expect(lib.getVideoPath(item, gallery)).toBe(expectedPath) }) }) @@ -80,7 +80,7 @@ describe('Album library', () => { expect(result.album.items[1].caption).toEqual('Video: Caption') // Video Thumb Caption expect(result.album.items[1].photoPath).toEqual('/galleries/demo/media/photos/2016/2016-Video-Filename.jpg') // Photo Path expect(result.album.items[1].mediaPath) - .toEqual('/view/video?sources=2016-Video-Filename.mov,2016-Video-Filename.avi&w=1280&h=720&gallery=demo') // Video Path + .toEqual('/video?sources=2016-Video-Filename.mov,2016-Video-Filename.avi&w=1280&h=720&gallery=demo') // Video Path expect(result.album.items[1].reference).toEqual('https://en.wikipedia.org/wiki/Purshia_tridentata') // Wikipedia reference }) }) diff --git a/app/src/lib/album.js b/app/src/lib/album.js index 2eca2bbc7..c34d799af 100644 --- a/app/src/lib/album.js +++ b/app/src/lib/album.js @@ -34,7 +34,7 @@ const getVideoPath = (item, gallery) => { const filename = (typeof item.filename === 'string') ? item.filename : item.filename.join(',') const dimensions = (item.size) ? { width: item.size.w, height: item.size.h } : { width: '', height: '' } - return `/view/video?sources=${filename}&w=${dimensions.width}&h=${dimensions.height}&gallery=${gallery}` + return `/video?sources=${filename}&w=${dimensions.width}&h=${dimensions.height}&gallery=${gallery}` } function title(item) { diff --git a/ui/app/containers/GalleryListItem/index.jsx b/ui/app/containers/GalleryListItem/index.jsx index 5e59e99c8..358c97465 100644 --- a/ui/app/containers/GalleryListItem/index.jsx +++ b/ui/app/containers/GalleryListItem/index.jsx @@ -8,7 +8,7 @@ import { hostCase } from '../../utils/host'; function GalleriesItem({ item: { name: gallery, host, id } }) { const content = [ - + {capitalize(gallery)} , `(${hostCase(host)})`,