diff --git a/.gitpod.yml b/.gitpod.yml index 8a4a9a03b..8c5fe37ba 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -2,7 +2,7 @@ image: file: .gitpod.dockerfile tasks: - - before: nvm install 16.15.0 && nvm use 16.15.0 + - before: nvm install 16.18.0 && nvm use 16.18.0 init: npm install command: npm run start-server diff --git a/Dockerfile b/Dockerfile index 477dd963b..dd2a2a357 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!! -FROM node:16.15.0-alpine +FROM node:16.18.0-alpine # Create app directory WORKDIR /usr/src/app diff --git a/bin/build-server.sh b/bin/build-server.sh index 1df3e0b54..202cb82a3 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PKG_DIR=dist/trilium-linux-x64-server -NODE_VERSION=16.15.0 +NODE_VERSION=16.18.0 if [ "$1" != "DONTCOPY" ] then diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 22998a749..e63ec9442 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -5,7 +5,7 @@ if [[ $# -eq 0 ]] ; then exit 1 fi -n exec 16.15.0 npm run webpack +n exec 16.18.0 npm run webpack DIR=$1 @@ -30,7 +30,7 @@ cp -r electron.js $DIR/ cp webpack-* $DIR/ # run in subshell (so we return to original dir) -(cd $DIR && n exec 16.15.0 npm install --only=prod) +(cd $DIR && n exec 16.18.0 npm install --only=prod) # cleanup of useless files in dependencies rm -r $DIR/node_modules/image-q/demo diff --git a/dump-db/README.md b/dump-db/README.md index 38f3f42b0..9dd43fbcc 100644 --- a/dump-db/README.md +++ b/dump-db/README.md @@ -6,7 +6,7 @@ It is meant as a last resort solution when the standard mean to access your data ## Installation -This tool requires node.js, testing has been done on 16.15.0, but it will probably work on other versions as well. +This tool requires node.js, testing has been done on 16.18.0, but it will probably work on other versions as well. ``` npm install diff --git a/package-lock.json b/package-lock.json index 37d0fff60..b197bd93c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trilium", - "version": "0.56.0-beta", + "version": "0.56.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trilium", - "version": "0.56.0-beta", + "version": "0.56.1", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { diff --git a/spec/search/note_cache_mocking.js b/spec/search/becca_mocking.js similarity index 100% rename from spec/search/note_cache_mocking.js rename to spec/search/becca_mocking.js diff --git a/spec/search/search.spec.js b/spec/search/search.spec.js index a662c4e8f..e74d48107 100644 --- a/spec/search/search.spec.js +++ b/spec/search/search.spec.js @@ -4,7 +4,7 @@ const Branch = require('../../src/becca/entities/branch'); const SearchContext = require('../../src/services/search/search_context'); const dateUtils = require('../../src/services/date_utils'); const becca = require('../../src/becca/becca'); -const {NoteBuilder, findNoteByTitle, note} = require('./note_cache_mocking'); +const {NoteBuilder, findNoteByTitle, note} = require('./becca_mocking.js'); describe("Search", () => { let rootNote; diff --git a/spec/search/value_extractor.spec.js b/spec/search/value_extractor.spec.js index 583781d66..1e664279f 100644 --- a/spec/search/value_extractor.spec.js +++ b/spec/search/value_extractor.spec.js @@ -1,4 +1,4 @@ -const {note} = require('./note_cache_mocking'); +const {note} = require('./becca_mocking.js'); const ValueExtractor = require('../../src/services/search/value_extractor'); const becca = require('../../src/becca/becca'); const SearchContext = require("../../src/services/search/search_context"); diff --git a/src/app.js b/src/app.js index 4cec105c4..739c79fb3 100644 --- a/src/app.js +++ b/src/app.js @@ -10,6 +10,7 @@ const FileStore = require('session-file-store')(session); const sessionSecret = require('./services/session_secret'); const dataDir = require('./services/data_dir'); const utils = require('./services/utils'); +const assetPath = require('./services/asset_path'); require('./services/handlers'); require('./becca/becca_loader'); @@ -34,14 +35,19 @@ app.use(express.json({limit: '500mb'})); app.use(express.raw({limit: '500mb'})); app.use(express.urlencoded({extended: false})); app.use(cookieParser()); -app.use(express.static(path.join(__dirname, 'public'))); -app.use('/libraries', express.static(path.join(__dirname, '..', 'libraries'))); +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(`/${assetPath}/stylesheets`, express.static(path.join(__dirname, 'public/stylesheets'))); +app.use(`/${assetPath}/libraries`, express.static(path.join(__dirname, '..', 'libraries'))); // excalidraw-view mode in shared notes -app.use('/node_modules/react/umd/react.production.min.js', express.static(path.join(__dirname, '..', 'node_modules/react/umd/react.production.min.js'))); -app.use('/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/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'))); // expose whole dist folder since complete assets are needed in edit and share -app.use('/node_modules/@excalidraw/excalidraw/dist/', express.static(path.join(__dirname, '..', 'node_modules/@excalidraw/excalidraw/dist/'))); -app.use('/images', express.static(path.join(__dirname, '..', 'images'))); +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'))); 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/app/services/glob.js b/src/public/app/services/glob.js index 7a22d4ad3..780818f7e 100644 --- a/src/public/app/services/glob.js +++ b/src/public/app/services/glob.js @@ -64,7 +64,7 @@ function setupGlobs() { }; for (const appCssNoteId of glob.appCssNoteIds || []) { - libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`); + libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`, false); } utils.initHelpButtons($(window)); diff --git a/src/public/app/services/library_loader.js b/src/public/app/services/library_loader.js index 7dbca8e18..eeac0fb44 100644 --- a/src/public/app/services/library_loader.js +++ b/src/public/app/services/library_loader.js @@ -86,6 +86,8 @@ async function requireLibrary(library) { const loadedScriptPromises = {}; async function requireScript(url) { + url = window.glob.assetPath + "/" + url; + if (!loadedScriptPromises[url]) { loadedScriptPromises[url] = $.ajax({ url: url, @@ -97,12 +99,16 @@ async function requireScript(url) { await loadedScriptPromises[url]; } -async function requireCss(url) { +async function requireCss(url, prependAssetPath = true) { const cssLinks = Array .from(document.querySelectorAll('link')) .map(el => el.href); if (!cssLinks.some(l => l.endsWith(url))) { + if (prependAssetPath) { + url = window.glob.assetPath + "/" + url; + } + $('head').append($('').attr('href', url)); } } diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 6562bd6c3..811c2c433 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -16,7 +16,7 @@ const TPL = ` } .global-menu-button { - background-image: url("images/icon-black.png"); + background-image: url("${window.glob.assetPath}/images/icon-black.png"); background-repeat: no-repeat; background-position: 50% 45%; width: 100%; @@ -26,7 +26,7 @@ const TPL = ` } .global-menu-button:hover { - background-image: url("images/icon-color.png"); + background-image: url("${window.glob.assetPath}/images/icon-color.png"); } .global-menu-button-update-available { diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index dd122067d..5e432cdd8 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -237,15 +237,17 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { $promotedAttributes = (await attributeRenderer.renderNormalAttributes(this.note)).$renderedAttributes; } + const {assetPath} = window.glob; + this.$widget.find('.note-detail-printable:visible').printThis({ header: $("
") .append($("

