Add new document properties and search options
This commit is contained in:
parent
7d49198552
commit
79f74d8731
5 changed files with 28 additions and 10 deletions
|
@ -26,6 +26,7 @@ export interface Document {
|
||||||
abstract: string
|
abstract: string
|
||||||
file: FileType
|
file: FileType
|
||||||
citation?: string
|
citation?: string
|
||||||
|
doi?: string
|
||||||
}
|
}
|
||||||
export interface DocumentManifest {
|
export interface DocumentManifest {
|
||||||
title: string
|
title: string
|
||||||
|
@ -282,6 +283,7 @@ On Day 1 we will discuss the ins and outs of the robot. The Electrical Sub team
|
||||||
},
|
},
|
||||||
abstract: `In this paper, we present eeXiv, an open-source, open-access project hosted by Team 1280 EECS ("Electrical Engineering and Computer Science"), independent of the department of the same name at UC Berkeley. We aim to rival arXiv as the single largest open-source and open-access research paper repository and as the largest research paper repository on the West Coast, transforming San Ramon Valley High School into a tier-1 research institution. Similar to arXiv, we host electronic preprints and postprints (known as e-prints) approved for posting after a rigorous peer review process. Our repository consists of scientific papers in the fields of mathematics, physics, astronomy, electrical engineering, computer science, quantitative biology, statistics, mathematical finance, and economics, with a focus on papers specific to the FIRST Robotics Competition. eeXiv bypasses the traditional bureaucracy of research publication, which involves lengthy peer review proesses and journal approval, by enabling "libre" and "open" publication, dissemination, and consumption of research artifacts. `,
|
abstract: `In this paper, we present eeXiv, an open-source, open-access project hosted by Team 1280 EECS ("Electrical Engineering and Computer Science"), independent of the department of the same name at UC Berkeley. We aim to rival arXiv as the single largest open-source and open-access research paper repository and as the largest research paper repository on the West Coast, transforming San Ramon Valley High School into a tier-1 research institution. Similar to arXiv, we host electronic preprints and postprints (known as e-prints) approved for posting after a rigorous peer review process. Our repository consists of scientific papers in the fields of mathematics, physics, astronomy, electrical engineering, computer science, quantitative biology, statistics, mathematical finance, and economics, with a focus on papers specific to the FIRST Robotics Competition. eeXiv bypasses the traditional bureaucracy of research publication, which involves lengthy peer review proesses and journal approval, by enabling "libre" and "open" publication, dissemination, and consumption of research artifacts. `,
|
||||||
file: 'pdf',
|
file: 'pdf',
|
||||||
|
doi: '10.5281/zenodo.10668656',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { ItemBadge, Status } from '@/app/components/Badges'
|
import { ItemBadge, Status } from '@/app/components/Badges'
|
||||||
import VersionChooser from './VersionChooser'
|
import VersionChooser from './VersionChooser'
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
|
import generateHash from '@/app/utils/hash'
|
||||||
import { Suspense } from 'react'
|
import { Suspense } from 'react'
|
||||||
import { loadDocument } from '@/app/db/loaders'
|
import { loadDocument } from '@/app/db/loaders'
|
||||||
import { useSuspenseQuery } from '@tanstack/react-query'
|
import { useSuspenseQuery } from '@tanstack/react-query'
|
||||||
|
@ -28,7 +29,7 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
let doc = data
|
let doc = data
|
||||||
|
|
||||||
const { manifest, abstract, citation } = doc
|
const { manifest, abstract, citation, doi } = doc
|
||||||
|
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
|
@ -44,11 +45,7 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
|
||||||
} = manifest
|
} = manifest
|
||||||
|
|
||||||
// git style hash
|
// git style hash
|
||||||
const hash = crypto
|
const hash = generateHash(slug)
|
||||||
.createHash('sha256')
|
|
||||||
.update(slug)
|
|
||||||
.digest('hex')
|
|
||||||
.substring(0, 7)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='max-w-4xl lg:max-w-6xl mx-auto'>
|
<div className='max-w-4xl lg:max-w-6xl mx-auto'>
|
||||||
|
@ -98,6 +95,12 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
|
||||||
<span className='font-bold'>Cite as: </span>
|
<span className='font-bold'>Cite as: </span>
|
||||||
{citation ? <>{citation}</> : <>eeXiv:{hash}</>}
|
{citation ? <>{citation}</> : <>eeXiv:{hash}</>}
|
||||||
</p>
|
</p>
|
||||||
|
{doi && (
|
||||||
|
<p className='my-2'>
|
||||||
|
<span className='font-bold'>DOI: </span>
|
||||||
|
{doi}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={
|
fallback={
|
||||||
<div className='max-w-sm animate-pulse flex flex-wrap gap-2'>
|
<div className='max-w-sm animate-pulse flex flex-wrap gap-2'>
|
||||||
|
|
|
@ -74,10 +74,7 @@ export default function Home() {
|
||||||
the fields of physics, mathematics, computer science, quantitative
|
the fields of physics, mathematics, computer science, quantitative
|
||||||
biology, quantitative finance, statistics, electrical engineering and
|
biology, quantitative finance, statistics, electrical engineering and
|
||||||
systems science, and economics, but mainly related to the{' '}
|
systems science, and economics, but mainly related to the{' '}
|
||||||
<Link
|
<Link href='./topic/frc' target='_blank'>
|
||||||
href='./topic/frc'
|
|
||||||
target='_blank'
|
|
||||||
>
|
|
||||||
FIRST Robotics Competition (FRC)
|
FIRST Robotics Competition (FRC)
|
||||||
</Link>
|
</Link>
|
||||||
. Materials on this site may be published independently through other
|
. Materials on this site may be published independently through other
|
||||||
|
|
10
src/app/utils/hash.ts
Normal file
10
src/app/utils/hash.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import crypto from 'crypto'
|
||||||
|
|
||||||
|
export default function hash(key: string) {
|
||||||
|
// git style hash
|
||||||
|
return crypto
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(key)
|
||||||
|
.digest('hex')
|
||||||
|
.substring(0, 7)
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
import { documents, authors, affiliations, topics } from '@/app/db/data'
|
import { documents, authors, affiliations, topics } from '@/app/db/data'
|
||||||
import MiniSearch from 'minisearch'
|
import MiniSearch from 'minisearch'
|
||||||
import { CustomSearchResult } from './searchDocs'
|
import { CustomSearchResult } from './searchDocs'
|
||||||
|
import crypto from 'crypto'
|
||||||
|
import hash from './hash'
|
||||||
|
|
||||||
// converting the documents object into an array that can be index by minisearch
|
// converting the documents object into an array that can be index by minisearch
|
||||||
const docs = Object.entries(documents).map(([key, value]) => ({
|
const docs = Object.entries(documents).map(([key, value]) => ({
|
||||||
|
@ -34,6 +36,8 @@ const docs = Object.entries(documents).map(([key, value]) => ({
|
||||||
)
|
)
|
||||||
.join(' '),
|
.join(' '),
|
||||||
key: key,
|
key: key,
|
||||||
|
citation: value.citation ? value.citation : hash(key),
|
||||||
|
doi: value.doi ? value.doi : undefined,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const miniSearch = new MiniSearch({
|
const miniSearch = new MiniSearch({
|
||||||
|
@ -45,6 +49,8 @@ const miniSearch = new MiniSearch({
|
||||||
'title',
|
'title',
|
||||||
'type',
|
'type',
|
||||||
'affiliations',
|
'affiliations',
|
||||||
|
'citation',
|
||||||
|
'doi',
|
||||||
],
|
],
|
||||||
storeFields: ['key', 'abstract', 'manifest'],
|
storeFields: ['key', 'abstract', 'manifest'],
|
||||||
searchOptions: {
|
searchOptions: {
|
||||||
|
|
Loading…
Reference in a new issue