Skip to content

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

format

Isaaca267d4ed3ab0
diff --git a/components/Preservation/Preservation.tsx b/components/Preservation/Preservation.tsx
index 0048c3d6..83148815 100644
--- a/components/Preservation/Preservation.tsx
+++ b/components/Preservation/Preservation.tsx
@@ -114,7 +114,7 @@ export default function Preservation({
className={clsx(
"bg-base-200",
!isExpanded &&
- `mx-auto relative p-2 h-full overflow-auto rounded-md sm:rounded-none`,
+ `mx-auto relative p-2 h-full overflow-auto rounded-md sm:rounded-none`,
isExpanded && "fixed inset-0 w-screen h-screen z-[9999]"
)}
style={{
@@ -129,7 +129,7 @@ export default function Preservation({
className={clsx(
"py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",
format === ArchivedFormat.readability &&
- "bg-primary bg-opacity-50"
+ "bg-primary bg-opacity-50"
)}
onClick={() => setFormat(ArchivedFormat.readability)}
>
@@ -143,7 +143,7 @@ export default function Preservation({
className={clsx(
"py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",
format === ArchivedFormat.monolith &&
- "bg-primary bg-opacity-50"
+ "bg-primary bg-opacity-50"
)}
onClick={() => setFormat(ArchivedFormat.monolith)}
>
@@ -157,9 +157,9 @@ export default function Preservation({
className={clsx(
"py-1 px-2 cursor-pointer duration-100 rounded-lg font-semibold text-center flex justify-between items-center w-6",
format ===
- (link?.image?.endsWith("png")
- ? ArchivedFormat.png
- : ArchivedFormat.jpeg) && "bg-primary bg-opacity-50"
+ (link?.image?.endsWith("png")
+ ? ArchivedFormat.png
+ : ArchivedFormat.jpeg) && "bg-primary bg-opacity-50"
)}
onClick={() =>
setFormat(
@@ -279,29 +279,29 @@ const RenderFormat = ({
const style = isExpanded
? {
- position: "fixed" as const,
- top: 0,
- left: 0,
- width: "100vw",
- height: "100vh",
- zIndex: 9999,
- transitionProperty:
- delayPassed && !shouldReduceMotion
- ? "width, height, top, left"
- : "none",
- }
+ position: "fixed" as const,
+ top: 0,
+ left: 0,
+ width: "100vw",
+ height: "100vh",
+ zIndex: 9999,
+ transitionProperty:
+ delayPassed && !shouldReduceMotion
+ ? "width, height, top, left"
+ : "none",
+ }
: {
- zIndex: 40,
- position: "absolute" as const,
- top: (containerRect?.top ?? 0) + window.scrollY + topPadding,
- left: (containerRect?.left ?? 0) + window.scrollX,
- width: containerRect?.width ?? 0,
- height: containerRect?.height ? containerRect.height - topPadding : 0,
- transitionProperty:
- delayPassed && !shouldReduceMotion
- ? "width, height, top, left"
- : "none",
- };
+ zIndex: 40,
+ position: "absolute" as const,
+ top: (containerRect?.top ?? 0) + window.scrollY + topPadding,
+ left: (containerRect?.left ?? 0) + window.scrollX,
+ width: containerRect?.width ?? 0,
+ height: containerRect?.height ? containerRect.height - topPadding : 0,
+ transitionProperty:
+ delayPassed && !shouldReduceMotion
+ ? "width, height, top, left"
+ : "none",
+ };
return ReactDOM.createPortal(
<div
diff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.ts
index e25ad66f..062410d2 100644
--- a/lib/api/archiveHandler.ts
+++ b/lib/api/archiveHandler.ts
@@ -87,8 +87,10 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await page.goto(link.url, { waitUntil: "domcontentloaded" });
const metaDescription = await page.evaluate(() => {
- const description = document.querySelector('meta[name="description"]');
- return description?.getAttribute('content') ?? undefined;
+ const description = document.querySelector(
+ 'meta[name="description"]'
+ );
+ return description?.getAttribute("content") ?? undefined;
});
const content = await page.content();
@@ -97,11 +99,9 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
if (
user.aiTaggingMethod !== AiTaggingMethod.DISABLED &&
!link.aiTagged &&
- (
- process.env.NEXT_PUBLIC_OLLAMA_ENDPOINT_URL ||
+ (process.env.NEXT_PUBLIC_OLLAMA_ENDPOINT_URL ||
process.env.OPENAI_API_KEY ||
- process.env.ANTHROPIC_API_KEY
- )
+ process.env.ANTHROPIC_API_KEY)
)
await autoTagLink(user, link.id, metaDescription);
@@ -146,7 +146,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
preview: !finalLink.preview ? "unavailable" : undefined,
aiTagged:
user.aiTaggingMethod !== AiTaggingMethod.DISABLED &&
- !finalLink.aiTagged
+ !finalLink.aiTagged
? true
: undefined,
},
diff --git a/lib/api/autoTagLink.ts b/lib/api/autoTagLink.ts
index 26aa056c..a566d52a 100644
--- a/lib/api/autoTagLink.ts
+++ b/lib/api/autoTagLink.ts
@@ -8,25 +8,35 @@ import { anthropic } from "@ai-sdk/anthropic";
import { createOllama } from "ollama-ai-provider";
// Function to concat /api with the base URL properly
-const ensureValidURL = (base: string, path: string) => `${base.replace(/\/$/, '')}/${path.replace(/^\//, '')}`;
+const ensureValidURL = (base: string, path: string) =>
+ `${base.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
const getAIModel = () => {
- if (process.env.OPENAI_API_KEY && process.env.OPENAI_MODEL) return openai(process.env.OPENAI_MODEL);
- if (process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_MODEL) return anthropic(process.env.ANTHROPIC_MODEL);
+ if (process.env.OPENAI_API_KEY && process.env.OPENAI_MODEL)
+ return openai(process.env.OPENAI_MODEL);
+ if (process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_MODEL)
+ return anthropic(process.env.ANTHROPIC_MODEL);
if (process.env.NEXT_PUBLIC_OLLAMA_ENDPOINT_URL && process.env.OLLAMA_MODEL) {
const ollama = createOllama({
- baseURL: ensureValidURL(process.env.NEXT_PUBLIC_OLLAMA_ENDPOINT_URL, 'api'),
+ baseURL: ensureValidURL(
+ process.env.NEXT_PUBLIC_OLLAMA_ENDPOINT_URL,
+ "api"
+ ),
});
return ollama(process.env.OLLAMA_MODEL, {
- structuredOutputs: true
- })
+ structuredOutputs: true,
+ });
}
throw new Error("No AI provider configured");
-}
+};
-export default async function autoTagLink(user: User, linkId: number, metaDescription: string | undefined) {
+export default async function autoTagLink(
+ user: User,
+ linkId: number,
+ metaDescription: string | undefined
+) {
const link = await prisma.link.findUnique({
where: { id: linkId },
});
@@ -58,12 +68,12 @@ export default async function autoTagLink(user: User, linkId: number, metaDescri
const { object } = await generateObject({
model: getAIModel(),
prompt: prompt,
- output: 'array',
- schema: z.string()
- })
+ output: "array",
+ schema: z.string(),
+ });
try {
- let tags = object
+ let tags = object;
console.log("Tags generated for link: ", link.url, tags);
diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts
index 5cc885b0..76e0eb85 100644
--- a/lib/api/controllers/links/postLink.ts
+++ b/lib/api/controllers/links/postLink.ts
@@ -16,8 +16,9 @@ export default async function postLink(
if (!dataValidation.success) {
return {
- response: `Error: ${dataValidation.error.issues[0].message
- } [${dataValidation.error.issues[0].path.join(", ")}]`,
+ response: `Error: ${
+ dataValidation.error.issues[0].message
+ } [${dataValidation.error.issues[0].path.join(", ")}]`,
status: 400,
};
}
@@ -133,8 +134,9 @@ export default async function postLink(
where: { id: newLink.id },
data: {
image: link.image
- ? `archives/${newLink.collectionId}/${newLink.id}.${link.image === "png" ? "png" : "jpeg"
- }`
+ ? `archives/${newLink.collectionId}/${newLink.id}.${
+ link.image === "png" ? "png" : "jpeg"
+ }`
: undefined,
},
});
diff --git a/lib/api/controllers/users/userId/updateUserById.ts b/lib/api/controllers/users/userId/updateUserById.ts
index 69393d25..66294cc5 100644
--- a/lib/api/controllers/users/userId/updateUserById.ts
+++ b/lib/api/controllers/users/userId/updateUserById.ts
@@ -19,8 +19,9 @@ export default async function updateUserById(
if (!dataValidation.success) {
return {
- response: `Error: ${dataValidation.error.issues[0].message
- } [${dataValidation.error.issues[0].path.join(", ")}]`,
+ response: `Error: ${
+ dataValidation.error.issues[0].message
+ } [${dataValidation.error.issues[0].path.join(", ")}]`,
status: 400,
};
}
@@ -32,18 +33,18 @@ export default async function updateUserById(
id: { not: userId },
OR: emailEnabled
? [
- {
- username: data.username.toLowerCase(),
- },
- {
- email: data.email?.toLowerCase(),
- },
- ]
+ {
+ username: data.username.toLowerCase(),
+ },
+ {
+ email: data.email?.toLowerCase(),
+ },
+ ]
: [
- {
- username: data.username.toLowerCase(),
- },
- ],
+ {
+ username: data.username.toLowerCase(),
+ },
+ ],
},
});
diff --git a/lib/shared/schemaValidation.ts b/lib/shared/schemaValidation.ts
index 7f80699d..30a9e952 100644
--- a/lib/shared/schemaValidation.ts
+++ b/lib/shared/schemaValidation.ts
@@ -41,12 +41,12 @@ export const PostUserSchema = () => {
username: emailEnabled
? z.string().optional()
: z
- .string()
- .trim()
- .toLowerCase()
- .min(3)
- .max(50)
- .regex(/^[a-z0-9_-]{3,50}$/),
+ .string()
+ .trim()
+ .toLowerCase()
+ .min(3)
+ .max(50)
+ .regex(/^[a-z0-9_-]{3,50}$/),
invite: z.boolean().optional(),
});
};
diff --git a/pages/api/v1/config/index.ts b/pages/api/v1/config/index.ts
index 25f8a116..3c0035eb 100644
--- a/pages/api/v1/config/index.ts
+++ b/pages/api/v1/config/index.ts
@@ -22,4 +22,4 @@ export const getEnvData = () => {
MAX_FILE_BUFFER: Number(process.env.NEXT_PUBLIC_MAX_FILE_BUFFER) || null,
AI_ENABLED: hasAiProvider || null,
};
-};
\ No newline at end of file
+};
diff --git a/pages/settings/access-tokens.tsx b/pages/settings/access-tokens.tsx
index d060eb73..af2d5def 100644
--- a/pages/settings/access-tokens.tsx
+++ b/pages/settings/access-tokens.tsx
@@ -67,11 +67,14 @@ export default function AccessTokens() {
)}
</td>
<td>
- {new Date(token.createdAt).toLocaleDateString(t("locale"), {
- month: "short",
- day: "numeric",
- year: "numeric",
- })}
+ {new Date(token.createdAt).toLocaleDateString(
+ t("locale"),
+ {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ }
+ )}
</td>
<td>
{new Date(token.expires).toLocaleDateString(t("locale"), {
diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsx
index 25849358..48230829 100644
--- a/pages/settings/preference.tsx
+++ b/pages/settings/preference.tsx
@@ -44,7 +44,9 @@ export default function Appearance() {
account.aiTaggingMethod
);
const [aiPredefinedTags, setAiPredefinedTags] = useState<string[]>();
- const [aiTagExistingLinks, setAiTagExistingLinks] = useState<boolean>(account.aiTagExistingLinks);
+ const [aiTagExistingLinks, setAiTagExistingLinks] = useState<boolean>(
+ account.aiTagExistingLinks
+ );
const { data: config } = useConfig();
@@ -147,10 +149,11 @@ export default function Appearance() {
].map(({ theme, icon, bgColor, textColor, activeColor }) => (
<div
key={theme}
- className={`w-full text-center outline-solid outline-neutral-content outline h-20 duration-100 rounded-xl flex items-center justify-center cursor-pointer select-none ${bgColor} ${localStorage.getItem("theme") === theme
- ? `outline-primary ${activeColor}`
- : textColor
- }`}
+ className={`w-full text-center outline-solid outline-neutral-content outline h-20 duration-100 rounded-xl flex items-center justify-center cursor-pointer select-none ${bgColor} ${
+ localStorage.getItem("theme") === theme
+ ? `outline-primary ${activeColor}`
+ : textColor
+ }`}
onClick={() => updateSettings({ theme })}
>
<i className={`${icon} text-3xl`}></i>
diff --git a/scripts/worker.ts b/scripts/worker.ts
index b225cc77..69ba9cad 100644
--- a/scripts/worker.ts
+++ b/scripts/worker.ts
@@ -115,13 +115,13 @@ async function processAITagging() {
createdBy: {
aiTagExistingLinks: true,
aiTaggingMethod: {
- in: ['GENERATE', 'PREDEFINED']
- }
- }
+ in: ["GENERATE", "PREDEFINED"],
+ },
+ },
},
include: {
- createdBy: true
- }
+ createdBy: true,
+ },
});
console.log(`Processing ${links.length} links for AI tagging...`);
@@ -143,12 +143,14 @@ async function processAITagging() {
await page.goto(link.url, {
waitUntil: "domcontentloaded",
- timeout: 30000
+ timeout: 30000,
});
const metaDescription = await page.evaluate(() => {
- const description = document.querySelector('meta[name="description"]');
- return description?.getAttribute('content') ?? undefined;
+ const description = document.querySelector(
+ 'meta[name="description"]'
+ );
+ return description?.getAttribute("content") ?? undefined;
});
await autoTagLink(link.createdBy, link.id, metaDescription);
@@ -156,7 +158,7 @@ async function processAITagging() {
// Mark the link as processed
await prisma.link.update({
where: { id: link.id },
- data: { aiTagged: true }
+ data: { aiTagged: true },
});
}
} catch (error) {
@@ -169,7 +171,7 @@ async function processAITagging() {
// Mark the link as processed even if it failed to prevent endless retries
await prisma.link.update({
where: { id: link.id },
- data: { aiTagged: true }
+ data: { aiTagged: true },
});
} finally {
if (browser) {