Skip to content

Commit

Permalink
fix missing doc resources for launchers, closes #3455
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Dec 25, 2022
1 parent c6485f8 commit 7c98ade
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/build-server.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 3 additions & 7 deletions bin/copy-trilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/public/app/widgets/buttons/global_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/widgets/type_widgets/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -38,7 +39,8 @@ function index(req, res) {
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
maxContentWidth: parseInt(options.maxContentWidth),
triliumVersion: packageJson.version,
assetPath: assetPath
assetPath: assetPath,
appPath: appPath
});
}

Expand Down
7 changes: 5 additions & 2 deletions src/routes/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/routes/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -31,7 +32,8 @@ function setupPage(req, res) {

res.render('setup', {
syncInProgress: syncInProgress,
assetPath: assetPath
assetPath: assetPath,
appPath: appPath
});
}

Expand Down
6 changes: 6 additions & 0 deletions src/services/app_path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const assetPath = require("./asset_path");
const env = require("./env");

module.exports = env.isDev()
? assetPath + "/app"
: assetPath + "/app-dist";
4 changes: 3 additions & 1 deletion src/share/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -111,7 +112,8 @@ function register(router) {
content,
isEmpty,
subRoot,
assetPath
assetPath,
appPath
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/views/desktop.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
triliumVersion: "<%= triliumVersion %>",
assetPath: "<%= assetPath %>",
appPath: "<%= appPath %>",
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
};
</script>
Expand Down Expand Up @@ -80,7 +81,7 @@
$("body").show();
</script>

<script src="<%= assetPath %>/app/desktop.js" crossorigin type="module"></script>
<script src="<%= appPath %>/desktop.js" crossorigin type="module"></script>

<link rel="stylesheet" type="text/css" href="<%= assetPath %>/libraries/boxicons/css/boxicons.min.css">

Expand Down
5 changes: 3 additions & 2 deletions src/views/mobile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
};
</script>
Expand All @@ -132,7 +133,7 @@
<link href="<%= assetPath %>/libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="<%= assetPath %>/libraries/bootstrap/js/bootstrap.bundle.min.js"></script>

<script src="<%= assetPath %>/app/mobile.js" crossorigin type="module"></script>
<script src="<%= appPath %>/mobile.js" crossorigin type="module"></script>

<link href="api/fonts" rel="stylesheet">
<link href="<%= assetPath %>/stylesheets/ckeditor-theme.css" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion src/views/setup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

<script src="<%= assetPath %>/libraries/knockout.min.js"></script>

<script src="<%= assetPath %>/app/setup.js" crossorigin type="module"></script>
<script src="<%= appPath %>/setup.js" crossorigin type="module"></script>
<link href="<%= assetPath %>/stylesheets/theme-light.css" rel="stylesheet">
</body>
</html>
2 changes: 1 addition & 1 deletion src/views/share/page.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<% } else { %>
<link rel="shortcut icon" href="../favicon.ico">
<% } %>
<script src="../<%= assetPath %>/app/share.js"></script>
<script src="../<%= appPath %>/share.js"></script>
<% if (!note.hasLabel("shareOmitDefaultCss")) { %>
<link href="../<%= assetPath %>/libraries/normalize.min.css" rel="stylesheet">
<link href="../<%= assetPath %>/stylesheets/share.css" rel="stylesheet">
Expand Down

0 comments on commit 7c98ade

Please sign in to comment.