Skip to content

Build your personal knowledge base with Trilium Notes

use trilium version number in asset paths to avoid caching issues

zadam75bd38885b6e
diff --git a/src/app.js b/src/app.js
index 739c79fb3d..c98d155911 100644
--- a/src/app.js
+++ b/src/app.js
@@ -39,8 +39,11 @@ app.use(express.static(path.join(__dirname, 'public/root')));
app.use(`/${assetPath}/app`, express.static(path.join(__dirname, 'public/app')));
app.use(`/${assetPath}/app-dist`, express.static(path.join(__dirname, 'public/app-dist')));
app.use(`/${assetPath}/fonts`, express.static(path.join(__dirname, 'public/fonts')));
+app.use(`/assets/vX/fonts`, express.static(path.join(__dirname, 'public/fonts')));
app.use(`/${assetPath}/stylesheets`, express.static(path.join(__dirname, 'public/stylesheets')));
+app.use(`/assets/vX/stylesheets`, express.static(path.join(__dirname, 'public/stylesheets')));
app.use(`/${assetPath}/libraries`, express.static(path.join(__dirname, '..', 'libraries')));
+app.use(`/assets/vX/libraries`, express.static(path.join(__dirname, '..', 'libraries')));
// excalidraw-view mode in shared notes
app.use(`/${assetPath}/node_modules/react/umd/react.production.min.js`, express.static(path.join(__dirname, '..', 'node_modules/react/umd/react.production.min.js')));
app.use(`/${assetPath}/node_modules/react-dom/umd/react-dom.production.min.js`, express.static(path.join(__dirname, '..', 'node_modules/react-dom/umd/react-dom.production.min.js')));
@@ -48,6 +51,7 @@ app.use(`/${assetPath}/node_modules/react-dom/umd/react-dom.production.min.js`,
app.use(`/node_modules/@excalidraw/excalidraw/dist/`, express.static(path.join(__dirname, '..', 'node_modules/@excalidraw/excalidraw/dist/')));
app.use(`/${assetPath}/node_modules/@excalidraw/excalidraw/dist/`, express.static(path.join(__dirname, '..', 'node_modules/@excalidraw/excalidraw/dist/')));
app.use(`/${assetPath}/images`, express.static(path.join(__dirname, '..', 'images')));
+app.use(`/assets/vX/images`, express.static(path.join(__dirname, '..', 'images')));
const sessionParser = session({
secret: sessionSecret,
resave: false, // true forces the session to be saved back to the session store, even if the session was never modified during the request.
diff --git a/src/public/manifest.webmanifest b/src/public/manifest.webmanifest
index 1468961a89..c0966987bf 100644
--- a/src/public/manifest.webmanifest
+++ b/src/public/manifest.webmanifest
@@ -7,7 +7,7 @@
"scope": "./",
"start_url": "./",
"icons": [{
- "src": "images/app-icons/ios/apple-touch-icon.png",
+ "src": "assets/vX/images/app-icons/ios/apple-touch-icon.png",
"sizes": "180x180",
"type": "image/png"
}]
diff --git a/src/routes/api/branches.js b/src/routes/api/branches.js
index 9292de5c8d..a44a93f1eb 100644
--- a/src/routes/api/branches.js
+++ b/src/routes/api/branches.js
@@ -191,6 +191,11 @@ function deleteBranch(req) {
const last = req.query.last === 'true';
const eraseNotes = req.query.eraseNotes === 'true';
const branch = becca.getBranch(req.params.branchId);
+
+ if (!branch) {
+ return [404, `Branch ${req.params.branchId} not found`];
+ }
+
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
const deleteId = utils.randomString(10);
diff --git a/src/share/content_renderer.js b/src/share/content_renderer.js
index c6bc914be4..a795ee084a 100644
--- a/src/share/content_renderer.js
+++ b/src/share/content_renderer.js
@@ -1,7 +1,16 @@
const {JSDOM} = require("jsdom");
const shaca = require("./shaca/shaca");
+const assetPath = require("../services/asset_path");
function getContent(note) {
+ if (note.isProtected) {
+ return {
+ header: '',
+ content: '<p>Protected note cannot be displayed</p>',
+ isEmpty: false
+ };
+ }
+
let content = note.getContent();
let header = '';
let isEmpty = false;
@@ -36,10 +45,10 @@ function getContent(note) {
if (content.includes(`<span class="math-tex">`)) {
header += `
-<script src="../../libraries/katex/katex.min.js"></script>
-<link rel="stylesheet" href="../../libraries/katex/katex.min.css">
-<script src="../../libraries/katex/auto-render.min.js"></script>
-<script src="../../libraries/katex/mhchem.min.js"></script>
+<script src="../../${assetPath}/libraries/katex/katex.min.js"></script>
+<link rel="stylesheet" href="../../${assetPath}/libraries/katex/katex.min.css">
+<script src="../../${assetPath}/libraries/katex/auto-render.min.js"></script>
+<script src="../../${assetPath}/libraries/katex/mhchem.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.getElementById('content'));
@@ -69,7 +78,7 @@ document.addEventListener("DOMContentLoaded", function() {
<summary>Chart source</summary>
<pre>${content}</pre>
</details>`
- header += `<script src="../../libraries/mermaid.min.js"></script>`;
+ header += `<script src="../../${assetPath}/libraries/mermaid.min.js"></script>`;
}
else if (note.type === 'image') {
content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`;
@@ -89,9 +98,9 @@ document.addEventListener("DOMContentLoaded", function() {
header += `<script>
window.EXCALIDRAW_ASSET_PATH = window.location.origin + "/node_modules/@excalidraw/excalidraw/dist/";
</script>`;
- header += `<script src="../../node_modules/react/umd/react.production.min.js"></script>`;
- header += `<script src="../../node_modules/react-dom/umd/react-dom.production.min.js"></script>`;
- header += `<script src="../../node_modules/@excalidraw/excalidraw/dist/excalidraw.production.min.js"></script>`;
+ header += `<script src="../../${assetPath}/node_modules/react/umd/react.production.min.js"></script>`;
+ header += `<script src="../../${assetPath}/node_modules/react-dom/umd/react-dom.production.min.js"></script>`;
+ header += `<script src="../../${assetPath}/node_modules/@excalidraw/excalidraw/dist/excalidraw.production.min.js"></script>`;
header += `<style>
.excalidraw-wrapper {
diff --git a/src/share/shaca/entities/note.js b/src/share/shaca/entities/note.js
index 1833ca0df7..27f54fc44e 100644
--- a/src/share/shaca/entities/note.js
+++ b/src/share/shaca/entities/note.js
@@ -11,19 +11,21 @@ const CREDENTIALS = 'shareCredentials';
const isCredentials = attr => attr.type === 'label' && attr.name === CREDENTIALS;
class Note extends AbstractEntity {
- constructor([noteId, title, type, mime, utcDateModified]) {
+ constructor([noteId, title, type, mime, utcDateModified, isProtected]) {
super();
/** @param {string} */
this.noteId = noteId;
/** @param {string} */
- this.title = title;
+ this.title = isProtected ? "[protected]" : title;
/** @param {string} */
this.type = type;
/** @param {string} */
this.mime = mime;
/** @param {string} */
this.utcDateModified = utcDateModified; // used for caching of images
+ /** @param {boolean} */
+ this.isProtected = isProtected;
/** @param {Branch[]} */
this.parentBranches = [];
@@ -65,7 +67,7 @@ class Note extends AbstractEntity {
return this.getChildBranches()
.filter(branch => !branch.isHidden)
.map(branch => branch.getNote())
- .filter(childNote => !childNote.hasLabel('shareHiddenFromTree') && !childNote.isProtected);
+ .filter(childNote => !childNote.hasLabel('shareHiddenFromTree'));
}
hasChildren() {
diff --git a/src/share/shaca/shaca_loader.js b/src/share/shaca/shaca_loader.js
index 92642f1730..3e6d457545 100644
--- a/src/share/shaca/shaca_loader.js
+++ b/src/share/shaca/shaca_loader.js
@@ -21,7 +21,7 @@ function load() {
SELECT ?
UNION
SELECT branches.noteId FROM branches
- JOIN tree ON branches.parentNoteId = tree.noteId
+ JOIN tree ON branches.parentNoteId = tree.noteId
WHERE branches.isDeleted = 0
)
SELECT noteId FROM tree`, [shareRoot.SHARE_ROOT_NOTE_ID]);
@@ -35,7 +35,7 @@ function load() {
const noteIdStr = noteIds.map(noteId => `'${noteId}'`).join(",");
const rawNoteRows = sql.getRawRows(`
- SELECT noteId, title, type, mime, utcDateModified
+ SELECT noteId, title, type, mime, utcDateModified, isProtected
FROM notes
WHERE isDeleted = 0
AND noteId IN (${noteIdStr})`);