mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	use trilium version number in asset paths to avoid caching issues
This commit is contained in:
		
							parent
							
								
									b499640db8
								
							
						
					
					
						commit
						75bd38885b
					
				@ -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`, express.static(path.join(__dirname, 'public/app')));
 | 
				
			||||||
app.use(`/${assetPath}/app-dist`, express.static(path.join(__dirname, 'public/app-dist')));
 | 
					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(`/${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(`/${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(`/${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
 | 
					// 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/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')));
 | 
					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(`/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}/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(`/${assetPath}/images`, express.static(path.join(__dirname, '..', 'images')));
 | 
				
			||||||
 | 
					app.use(`/assets/vX/images`, express.static(path.join(__dirname, '..', 'images')));
 | 
				
			||||||
const sessionParser = session({
 | 
					const sessionParser = session({
 | 
				
			||||||
    secret: sessionSecret,
 | 
					    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.
 | 
					    resave: false, // true forces the session to be saved back to the session store, even if the session was never modified during the request.
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@
 | 
				
			|||||||
  "scope": "./",
 | 
					  "scope": "./",
 | 
				
			||||||
  "start_url": "./",
 | 
					  "start_url": "./",
 | 
				
			||||||
  "icons": [{
 | 
					  "icons": [{
 | 
				
			||||||
    "src": "images/app-icons/ios/apple-touch-icon.png",
 | 
					    "src": "assets/vX/images/app-icons/ios/apple-touch-icon.png",
 | 
				
			||||||
    "sizes": "180x180",
 | 
					    "sizes": "180x180",
 | 
				
			||||||
    "type": "image/png"
 | 
					    "type": "image/png"
 | 
				
			||||||
  }]
 | 
					  }]
 | 
				
			||||||
 | 
				
			|||||||
@ -191,6 +191,11 @@ function deleteBranch(req) {
 | 
				
			|||||||
    const last = req.query.last === 'true';
 | 
					    const last = req.query.last === 'true';
 | 
				
			||||||
    const eraseNotes = req.query.eraseNotes === 'true';
 | 
					    const eraseNotes = req.query.eraseNotes === 'true';
 | 
				
			||||||
    const branch = becca.getBranch(req.params.branchId);
 | 
					    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 taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const deleteId = utils.randomString(10);
 | 
					    const deleteId = utils.randomString(10);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,16 @@
 | 
				
			|||||||
const {JSDOM} = require("jsdom");
 | 
					const {JSDOM} = require("jsdom");
 | 
				
			||||||
const shaca = require("./shaca/shaca");
 | 
					const shaca = require("./shaca/shaca");
 | 
				
			||||||
 | 
					const assetPath = require("../services/asset_path");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getContent(note) {
 | 
					function getContent(note) {
 | 
				
			||||||
 | 
					    if (note.isProtected) {
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            header: '',
 | 
				
			||||||
 | 
					            content: '<p>Protected note cannot be displayed</p>',
 | 
				
			||||||
 | 
					            isEmpty: false
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let content = note.getContent();
 | 
					    let content = note.getContent();
 | 
				
			||||||
    let header = '';
 | 
					    let header = '';
 | 
				
			||||||
    let isEmpty = false;
 | 
					    let isEmpty = false;
 | 
				
			||||||
@ -36,10 +45,10 @@ function getContent(note) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (content.includes(`<span class="math-tex">`)) {
 | 
					            if (content.includes(`<span class="math-tex">`)) {
 | 
				
			||||||
                header += `
 | 
					                header += `
 | 
				
			||||||
<script src="../../libraries/katex/katex.min.js"></script>
 | 
					<script src="../../${assetPath}/libraries/katex/katex.min.js"></script>
 | 
				
			||||||
<link rel="stylesheet" href="../../libraries/katex/katex.min.css">
 | 
					<link rel="stylesheet" href="../../${assetPath}/libraries/katex/katex.min.css">
 | 
				
			||||||
<script src="../../libraries/katex/auto-render.min.js"></script>
 | 
					<script src="../../${assetPath}/libraries/katex/auto-render.min.js"></script>
 | 
				
			||||||
<script src="../../libraries/katex/mhchem.min.js"></script>
 | 
					<script src="../../${assetPath}/libraries/katex/mhchem.min.js"></script>
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
document.addEventListener("DOMContentLoaded", function() {
 | 
					document.addEventListener("DOMContentLoaded", function() {
 | 
				
			||||||
    renderMathInElement(document.getElementById('content'));
 | 
					    renderMathInElement(document.getElementById('content'));
 | 
				
			||||||
@ -69,7 +78,7 @@ document.addEventListener("DOMContentLoaded", function() {
 | 
				
			|||||||
    <summary>Chart source</summary>
 | 
					    <summary>Chart source</summary>
 | 
				
			||||||
    <pre>${content}</pre>
 | 
					    <pre>${content}</pre>
 | 
				
			||||||
</details>`
 | 
					</details>`
 | 
				
			||||||
        header += `<script src="../../libraries/mermaid.min.js"></script>`;
 | 
					        header += `<script src="../../${assetPath}/libraries/mermaid.min.js"></script>`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (note.type === 'image') {
 | 
					    else if (note.type === 'image') {
 | 
				
			||||||
        content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`;
 | 
					        content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`;
 | 
				
			||||||
@ -89,9 +98,9 @@ document.addEventListener("DOMContentLoaded", function() {
 | 
				
			|||||||
        header += `<script>
 | 
					        header += `<script>
 | 
				
			||||||
                    window.EXCALIDRAW_ASSET_PATH = window.location.origin + "/node_modules/@excalidraw/excalidraw/dist/";
 | 
					                    window.EXCALIDRAW_ASSET_PATH = window.location.origin + "/node_modules/@excalidraw/excalidraw/dist/";
 | 
				
			||||||
                   </script>`;
 | 
					                   </script>`;
 | 
				
			||||||
        header += `<script src="../../node_modules/react/umd/react.production.min.js"></script>`;
 | 
					        header += `<script src="../../${assetPath}/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="../../${assetPath}/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/@excalidraw/excalidraw/dist/excalidraw.production.min.js"></script>`;
 | 
				
			||||||
        header += `<style>
 | 
					        header += `<style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            .excalidraw-wrapper {
 | 
					            .excalidraw-wrapper {
 | 
				
			||||||
 | 
				
			|||||||
@ -11,19 +11,21 @@ const CREDENTIALS = 'shareCredentials';
 | 
				
			|||||||
const isCredentials = attr => attr.type === 'label' && attr.name === CREDENTIALS;
 | 
					const isCredentials = attr => attr.type === 'label' && attr.name === CREDENTIALS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Note extends AbstractEntity {
 | 
					class Note extends AbstractEntity {
 | 
				
			||||||
    constructor([noteId, title, type, mime, utcDateModified]) {
 | 
					    constructor([noteId, title, type, mime, utcDateModified, isProtected]) {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /** @param {string} */
 | 
					        /** @param {string} */
 | 
				
			||||||
        this.noteId = noteId;
 | 
					        this.noteId = noteId;
 | 
				
			||||||
        /** @param {string} */
 | 
					        /** @param {string} */
 | 
				
			||||||
        this.title = title;
 | 
					        this.title = isProtected ? "[protected]" : title;
 | 
				
			||||||
        /** @param {string} */
 | 
					        /** @param {string} */
 | 
				
			||||||
        this.type = type;
 | 
					        this.type = type;
 | 
				
			||||||
        /** @param {string} */
 | 
					        /** @param {string} */
 | 
				
			||||||
        this.mime = mime;
 | 
					        this.mime = mime;
 | 
				
			||||||
        /** @param {string} */
 | 
					        /** @param {string} */
 | 
				
			||||||
        this.utcDateModified = utcDateModified; // used for caching of images
 | 
					        this.utcDateModified = utcDateModified; // used for caching of images
 | 
				
			||||||
 | 
					        /** @param {boolean} */
 | 
				
			||||||
 | 
					        this.isProtected = isProtected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /** @param {Branch[]} */
 | 
					        /** @param {Branch[]} */
 | 
				
			||||||
        this.parentBranches = [];
 | 
					        this.parentBranches = [];
 | 
				
			||||||
@ -65,7 +67,7 @@ class Note extends AbstractEntity {
 | 
				
			|||||||
        return this.getChildBranches()
 | 
					        return this.getChildBranches()
 | 
				
			||||||
            .filter(branch => !branch.isHidden)
 | 
					            .filter(branch => !branch.isHidden)
 | 
				
			||||||
            .map(branch => branch.getNote())
 | 
					            .map(branch => branch.getNote())
 | 
				
			||||||
            .filter(childNote => !childNote.hasLabel('shareHiddenFromTree') && !childNote.isProtected);
 | 
					            .filter(childNote => !childNote.hasLabel('shareHiddenFromTree'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hasChildren() {
 | 
					    hasChildren() {
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,7 @@ function load() {
 | 
				
			|||||||
            SELECT ?
 | 
					            SELECT ?
 | 
				
			||||||
            UNION
 | 
					            UNION
 | 
				
			||||||
            SELECT branches.noteId FROM branches
 | 
					            SELECT branches.noteId FROM branches
 | 
				
			||||||
                JOIN tree ON branches.parentNoteId = tree.noteId
 | 
					              JOIN tree ON branches.parentNoteId = tree.noteId
 | 
				
			||||||
            WHERE branches.isDeleted = 0
 | 
					            WHERE branches.isDeleted = 0
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        SELECT noteId FROM tree`, [shareRoot.SHARE_ROOT_NOTE_ID]);
 | 
					        SELECT noteId FROM tree`, [shareRoot.SHARE_ROOT_NOTE_ID]);
 | 
				
			||||||
@ -35,7 +35,7 @@ function load() {
 | 
				
			|||||||
    const noteIdStr = noteIds.map(noteId => `'${noteId}'`).join(",");
 | 
					    const noteIdStr = noteIds.map(noteId => `'${noteId}'`).join(",");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const rawNoteRows = sql.getRawRows(`
 | 
					    const rawNoteRows = sql.getRawRows(`
 | 
				
			||||||
        SELECT noteId, title, type, mime, utcDateModified 
 | 
					        SELECT noteId, title, type, mime, utcDateModified, isProtected
 | 
				
			||||||
        FROM notes 
 | 
					        FROM notes 
 | 
				
			||||||
        WHERE isDeleted = 0 
 | 
					        WHERE isDeleted = 0 
 | 
				
			||||||
          AND noteId IN (${noteIdStr})`);
 | 
					          AND noteId IN (${noteIdStr})`);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user