diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx
index 62a6cfb..fc23253 100644
--- a/components/LinkCard.tsx
+++ b/components/LinkCard.tsx
@@ -26,7 +26,6 @@ import unescapeString from "@/lib/client/unescapeString";
import { useRouter } from "next/router";
import EditLinkModal from "./ModalContent/EditLinkModal";
import DeleteLinkModal from "./ModalContent/DeleteLinkModal";
-import ExpandedLink from "./ModalContent/ExpandedLink";
import PreservedFormatsModal from "./ModalContent/PreservedFormatsModal";
type Props = {
@@ -112,11 +111,10 @@ export default function LinkCard({ link, count, className }: Props) {
const [editLinkModal, setEditLinkModal] = useState(false);
const [deleteLinkModal, setDeleteLinkModal] = useState(false);
const [preservedFormatsModal, setPreservedFormatsModal] = useState(false);
- const [expandedLink, setExpandedLink] = useState(false);
return (
@@ -200,12 +198,8 @@ export default function LinkCard({ link, count, className }: Props) {
) : undefined}
- router.push("/links/" + link.id)
- // // setExpandedLink(true)
- // }
+ link.url && window.open(link.url || "", "_blank")}
className="flex flex-col justify-between cursor-pointer h-full w-full gap-1 p-3"
>
{link.url && url ? (
@@ -241,13 +235,7 @@ export default function LinkCard({ link, count, className }: Props) {
{link.url ? (
- {
- e.preventDefault();
- window.open(link.url || "", "_blank");
- }}
- className="flex items-center gap-1 max-w-full w-fit text-neutral hover:opacity-60 duration-100"
- >
+
@@ -257,7 +245,7 @@ export default function LinkCard({ link, count, className }: Props) {
{
- e.preventDefault();
+ e.stopPropagation();
router.push(`/collections/${link.collection.id}`);
}}
className="flex items-center gap-1 max-w-full w-fit hover:opacity-70 duration-100"
@@ -295,7 +283,7 @@ export default function LinkCard({ link, count, className }: Props) {
) : (
No Tags
)} */}
-
+
{editLinkModal ? (
setEditLinkModal(false)}
@@ -314,9 +302,6 @@ export default function LinkCard({ link, count, className }: Props) {
activeLink={link}
/>
) : undefined}
- {/* {expandedLink ? (
- setExpandedLink(false)} link={link} />
- ) : undefined} */}
);
}
diff --git a/components/Modal.tsx b/components/Modal.tsx
index c7f4da5..2ddf656 100644
--- a/components/Modal.tsx
+++ b/components/Modal.tsx
@@ -21,7 +21,7 @@ export default function Modal({ toggleModal, className, children }: Props) {
}
- className="absolute top-3 right-3 btn btn-sm outline-none btn-circle btn-ghost"
+ className="absolute top-3 right-3 btn btn-sm outline-none btn-circle btn-ghost z-10"
>
diff --git a/components/ModalContent/ExpandedLink.tsx b/components/ModalContent/ExpandedLink.tsx
deleted file mode 100644
index 464d568..0000000
--- a/components/ModalContent/ExpandedLink.tsx
+++ /dev/null
@@ -1,254 +0,0 @@
-import {
- CollectionIncludingMembersAndLinkCount,
- LinkIncludingShortenedCollectionAndTags,
-} from "@/types/global";
-import Image from "next/image";
-import ColorThief, { RGBColor } from "colorthief";
-import { useEffect, useState } from "react";
-import Link from "next/link";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import {
- faArrowUpRightFromSquare,
- faBoxArchive,
- faCloudArrowDown,
- faFolder,
-} from "@fortawesome/free-solid-svg-icons";
-import useCollectionStore from "@/store/collections";
-import {
- faCalendarDays,
- faFileImage,
- faFilePdf,
-} from "@fortawesome/free-regular-svg-icons";
-import isValidUrl from "@/lib/shared/isValidUrl";
-import unescapeString from "@/lib/client/unescapeString";
-import useLocalSettingsStore from "@/store/localSettings";
-import Modal from "../Modal";
-
-type Props = {
- link: LinkIncludingShortenedCollectionAndTags;
- onClose: Function;
-};
-
-export default function LinkDetails({ link, onClose }: Props) {
- const {
- settings: { theme },
- } = useLocalSettingsStore();
-
- const [imageError, setImageError] = useState
(false);
- const formattedDate = new Date(link.createdAt as string).toLocaleString(
- "en-US",
- {
- year: "numeric",
- month: "short",
- day: "numeric",
- }
- );
-
- const { collections } = useCollectionStore();
-
- const [collection, setCollection] =
- useState(
- collections.find(
- (e) => e.id === link.collection.id
- ) as CollectionIncludingMembersAndLinkCount
- );
-
- useEffect(() => {
- setCollection(
- collections.find(
- (e) => e.id === link.collection.id
- ) as CollectionIncludingMembersAndLinkCount
- );
- }, [collections]);
-
- const [colorPalette, setColorPalette] = useState();
-
- const colorThief = new ColorThief();
-
- const url = link.url && isValidUrl(link.url) ? new URL(link.url) : undefined;
-
- const handleDownload = (format: "png" | "pdf") => {
- const path = `/api/v1/archives/${link.collection.id}/${link.id}.${format}`;
- fetch(path)
- .then((response) => {
- if (response.ok) {
- // Create a temporary link and click it to trigger the download
- const link = document.createElement("a");
- link.href = path;
- link.download = format === "pdf" ? "PDF" : "Screenshot";
- link.click();
- } else {
- console.error("Failed to download file");
- }
- })
- .catch((error) => {
- console.error("Error:", error);
- });
- };
-
- return (
-
-
- {!imageError && url && (
-
{
- try {
- const color = colorThief.getPalette(
- e.target as HTMLImageElement,
- 4
- );
-
- setColorPalette(color);
- } catch (err) {
- console.log(err);
- }
- }}
- onError={(e) => {
- setImageError(true);
- }}
- />
- )}
-
-
- {unescapeString(link.name)}
-
-
- {url ? url.host : link.url}
-
-
-
-
-
-
-
- {collection?.name}
-
-
- {link.tags.map((e, i) => (
-
-
- {e.name}
-
-
- ))}
-
- {link.description && (
- <>
-
- {unescapeString(link.description)}
-
- >
- )}
-
-
-
-
-
-
-
-
-
-
-
-
handleDownload("png")}
- className="cursor-pointer hover:bg-slate-200 hover:dark:bg-neutral-700 duration-100 p-2 rounded-md"
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
handleDownload("pdf")}
- className="cursor-pointer hover:bg-slate-200 hover:dark:bg-neutral-700 duration-100 p-2 rounded-md"
- >
-
-
-
-
-
-
- );
-}
diff --git a/components/ModalContent/PreservedFormatsModal.tsx b/components/ModalContent/PreservedFormatsModal.tsx
index ff0556b..964dab5 100644
--- a/components/ModalContent/PreservedFormatsModal.tsx
+++ b/components/ModalContent/PreservedFormatsModal.tsx
@@ -15,11 +15,16 @@ import {
faUpRightFromSquare,
} from "@fortawesome/free-solid-svg-icons";
import Modal from "../Modal";
-import { faFileImage, faFilePdf } from "@fortawesome/free-regular-svg-icons";
+import {
+ faFileImage,
+ faFileLines,
+ faFilePdf,
+} from "@fortawesome/free-regular-svg-icons";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import {
pdfAvailable,
+ readabilityAvailable,
screenshotAvailable,
} from "@/lib/shared/getArchiveValidity";
@@ -30,7 +35,7 @@ type Props = {
export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
const session = useSession();
- const { links, getLink } = useLinkStore();
+ const { getLink } = useLinkStore();
const [link, setLink] =
useState(activeLink);
@@ -110,9 +115,54 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
Preserved Formats
-
+
+
+ {screenshotAvailable(link) ||
+ pdfAvailable(link) ||
+ readabilityAvailable(link) ? (
+
+ The following formats are available for this link:
+
+ ) : (
+ No preserved formats available.
+ )}
+ {readabilityAvailable(link) ? (
+
+
+
+
+ {/*
handleDownload(ArchivedFormat.pdf)}
+ className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
+ >
+
+
*/}
+
+
+
+
+
+
+ ) : undefined}
+
{screenshotAvailable(link) ? (
@@ -152,7 +202,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
) : undefined}
- {link?.pdfPath && link.pdfPath !== "pending" ? (
+ {pdfAvailable(link) ? (
@@ -191,7 +241,11 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
{link?.collection.ownerId === session.data?.user.id ? (
updateArchive()}
>
@@ -208,11 +262,15 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
)}`}
target="_blank"
className={`text-neutral duration-100 hover:opacity-60 flex gap-2 w-1/2 justify-center items-center text-sm ${
- screenshotAvailable(link) && pdfAvailable(link) ? "sm:mt-3" : ""
+ screenshotAvailable(link) &&
+ pdfAvailable(link) &&
+ readabilityAvailable(link)
+ ? "sm:mt-3"
+ : ""
}`}
>
- View Latest Snapshot on archive.org
+ View latest snapshot on archive.org