mirror of
https://github.com/zadam/trilium.git
synced 2025-01-28 01:50:46 +08:00
use trilium version number in asset paths to avoid caching issues
This commit is contained in:
parent
b499640db8
commit
75bd38885b
6 changed files with 34 additions and 14 deletions
src
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
}]
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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})`);
|
||||
|
|
Loading…
Reference in a new issue