Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

added read-only mode + visual improvements

daniel31x139c5226ee51ba
diff --git a/.env.sample b/.env.sample
index b7161ae9..2993c39a 100644
--- a/.env.sample
+++ b/.env.sample
@@ -21,6 +21,7 @@ BROWSER_TIMEOUT=
IGNORE_UNAUTHORIZED_CA=
IGNORE_HTTPS_ERRORS=
IGNORE_URL_SIZE_LIMIT=
+DEMO_MODE=
NEXT_PUBLIC_ADMIN=
NEXT_PUBLIC_MAX_FILE_BUFFER=
MONOLITH_MAX_BUFFER=
diff --git a/components/LinkListOptions.tsx b/components/LinkListOptions.tsx
index 880e91da..842363ee 100644
--- a/components/LinkListOptions.tsx
+++ b/components/LinkListOptions.tsx
@@ -81,12 +81,15 @@ const LinkListOptions = ({
toast.dismiss(load);
- response.ok &&
+ if (response.ok) {
toast.success(
selectedLinks.length === 1
? t("link_deleted")
: t("links_deleted", { count: selectedLinks.length })
);
+ } else {
+ toast.error(response.data as string);
+ }
};
return (
diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsx
index 46aff1dd..c68dd060 100644
--- a/components/LinkViews/LinkComponents/LinkActions.tsx
+++ b/components/LinkViews/LinkComponents/LinkActions.tsx
@@ -55,8 +55,11 @@ export default function LinkActions({
toast.dismiss(load);
- response.ok &&
+ if (response.ok) {
toast.success(isAlreadyPinned ? t("link_unpinned") : t("link_unpinned"));
+ } else {
+ toast.error(response.data as string);
+ }
};
const deleteLink = async () => {
@@ -66,7 +69,11 @@ export default function LinkActions({
toast.dismiss(load);
- response.ok && toast.success(t("deleted"));
+ if (response.ok) {
+ toast.success(t("deleted"));
+ } else {
+ toast.error(response.data as string);
+ }
};
return (
diff --git a/components/LinkViews/LinkList.tsx b/components/LinkViews/LinkList.tsx
index 0f944d89..723c47e2 100644
--- a/components/LinkViews/LinkList.tsx
+++ b/components/LinkViews/LinkList.tsx
@@ -157,7 +157,12 @@ export default function LinkCardCompact({
// linkInfo={showInfo}
/>
</div>
- <div className="divider my-0 last:hidden h-[1px]"></div>
+ <div
+ className="last:hidden rounded-none"
+ style={{
+ borderTop: "1px solid var(--fallback-bc,oklch(var(--bc)/0.1))",
+ }}
+ ></div>
</>
);
}
diff --git a/components/ModalContent/DeleteLinkModal.tsx b/components/ModalContent/DeleteLinkModal.tsx
index 92de1047..192dfb76 100644
--- a/components/ModalContent/DeleteLinkModal.tsx
+++ b/components/ModalContent/DeleteLinkModal.tsx
@@ -30,7 +30,11 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
toast.dismiss(load);
- response.ok && toast.success(t("deleted"));
+ if (response.ok) {
+ toast.success(t("deleted"));
+ } else {
+ toast.error(response.data as string);
+ }
if (router.pathname.startsWith("/links/[id]")) {
router.push("/dashboard");
diff --git a/components/ModalContent/DeleteUserModal.tsx b/components/ModalContent/DeleteUserModal.tsx
index 73a81ed0..6dc7ee2a 100644
--- a/components/ModalContent/DeleteUserModal.tsx
+++ b/components/ModalContent/DeleteUserModal.tsx
@@ -20,7 +20,11 @@ export default function DeleteUserModal({ onClose, userId }: Props) {
toast.dismiss(load);
- response.ok && toast.success(t("user_deleted"));
+ if (response.ok) {
+ toast.success(t("user_deleted"));
+ } else {
+ toast.error(response.data as string);
+ }
onClose();
};
diff --git a/components/ModalContent/RevokeTokenModal.tsx b/components/ModalContent/RevokeTokenModal.tsx
index 9342a3a1..6b741e69 100644
--- a/components/ModalContent/RevokeTokenModal.tsx
+++ b/components/ModalContent/RevokeTokenModal.tsx
@@ -30,6 +30,8 @@ export default function DeleteTokenModal({ onClose, activeToken }: Props) {
if (response.ok) {
toast.success(t("token_revoked"));
+ } else {
+ toast.error(response.data as string);
}
onClose();
diff --git a/components/PageHeader.tsx b/components/PageHeader.tsx
index 6af9a259..d4f78504 100644
--- a/components/PageHeader.tsx
+++ b/components/PageHeader.tsx
@@ -12,7 +12,7 @@ export default function PageHeader({
return (
<div className="flex items-center gap-3">
<i
- className={`${icon} text-primary text-3xl sm:text-4xl drop-shadow`}
+ className={`${icon} text-primary sm:text-3xl text-2xl drop-shadow`}
></i>
<div>
<p className="text-3xl capitalize font-thin">{title}</p>
diff --git a/pages/api/v1/archives/[linkId].ts b/pages/api/v1/archives/[linkId].ts
index faa3dd22..cf044b1e 100644
--- a/pages/api/v1/archives/[linkId].ts
+++ b/pages/api/v1/archives/[linkId].ts
@@ -77,6 +77,12 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
return res.send(file);
}
} else if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const user = await verifyUser({ req, res });
if (!user) return;
@@ -86,14 +92,18 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
});
if (!collectionPermissions)
- return { response: "Collection is not accessible.", status: 400 };
+ return res.status(400).json({
+ response: "Collection is not accessible.",
+ });
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: 400 };
+ return res.status(400).json({
+ response: "Collection is not accessible.",
+ });
// await uploadHandler(linkId, )
@@ -108,10 +118,10 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
});
if (numberOfLinksTheUserHas > MAX_LINKS_PER_USER)
- return {
- response: `Each collection owner can only have a maximum of ${MAX_LINKS_PER_USER} Links.`,
- status: 400,
- };
+ return res.status(400).json({
+ response:
+ "Each collection owner can only have a maximum of ${MAX_LINKS_PER_USER} Links.",
+ });
const NEXT_PUBLIC_MAX_FILE_BUFFER = Number(
process.env.NEXT_PUBLIC_MAX_FILE_BUFFER || 10
diff --git a/pages/api/v1/auth/forgot-password.ts b/pages/api/v1/auth/forgot-password.ts
index 0672914c..17283652 100644
--- a/pages/api/v1/auth/forgot-password.ts
+++ b/pages/api/v1/auth/forgot-password.ts
@@ -7,6 +7,12 @@ export default async function forgotPassword(
res: NextApiResponse
) {
if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const email = req.body.email;
if (!email) {
diff --git a/pages/api/v1/auth/reset-password.ts b/pages/api/v1/auth/reset-password.ts
index 14287f36..7199fcb5 100644
--- a/pages/api/v1/auth/reset-password.ts
+++ b/pages/api/v1/auth/reset-password.ts
@@ -7,6 +7,12 @@ export default async function resetPassword(
res: NextApiResponse
) {
if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const token = req.body.token;
const password = req.body.password;
diff --git a/pages/api/v1/auth/verify-email.ts b/pages/api/v1/auth/verify-email.ts
index 2621c1e0..c19521d7 100644
--- a/pages/api/v1/auth/verify-email.ts
+++ b/pages/api/v1/auth/verify-email.ts
@@ -7,6 +7,12 @@ export default async function verifyEmail(
res: NextApiResponse
) {
if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const token = req.query.token;
if (!token || typeof token !== "string") {
diff --git a/pages/api/v1/collections/[id].ts b/pages/api/v1/collections/[id].ts
index 637e10f6..994dd335 100644
--- a/pages/api/v1/collections/[id].ts
+++ b/pages/api/v1/collections/[id].ts
@@ -19,9 +19,21 @@ export default async function collections(
.status(collections.status)
.json({ response: collections.response });
} else if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const updated = await updateCollectionById(user.id, collectionId, req.body);
return res.status(updated.status).json({ response: updated.response });
} else if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const deleted = await deleteCollectionById(user.id, collectionId);
return res.status(deleted.status).json({ response: deleted.response });
}
diff --git a/pages/api/v1/collections/index.ts b/pages/api/v1/collections/index.ts
index 3b229ddf..369863f3 100644
--- a/pages/api/v1/collections/index.ts
+++ b/pages/api/v1/collections/index.ts
@@ -16,6 +16,12 @@ export default async function collections(
.status(collections.status)
.json({ response: collections.response });
} else if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const newCollection = await postCollection(req.body, user.id);
return res
.status(newCollection.status)
diff --git a/pages/api/v1/links/[id]/archive/index.ts b/pages/api/v1/links/[id]/archive/index.ts
index ef91a4e7..fa6cf83b 100644
--- a/pages/api/v1/links/[id]/archive/index.ts
+++ b/pages/api/v1/links/[id]/archive/index.ts
@@ -29,6 +29,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
});
if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
if (
link?.lastPreserved &&
getTimezoneDifferenceInMinutes(new Date(), link?.lastPreserved) <
diff --git a/pages/api/v1/links/[id]/index.ts b/pages/api/v1/links/[id]/index.ts
index 146ecb2f..02299f47 100644
--- a/pages/api/v1/links/[id]/index.ts
+++ b/pages/api/v1/links/[id]/index.ts
@@ -14,6 +14,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
response: updated.response,
});
} else if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const updated = await updateLinkById(
user.id,
Number(req.query.id),
@@ -23,6 +29,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
response: updated.response,
});
} else if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const deleted = await deleteLinkById(user.id, Number(req.query.id));
return res.status(deleted.status).json({
response: deleted.response,
diff --git a/pages/api/v1/links/index.ts b/pages/api/v1/links/index.ts
index 35b0243e..f506d3b9 100644
--- a/pages/api/v1/links/index.ts
+++ b/pages/api/v1/links/index.ts
@@ -37,11 +37,23 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
const links = await getLinks(user.id, convertedData);
return res.status(links.status).json({ response: links.response });
} else if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const newlink = await postLink(req.body, user.id);
return res.status(newlink.status).json({
response: newlink.response,
});
} else if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const updated = await updateLinks(
user.id,
req.body.links,
@@ -52,6 +64,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
response: updated.response,
});
} else if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const deleted = await deleteLinksById(user.id, req.body.linkIds);
return res.status(deleted.status).json({
response: deleted.response,
diff --git a/pages/api/v1/migration/index.ts b/pages/api/v1/migration/index.ts
index 8cdf5db9..60f52a74 100644
--- a/pages/api/v1/migration/index.ts
+++ b/pages/api/v1/migration/index.ts
@@ -30,6 +30,12 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
.status(data.status)
.json(data.response);
} else if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const request: MigrationRequest = JSON.parse(req.body);
let data;
diff --git a/pages/api/v1/tags/[id].ts b/pages/api/v1/tags/[id].ts
index d82b1f7b..f9a9fd84 100644
--- a/pages/api/v1/tags/[id].ts
+++ b/pages/api/v1/tags/[id].ts
@@ -10,9 +10,21 @@ export default async function tags(req: NextApiRequest, res: NextApiResponse) {
const tagId = Number(req.query.id);
if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const tags = await updeteTagById(user.id, tagId, req.body);
return res.status(tags.status).json({ response: tags.response });
} else if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const tags = await deleteTagById(user.id, tagId);
return res.status(tags.status).json({ response: tags.response });
}
diff --git a/pages/api/v1/tokens/[id].ts b/pages/api/v1/tokens/[id].ts
index 6c2e51b7..a0615d7a 100644
--- a/pages/api/v1/tokens/[id].ts
+++ b/pages/api/v1/tokens/[id].ts
@@ -7,6 +7,12 @@ export default async function token(req: NextApiRequest, res: NextApiResponse) {
if (!user) return;
if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const deleted = await deleteToken(user.id, Number(req.query.id) as number);
return res.status(deleted.status).json({ response: deleted.response });
}
diff --git a/pages/api/v1/tokens/index.ts b/pages/api/v1/tokens/index.ts
index 8af63fbd..915980f9 100644
--- a/pages/api/v1/tokens/index.ts
+++ b/pages/api/v1/tokens/index.ts
@@ -11,6 +11,12 @@ export default async function tokens(
if (!user) return;
if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const token = await postToken(JSON.parse(req.body), user.id);
return res.status(token.status).json({ response: token.response });
} else if (req.method === "GET") {
diff --git a/pages/api/v1/users/[id].ts b/pages/api/v1/users/[id].ts
index de8ef562..9e102f9a 100644
--- a/pages/api/v1/users/[id].ts
+++ b/pages/api/v1/users/[id].ts
@@ -58,9 +58,21 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
}
if (req.method === "PUT") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const updated = await updateUserById(userId, req.body);
return res.status(updated.status).json({ response: updated.response });
} else if (req.method === "DELETE") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const updated = await deleteUserById(userId, req.body, isServerAdmin);
return res.status(updated.status).json({ response: updated.response });
}
diff --git a/pages/api/v1/users/index.ts b/pages/api/v1/users/index.ts
index c94e9f24..8f1f7703 100644
--- a/pages/api/v1/users/index.ts
+++ b/pages/api/v1/users/index.ts
@@ -5,6 +5,12 @@ import verifyUser from "@/lib/api/verifyUser";
export default async function users(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
+ if (process.env.DEMO_MODE === "true")
+ return res.status(400).json({
+ response:
+ "This action is disabled because this is a read-only demo of Linkwarden.",
+ });
+
const response = await postUser(req, res);
return res.status(response.status).json({ response: response.response });
} else if (req.method === "GET") {
diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx
index bdfbfe9a..bd24a95c 100644
--- a/pages/collections/[id].tsx
+++ b/pages/collections/[id].tsx
@@ -128,7 +128,7 @@ export default function Index() {
style={{ color: activeCollection?.color }}
></i>
- <p className="sm:text-4xl text-3xl capitalize w-full py-1 break-words hyphens-auto font-thin">
+ <p className="sm:text-3xl text-2xl capitalize w-full py-1 break-words hyphens-auto font-thin">
{activeCollection?.name}
</p>
</div>
diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsx
index 41776814..ac05f74c 100644
--- a/pages/tags/[id].tsx
+++ b/pages/tags/[id].tsx
@@ -145,7 +145,7 @@ export default function Index() {
<input
type="text"
autoFocus
- className="sm:text-4xl text-3xl capitalize bg-transparent h-10 w-3/4 outline-none border-b border-b-neutral-content"
+ className="sm:text-3xl text-2xl capitalize bg-transparent h-10 w-3/4 outline-none border-b border-b-neutral-content"
value={newTagName}
onChange={(e) => setNewTagName(e.target.value)}
/>
@@ -167,7 +167,7 @@ export default function Index() {
</>
) : (
<>
- <p className="sm:text-4xl text-3xl capitalize">
+ <p className="sm:text-3xl text-2xl capitalize">
{activeTag?.name}
</p>
<div className="relative">