diff --git a/components/CollectionCard.tsx b/components/CollectionCard.tsx index 086f742..da634cc 100644 --- a/components/CollectionCard.tsx +++ b/components/CollectionCard.tsx @@ -39,7 +39,7 @@ export default function CollectionCard({ collection, className }: Props) { username: "", image: "", archiveAsScreenshot: undefined as unknown as boolean, - archiveAsSinglefile: undefined as unknown as boolean, + archiveAsMonolith: undefined as unknown as boolean, archiveAsPDF: undefined as unknown as boolean, }); @@ -55,7 +55,7 @@ export default function CollectionCard({ collection, className }: Props) { username: account.username as string, image: account.image as string, archiveAsScreenshot: account.archiveAsScreenshot as boolean, - archiveAsSinglefile: account.archiveAsSinglefile as boolean, + archiveAsMonolith: account.archiveAsMonolith as boolean, archiveAsPDF: account.archiveAsPDF as boolean, }); } diff --git a/components/LinkViews/LinkComponents/LinkIcon.tsx b/components/LinkViews/LinkComponents/LinkIcon.tsx index e38e8d1..e60c23a 100644 --- a/components/LinkViews/LinkComponents/LinkIcon.tsx +++ b/components/LinkViews/LinkComponents/LinkIcon.tsx @@ -70,9 +70,14 @@ export default function LinkIcon({ size={size} icon="bi-file-earmark-image" /> - ) : link.type === "singlefile" ? ( - - ) : undefined} + ) : // : link.type === "monolith" ? ( + // + // ) + undefined} ); } diff --git a/components/ModalContent/EditCollectionSharingModal.tsx b/components/ModalContent/EditCollectionSharingModal.tsx index b5eea1b..9a9f5fa 100644 --- a/components/ModalContent/EditCollectionSharingModal.tsx +++ b/components/ModalContent/EditCollectionSharingModal.tsx @@ -68,7 +68,7 @@ export default function EditCollectionSharingModal({ username: "", image: "", archiveAsScreenshot: undefined as unknown as boolean, - archiveAsSinglefile: undefined as unknown as boolean, + archiveAsMonolith: undefined as unknown as boolean, archiveAsPDF: undefined as unknown as boolean, }); diff --git a/components/ModalContent/NewLinkModal.tsx b/components/ModalContent/NewLinkModal.tsx index 5506756..0284687 100644 --- a/components/ModalContent/NewLinkModal.tsx +++ b/components/ModalContent/NewLinkModal.tsx @@ -30,7 +30,7 @@ export default function NewLinkModal({ onClose }: Props) { image: "", pdf: "", readable: "", - singlefile: "", + monolith: "", textContent: "", collection: { name: "", diff --git a/components/ModalContent/PreservedFormatsModal.tsx b/components/ModalContent/PreservedFormatsModal.tsx index 17468e7..87e84a7 100644 --- a/components/ModalContent/PreservedFormatsModal.tsx +++ b/components/ModalContent/PreservedFormatsModal.tsx @@ -12,7 +12,7 @@ import { useSession } from "next-auth/react"; import { pdfAvailable, readabilityAvailable, - singlefileAvailable, + monolithAvailable, screenshotAvailable, } from "@/lib/shared/getArchiveValidity"; import PreservedFormatRow from "@/components/PreserverdFormatRow"; @@ -43,7 +43,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { username: "", image: "", archiveAsScreenshot: undefined as unknown as boolean, - archiveAsSinglefile: undefined as unknown as boolean, + archiveAsMonolith: undefined as unknown as boolean, archiveAsPDF: undefined as unknown as boolean, }); @@ -61,7 +61,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { username: account.username as string, image: account.image as string, archiveAsScreenshot: account.archiveAsScreenshot as boolean, - archiveAsSinglefile: account.archiveAsScreenshot as boolean, + archiveAsMonolith: account.archiveAsScreenshot as boolean, archiveAsPDF: account.archiveAsPDF as boolean, }); } @@ -76,8 +76,8 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { (collectionOwner.archiveAsScreenshot === true ? link.pdf && link.pdf !== "pending" : true) && - (collectionOwner.archiveAsSinglefile === true - ? link.singlefile && link.singlefile !== "pending" + (collectionOwner.archiveAsMonolith === true + ? link.monolith && link.monolith !== "pending" : true) && (collectionOwner.archiveAsPDF === true ? link.pdf && link.pdf !== "pending" @@ -92,7 +92,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { screenshotAvailable(link) || pdfAvailable(link) || readabilityAvailable(link) || - singlefileAvailable(link) + monolithAvailable(link) ); }; @@ -124,7 +124,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { clearInterval(interval); } }; - }, [link?.singlefile]); + }, [link?.monolith]); const updateArchive = async () => { const load = toast.loading(t("sending_request")); @@ -152,18 +152,18 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) { {screenshotAvailable(link) || pdfAvailable(link) || readabilityAvailable(link) || - singlefileAvailable(link) ? ( + monolithAvailable(link) ? (

