").append(
- $("").text("File size:"),
- $(" | ").text(revisionItem.contentLength + " bytes")
- ))
- );
+ else if (revisionItem.type === 'file') {
+ const $table = $("")
+ .append($("").append(
+ $("").text("MIME: "),
+ $(" | ").text(revisionItem.mime)
+ ))
+ .append($(" | ").append(
+ $("").text("File size:"),
+ $(" | ").text(revisionItem.contentLength + " bytes")
+ ));
+
+ if (fullNoteRevision.content) {
+ $table.append($(" | ").append(
+ $("").text("Preview:"),
+ $(" | ").append(
+ $('')
+ .text(fullNoteRevision.content)
+ )
+ ));
+ }
+
+ $content.html($table);
}
else {
$content.text("Preview isn't available for this note type.");
diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js
index f8f3bcdee..1f1560d74 100644
--- a/src/public/javascripts/services/utils.js
+++ b/src/public/javascripts/services/utils.js
@@ -96,6 +96,8 @@ function getHost() {
}
function download(url) {
+ url += '?' + Date.now(); // don't use cache
+
if (isElectron()) {
const remote = require('electron').remote;
@@ -227,7 +229,6 @@ export default {
assertArguments,
escapeHtml,
stopWatch,
- formatValueWithWhitespace,
formatLabel,
getHost,
download,
diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.js
index 4177586f8..62f0c6c7d 100644
--- a/src/routes/api/note_revisions.js
+++ b/src/routes/api/note_revisions.js
@@ -19,7 +19,14 @@ async function getNoteRevisions(req) {
async function getNoteRevision(req) {
const noteRevision = await repository.getNoteRevision(req.params.noteRevisionId);
- if (noteRevision.type !== 'file') {
+ if (noteRevision.type === 'file') {
+ if (noteRevision.isStringNote()) {
+ await noteRevision.getContent();
+
+ noteRevision.content = noteRevision.content.substr(0, 10000);
+ }
+ }
+ else {
await noteRevision.getContent();
if (noteRevision.content && noteRevision.type === 'image') {
diff --git a/src/services/note_revisions.js b/src/services/note_revisions.js
index 24f40e580..8548bf9f8 100644
--- a/src/services/note_revisions.js
+++ b/src/services/note_revisions.js
@@ -9,8 +9,13 @@ const dateUtils = require('../services/date_utils');
async function protectNoteRevisions(note) {
for (const revision of await note.getRevisions()) {
if (note.isProtected !== revision.isProtected) {
+ const content = await revision.getContent();
+
revision.isProtected = note.isProtected;
+ // this will force de/encryption
+ await revision.setContent(content);
+
await revision.save();
}
}
| |