Skip to content

Commit

Permalink
fix(#352) other layout changes + improved search
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdc committed Jul 23, 2022
1 parent fa219e4 commit 057d123
Show file tree
Hide file tree
Showing 12 changed files with 663 additions and 93 deletions.
2 changes: 1 addition & 1 deletion libs/db/gall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export const searchGalls = (q: string): TaskEither<Error, GallApi[]> => getGalls
export const gallByName = (name: string): TaskEither<Error, GallApi[]> => getGalls([{ species: { name: name } }]);

export const randomGall = (): TaskEither<Error, RandomGall[]> => {
// It is possible that this is naive and sacnning the entire table to get one random row will eventually create
// It is possible that this is naive and scanning the entire table to get one random row will eventually create
// perf issues. We shall see...
const gall = (): Promise<GallRet[]> =>
db.$queryRaw`
Expand Down
3 changes: 2 additions & 1 deletion libs/db/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export type GlobalSearchResults = {
};

export const globalSearch = (search: string): TE.TaskEither<Error, GlobalSearchResults> => {
const q = `%${search}%`;
// const q = `%${search}%`;
const q = `${search.replaceAll(' ', '%')}`;

const speciesSearch = () =>
db.species.findMany({
Expand Down
6 changes: 1 addition & 5 deletions pages/api/filterfield/[fieldType]/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export default async (req: NextApiRequest, res: NextApiResponse): Promise<void>

return await pipe(
query,
// eslint-disable-next-line prettier/prettier
E.map((q) => pipe(
deleteFilterField(asFilterFieldType(q.fieldType), q.id),
TE.mapLeft(toErr),
)),
E.map((q) => pipe(deleteFilterField(asFilterFieldType(q.fieldType), q.id), TE.mapLeft(toErr))),
TE.fromEither,
TE.flatten,
TE.fold(sendErrResponse(res), sendSuccResponse(res)),
Expand Down
2 changes: 1 addition & 1 deletion pages/globalsearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Props = {
const imageForType = (i: SearchResultItem) => {
switch (i.type) {
case 'gall':
return <Image src="/images/gall.svg" alt="gallformer" aria-label="gallformer" width="25px" height="25px" />;
return <Image src="/images/cynipid_R.svg" alt="gallformer" aria-label="gallformer" width="45px" height="45px" />;
case 'plant':
return <Image src="/images/host.svg" alt="plant" aria-label="plant" width="25px" height="25px" />;
case 'entry':
Expand Down
141 changes: 59 additions & 82 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetServerSideProps } from 'next';
import Head from 'next/head';
import Image from 'next/image';
import Link from 'next/link';
import React from 'react';
import { Card, Col, Container, Row } from 'react-bootstrap';
Expand All @@ -17,40 +18,75 @@ function Home({ randomGall }: Props): JSX.Element {
<Head>
<meta name="description" content="The place to ID and learn about galls on plants in the US and Canada." />
</Head>
<Container className="text-center p-5 ">
<Row>
<Col>
<Container className="">
<Row className="d-flex pb-0">
<Col xs={3} className="text-end p-0 m-0">
<Image src="/images/cynipid_L.svg" width="100" height="100" />
</Col>
<Col xs={6} className="text-center p-0 m-0">
<h1>Welcome to Gallformers</h1>
<div>The place to identify and learn about galls on plants in the US and Canada.</div>
</Col>
<Col xs={3} className="text-start p-0 m-0">
<Image src="/images/cynipid_R.svg" width="100" height="100" />
</Col>
</Row>
<Row>
<Col>The place to identify and learn about galls on plants in the US and Canada.</Col>
</Row>
</Container>
<Container>
<Row className="text-center pb-3"></Row>
<Row>
<Col>
<Card>
<Card.Header>
<Link href="/id">
<a style={{ textDecoration: 'none' }}>
<h2>Identify a Gall &rarr;</h2>
</a>
</Link>
<h2>Things To Do</h2>
</Card.Header>
<Card.Body>Try and get an Identity for a gall by providing known information.</Card.Body>
<Card.Body>
<Row>
<Col>
<Link href="/id">
<a style={{ textDecoration: 'none' }}>
<h3>Identify a Gall &rarr;</h3>
</a>
</Link>
</Col>
<Col>
<Link href="/explore">
<a style={{ textDecoration: 'none' }}>
<h3>Explore &rarr;</h3>
</a>
</Link>
</Col>
</Row>
<Row>
<Col>
<Link href="/resources">
<a style={{ textDecoration: 'none' }}>
<h3>Resources &rarr;</h3>
</a>
</Link>
</Col>
<Col>
<Link href="/glossary">
<a style={{ textDecoration: 'none' }}>
<h3>Glossary &rarr;</h3>
</a>
</Link>
</Col>
</Row>
</Card.Body>
</Card>
</Col>
<Col>
<Card>
<Card.Header>
<Link href="/explore">
<a style={{ textDecoration: 'none' }}>
<h2>Explore &rarr;</h2>
</a>
</Link>
<h2>What the heck is a gall?!</h2>
</Card.Header>
<Card.Body>Explore Galls (including Undescribed species) and Host Plants.</Card.Body>
<Card.Body>
Plant galls are abnormal growths of plant tissues, similar to tumors or warts in animals, that
have an external cause--such as an insect, mite, nematode, virus, fungus, bacterium, or even
another plant species. Growths caused by genetic mutations are not galls. Nor are lerps and other
constructions on a plant that do not contain plant tissue. Plant galls are often complex
structures that allow the insect or mite that caused the gall to be identified even if that insect
or mite is not visible.
</Card.Body>
</Card>
</Col>
</Row>
Expand Down Expand Up @@ -90,7 +126,9 @@ function Home({ randomGall }: Props): JSX.Element {
<Col>
<Card>
<Card.Body>
<Card.Title>Help Us Out</Card.Title>
<Card.Title>
<h2>Help Us Out</h2>
</Card.Title>
If you find gallformers.org useful and you are interested in helping us out there are a
few ways you can do so:
<ul>
Expand All @@ -114,67 +152,6 @@ function Home({ randomGall }: Props): JSX.Element {
</Card>
</Col>
</Row>
<Row className="pb-4">
<Col>
<Card>
<Card.Body>
<Card.Title>Resources</Card.Title>
<ul>
<li>
<Link href="/ref/IDGuide">Our guide to gall identification.</Link>
</li>
<li>
<Link href="/filterguide">Detailed descriptions for our key filters.</Link>
</li>
<li>
<Link href="/glossary">Glossary for plant and insect terms.</Link>
</li>
<li>
To ID galls and other plant symptoms in Europe, visit{' '}
<a href="https://bladmineerders.nl/" target="_blank" rel="noreferrer">
bladmineerders.nl
</a>
</li>
</ul>
</Card.Body>
</Card>
</Col>
</Row>
<Row>
<Col>
<Card>
<Card.Body>
<Card.Title>Interesting Reading</Card.Title>
<ul>
<li>
If you are new to galls <a href="http://charleyeiseman.com/">Charley Eiseman</a>{' '}
and Noah Charney&apos;s{' '}
<a href="https://bookshop.org/books/tracks-sign-of-insects-other-invertebrates-a-guide-to-north-american-species/9780811736244">
Tracks & Signs of Insects & Other Invertebrates: A Guide to North American
Species
</a>{' '}
is a good place to start learning. It covers a lot more than just galls and is an
excellent resource.
</li>
<li>
A long-anticipated update to{' '}
<a href="https://press.princeton.edu/books/paperback/9780691205762/plant-galls-of-the-western-united-states">
Russo&apos;s guide to galls of the Western US
</a>{' '}
was recently released by Princeton University Press.
</li>
<li>
Some{' '}
<a href="https://www.inaturalist.org/posts/47564-tips-for-gall-hunting">
advice on finding galls
</a>
.
</li>
</ul>
</Card.Body>
</Card>
</Col>
</Row>
</Col>
</Row>
</Container>
Expand Down
75 changes: 75 additions & 0 deletions pages/resources/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Head from 'next/head';
import Link from 'next/link';
import { Container, Col, Row } from 'react-bootstrap';

function Resources(): JSX.Element {
return (
<Container className="p-3 m-3">
<Head>
<meta name="description" content="Resources about plant galls" />
</Head>
<Row>
<Col>
<h1>General Resources</h1>
<ul>
<li>
<Link href="/ref/IDGuide">Our guide to gall identification</Link>
</li>
<li>
<Link href="/filterguide">Detailed descriptions for our key filters</Link>
</li>
<li>
<Link href="/glossary">Glossary for plant and insect terms</Link>
</li>
<li>
<Link href="/refindex">Our reference library</Link>
</li>
<li>
<a href="https://www.inaturalist.org/posts/47564-tips-for-gall-hunting">Advice on finding galls</a>
</li>
<li>
<a href="https://www.inaturalist.org/journal/jeffdc/67593-getting-an-oak-identified">
Documenting Trees (Oak focused) for identification
</a>
</li>
</ul>
</Col>
</Row>
<Row>
<Col>
<h1>Books</h1>
<ul>
<li>
If you are new to galls <a href="http://charleyeiseman.com/">Charley Eiseman</a> and Noah
Charney&apos;s{' '}
<a href="https://bookshop.org/books/tracks-sign-of-insects-other-invertebrates-a-guide-to-north-american-species/9780811736244">
Tracks & Signs of Insects & Other Invertebrates: A Guide to North American Species
</a>{' '}
is a good place to start learning. It covers a lot more than just galls and is an excellent resource.
</li>
<li>
<a href="https://press.princeton.edu/books/paperback/9780691205762/plant-galls-of-the-western-united-states">
Russo&apos;s guide to galls of the Western US
</a>
</li>
</ul>
</Col>
</Row>
<Row>
<Col>
<h1>Non North American Resources</h1>
<ul>
<li>
To ID galls and other plant symptoms in Europe, visit{' '}
<a href="https://bladmineerders.nl/" target="_blank" rel="noreferrer">
bladmineerders.nl
</a>
</li>
</ul>
</Col>
</Row>
</Container>
);
}

export default Resources;
6 changes: 3 additions & 3 deletions pages/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ a:hover {
}

.logotext {
font-family: Futura, Helvetiva, Arial, sans-serif;
font-family: Futura, Helvetica, Arial, sans-serif;
color: white;
}

.darklogotext {
font-family: Futura, Helvetiva, Arial, sans-serif;
font-family: Futura, Helvetica, Arial, sans-serif;
color: $logo-blue;
}

.navbar-custom {
background-color: $logo-blue;
font-family: Futura, Helvetiva, Arial, sans-serif;
font-family: Futura, Helvetica, Arial, sans-serif;
}

.navbar-custom .navbar-brand,
Expand Down
Binary file modified prisma/gallformers.sqlite
Binary file not shown.
Loading

0 comments on commit 057d123

Please sign in to comment.