⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
more improved UI
daniel31x13bd21c3d8c315
diff --git a/components/LinkDetails.tsx b/components/LinkDetails.tsxindex a508d3b9..fad065a5 100644--- a/components/LinkDetails.tsx+++ b/components/LinkDetails.tsx@@ -4,7 +4,10 @@ import {ArchivedFormat,} from "@/types/global";import Link from "next/link";-import { formatAvailable } from "@/lib/shared/formatStats";+import {+ atLeastOneFormatAvailable,+ formatAvailable,+} from "@/lib/shared/formatStats";import getPublicUserData from "@/lib/client/getPublicUserData";import { useTranslation } from "next-i18next";import { useUser } from "@/hooks/store/user";@@ -203,7 +206,7 @@ export default function LinkDetails({!standalone && "sm:flex sm:h-[80vh]")}>- {width >= 640 && (+ {width >= 640 && atLeastOneFormatAvailable(link) && (<div className="w-1/2 lg:w-2/3 overflow-y-auto">{link.id && (<Preservation@@ -214,7 +217,12 @@ export default function LinkDetails({)}</div>)}- <div className={clsx("sm:overflow-y-auto sm:w-1/2 lg:w-1/3")}>+ <div+ className={clsx(+ "sm:overflow-y-auto",+ atLeastOneFormatAvailable(link) && "sm:w-1/2 lg:w-1/3"+ )}+ >{setMode && onClose && (<div className={clsx("flex justify-center -mb-11 pt-3 relative")}>{(permissions === true || permissions?.canUpdate) &&diff --git a/components/Modal.tsx b/components/Modal.tsxindex 7e22786f..c2d645cb 100644--- a/components/Modal.tsx+++ b/components/Modal.tsx@@ -9,7 +9,10 @@ type Props = {children: ReactNode;className?: string;dismissible?: boolean;- isLinkModal?: boolean;+ linkModal?: {+ state: boolean;+ size: "full" | "half";+ };};export default function Modal({@@ -17,7 +20,7 @@ export default function Modal({className,children,dismissible = true,- isLinkModal,+ linkModal,}: Props) {const [drawerIsOpen, setDrawerIsOpen] = React.useState(true);@@ -49,7 +52,7 @@ export default function Modal({className="p-4 bg-base-100 rounded-t-2xl flex-1 border-neutral-content border-t overflow-y-auto"data-testid="mobile-modal-container">- {!isLinkModal && (+ {!linkModal?.state && (<divclassName="mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-neutral mb-5"data-testid="mobile-modal-slider"@@ -71,20 +74,22 @@ export default function Modal({onClickOutside={() => dismissible && toggleModal()}className={clsx("w-full mt-auto sm:m-auto",- isLinkModal ? "sm:w-[80vw] sm:h-[80vh]" : "sm:w-11/12 sm:max-w-2xl",+ linkModal?.state && linkModal.size === "full"+ ? "sm:w-[80vw] sm:h-[80vh]"+ : "sm:w-11/12 sm:max-w-2xl",className)}><divclassName={clsx("slide-up mt-auto sm:m-auto relative border-neutral-content rounded-t-2xl sm:rounded-2xl border-t sm:border shadow-2xl bg-base-100",- isLinkModal+ linkModal?.state? "h-full overflow-hidden": "overflow-y-auto sm:overflow-y-visible p-5")}data-testid="modal-container">- {dismissible && !isLinkModal && (+ {dismissible && !linkModal?.state && (<divonClick={toggleModal as MouseEventHandler<HTMLDivElement>}className="absolute top-4 right-3 btn btn-sm outline-none btn-circle btn-ghost z-10"diff --git a/components/ModalContent/LinkModal.tsx b/components/ModalContent/LinkModal.tsxindex 9ded58b8..6d86ae58 100644--- a/components/ModalContent/LinkModal.tsx+++ b/components/ModalContent/LinkModal.tsx@@ -1,6 +1,7 @@import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";import LinkDetails from "../LinkDetails";import Modal from "../Modal";+import { atLeastOneFormatAvailable } from "@/lib/shared/formatStats";type Props = {onClose: Function;@@ -20,7 +21,13 @@ export default function LinkModal({activeMode,}: Props) {return (- <Modal toggleModal={onClose} isLinkModal>+ <Modal+ toggleModal={onClose}+ linkModal={{+ state: true,+ size: atLeastOneFormatAvailable(link) ? "full" : "half",+ }}+ ><LinkDetailsactiveLink={link}className="sm:mt-0 -mt-11"diff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.tsindex daf9d759..b8edffa4 100644--- a/lib/api/archiveHandler.ts+++ b/lib/api/archiveHandler.ts@@ -180,6 +180,8 @@ export default async function archiveHandler(where: { id: link.id },});+ console.log(finalLink);+if (finalLink)await prisma.link.update({where: { id: link.id },@@ -191,7 +193,10 @@ export default async function archiveHandler(pdf: !finalLink.pdf ? "unavailable" : undefined,preview: !finalLink.preview ? "unavailable" : undefined,aiTagged:- (archivalSettings.aiTag && !finalLink.aiTagged) || undefined,+ user.aiTaggingMethod !== AiTaggingMethod.DISABLED &&+ !finalLink.aiTagged+ ? true+ : undefined,},});else {diff --git a/pages/api/v1/links/archive/index.ts b/pages/api/v1/links/archive/index.tsindex bedf5eda..7e143f90 100644--- a/pages/api/v1/links/archive/index.ts+++ b/pages/api/v1/links/archive/index.ts@@ -32,13 +32,23 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {const { action } = dataValidation.data;if (action === "allAndIgnore") {- const allLinks = await prisma.link.findMany();+ const allLinks = await prisma.link.findMany({+ where: {+ type: "url",+ url: {+ not: null,+ },+ },+ });for (const link of allLinks) {+ console.log("Deleted preservation link:", link.id);+await removePreservationFiles(link.id, link.collectionId);await prisma.link.update({where: { id: link.id },data: {+ preview: link.preview ? link.preview : undefined,image: "unavailable",pdf: "unavailable",readable: "unavailable",@@ -49,8 +59,17 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {return res.status(200).json({ response: "Success." });} else if (action === "allAndRePreserve") {- const allLinks = await prisma.link.findMany();+ const allLinks = await prisma.link.findMany({+ where: {+ type: "url",+ url: {+ not: null,+ },+ },+ });for (const link of allLinks) {+ console.log("Deleted preservation link:", link.id);+await removeFiles(link.id, link.collectionId);await prisma.link.update({where: { id: link.id },@@ -68,6 +87,10 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {} else if (action === "allBroken") {const brokenArchives = await prisma.link.findMany({where: {+ type: "url",+ url: {+ not: null,+ },OR: [{ image: "unavailable" },{ pdf: "unavailable" },diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsxindex dcdc5ba3..00fd2a74 100644--- a/pages/settings/preference.tsx+++ b/pages/settings/preference.tsx@@ -435,14 +435,8 @@ export default function Preference() {}/></div>- <div className="w-full flex items-center justify-between">- <p>{t("archival_tag_settings")}</p>- <div- className="tooltip tooltip-top"- data-tip={t("archival_tag_info")}- >- <i className="bi-info-lg text-lg leading-none"></i>- </div>+ <div className="max-w-full">+ <p>{t("tag_preservation_rule_label")}</p></div><div className="p-3"><TagSelection@@ -455,13 +449,22 @@ export default function Preference() {archivalTags.filter(isArchivalTag).map((tag) => (<divkey={tag.label}- className="w-full flex items-center justify-between bg-base-200 p-2 rounded first-of-type:mt-4"+ className="w-full bg-base-200 py-2 px-4 rounded-md first-of-type:mt-4 max-w-full shadow">- <span className="text-xl sm:text-lg text-white truncate max-w-[10rem]">- {tag.label}- </span>- <div className="flex items-center gap-1">- <div className="grid grid-cols-3 sm:grid-cols-6 gap-1">+ <div className="flex justify-between gap-1">+ <span className="block sm:text-lg truncate max-w-sm">+ {tag.label}+ </span>+ <button+ className="py-1 px-2 btn btn-sm btn-ghost btn-square hover:bg-red-500"+ onClick={() => removeTag(tag)}+ >+ <i className="bi-x text-lg leading-none"></i>+ </button>+ </div>+ <div className="flex flex-wrap items-center justify-between gap-1 mt-1">+ <p className="text-sm">{t("preservation_rules")}</p>+ <div className="flex gap-1">{ARCHIVAL_OPTIONS.map(({ type, icon, label }) => (<divkey={type}@@ -470,26 +473,16 @@ export default function Preference() {><buttononClick={() => toggleOption(tag, type)}- className={cn("py-1 px-2 bg-base-300 rounded", {- "bg-primary bg-opacity-25": tag[type],- })}+ className={cn(+ "py-1 px-2 btn btn-sm btn-square",+ tag[type] ? "btn-primary" : "btn-ghost"+ )}><i className={`${icon} text-lg leading-none`}></i></button></div>))}</div>- <div- className="tooltip tooltip-top"- data-tip={t("delete")}- >- <button- className="py-1 px-2"- onClick={() => removeTag(tag)}- >- <i className="bi-x text-lg leading-none"></i>- </button>- </div></div></div>))}diff --git a/pages/settings/worker.tsx b/pages/settings/worker.tsxindex 3d18e5a1..a90e95ee 100644--- a/pages/settings/worker.tsx+++ b/pages/settings/worker.tsx@@ -87,11 +87,11 @@ export default function Worker() {</button></div><div className="flex flex-col sm:flex-row sm:items-center gap-3">- <span>{t("delete_all_preservations")}</span>+ <span>{t("delete_all_preservations_and_regenerate")}</span><button- className={`btn btn-sm ml-auto btn-accent dark:border-violet-400 text-white tracking-wider w-fit flex items-center gap-2`}+ className={`btn btn-sm ml-auto btn-error text-white tracking-wider w-fit flex items-center gap-2`}onClick={() => {- setAction("allAndIgnore");+ setAction("allAndRePreserve");setShowModal(true);}}>@@ -99,11 +99,11 @@ export default function Worker() {</button></div><div className="flex flex-col sm:flex-row sm:items-center gap-3">- <span>{t("delete_all_preservations_and_regenerate")}</span>+ <span>{t("delete_all_preservations")}</span><button- className={`btn btn-sm ml-auto btn-accent dark:border-violet-400 text-white tracking-wider w-fit flex items-center gap-2`}+ className={`btn btn-sm ml-auto btn-error text-white tracking-wider w-fit flex items-center gap-2`}onClick={() => {- setAction("allAndRePreserve");+ setAction("allAndIgnore");setShowModal(true);}}>diff --git a/public/locales/en/common.json b/public/locales/en/common.jsonindex 1819da9f..aa17c372 100644--- a/public/locales/en/common.json+++ b/public/locales/en/common.json@@ -464,15 +464,15 @@"search_query_invalid_symbol": "The search query should not contain '%'.","open_modal_new_tab": "Open this modal in a new tab","file": "File",- "archival_tag_settings": "Tag archival settings:",- "archival_tag_info": "Applying archival tags to a link will override the global archival settings.",+ "tag_preservation_rule_label": "Preservation rules by tag (override global settings):","ai_tagging": "AI Tagging","worker": "Worker","regenerate_broken_preservations": "Regenerate all broken or missing preservations for all users.","delete_all_preservations": "Delete preservation for all webpages, applies to all users.",- "delete_all_preservations_and_regenerate": "Delete preservation for all webpages and re-preserve, applies to all users.",+ "delete_all_preservations_and_regenerate": "Delete and re-preserve all webpages, applies to all users.","delete_all_preservation_warning": "This action will delete all existing preservations on the server.","no_broken_preservations": "No broken preservations.","links_are_being_represerved": "Links are being re-preserved...",- "cancel": "Cancel"+ "cancel": "Cancel",+ "preservation_rules": "Preservation rules:"}\ No newline at end of file