changed readable format to json

This commit is contained in:
daniel31x13 2023-10-30 00:50:43 -04:00
parent c9c62b615b
commit ed91c4267b
4 changed files with 13 additions and 10 deletions

View File

@ -44,6 +44,8 @@ export default async function archive(
},
});
// Archive.org
if (user?.archiveAsWaybackMachine) sendToWayback(url);
if (user?.archiveAsPDF || user?.archiveAsScreenshot) {
@ -74,13 +76,13 @@ export default async function archive(
id: linkId,
},
data: {
readabilityPath: `archives/${targetLink.collectionId}/${linkId}_readability.txt`,
readabilityPath: `archives/${targetLink.collectionId}/${linkId}_readability.json`,
},
});
await createFile({
data: JSON.stringify(article),
filePath: `archives/${targetLink.collectionId}/${linkId}_readability.txt`,
filePath: `archives/${targetLink.collectionId}/${linkId}_readability.json`,
});
console.log(JSON.parse(JSON.stringify(article)));

View File

@ -32,7 +32,7 @@ export default async function deleteLink(userId: number, linkId: number) {
filePath: `archives/${collectionIsAccessible?.id}/${linkId}.png`,
});
removeFile({
filePath: `archives/${collectionIsAccessible?.id}/${linkId}_readability.txt`,
filePath: `archives/${collectionIsAccessible?.id}/${linkId}_readability.json`,
});
return { response: deleteLink, status: 200 };

View File

@ -104,8 +104,8 @@ export default async function updateLinkById(
);
await moveFile(
`archives/${collectionIsAccessible?.id}/${linkId}_readability.txt`,
`archives/${data.collection.id}/${linkId}_readability.txt`
`archives/${collectionIsAccessible?.id}/${linkId}_readability.json`,
`archives/${data.collection.id}/${linkId}_readability.json`
);
}

View File

@ -12,7 +12,8 @@ type ReturnContentTypes =
| "text/plain"
| "image/jpeg"
| "image/png"
| "application/pdf";
| "application/pdf"
| "application/json";
export default async function readFile(filePath: string) {
let contentType: ReturnContentTypes;
@ -58,8 +59,8 @@ export default async function readFile(filePath: string) {
contentType = "application/pdf";
} else if (filePath.endsWith(".png")) {
contentType = "image/png";
} else if (filePath.endsWith("_readability.txt")) {
contentType = "text/plain";
} else if (filePath.endsWith("_readability.json")) {
contentType = "application/json";
} else {
// if (filePath.endsWith(".jpg"))
contentType = "image/jpeg";
@ -85,8 +86,8 @@ export default async function readFile(filePath: string) {
contentType = "application/pdf";
} else if (filePath.endsWith(".png")) {
contentType = "image/png";
} else if (filePath.endsWith("_readability.txt")) {
contentType = "text/plain";
} else if (filePath.endsWith("_readability.json")) {
contentType = "application/json";
} else {
// if (filePath.endsWith(".jpg"))
contentType = "image/jpeg";