From 6952b643ae636a8926776cd2ba5b0a5506d0e135 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 7 Feb 2019 22:16:40 +0100 Subject: [PATCH] note content refactoring, WIP --- src/entities/note.js | 7 +++++++ src/public/stylesheets/style.css | 2 +- src/routes/api/notes.js | 6 +++++- src/services/protected_session.js | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/entities/note.js b/src/entities/note.js index bc4937cdd..faabc4714 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -74,6 +74,13 @@ class Note extends Entity { return noteContent.content; } + /** @returns {Promise<*>} */ + async getJsonContent() { + const content = await this.getContent(); + + return JSON.parse(content); + } + /** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */ isRoot() { return this.noteId === 'root'; diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index b460c32d1..ad46a2bd3 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -99,7 +99,7 @@ body { font-family: var(--main-font-family); } -input, select { +input, select, textarea { color: var(--input-text-color) !important; background: var(--input-background-color) !important; } diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index 7112e8ef4..a7e70b4a9 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -12,10 +12,14 @@ async function getNote(req) { return [404, "Note " + noteId + " has not been found."]; } - if (note.mime.startsWith('text/')) { + if (["text", "code", "relation-map"].includes(note.type) || note.mime.startsWith('text/')) { const noteContent = await note.getNoteContent(); noteContent.content = noteContent.content.toString("UTF-8"); + + if (note.type === 'file') { + noteContent.content = noteContent.content.substr(0, 10000); + } } return note; diff --git a/src/services/protected_session.js b/src/services/protected_session.js index be0b60c97..83b877aff 100644 --- a/src/services/protected_session.js +++ b/src/services/protected_session.js @@ -52,7 +52,7 @@ function decryptNote(note) { } if (note.title) { - note.title = decryptNoteTitle(note.noteId) + note.title = decryptNoteTitle(note.noteId, note.title); } }