Compare commits

..

17 Commits

Author SHA1 Message Date
zadam
ae17e4dc60 release 0.30.4 2019-03-07 22:40:05 +01:00
zadam
02eddc347a fix export of protected notes to tar archive, fixes #432 2019-03-07 22:00:23 +01:00
zadam
ee58bf3d5c fix bundle execution error handling 2019-03-07 20:51:55 +01:00
zadam
ecbaffa5f3 return focus back to note detail after quitting add link dialog 2019-03-07 20:45:32 +01:00
zadam
fe86c09f22 make sure date label is always created with YYYY-MM-DD and not the rest of date time 2019-03-05 20:49:39 +01:00
zadam
c8e01d6cce pretty print JSON into note content 2019-03-05 20:44:50 +01:00
zadam
7c404f03db unused param 2019-03-04 22:18:27 +01:00
zadam
ed1cf6aad5 fix passing of startNote and originEntity to backend script API 2019-03-04 21:17:34 +01:00
zadam
9703fd61e2 protected note's shield background now looks better on the dark themes 2019-03-04 20:53:57 +01:00
zadam
16790e388b recent changes should show titles of protected notes correctly when in protected session 2019-03-04 20:44:20 +01:00
zadam
b48474998b release 0.30.3-beta 2019-03-03 20:47:50 +01:00
zadam
95d8f07458 debugging info for image shrinking 2019-03-03 20:41:03 +01:00
zadam
e628c30c89 fix OPML export to include correct OPML version 2019-03-03 19:43:30 +01:00
zadam
52a8aae74f moved test enex files to separate repo 2019-03-03 19:40:47 +01:00
zadam
54b5898582 detect mime types from the filename instead of relying on upload mime type 2019-03-03 00:25:31 +01:00
zadam
64974d75d5 added sync fill for note_contents 2019-03-02 19:59:32 +01:00
zadam
bd118027fb note content is also part of hash check 2019-03-02 12:40:46 +01:00
19 changed files with 63 additions and 5561 deletions

View File

@@ -0,0 +1,2 @@
INSERT OR REPLACE INTO sync (entityName, entityId, sourceId, syncDate)
SELECT 'note_contents', noteContentId, '', '2019-03-02T18:07:29.182Z' FROM note_contents;

47
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "trilium",
"version": "0.30.1-beta",
"version": "0.30.3-beta",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -4935,9 +4935,9 @@
}
},
"get-port": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-4.1.0.tgz",
"integrity": "sha512-4/fqAYrzrzOiqDrdeZRKXGdTGgbkfTEumGlNQPeP6Jy8w0PzN9mzeNQ3XgHaTNie8pQ3hOUkrwlZt2Fzk5H9mA=="
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-4.2.0.tgz",
"integrity": "sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw=="
},
"get-proxy": {
"version": "1.1.0",
@@ -11047,11 +11047,11 @@
}
},
"tar-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.0.0.tgz",
"integrity": "sha512-n2vtsWshZOVr/SY4KtslPoUlyNh06I2SGgAOCZmquCEjlbV/LjY2CY80rDtdQRHFOYXNlgBDo6Fr3ww2CWPOtA==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.0.1.tgz",
"integrity": "sha512-I6OJF7wE62BC6zNPdHDtseK0D0187PBjbKSLYY4ffvVkBM6tyBn2O9plDvVM2229/mozfEL/X3++qSvYYQE2xw==",
"requires": {
"bl": "^2.2.0",
"bl": "^3.0.0",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
@@ -11059,34 +11059,17 @@
},
"dependencies": {
"bl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-2.2.0.tgz",
"integrity": "sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz",
"integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==",
"requires": {
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
},
"dependencies": {
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
}
"readable-stream": "^3.0.1"
}
},
"readable-stream": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.1.tgz",
"integrity": "sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz",
"integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",

View File

