diff --git a/src/app/db/data.ts b/src/app/db/data.ts index 1f7f0e7..dc698c1 100644 --- a/src/app/db/data.ts +++ b/src/app/db/data.ts @@ -26,6 +26,7 @@ export interface Document { abstract: string file: FileType citation?: string + doi?: string } export interface DocumentManifest { 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. `, file: 'pdf', + doi: '10.5281/zenodo.10668656', }, } diff --git a/src/app/document/view/[slug]/DocumentViewer.tsx b/src/app/document/view/[slug]/DocumentViewer.tsx index b36c2ec..be9dd41 100644 --- a/src/app/document/view/[slug]/DocumentViewer.tsx +++ b/src/app/document/view/[slug]/DocumentViewer.tsx @@ -11,6 +11,7 @@ import { import { ItemBadge, Status } from '@/app/components/Badges' import VersionChooser from './VersionChooser' import crypto from 'crypto' +import generateHash from '@/app/utils/hash' import { Suspense } from 'react' import { loadDocument } from '@/app/db/loaders' import { useSuspenseQuery } from '@tanstack/react-query' @@ -28,7 +29,7 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => { if (error) throw error let doc = data - const { manifest, abstract, citation } = doc + const { manifest, abstract, citation, doi } = doc const { title, @@ -44,11 +45,7 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => { } = manifest // git style hash - const hash = crypto - .createHash('sha256') - .update(slug) - .digest('hex') - .substring(0, 7) + const hash = generateHash(slug) return (
@@ -98,6 +95,12 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => { Cite as: {citation ? <>{citation} : <>eeXiv:{hash}}

+ {doi && ( +

+ DOI: + {doi} +

+)} diff --git a/src/app/page.tsx b/src/app/page.tsx index 6cc27b7..5d66c6d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -74,10 +74,7 @@ export default function Home() { the fields of physics, mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and systems science, and economics, but mainly related to the{' '} - + FIRST Robotics Competition (FRC) . Materials on this site may be published independently through other diff --git a/src/app/utils/hash.ts b/src/app/utils/hash.ts new file mode 100644 index 0000000..06c992b --- /dev/null +++ b/src/app/utils/hash.ts @@ -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) +} diff --git a/src/app/utils/search.worker.ts b/src/app/utils/search.worker.ts index 0beeb70..58cb602 100644 --- a/src/app/utils/search.worker.ts +++ b/src/app/utils/search.worker.ts @@ -1,6 +1,8 @@ import { documents, authors, affiliations, topics } from '@/app/db/data' import MiniSearch from 'minisearch' 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 const docs = Object.entries(documents).map(([key, value]) => ({ @@ -34,6 +36,8 @@ const docs = Object.entries(documents).map(([key, value]) => ({ ) .join(' '), key: key, + citation: value.citation ? value.citation : hash(key), + doi: value.doi ? value.doi : undefined, })) const miniSearch = new MiniSearch({ @@ -45,6 +49,8 @@ const miniSearch = new MiniSearch({ 'title', 'type', 'affiliations', + 'citation', + 'doi', ], storeFields: ['key', 'abstract', 'manifest'], searchOptions: {