1
1
Fork 0
mirror of https://github.com/zadam/trilium.git synced 2025-01-24 07:59:08 +08:00

removed unused clipper image API (migrated to clippings)

This commit is contained in:
zadam 2019-07-18 22:35:16 +02:00
parent e825abf893
commit 97219aa12e
3 changed files with 2 additions and 49 deletions

View file

@ -31,7 +31,7 @@
"dayjs": "1.8.15",
"debug": "4.1.1",
"ejs": "2.6.2",
"electron-context-menu": "^0.13.0",
"electron-context-menu": "0.13.0",
"electron-debug": "3.0.1",
"electron-dl": "1.14.0",
"electron-find": "1.0.6",
@ -56,7 +56,7 @@
"node-abi": "2.9.0",
"open": "6.4.0",
"pngjs": "3.4.0",
"portscanner": "^2.2.0",
"portscanner": "2.2.0",
"rand-token": "0.4.0",
"rcedit": "2.0.0",
"rimraf": "2.6.3",

View file

@ -99,51 +99,6 @@ async function addImagesToNote(images, note, content) {
return rewrittenContent;
}
async function createImage(req) {
let {dataUrl, title, imageUrl, pageUrl} = req.body;
if (!dataUrl) {
// this is image inlined into the src attribute so there isn't any source image URL
dataUrl = imageUrl;
imageUrl = null;
}
if (!dataUrl.startsWith("data:image/")) {
const message = "Unrecognized prefix: " + dataUrl.substr(0, Math.min(dataUrl.length, 100));
log.info(message);
return [400, message];
}
if (!title && imageUrl) {
title = path.basename(imageUrl);
}
if (!title) {
title = "clipped image";
}
const buffer = Buffer.from(dataUrl.split(",")[1], 'base64');
const todayNote = await dateNoteService.getDateNote(dateUtils.localNowDate());
const {note} = await imageService.saveImage(buffer, title, todayNote.noteId, true);
await note.setLabel('clipType', 'image');
if (imageUrl) {
await note.setLabel('imageUrl', imageUrl);
}
if (pageUrl) {
await note.setLabel('pageUrl', pageUrl);
}
return {
noteId: note.noteId
};
}
async function openNote(req) {
if (utils.isElectron()) {
messagingService.sendMessageToAllClients({
@ -171,7 +126,6 @@ async function handshake() {
module.exports = {
createNote,
createImage,
addClipping,
openNote,
handshake

View file

@ -232,7 +232,6 @@ function register(app) {
route(GET, '/api/clipper/handshake', clipperMiddleware, clipperRoute.handshake, apiResultHandler);
route(POST, '/api/clipper/clippings', clipperMiddleware, clipperRoute.addClipping, apiResultHandler);
route(POST, '/api/clipper/notes', clipperMiddleware, clipperRoute.createNote, apiResultHandler);
route(POST, '/api/clipper/image', clipperMiddleware, clipperRoute.createImage, apiResultHandler);
route(POST, '/api/clipper/open/:noteId', clipperMiddleware, clipperRoute.openNote, apiResultHandler);
app.use('', router);