@@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.30.2-beta",
"version": "0.30.4",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {
@@ -37,7 +37,7 @@
"express-session": "1.15.6",
"file-type": "10.8.0",
"fs-extra": "7.0.1",
"get-port": "4.1.0",
"get-port": "4.2.0",
"helmet": "3.15.1",
"html": "1.0.0",
"image-type": "3.0.0",
@@ -62,7 +62,7 @@
"session-file-store": "1.2.0",
"simple-node-logger": "18.12.22",
"sqlite": "3.0.2",
"tar-stream": "2.0.0",
"tar-stream": "2.0.1",
"turndown": "5.0.3",
"unescape": "1.0.1",
"ws": "6.1.4",

View File

@@ -106,7 +106,7 @@ class Note extends Entity {
/** @returns {Promise} */
async setJsonContent(content) {
await this.setContent(JSON.stringify(content));
await this.setContent(JSON.stringify(content, null, '\t'));
}
/** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fafafa" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shield"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-opacity="0.03" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shield"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 296 B

View File

@@ -137,6 +137,10 @@ function linkTypeChanged() {
$linkTypes.change(linkTypeChanged);
// return back focus to note text detail after quitting add link
// the problem is that cursor position is reset
$dialog.on("hidden.bs.modal", () => noteDetailText.focus());
export default {
showDialog
};

View File

@@ -9,6 +9,8 @@ async function getAndExecuteBundle(noteId, originEntity = null) {
}
async function executeBundle(bundle, originEntity) {
console.log(bundle);
const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity);
try {
@@ -17,7 +19,7 @@ async function executeBundle(bundle, originEntity) {
}.call(apiContext));
}
catch (e) {
infoService.showAndLogError(`Execution of script "${bundle.note.title}" (${bundle.note.noteId}) failed with error: ${e.message}`);
infoService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`);
}
}

View File

@@ -17,9 +17,13 @@ async function getRecentChanges() {
dateModifiedTo DESC
LIMIT 1000`);
if (!protectedSessionService.isProtectedSessionAvailable()) {
for (const change of recentChanges) {
if (change.current_isProtected) {
for (const change of recentChanges) {
if (change.current_isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
change.title = protectedSessionService.decryptNoteTitle(change.noteId, change.title);
change.current_title = protectedSessionService.decryptNoteTitle(change.noteId, change.current_title);
}
else {
change.title = change.current_title = "[Protected]";
}
}

View File

@@ -4,8 +4,8 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 125;
const SYNC_VERSION = 5;
const APP_DB_VERSION = 126;
const SYNC_VERSION = 6;
module.exports = {
appVersion: packageJson.version,

View File

@@ -1 +1 @@
module.exports = { buildDate:"2019-02-28T22:33:33+01:00", buildRevision: "b5283d58bb937dacd8a890a40e09657c6d489364" };
module.exports = { buildDate:"2019-03-07T22:40:05+01:00", buildRevision: "02eddc347abebce63a8882f6f83ac73655005849" };

View File

@@ -8,6 +8,7 @@ const messagingService = require('./messaging');
const ApiToken = require('../entities/api_token');
const Branch = require('../entities/branch');
const Note = require('../entities/note');
const NoteContent = require('../entities/note_content');
const Attribute = require('../entities/attribute');
const NoteRevision = require('../entities/note_revision');
const RecentNote = require('../entities/recent_note');
@@ -33,6 +34,7 @@ async function getHashes() {
const hashes = {
notes: await getHash(Note),
note_contents: await getHash(NoteContent),
branches: await getHash(Branch),
note_revisions: await getHash(NoteRevision),
recent_notes: await getHash(RecentNote),

View File

@@ -116,7 +116,7 @@ async function getDateNote(dateStr) {
dateNote = await createNote(monthNote.noteId, noteTitle);
}
await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr);
await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10));
}
return dateNote;

View File

@@ -54,7 +54,7 @@ async function exportToOpml(exportContext, branch, version, res) {
res.setHeader('Content-Type', 'text/x-opml');
res.write(`<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<opml version="${version}">
<head>
<title>Trilium export</title>
</head>

View File

@@ -13,7 +13,7 @@ const imageType = require('image-type');
const sanitizeFilename = require('sanitize-filename');
async function saveImage(buffer, originalName, parentNoteId, shrinkImageSwitch) {
const finalImageBuffer = shrinkImageSwitch ? await shrinkImage(buffer) : buffer;
const finalImageBuffer = shrinkImageSwitch ? await shrinkImage(buffer, originalName) : buffer;
const imageFormat = imageType(finalImageBuffer);
@@ -41,14 +41,14 @@ async function saveImage(buffer, originalName, parentNoteId, shrinkImageSwitch)
};
}
async function shrinkImage(buffer) {
async function shrinkImage(buffer, originalName) {
const resizedImage = await resize(buffer);
let finalImageBuffer;
try {
finalImageBuffer = await optimize(resizedImage);
} catch (e) {
log.error(e.message + e.stack);
log.error("Failed to optimize image '" + originalName + "\nStack: " + e.stack);
finalImageBuffer = resizedImage;
}
return finalImageBuffer;

View File

@@ -5,6 +5,7 @@ const imageService = require('../../services/image');
const protectedSessionService = require('../protected_session');
const commonmark = require('commonmark');
const path = require('path');
const mimeTypes = require('mime-types');
const CODE_MIME_TYPES = {
'text/plain': true,
@@ -47,21 +48,23 @@ const CODE_MIME_TYPES = {
};
async function importSingleFile(importContext, file, parentNote) {
const mime = mimeTypes.lookup(file.originalname);
if (importContext.textImportedAsText) {
if (file.mimetype === 'text/html') {
if (mime === 'text/html') {
return await importHtml(importContext, file, parentNote);
} else if (['text/markdown', 'text/x-markdown'].includes(file.mimetype)) {
} else if (['text/markdown', 'text/x-markdown'].includes(mime)) {
return await importMarkdown(importContext, file, parentNote);
} else if (file.mimetype === 'text/plain') {
} else if (mime === 'text/plain') {
return await importPlainText(importContext, file, parentNote);
}
}
if (importContext.codeImportedAsCode && file.mimetype in CODE_MIME_TYPES) {
if (importContext.codeImportedAsCode && mime in CODE_MIME_TYPES) {
return await importCodeNote(importContext, file, parentNote);
}
if (["image/jpeg", "image/gif", "image/png"].includes(file.mimetype)) {
if (["image/jpeg", "image/gif", "image/png"].includes(mime)) {
return await importImage(file, parentNote, importContext);
}
@@ -84,7 +87,7 @@ async function importFile(importContext, file, parentNote) {
target: 'into',
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
type: 'file',
mime: file.mimetype,
mime: mimeTypes.lookup(originalName),
attributes: [
{ type: "label", name: "originalFileName", value: originalName },
{ type: "label", name: "fileSize", value: size }
@@ -99,7 +102,8 @@ async function importFile(importContext, file, parentNote) {
async function importCodeNote(importContext, file, parentNote) {
const title = getFileNameWithoutExtension(file.originalname);
const content = file.buffer.toString("UTF-8");
const mime = CODE_MIME_TYPES[file.mimetype] === true ? file.mimetype : CODE_MIME_TYPES[file.mimetype];
const detectedMime = mimeTypes.lookup(file.originalname);
const mime = CODE_MIME_TYPES[detectedMime] === true ? detectedMime : CODE_MIME_TYPES[detectedMime];
const {note} = await noteService.createNote(parentNote.noteId, title, content, {
type: 'code',

View File

@@ -15,7 +15,7 @@ function setDataKey(decryptedDataKey) {
}
function setProtectedSessionId(req) {
cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id']);
cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id'] || req.query.protectedSessionId);
}
function getProtectedSessionId() {
@@ -62,7 +62,9 @@ function decryptNoteContent(noteContent) {
}
try {
noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content);
if (noteContent.content != null) {
noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content.toString());
}
}
catch (e) {
e.message = `Cannot decrypt note content for noteContentId=${noteContent.noteContentId}: ` + e.message;

View File

@@ -65,10 +65,10 @@ async function executeScript(script, params, startNoteId, currentNoteId, originE
const bundle = await getScriptBundle(currentNote);
return await executeBundle(bundle, startNote, originEntity);
return await executeBundle(bundle, { startNote, originEntity });
}
async function execute(ctx, script, params = []) {
async function execute(ctx, script) {
// scripts run as "server" sourceId so clients recognize the changes as "foreign" and update themselves
cls.namespace.set('sourceId', sourceIdService.getCurrentSourceId());

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd">
<en-export export-date="20181101T193909Z" application="Evernote/Windows" version="6.x">
<note><title>Note</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note><div>this is a note in a notebook in a stack</div></en-note>]]></content><created>20181101T193703Z</created><updated>20181101T193712Z</updated><note-attributes><author>Adam Zivner</author><source>desktop.win</source><source-application>evernote.win32</source-application></note-attributes></note></en-export>

File diff suppressed because it is too large Load Diff