save note in clipper

This commit is contained in:
zadam 2019-07-06 16:48:06 +02:00
parent 093dfb4a39
commit 976684a3a8
5 changed files with 39 additions and 41 deletions

View File

@ -1,4 +1,4 @@
FROM node:12.4.0-alpine FROM node:12.6.0-alpine
# Create app directory # Create app directory
WORKDIR /usr/src/app WORKDIR /usr/src/app

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PKG_DIR=dist/trilium-linux-x64-server PKG_DIR=dist/trilium-linux-x64-server
NODE_VERSION=12.4.0 NODE_VERSION=12.6.0
rm -r $PKG_DIR rm -r $PKG_DIR
mkdir $PKG_DIR mkdir $PKG_DIR

6
package-lock.json generated
View File

@ -5287,9 +5287,9 @@
} }
}, },
"file-type": { "file-type": {
"version": "12.0.0", "version": "12.0.1",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-12.0.0.tgz", "resolved": "https://registry.npmjs.org/file-type/-/file-type-12.0.1.tgz",
"integrity": "sha512-VV3aQAyoV/fHl0I9uU3/DGjItgh5nylAoJPHOXkZXHW4nFFrxJnHR2xdVqsqyw/9fqYy80m+tS+Rf77w0FTKqg==" "integrity": "sha512-YIs1E51cmqcmgF38ODjy0+M/l5DyfIIy3vngTOujQr/lXqkaSskfBniaZoZ1HVIpa5FTf5e7hCXS4TzxfNGMRQ=="
}, },
"filename-regex": { "filename-regex": {
"version": "2.0.1", "version": "2.0.1",

View File

@ -38,7 +38,7 @@
"electron-window-state": "5.0.3", "electron-window-state": "5.0.3",
"express": "4.17.1", "express": "4.17.1",
"express-session": "1.16.2", "express-session": "1.16.2",
"file-type": "12.0.0", "file-type": "12.0.1",
"fs-extra": "8.1.0", "fs-extra": "8.1.0",
"get-port": "5.0.0", "get-port": "5.0.0",
"helmet": "3.18.0", "helmet": "3.18.0",

View File

@ -10,22 +10,19 @@ const path = require('path');
const Link = require('../../entities/link'); const Link = require('../../entities/link');
async function createNote(req) { async function createNote(req) {
const {title, html, url, images} = req.body; const {title, content, url, images} = req.body;
const todayNote = await dateNoteService.getDateNote(dateUtils.localNowDate()); const todayNote = await dateNoteService.getDateNote(dateUtils.localNowDate());
const {note} = await noteService.createNote(todayNote.noteId, title, html, { const {note} = await noteService.createNote(todayNote.noteId, title, content);
attributes: [
{ if (url) {
type: 'label', await note.setLabel('sourceUrl', url);
name: 'sourceUrl',
value: url
} }
]
});
let rewrittenHtml = html; let rewrittenContent = content;
if (images) {
for (const {src, dataUrl, imageId} of images) { for (const {src, dataUrl, imageId} of images) {
const filename = path.basename(src); const filename = path.basename(src);
@ -46,12 +43,11 @@ async function createNote(req) {
console.log(`Replacing ${imageId} with ${url}`); console.log(`Replacing ${imageId} with ${url}`);
rewrittenHtml = rewrittenHtml.replace(imageId, url); rewrittenContent = rewrittenContent.replace(imageId, url);
}
} }
console.log("Done", rewrittenHtml); await note.setContent(rewrittenContent);
await note.setContent(rewrittenHtml);
return { return {
noteId: note.noteId noteId: note.noteId
@ -105,6 +101,8 @@ async function openNote(req) {
type: 'open-note', type: 'open-note',
noteId: req.params.noteId noteId: req.params.noteId
}); });
return {};
} }
async function ping(req, res) { async function ping(req, res) {