From 7c98ade72b312b43c83cc887f21ae75b62991515 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 25 Dec 2022 11:58:24 +0100 Subject: [PATCH] fix missing doc resources for launchers, closes #3455 --- .gitpod.yml | 2 +- Dockerfile | 8 ++------ bin/build-server.sh | 2 +- bin/copy-trilium.sh | 10 +++------- src/public/app/widgets/buttons/global_menu.js | 2 +- src/public/app/widgets/type_widgets/doc.js | 2 +- src/routes/index.js | 4 +++- src/routes/login.js | 7 +++++-- src/routes/setup.js | 4 +++- src/services/app_path.js | 6 ++++++ src/share/routes.js | 4 +++- src/views/desktop.ejs | 3 ++- src/views/mobile.ejs | 5 +++-- src/views/setup.ejs | 2 +- src/views/share/page.ejs | 2 +- 15 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 src/services/app_path.js diff --git a/.gitpod.yml b/.gitpod.yml index 8c5fe37ba..914a89919 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -2,7 +2,7 @@ image: file: .gitpod.dockerfile tasks: - - before: nvm install 16.18.0 && nvm use 16.18.0 + - before: nvm install 16.19.0 && nvm use 16.19.0 init: npm install command: npm run start-server diff --git a/Dockerfile b/Dockerfile index 4675fa88a..caca792ab 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.18.0-alpine +FROM node:16.19.0-alpine # Create app directory WORKDIR /usr/src/app @@ -25,12 +25,8 @@ RUN set -x \ && apk del .build-dependencies \ && npm run webpack \ && npm prune --omit=dev \ -# Set the path to the newly created webpack bundle - && sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' src/views/desktop.ejs \ - && sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' src/views/mobile.ejs \ - && sed -i -e 's/app\/setup.js/app-dist\/setup.js/g' src/views/setup.ejs \ - && sed -i -e 's/app\/share.js/app-dist\/share.js/g' src/views/share/*.ejs \ && cp src/public/app/share.js src/public/app-dist/. \ + && cp -r src/public/app/doc_notes src/public/app-dist/. \ && rm -rf src/public/app # Some setup tools need to be kept diff --git a/bin/build-server.sh b/bin/build-server.sh index accb11f32..2c42c9105 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.18.0 +NODE_VERSION=16.19.0 if [ "$1" != "DONTCOPY" ] then diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 77f754d17..fdcb99a40 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.18.0 npm run webpack +n exec 16.19.0 npm run webpack DIR=$1 @@ -27,7 +27,7 @@ cp -r electron.js $DIR/ cp webpack-* $DIR/ # run in subshell (so we return to original dir) -(cd $DIR && n exec 16.18.0 npm install --only=prod) +(cd $DIR && n exec 16.19.0 npm install --only=prod) # cleanup of useless files in dependencies rm -r $DIR/node_modules/image-q/demo @@ -45,10 +45,6 @@ find $DIR/node_modules -name demo -exec rm -rf {} \; find $DIR/libraries -name "*.map" -type f -delete cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/ +cp -r $DIR/src/public/app/doc_notes $DIR/src/public/app-dist/ rm -rf $DIR/src/public/app - -sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' $DIR/src/views/desktop.ejs -sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' $DIR/src/views/mobile.ejs -sed -i -e 's/app\/setup.js/app-dist\/setup.js/g' $DIR/src/views/setup.ejs -sed -i -e 's/app\/share.js/app-dist\/share.js/g' $DIR/src/views/share/*.ejs diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index c268216a2..89adaabad 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -80,7 +80,7 @@ const TPL = ` display: none; } - body.mobile .dropdown-submenu .dropdown-menu { + body.mobile .global-menu .dropdown-submenu .dropdown-menu { display: block; font-size: 90%; position: relative; diff --git a/src/public/app/widgets/type_widgets/doc.js b/src/public/app/widgets/type_widgets/doc.js index fc775a62f..234ff21aa 100644 --- a/src/public/app/widgets/type_widgets/doc.js +++ b/src/public/app/widgets/type_widgets/doc.js @@ -31,7 +31,7 @@ export default class DocTypeWidget extends TypeWidget { const docName = note.getLabelValue('docName'); if (docName) { - this.$content.load(`${window.glob.assetPath}/app/doc_notes/${docName}.html`); + this.$content.load(`${window.glob.appPath}/doc_notes/${docName}.html`); } else { this.$content.empty(); } diff --git a/src/routes/index.js b/src/routes/index.js index 38ccbb498..7d01e08a5 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -10,6 +10,7 @@ const utils = require('../services/utils'); const protectedSessionService = require("../services/protected_session"); const packageJson = require('../../package.json'); const assetPath = require("../services/asset_path"); +const appPath = require("../services/app_path"); function index(req, res) { const options = optionService.getOptionsMap(); @@ -38,7 +39,8 @@ function index(req, res) { isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(), maxContentWidth: parseInt(options.maxContentWidth), triliumVersion: packageJson.version, - assetPath: assetPath + assetPath: assetPath, + appPath: appPath }); } diff --git a/src/routes/login.js b/src/routes/login.js index f824931c6..9dc9075e7 100644 --- a/src/routes/login.js +++ b/src/routes/login.js @@ -6,19 +6,22 @@ const myScryptService = require('../services/my_scrypt'); const log = require('../services/log'); const passwordService = require("../services/password"); const assetPath = require("../services/asset_path"); +const appPath = require("../services/app_path"); const ValidationError = require("../errors/validation_error"); function loginPage(req, res) { res.render('login', { failedAuth: false, - assetPath: assetPath + assetPath: assetPath, + appPath: appPath }); } function setPasswordPage(req, res) { res.render('set_password', { error: false, - assetPath: assetPath + assetPath: assetPath, + appPath: appPath }); } diff --git a/src/routes/setup.js b/src/routes/setup.js index 3e3eab29b..c3f58077d 100644 --- a/src/routes/setup.js +++ b/src/routes/setup.js @@ -4,6 +4,7 @@ const sqlInit = require('../services/sql_init'); const setupService = require('../services/setup'); const utils = require('../services/utils'); const assetPath = require("../services/asset_path"); +const appPath = require("../services/app_path.js"); function setupPage(req, res) { if (sqlInit.isDbInitialized()) { @@ -31,7 +32,8 @@ function setupPage(req, res) { res.render('setup', { syncInProgress: syncInProgress, - assetPath: assetPath + assetPath: assetPath, + appPath: appPath }); } diff --git a/src/services/app_path.js b/src/services/app_path.js new file mode 100644 index 000000000..09129aadb --- /dev/null +++ b/src/services/app_path.js @@ -0,0 +1,6 @@ +const assetPath = require("./asset_path"); +const env = require("./env"); + +module.exports = env.isDev() + ? assetPath + "/app" + : assetPath + "/app-dist"; diff --git a/src/share/routes.js b/src/share/routes.js index 626ede63c..6ea82e62a 100644 --- a/src/share/routes.js +++ b/src/share/routes.js @@ -7,6 +7,7 @@ const shacaLoader = require("./shaca/shaca_loader"); const shareRoot = require("./share_root"); const contentRenderer = require("./content_renderer"); const assetPath = require("../services/asset_path"); +const appPath = require("../services/app_path"); function getSharedSubTreeRoot(note) { if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) { @@ -111,7 +112,8 @@ function register(router) { content, isEmpty, subRoot, - assetPath + assetPath, + appPath }); } diff --git a/src/views/desktop.ejs b/src/views/desktop.ejs index 684884722..f1e91b77d 100644 --- a/src/views/desktop.ejs +++ b/src/views/desktop.ejs @@ -36,6 +36,7 @@ isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>, triliumVersion: "<%= triliumVersion %>", assetPath: "<%= assetPath %>", + appPath: "<%= appPath %>", TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %> }; @@ -80,7 +81,7 @@ $("body").show(); - + diff --git a/src/views/mobile.ejs b/src/views/mobile.ejs index 4edb46a2f..4ff1fbd57 100644 --- a/src/views/mobile.ejs +++ b/src/views/mobile.ejs @@ -115,9 +115,10 @@ csrfToken: '<%= csrfToken %>', isDev: <%= isDev %>, appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>, + isMainWindow: true, isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>, assetPath: "<%= assetPath %>", - isMainWindow: true, + appPath: "<%= appPath %>", TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %> }; @@ -132,7 +133,7 @@ - + diff --git a/src/views/setup.ejs b/src/views/setup.ejs index 6f4578a8c..185df189f 100644 --- a/src/views/setup.ejs +++ b/src/views/setup.ejs @@ -161,7 +161,7 @@ - + diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs index 1afacd8d1..41e0a5c19 100644 --- a/src/views/share/page.ejs +++ b/src/views/share/page.ejs @@ -12,7 +12,7 @@ <% } else { %> <% } %> - + <% if (!note.hasLabel("shareOmitDefaultCss")) { %>