-
+
*/}
-
{
- if (router.pathname.startsWith("/public")) {
- router.push(
- `/public/collections/${
+
- Back{" "}
-
- to{" "}
-
- {router.pathname.startsWith("/public")
- ? linkCollection?.name || link?.collection?.name
- : "Dashboard"}
-
+
+ {router.pathname.startsWith("/public")
+ ? linkCollection?.name || link?.collection?.name
+ : "Dashboard"}
-
+
-
+
{link?.collection?.ownerId === userId ||
linkCollection?.members.some(
(e) => e.userId === userId && e.canUpdate
@@ -125,20 +119,13 @@ export default function LinkLayout({ children }: Props) {
{
- link
- ? setModal({
- modal: "LINK",
- state: true,
- active: link,
- method: "UPDATE",
- })
- : undefined;
+ setEditLinkModal(true);
}}
- className={`hover:opacity-60 duration-100 py-2 px-2 cursor-pointer flex items-center gap-4 w-full rounded-md h-8`}
+ className={`btn btn-ghost btn-square btn-sm`}
>
) : undefined}
@@ -201,6 +188,12 @@ export default function LinkLayout({ children }: Props) {
) : null}
+ {link && editLinkModal ? (
+
setEditLinkModal(false)}
+ activeLink={link}
+ />
+ ) : undefined}
>
);
diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts
index 6cd4d55..3d28a3f 100644
--- a/lib/api/controllers/links/postLink.ts
+++ b/lib/api/controllers/links/postLink.ts
@@ -1,6 +1,6 @@
import { prisma } from "@/lib/api/db";
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
-import getTitle from "@/lib/api/getTitle";
+import getTitle from "@/lib/shared/getTitle";
import urlHandler from "@/lib/api/urlHandler";
import { UsersAndCollections } from "@prisma/client";
import getPermission from "@/lib/api/getPermission";
diff --git a/lib/api/getTitle.ts b/lib/shared/getTitle.ts
similarity index 100%
rename from lib/api/getTitle.ts
rename to lib/shared/getTitle.ts
diff --git a/pages/api/v1/archives/[linkId].ts b/pages/api/v1/archives/[linkId].ts
index 0b8992e..8686c15 100644
--- a/pages/api/v1/archives/[linkId].ts
+++ b/pages/api/v1/archives/[linkId].ts
@@ -62,82 +62,83 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
res.setHeader("Content-Type", contentType).status(status as number);
return res.send(file);
- } else if (req.method === "POST") {
- const user = await verifyUser({ req, res });
- if (!user) return;
-
- const collectionPermissions = await getPermission({
- userId: user.id,
- linkId,
- });
-
- const memberHasAccess = collectionPermissions?.members.some(
- (e: UsersAndCollections) => e.userId === user.id && e.canCreate
- );
-
- if (!(collectionPermissions?.ownerId === user.id || memberHasAccess))
- return { response: "Collection is not accessible.", status: 401 };
-
- // await uploadHandler(linkId, )
-
- const MAX_UPLOAD_SIZE = Number(process.env.NEXT_PUBLIC_MAX_UPLOAD_SIZE);
-
- const form = formidable({
- maxFields: 1,
- maxFiles: 1,
- maxFileSize: MAX_UPLOAD_SIZE || 30 * 1048576,
- });
-
- form.parse(req, async (err, fields, files) => {
- const allowedMIMETypes = [
- "application/pdf",
- "image/png",
- "image/jpg",
- "image/jpeg",
- ];
-
- if (
- err ||
- !files.file ||
- !files.file[0] ||
- !allowedMIMETypes.includes(files.file[0].mimetype || "")
- ) {
- // Handle parsing error
- return res.status(500).json({
- response: `Sorry, we couldn't process your file. Please ensure it's a PDF, PNG, or JPG format and doesn't exceed ${MAX_UPLOAD_SIZE}MB.`,
- });
- } else {
- const fileBuffer = fs.readFileSync(files.file[0].filepath);
-
- const linkStillExists = await prisma.link.findUnique({
- where: { id: linkId },
- });
-
- if (linkStillExists) {
- await createFile({
- filePath: `archives/${collectionPermissions?.id}/${
- linkId + suffix
- }`,
- data: fileBuffer,
- });
-
- await prisma.link.update({
- where: { id: linkId },
- data: {
- screenshotPath: `archives/${collectionPermissions?.id}/${
- linkId + suffix
- }`,
- lastPreserved: new Date().toISOString(),
- },
- });
- }
-
- fs.unlinkSync(files.file[0].filepath);
- }
-
- return res.status(200).json({
- response: files,
- });
- });
}
+ // else if (req.method === "POST") {
+ // const user = await verifyUser({ req, res });
+ // if (!user) return;
+
+ // const collectionPermissions = await getPermission({
+ // userId: user.id,
+ // linkId,
+ // });
+
+ // const memberHasAccess = collectionPermissions?.members.some(
+ // (e: UsersAndCollections) => e.userId === user.id && e.canCreate
+ // );
+
+ // if (!(collectionPermissions?.ownerId === user.id || memberHasAccess))
+ // return { response: "Collection is not accessible.", status: 401 };
+
+ // // await uploadHandler(linkId, )
+
+ // const MAX_UPLOAD_SIZE = Number(process.env.NEXT_PUBLIC_MAX_UPLOAD_SIZE);
+
+ // const form = formidable({
+ // maxFields: 1,
+ // maxFiles: 1,
+ // maxFileSize: MAX_UPLOAD_SIZE || 30 * 1048576,
+ // });
+
+ // form.parse(req, async (err, fields, files) => {
+ // const allowedMIMETypes = [
+ // "application/pdf",
+ // "image/png",
+ // "image/jpg",
+ // "image/jpeg",
+ // ];
+
+ // if (
+ // err ||
+ // !files.file ||
+ // !files.file[0] ||
+ // !allowedMIMETypes.includes(files.file[0].mimetype || "")
+ // ) {
+ // // Handle parsing error
+ // return res.status(500).json({
+ // response: `Sorry, we couldn't process your file. Please ensure it's a PDF, PNG, or JPG format and doesn't exceed ${MAX_UPLOAD_SIZE}MB.`,
+ // });
+ // } else {
+ // const fileBuffer = fs.readFileSync(files.file[0].filepath);
+
+ // const linkStillExists = await prisma.link.findUnique({
+ // where: { id: linkId },
+ // });
+
+ // if (linkStillExists) {
+ // await createFile({
+ // filePath: `archives/${collectionPermissions?.id}/${
+ // linkId + suffix
+ // }`,
+ // data: fileBuffer,
+ // });
+
+ // await prisma.link.update({
+ // where: { id: linkId },
+ // data: {
+ // screenshotPath: `archives/${collectionPermissions?.id}/${
+ // linkId + suffix
+ // }`,
+ // lastPreserved: new Date().toISOString(),
+ // },
+ // });
+ // }
+
+ // fs.unlinkSync(files.file[0].filepath);
+ // }
+
+ // return res.status(200).json({
+ // response: files,
+ // });
+ // });
+ // }
}
diff --git a/pages/links/[id].tsx b/pages/links/[id].tsx
index 0a991e1..5d98a76 100644
--- a/pages/links/[id].tsx
+++ b/pages/links/[id].tsx
@@ -13,7 +13,11 @@ import unescapeString from "@/lib/client/unescapeString";
import isValidUrl from "@/lib/shared/isValidUrl";
import DOMPurify from "dompurify";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { faBoxesStacked, faFolder } from "@fortawesome/free-solid-svg-icons";
+import {
+ faBoxesStacked,
+ faFolder,
+ faLink,
+} from "@fortawesome/free-solid-svg-icons";
import useModalStore from "@/store/modals";
import { useSession } from "next-auth/react";
import useLocalSettingsStore from "@/store/localSettings";
@@ -118,19 +122,19 @@ export default function Index() {
if (colorPalette && banner && bannerInner) {
if (colorPalette[0] && colorPalette[1]) {
- banner.style.background = `linear-gradient(to right, ${rgbToHex(
+ banner.style.background = `linear-gradient(to bottom, ${rgbToHex(
colorPalette[0][0],
colorPalette[0][1],
colorPalette[0][2]
- )}30, ${rgbToHex(
+ )}20, ${rgbToHex(
colorPalette[1][0],
colorPalette[1][1],
colorPalette[1][2]
- )}30)`;
+ )}20)`;
}
if (colorPalette[2] && colorPalette[3]) {
- bannerInner.style.background = `linear-gradient(to left, ${rgbToHex(
+ bannerInner.style.background = `linear-gradient(to bottom, ${rgbToHex(
colorPalette[2][0],
colorPalette[2][1],
colorPalette[2][2]
@@ -145,19 +149,15 @@ export default function Index() {
return (
-
+
-
+ {/*
*/}
-
+
{!imageError && link?.url && (
{
try {
@@ -184,76 +184,76 @@ export default function Index() {
}}
/>
)}
-
-
-
- {link?.createdAt
- ? new Date(link?.createdAt).toLocaleString("en-US", {
- year: "numeric",
- month: "long",
- day: "numeric",
- })
- : undefined}
+
+
+ {unescapeString(link?.name || link?.description || "")}
{link?.url ? (
- <>
-
•
-
- {isValidUrl(link?.url || "")
- ? new URL(link?.url as string).host
- : undefined}
-
- >
+
+
+
+ {isValidUrl(link?.url || "")
+ ? new URL(link?.url as string).host
+ : undefined}
+
) : undefined}
-
-
- {unescapeString(link?.name || link?.description || "")}
-
-
-
-
+
+
+
-
+ {link?.collection.name}
+
+
+ {link?.tags.map((e, i) => (
+
- {link?.collection.name}
+ #{e.name}
- {link?.tags.map((e, i) => (
-
-
- #{e.name}
-
-
- ))}
-
+ ))}
+
+
+ {link?.createdAt
+ ? new Date(link?.createdAt).toLocaleString("en-US", {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ })
+ : undefined}
+
+
+ {link?.name ? {link?.description}
: undefined}
+
+
{link?.readabilityPath?.startsWith("archives") ? (
()((set) => ({
};
}
});
+
+ return data;
}
return { ok: response.ok, data: data.response };