{t("available_formats")}

) : ( "" )}
- {singlefileAvailable(link) ? ( + {monolithAvailable(link) ? ( diff --git a/components/ModalContent/UploadFileModal.tsx b/components/ModalContent/UploadFileModal.tsx index ad4743f..2480431 100644 --- a/components/ModalContent/UploadFileModal.tsx +++ b/components/ModalContent/UploadFileModal.tsx @@ -33,7 +33,7 @@ export default function UploadFileModal({ onClose }: Props) { image: "", pdf: "", readable: "", - singlefile: "", + monolith: "", textContent: "", collection: { name: "", @@ -97,7 +97,7 @@ export default function UploadFileModal({ onClose }: Props) { const submit = async () => { if (!submitLoader && file) { let fileType: ArchivedFormat | null = null; - let linkType: "url" | "image" | "singlefile" | "pdf" | null = null; + let linkType: "url" | "image" | "monolith" | "pdf" | null = null; if (file?.type === "image/jpg" || file.type === "image/jpeg") { fileType = ArchivedFormat.jpeg; @@ -105,13 +105,14 @@ export default function UploadFileModal({ onClose }: Props) { } else if (file.type === "image/png") { fileType = ArchivedFormat.png; linkType = "image"; - } else if (file.type === "text/html") { - fileType = ArchivedFormat.singlefile; - linkType = "singlefile"; } else if (file.type === "application/pdf") { fileType = ArchivedFormat.pdf; linkType = "pdf"; } + // else if (file.type === "text/html") { + // fileType = ArchivedFormat.monolith; + // linkType = "monolith"; + // } setSubmitLoader(true); const load = toast.loading(t("creating")); diff --git a/components/PreserverdFormatRow.tsx b/components/PreserverdFormatRow.tsx index 0ec0b1b..ce0f21d 100644 --- a/components/PreserverdFormatRow.tsx +++ b/components/PreserverdFormatRow.tsx @@ -61,7 +61,7 @@ export default function PreservedFormatRow({ clearInterval(interval); } }; - }, [link?.image, link?.pdf, link?.readable, link?.singlefile]); + }, [link?.image, link?.pdf, link?.readable, link?.monolith]); const handleDownload = () => { const path = `/api/v1/archives/${link?.id}?format=${format}`; @@ -72,7 +72,7 @@ export default function PreservedFormatRow({ const anchorElement = document.createElement("a"); anchorElement.href = path; anchorElement.download = - format === ArchivedFormat.singlefile + format === ArchivedFormat.monolith ? "Webpage" : format === ArchivedFormat.pdf ? "PDF" diff --git a/components/ReadableView.tsx b/components/ReadableView.tsx index 8c5e0ac..b600236 100644 --- a/components/ReadableView.tsx +++ b/components/ReadableView.tsx @@ -81,11 +81,11 @@ export default function ReadableView({ link }: Props) { (link?.image === "pending" || link?.pdf === "pending" || link?.readable === "pending" || - link?.singlefile === "pending" || + link?.monolith === "pending" || !link?.image || !link?.pdf || !link?.readable || - !link?.singlefile) + !link?.monolith) ) { interval = setInterval(() => getLink(link.id as number), 5000); } else { @@ -99,7 +99,7 @@ export default function ReadableView({ link }: Props) { clearInterval(interval); } }; - }, [link?.image, link?.pdf, link?.readable, link?.singlefile]); + }, [link?.image, link?.pdf, link?.readable, link?.monolith]); const rgbToHex = (r: number, g: number, b: number): string => "#" + diff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.ts index 99729cf..49b9f77 100644 --- a/lib/api/archiveHandler.ts +++ b/lib/api/archiveHandler.ts @@ -102,7 +102,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) { readable: !link.readable?.startsWith("archive") ? "pending" : undefined, - singlefile: !link.singlefile?.startsWith("archive") + monolith: !link.monolith?.startsWith("archive") ? "pending" : undefined, preview: !link.readable?.startsWith("archive") @@ -151,11 +151,11 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) { ) await handleScreenshotAndPdf(link, page, user); - // SingleFile + // Monolith if ( - !link.singlefile?.startsWith("archive") && - !link.singlefile?.startsWith("unavailable") && - user.archiveAsSinglefile && + !link.monolith?.startsWith("archive") && + !link.monolith?.startsWith("unavailable") && + user.archiveAsMonolith && link.url ) await handleMonolith(link, content); @@ -183,7 +183,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) { image: !finalLink.image?.startsWith("archives") ? "unavailable" : undefined, - singlefile: !finalLink.singlefile?.startsWith("archives") + monolith: !finalLink.monolith?.startsWith("archives") ? "unavailable" : undefined, pdf: !finalLink.pdf?.startsWith("archives") diff --git a/lib/api/controllers/public/users/getPublicUser.ts b/lib/api/controllers/public/users/getPublicUser.ts index 1816051..68b6fab 100644 --- a/lib/api/controllers/public/users/getPublicUser.ts +++ b/lib/api/controllers/public/users/getPublicUser.ts @@ -75,7 +75,7 @@ export default async function getPublicUser( username: lessSensitiveInfo.username, image: lessSensitiveInfo.image, archiveAsScreenshot: lessSensitiveInfo.archiveAsScreenshot, - archiveAsSinglefile: lessSensitiveInfo.archiveAsSinglefile, + archiveAsMonolith: lessSensitiveInfo.archiveAsMonolith, archiveAsPDF: lessSensitiveInfo.archiveAsPDF, }; diff --git a/lib/api/controllers/users/userId/updateUserById.ts b/lib/api/controllers/users/userId/updateUserById.ts index fe55b05..ebae737 100644 --- a/lib/api/controllers/users/userId/updateUserById.ts +++ b/lib/api/controllers/users/userId/updateUserById.ts @@ -207,7 +207,7 @@ export default async function updateUserById( ), locale: i18n.locales.includes(data.locale) ? data.locale : "en", archiveAsScreenshot: data.archiveAsScreenshot, - archiveAsSinglefile: data.archiveAsSinglefile, + archiveAsMonolith: data.archiveAsMonolith, archiveAsPDF: data.archiveAsPDF, archiveAsWaybackMachine: data.archiveAsWaybackMachine, linksRouteTo: data.linksRouteTo, diff --git a/lib/api/preservationScheme/handleMonolith.ts b/lib/api/preservationScheme/handleMonolith.ts index 111b937..52ff91d 100644 --- a/lib/api/preservationScheme/handleMonolith.ts +++ b/lib/api/preservationScheme/handleMonolith.ts @@ -19,7 +19,7 @@ const handleMonolith = async (link: Link, content: string) => { ); if (!html?.length) { - console.error("Error running SINGLEFILE_ARCHIVE_COMMAND: Empty buffer"); + console.error("Error running MONOLITH: Empty buffer"); return; } @@ -30,12 +30,12 @@ const handleMonolith = async (link: Link, content: string) => { await prisma.link.update({ where: { id: link.id }, data: { - singlefile: `archives/${link.collectionId}/${link.id}.html`, + monolith: `archives/${link.collectionId}/${link.id}.html`, }, }); }); } catch (err) { - console.error("Error running SINGLEFILE_ARCHIVE_COMMAND:", err); + console.error("Error running MONOLITH:", err); } }; diff --git a/lib/client/generateLinkHref.ts b/lib/client/generateLinkHref.ts index dd1c398..721c671 100644 --- a/lib/client/generateLinkHref.ts +++ b/lib/client/generateLinkHref.ts @@ -8,7 +8,7 @@ import { pdfAvailable, readabilityAvailable, screenshotAvailable, - singlefileAvailable, + monolithAvailable, } from "../shared/getArchiveValidity"; export const generateLinkHref = ( @@ -39,10 +39,10 @@ export const generateLinkHref = ( return `/preserved/${link?.id}?format=${ link?.image?.endsWith("png") ? ArchivedFormat.png : ArchivedFormat.jpeg }`; - } else if (account.linksRouteTo === LinksRouteTo.SINGLEFILE) { - if (!singlefileAvailable(link)) return link.url || ""; + } else if (account.linksRouteTo === LinksRouteTo.MONOLITH) { + if (!monolithAvailable(link)) return link.url || ""; - return `/preserved/${link?.id}?format=${ArchivedFormat.singlefile}`; + return `/preserved/${link?.id}?format=${ArchivedFormat.monolith}`; } else { return link.url || ""; } diff --git a/lib/shared/getArchiveValidity.ts b/lib/shared/getArchiveValidity.ts index 9f19c35..8ec8c44 100644 --- a/lib/shared/getArchiveValidity.ts +++ b/lib/shared/getArchiveValidity.ts @@ -28,14 +28,14 @@ export function readabilityAvailable( ); } -export function singlefileAvailable( +export function monolithAvailable( link: LinkIncludingShortenedCollectionAndTags ) { return ( link && - link.singlefile && - link.singlefile !== "pending" && - link.singlefile !== "unavailable" + link.monolith && + link.monolith !== "pending" && + link.monolith !== "unavailable" ); } diff --git a/pages/api/v1/archives/[linkId].ts b/pages/api/v1/archives/[linkId].ts index 411b643..2a6fe50 100644 --- a/pages/api/v1/archives/[linkId].ts +++ b/pages/api/v1/archives/[linkId].ts @@ -29,7 +29,7 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) { else if (format === ArchivedFormat.jpeg) suffix = ".jpeg"; else if (format === ArchivedFormat.pdf) suffix = ".pdf"; else if (format === ArchivedFormat.readability) suffix = "_readability.json"; - else if (format === ArchivedFormat.singlefile) suffix = ".html"; + else if (format === ArchivedFormat.monolith) suffix = ".html"; //@ts-ignore if (!linkId || !suffix) diff --git a/pages/api/v1/links/[id]/archive/index.ts b/pages/api/v1/links/[id]/archive/index.ts index aa11625..ef91a4e 100644 --- a/pages/api/v1/links/[id]/archive/index.ts +++ b/pages/api/v1/links/[id]/archive/index.ts @@ -76,7 +76,7 @@ const deleteArchivedFiles = async (link: Link & { collection: Collection }) => { image: null, pdf: null, readable: null, - singlefile: null, + monolith: null, preview: null, }, }); diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index 4804a7b..bdfbfe9 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -59,7 +59,7 @@ export default function Index() { username: "", image: "", archiveAsScreenshot: undefined as unknown as boolean, - archiveAsSinglefile: undefined as unknown as boolean, + archiveAsMonolith: undefined as unknown as boolean, archiveAsPDF: undefined as unknown as boolean, }); @@ -77,7 +77,7 @@ export default function Index() { username: account.username as string, image: account.image as string, archiveAsScreenshot: account.archiveAsScreenshot as boolean, - archiveAsSinglefile: account.archiveAsScreenshot as boolean, + archiveAsMonolith: account.archiveAsScreenshot as boolean, archiveAsPDF: account.archiveAsPDF as boolean, }); } diff --git a/pages/preserved/[id].tsx b/pages/preserved/[id].tsx index 65a8047..99fe033 100644 --- a/pages/preserved/[id].tsx +++ b/pages/preserved/[id].tsx @@ -37,9 +37,9 @@ export default function Index() { {link && Number(router.query.format) === ArchivedFormat.readability && ( )} - {link && Number(router.query.format) === ArchivedFormat.singlefile && ( + {link && Number(router.query.format) === ArchivedFormat.monolith && ( )} diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx index e3a40ad..47e074f 100644 --- a/pages/public/collections/[id].tsx +++ b/pages/public/collections/[id].tsx @@ -42,7 +42,7 @@ export default function PublicCollections() { username: "", image: "", archiveAsScreenshot: undefined as unknown as boolean, - archiveAsSinglefile: undefined as unknown as boolean, + archiveAsMonolith: undefined as unknown as boolean, archiveAsPDF: undefined as unknown as boolean, }); diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsx index 5502778..55c0167 100644 --- a/pages/settings/preference.tsx +++ b/pages/settings/preference.tsx @@ -26,8 +26,8 @@ export default function Appearance() { account.archiveAsPDF ); - const [archiveAsSinglefile, setArchiveAsSinglefile] = useState( - account.archiveAsSinglefile + const [archiveAsMonolith, setArchiveAsMonolith] = useState( + account.archiveAsMonolith ); const [archiveAsWaybackMachine, setArchiveAsWaybackMachine] = @@ -39,7 +39,7 @@ export default function Appearance() { setUser({ ...account, archiveAsScreenshot, - archiveAsSinglefile, + archiveAsMonolith, archiveAsPDF, archiveAsWaybackMachine, linksRouteTo, @@ -48,7 +48,7 @@ export default function Appearance() { }, [ account, archiveAsScreenshot, - archiveAsSinglefile, + archiveAsMonolith, archiveAsPDF, archiveAsWaybackMachine, linksRouteTo, @@ -62,7 +62,7 @@ export default function Appearance() { useEffect(() => { if (!objectIsEmpty(account)) { setArchiveAsScreenshot(account.archiveAsScreenshot); - setArchiveAsSinglefile(account.archiveAsSinglefile); + setArchiveAsMonolith(account.archiveAsMonolith); setArchiveAsPDF(account.archiveAsPDF); setArchiveAsWaybackMachine(account.archiveAsWaybackMachine); setLinksRouteTo(account.linksRouteTo); @@ -136,9 +136,9 @@ export default function Appearance() { /> setArchiveAsSinglefile(!archiveAsSinglefile)} + label={t("webpage")} + state={archiveAsMonolith} + onClick={() => setArchiveAsMonolith(!archiveAsMonolith)} /> setLinksRouteTo(LinksRouteTo.SINGLEFILE)} + value="Monolith" + checked={linksRouteTo === LinksRouteTo.MONOLITH} + onChange={() => setLinksRouteTo(LinksRouteTo.MONOLITH)} /> - Open Singlefile, if available - - -