changed readable format to json
This commit is contained in:
parent
c9c62b615b
commit
ed91c4267b
|
@ -44,6 +44,8 @@ export default async function archive(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Archive.org
|
||||||
|
|
||||||
if (user?.archiveAsWaybackMachine) sendToWayback(url);
|
if (user?.archiveAsWaybackMachine) sendToWayback(url);
|
||||||
|
|
||||||
if (user?.archiveAsPDF || user?.archiveAsScreenshot) {
|
if (user?.archiveAsPDF || user?.archiveAsScreenshot) {
|
||||||
|
@ -74,13 +76,13 @@ export default async function archive(
|
||||||
id: linkId,
|
id: linkId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
readabilityPath: `archives/${targetLink.collectionId}/${linkId}_readability.txt`,
|
readabilityPath: `archives/${targetLink.collectionId}/${linkId}_readability.json`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await createFile({
|
await createFile({
|
||||||
data: JSON.stringify(article),
|
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)));
|
console.log(JSON.parse(JSON.stringify(article)));
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default async function deleteLink(userId: number, linkId: number) {
|
||||||
filePath: `archives/${collectionIsAccessible?.id}/${linkId}.png`,
|
filePath: `archives/${collectionIsAccessible?.id}/${linkId}.png`,
|
||||||
});
|
});
|
||||||
removeFile({
|
removeFile({
|
||||||
filePath: `archives/${collectionIsAccessible?.id}/${linkId}_readability.txt`,
|
filePath: `archives/${collectionIsAccessible?.id}/${linkId}_readability.json`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { response: deleteLink, status: 200 };
|
return { response: deleteLink, status: 200 };
|
||||||
|
|
|
@ -104,8 +104,8 @@ export default async function updateLinkById(
|
||||||
);
|
);
|
||||||
|
|
||||||
await moveFile(
|
await moveFile(
|
||||||
`archives/${collectionIsAccessible?.id}/${linkId}_readability.txt`,
|
`archives/${collectionIsAccessible?.id}/${linkId}_readability.json`,
|
||||||
`archives/${data.collection.id}/${linkId}_readability.txt`
|
`archives/${data.collection.id}/${linkId}_readability.json`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ type ReturnContentTypes =
|
||||||
| "text/plain"
|
| "text/plain"
|
||||||
| "image/jpeg"
|
| "image/jpeg"
|
||||||
| "image/png"
|
| "image/png"
|
||||||
| "application/pdf";
|
| "application/pdf"
|
||||||
|
| "application/json";
|
||||||
|
|
||||||
export default async function readFile(filePath: string) {
|
export default async function readFile(filePath: string) {
|
||||||
let contentType: ReturnContentTypes;
|
let contentType: ReturnContentTypes;
|
||||||
|
@ -58,8 +59,8 @@ export default async function readFile(filePath: string) {
|
||||||
contentType = "application/pdf";
|
contentType = "application/pdf";
|
||||||
} else if (filePath.endsWith(".png")) {
|
} else if (filePath.endsWith(".png")) {
|
||||||
contentType = "image/png";
|
contentType = "image/png";
|
||||||
} else if (filePath.endsWith("_readability.txt")) {
|
} else if (filePath.endsWith("_readability.json")) {
|
||||||
contentType = "text/plain";
|
contentType = "application/json";
|
||||||
} else {
|
} else {
|
||||||
// if (filePath.endsWith(".jpg"))
|
// if (filePath.endsWith(".jpg"))
|
||||||
contentType = "image/jpeg";
|
contentType = "image/jpeg";
|
||||||
|
@ -85,8 +86,8 @@ export default async function readFile(filePath: string) {
|
||||||
contentType = "application/pdf";
|
contentType = "application/pdf";
|
||||||
} else if (filePath.endsWith(".png")) {
|
} else if (filePath.endsWith(".png")) {
|
||||||
contentType = "image/png";
|
contentType = "image/png";
|
||||||
} else if (filePath.endsWith("_readability.txt")) {
|
} else if (filePath.endsWith("_readability.json")) {
|
||||||
contentType = "text/plain";
|
contentType = "application/json";
|
||||||
} else {
|
} else {
|
||||||
// if (filePath.endsWith(".jpg"))
|
// if (filePath.endsWith(".jpg"))
|
||||||
contentType = "image/jpeg";
|
contentType = "image/jpeg";
|
||||||
|
|
Ŝarĝante…
Reference in New Issue