From 6fd3a94fac5fb8ba036990e609d5fc9cdc6ee633 Mon Sep 17 00:00:00 2001
From: Team 1280 Programming Laptop
<59985235+Team1280Programming@users.noreply.github.com>
Date: Wed, 14 Feb 2024 18:11:07 -0800
Subject: [PATCH] Enable BibTeX export
---
src/app/db/loaders.ts | 6 +--
.../document/view/[slug]/DocumentViewer.tsx | 10 ++++-
.../document/view/[slug]/VersionChooser.tsx | 42 ++++++++++++++++++-
src/app/utils/epoch2datestring.ts | 4 ++
4 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/src/app/db/loaders.ts b/src/app/db/loaders.ts
index 2af5727..7f5ecea 100644
--- a/src/app/db/loaders.ts
+++ b/src/app/db/loaders.ts
@@ -83,11 +83,7 @@ export const loadAllAuthors = (): Promise<{ [key: string]: Author }> => {
worker.postMessage('LOAD')
} else {
- reject(
- new Error(
- 'Web Workers are not supported in this environment. Please avoid using a prehistoric browser.'
- )
- )
+ return
}
})
}
diff --git a/src/app/document/view/[slug]/DocumentViewer.tsx b/src/app/document/view/[slug]/DocumentViewer.tsx
index 0532e37..6066257 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 { notFound } from 'next/navigation'
import VersionChooser from './VersionChooser'
+import crypto from 'crypto'
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
@@ -32,6 +33,13 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
status,
} = manifest
+ // git style hash
+ const hash = crypto
+ .createHash('sha256')
+ .update(slug)
+ .digest('hex')
+ .substring(0, 7)
+
return (
) => {
Cite as:
- {citation ? <>{citation}> : <>eeXiv:{slug}>}
+ {citation ? <>{citation}> : <>eeXiv:{hash}>}
diff --git a/src/app/document/view/[slug]/VersionChooser.tsx b/src/app/document/view/[slug]/VersionChooser.tsx
index ef2b62e..9172621 100644
--- a/src/app/document/view/[slug]/VersionChooser.tsx
+++ b/src/app/document/view/[slug]/VersionChooser.tsx
@@ -2,13 +2,28 @@
import { useState } from 'react'
import { Document } from '@/app/db/data'
import Link from 'next/link'
+import { loadAllAuthors } from '@/app/db/loaders'
+import { useSuspenseQuery } from '@tanstack/react-query'
+import { epoch2date } from '@/app/utils/epoch2datestring'
const VersionChooser = ({
doc,
slug,
}: Readonly<{ doc: Document; slug: string }>) => {
+ const { data, error } = useSuspenseQuery({
+ queryKey: ['authors_all'],
+ queryFn: () => {
+ const data = loadAllAuthors()
+ return data
+ },
+ })
+ if (error) throw error
+
+ let authorList = data
+
const { file } = doc
- const { latest } = doc.manifest
+ const { authors, latest } = doc.manifest
+ const date = epoch2date(doc.manifest.dates[doc.manifest.dates.length - 1])
const fileEnding = file === 'other' ? '' : `.${file}`
const [selectedRevision, setSelectedRevision] = useState(latest) // Initialize the selected revision with the latest revision
@@ -31,8 +46,31 @@ const VersionChooser = ({
})()}
+