").text(this.note.title)) .append($promotedAttributes) .prop('outerHTML'), footer: ` - - - + + + @@ -47,40 +48,40 @@ - + - - + + - - + + - + - + - + - + - + - + <% if (themeCssUrl) { %> <% } %> - + - + - + diff --git a/src/views/login.ejs b/src/views/login.ejs index 42f3b9d20..396d18c53 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -4,7 +4,7 @@ Login - + @@ -68,6 +68,6 @@ } - + diff --git a/src/views/mobile.ejs b/src/views/mobile.ejs index cfc84b85f..c0b3569e1 100644 --- a/src/views/mobile.ejs +++ b/src/views/mobile.ejs @@ -115,31 +115,32 @@ csrfToken: '<%= csrfToken %>', isDev: <%= isDev %>, appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>, - isProtectedSessionAvailable: <%= isProtectedSessionAvailable %> + isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>, + assetPath: "<%= assetPath %>" }; - + - + - - + + - - + + - + - - + + <% if (themeCssUrl) { %> <% } %> - + - + diff --git a/src/views/set_password.ejs b/src/views/set_password.ejs index 65a967de7..8375ded67 100644 --- a/src/views/set_password.ejs +++ b/src/views/set_password.ejs @@ -4,7 +4,7 @@ Login - + @@ -46,6 +46,6 @@ if (typeof module === 'object') {window.module = module; module = undefined;} - + diff --git a/src/views/setup.ejs b/src/views/setup.ejs index e7f04dc19..6f4578a8c 100644 --- a/src/views/setup.ejs +++ b/src/views/setup.ejs @@ -153,15 +153,15 @@ - - + + - - + + - + - - + + diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs index 6cbac27a1..abed996c2 100644 --- a/src/views/share/page.ejs +++ b/src/views/share/page.ejs @@ -12,13 +12,13 @@ <% } else { %> <% } %> - + <% if (!note.hasLabel("shareOmitDefaultCss")) { %> - - + + <% } %> <% if (note.type === 'text' || note.type === 'book') { %> - + <% } %> <% for (const cssRelation of note.getRelations("shareCss")) { %> diff --git a/webpack-desktop.config.js b/webpack-desktop.config.js index 3a3ab7b0e..5fd8aef97 100644 --- a/webpack-desktop.config.js +++ b/webpack-desktop.config.js @@ -1,4 +1,5 @@ const path = require('path'); +const assetPath = require('./src/services/asset_path'); module.exports = { mode: 'production', @@ -6,7 +7,7 @@ module.exports = { mobile: './src/public/app/desktop.js', }, output: { - publicPath: 'app-dist/', + publicPath: `/${assetPath}/app-dist/`, path: path.resolve(__dirname, 'src/public/app-dist'), filename: 'desktop.js' }, diff --git a/webpack-mobile.config.js b/webpack-mobile.config.js index a60133980..800ef038e 100644 --- a/webpack-mobile.config.js +++ b/webpack-mobile.config.js @@ -1,4 +1,5 @@ const path = require('path'); +const assetPath = require('./src/services/asset_path'); module.exports = { mode: 'production', @@ -6,7 +7,7 @@ module.exports = { mobile: './src/public/app/mobile.js', }, output: { - publicPath: 'app-dist/', + publicPath: `/${assetPath}/app-dist/`, path: path.resolve(__dirname, 'src/public/app-dist'), filename: 'mobile.js' }, diff --git a/webpack-setup.config.js b/webpack-setup.config.js index c7ec8f349..46d7ebe80 100644 --- a/webpack-setup.config.js +++ b/webpack-setup.config.js @@ -1,4 +1,5 @@ const path = require('path'); +const assetPath = require('./src/services/asset_path'); module.exports = { mode: 'production', @@ -6,7 +7,7 @@ module.exports = { mobile: './src/public/app/setup.js', }, output: { - publicPath: 'app-dist/', + publicPath: `/${assetPath}/app-dist/`, path: path.resolve(__dirname, 'src/public/app-dist'), filename: 'setup.js' },