From d73da33b081a0027fbc366ea63873725d805f91b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Aug 2022 02:43:09 +0300 Subject: [PATCH 1/8] Fix max content width not working (fixes #3056) --- src/public/app/widgets/note_wrapper.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/public/app/widgets/note_wrapper.js b/src/public/app/widgets/note_wrapper.js index 8b02daa2a..cae922a3a 100644 --- a/src/public/app/widgets/note_wrapper.js +++ b/src/public/app/widgets/note_wrapper.js @@ -10,12 +10,6 @@ export default class NoteWrapperWidget extends FlexContainer { .collapsible(); } - doRender() { - super.doRender(); - - this.$widget.addClass("note-split"); - } - setNoteContextEvent({noteContext}) { this.noteContext = noteContext; @@ -42,6 +36,7 @@ export default class NoteWrapperWidget extends FlexContainer { return; } + this.$widget.addClass("note-split"); this.$widget.toggleClass("full-content-width", ['image', 'mermaid', 'book', 'render', 'canvas', 'web-view'].includes(note.type) || !!note?.hasLabel('fullContentWidth') From d1f3ce0957b967a99234c1d67be21c40c14762d2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Aug 2022 04:01:21 +0300 Subject: [PATCH 2/8] Fix UTF-8 file name encoding for uploads (fixes #3013) --- src/routes/routes.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/routes/routes.js b/src/routes/routes.js index 3e2ade7c0..b957139fe 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -4,7 +4,14 @@ const setupRoute = require('./setup'); const loginRoute = require('./login'); const indexRoute = require('./index'); const utils = require('../services/utils'); -const multer = require('multer')(); +const multer = require('multer')({ + fileFilter: (req, file, cb) => { + // UTF-8 file names are not well decoded by multer/busboy, so we handle the conversion on our side. + // See https://github.com/expressjs/multer/pull/1102. + file.originalname = Buffer.from(file.originalname, "latin1").toString("utf-8"); + cb(null, true); + } +}); // API routes const treeApiRoute = require('./api/tree'); From ddb57e35f3c8ef0631e1c10b213f106f2cfc200f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Aug 2022 04:30:00 +0300 Subject: [PATCH 3/8] Fix relation map crash on missing inverse pair (fixes #3055) --- src/routes/api/notes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index ccd6dec0e..bb4935303 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -181,6 +181,7 @@ function getRelationMap(req) { if (def.inverseRelation) { resp.inverseRelations[relationDefinition.getDefinedName()] = def.inverseRelation; + resp.inverseRelations[def.inverseRelation] = relationDefinition.getDefinedName(); } } } From 65942213de11af8c9185e5f6a9492c99b7ac774e Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Mon, 15 Aug 2022 12:01:55 -0400 Subject: [PATCH 4/8] Add Flatpak to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index edea86588..746a3e7e3 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ Trilium is provided as either desktop application (Linux and Windows) or web app * If you want to install Trilium on server, follow [this page](https://github.com/zadam/trilium/wiki/Server-installation). * Currently only recent Chrome and Firefox are supported (tested) browsers. +Trilium is also provided as a Flatpak: + +[](https://flathub.org/apps/details/com.github.zadam.trilium) + ## Documentation [See wiki for complete list of documentation pages.](https://github.com/zadam/trilium/wiki/) From 10676a8d0cf09814c28ccf28f4cace019e6103a7 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Wed, 17 Aug 2022 15:18:34 -0400 Subject: [PATCH 5/8] Add shareDescription --- bin/tpl/anonymize-database.sql | 4 ++-- src/public/app/widgets/attribute_widgets/attribute_detail.js | 1 + src/services/builtin_attributes.js | 1 + src/views/share/page.ejs | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/tpl/anonymize-database.sql b/bin/tpl/anonymize-database.sql index e7e061047..94c0140f7 100644 --- a/bin/tpl/anonymize-database.sql +++ b/bin/tpl/anonymize-database.sql @@ -5,8 +5,8 @@ UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; -UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND name NOT IN('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarked', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); -UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN ('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarked', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); +UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND name NOT IN('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarked', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); +UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN ('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarked', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered'; UPDATE options SET value = 'anonymized' WHERE name IN ('documentId', 'documentSecret', 'encryptedDataKey', diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index 0d609b65c..98cebd523 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -216,6 +216,7 @@ const ATTR_HELP = { "shareAlias": "define an alias using which the note will be available under https://your_trilium_host/share/[your_alias]", "shareOmitDefaultCss": "default share page CSS will be omitted. Use when you make extensive styling changes.", "shareRoot": "marks note which is served on /share root.", + "shareDescription": "define text to be added to the HTML meta tag for description", "shareRaw": "note will be served in its raw format, without HTML wrapper", "shareDisallowRobotIndexing": `will forbid robot indexing of this note via X-Robots-Tag: noindex header`, "shareCredentials": "require credentials to access this shared note. Value is expected to be in format 'username:password'. Don't forget to make this inheritable to apply to child-notes/images.", diff --git a/src/services/builtin_attributes.js b/src/services/builtin_attributes.js index 6be9888a9..9c0a6b853 100644 --- a/src/services/builtin_attributes.js +++ b/src/services/builtin_attributes.js @@ -47,6 +47,7 @@ module.exports = [ { type: 'label', name: 'shareAlias' }, { type: 'label', name: 'shareOmitDefaultCss' }, { type: 'label', name: 'shareRoot' }, + { type: 'label', name: 'shareDescription' }, { type: 'label', name: 'shareRaw' }, { type: 'label', name: 'shareDisallowRobotIndexing' }, { type: 'label', name: 'shareCredentials' }, diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs index d20dfdc27..6cbac27a1 100644 --- a/src/views/share/page.ejs +++ b/src/views/share/page.ejs @@ -2,6 +2,10 @@ + <% if (note.hasLabel("shareDescription")) { %> + "> + <% } %> + <% if (note.hasRelation("shareFavicon")) { %> /download"> From c85ec957ecf6721a55416838f4feeb737b5cfd84 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Thu, 18 Aug 2022 23:12:58 -0400 Subject: [PATCH 6/8] Filter excludeFromNoteMap from backlinks --- src/routes/api/note_map.js | 2 +- src/routes/api/notes.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.js index be07f3fe4..45b438d89 100644 --- a/src/routes/api/note_map.js +++ b/src/routes/api/note_map.js @@ -299,7 +299,7 @@ function getBacklinks(req) { let backlinksWithExcerptCount = 0; - return backlinks.map(backlink => { + return backlinks.filter(note => !note.getNote().hasLabel('excludeFromNoteMap')).map(backlink => { const sourceNote = backlink.note; if (sourceNote.type !== 'text' || backlinksWithExcerptCount > 50) { diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index bb4935303..d21addaad 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -315,7 +315,7 @@ function getBacklinkCount(req) { } else { return { - count: note.getTargetRelations().length + count: note.getTargetRelations().filter(note => !note.getNote().hasLabel('excludeFromNoteMap')).length }; } } From 8e7d26bf4f77bc0e983240661263b63318755db6 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Sat, 20 Aug 2022 17:30:35 -0400 Subject: [PATCH 7/8] Add compression --- src/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app.js b/src/app.js index 0b984448c..4673013f8 100644 --- a/src/app.js +++ b/src/app.js @@ -5,6 +5,7 @@ const favicon = require('serve-favicon'); const cookieParser = require('cookie-parser'); const helmet = require('helmet'); const session = require('express-session'); +const compression = require('compression') const FileStore = require('session-file-store')(session); const sessionSecret = require('./services/session_secret'); const dataDir = require('./services/data_dir'); @@ -18,6 +19,9 @@ const app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); +// add compression +app.use(compression()) + app.use(helmet({ hidePoweredBy: false, // errors out in electron contentSecurityPolicy: false, From 84fc00465e60186951d4eb0255c23613b5c273f2 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Sat, 20 Aug 2022 20:33:10 -0400 Subject: [PATCH 8/8] Fix minor typo --- src/public/app/widgets/search_options/ancestor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/search_options/ancestor.js b/src/public/app/widgets/search_options/ancestor.js index 9372e52fa..ea74b76a0 100644 --- a/src/public/app/widgets/search_options/ancestor.js +++ b/src/public/app/widgets/search_options/ancestor.js @@ -13,7 +13,7 @@ const TPL = `
depth: