From e5cb9aa848009ea22c1385e4d33b7edf372979fb Mon Sep 17 00:00:00 2001 From: Ahmad Mujahid <55625580+AhmadMuj@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:25:16 +0400 Subject: feat: Add PDF screenshot generation and display (#995) * Updated pdf2json to 3.1.5 * Extract and store a screenshot from PDF files using pdf2pic * Installing graphicsmagick and ghostscript * Generate Missing PDF screenshot with tidyAssets worker for backward support * Display PDF screenshot instead of the PDF in web if it exists. * Display PDF screenshot in mobile app if exists. * Updated pnpm-lock.yaml * Removed console.log * Revert the unnecessary changes in package.json * Revert pnpm-lock changes * Prevent rendering PDF files if the screenshot is not generated * refactor: replace useEffect with useMemo for section initialization * feat: show PDF file download button and handle large PDFs by defaulting to screenshot view * feat: add file size to openapi spec * feature: Add Assets preprocessing in fix mode to admin actions * i18n: add reprocess_assets_fix_mode translation * i18n: Add missing ar translations * A bunch of fixes * Fix openspec schema --------- Co-authored-by: Mohamed Bassem --- packages/trpc/lib/attachments.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/trpc/lib') diff --git a/packages/trpc/lib/attachments.ts b/packages/trpc/lib/attachments.ts index f4fda9cd..3ad79a5a 100644 --- a/packages/trpc/lib/attachments.ts +++ b/packages/trpc/lib/attachments.ts @@ -6,6 +6,7 @@ import { ZAssetType, zAssetTypesSchema } from "@hoarder/shared/types/bookmarks"; export function mapDBAssetTypeToUserType(assetType: AssetTypes): ZAssetType { const map: Record> = { [AssetTypes.LINK_SCREENSHOT]: "screenshot", + [AssetTypes.ASSET_SCREENSHOT]: "assetScreenshot", [AssetTypes.LINK_FULL_PAGE_ARCHIVE]: "fullPageArchive", [AssetTypes.LINK_PRECRAWLED_ARCHIVE]: "precrawledArchive", [AssetTypes.LINK_BANNER_IMAGE]: "bannerImage", @@ -21,6 +22,7 @@ export function mapSchemaAssetTypeToDB( ): AssetTypes { const map: Record = { screenshot: AssetTypes.LINK_SCREENSHOT, + assetScreenshot: AssetTypes.ASSET_SCREENSHOT, fullPageArchive: AssetTypes.LINK_FULL_PAGE_ARCHIVE, precrawledArchive: AssetTypes.LINK_PRECRAWLED_ARCHIVE, bannerImage: AssetTypes.LINK_BANNER_IMAGE, @@ -34,6 +36,7 @@ export function mapSchemaAssetTypeToDB( export function humanFriendlyNameForAssertType(type: ZAssetType) { const map: Record = { screenshot: "Screenshot", + assetScreenshot: "Asset Screenshot", fullPageArchive: "Full Page Archive", precrawledArchive: "Precrawled Archive", bannerImage: "Banner Image", @@ -47,6 +50,7 @@ export function humanFriendlyNameForAssertType(type: ZAssetType) { export function isAllowedToAttachAsset(type: ZAssetType) { const map: Record = { screenshot: true, + assetScreenshot: true, fullPageArchive: false, precrawledArchive: false, bannerImage: true, @@ -60,6 +64,7 @@ export function isAllowedToAttachAsset(type: ZAssetType) { export function isAllowedToDetachAsset(type: ZAssetType) { const map: Record = { screenshot: true, + assetScreenshot: true, fullPageArchive: true, precrawledArchive: false, bannerImage: true, -- cgit v1.2.3-70-g09d2