Skip to content

Commit

Permalink
Don't use process.resourcesPath.
Browse files Browse the repository at this point in the history
Instead pass around __dirname from main.js as a common point of reference.

Maybe fixes #19.
  • Loading branch information
henrikingo committed Jul 6, 2019
1 parent cdf9e7d commit 8616c0d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ have to edit raw CSS and HTML.

## HOWTO

Pre-requisites: git, node 6.5+ and npm
Pre-requisites: git, node 6.5+ and npm 5+

git clone --recursive https://github.com/henrikingo/impressionist.git
cd impressionist
Expand Down
11 changes: 6 additions & 5 deletions js/impressionist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@
// Aaannd then we reload impress and put the impressionist bits right back to where they were
impress().init();
var script = impressionist().util.loadJavaScript(
process.resourcesPath + "/../../../../js/impressionist.js", function(){
impressionist().rootDir + "/js/impressionist.js", function(){
impressionist().gc.pushElement(script); // The circle of life :-)
impressionist().util.triggerEvent(document, "impressionist:init", {})
});
Expand Down Expand Up @@ -1107,9 +1107,10 @@
*/
(function ( document, window ) {
'use strict';
// Just load it ASAP. No need to wait for impressionist:init
var link = impressionist().util.loadCss(process.resourcesPath + "/../../../../css/impressionist.css");
impressionist().gc.pushElement(link);
impressionist().gc.addEventListener(document, "impressionist:init", function (event) {
var link = impressionist().util.loadCss(impressionist().rootDir + "/css/impressionist.css");
impressionist().gc.pushElement(link);
});

})(document, window);

Expand Down Expand Up @@ -1564,7 +1565,7 @@
var html = '<div id="tinymce-toolbar"></div>';
toolbar = impressionist().util.makeDomElement(html);
gc.appendChild(document.body, toolbar);
script = impressionist().util.loadJavaScript(process.resourcesPath + "/../../../tinymce/tinymce.js", tinymceInit);
script = impressionist().util.loadJavaScript(impressionist().rootDir + "/node_modules/tinymce/tinymce.js", tinymceInit);
impressionist().gc.pushElement(script);
});

Expand Down
10 changes: 5 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function createWindow () {
})
mainWindow.maximize()
// debug
//mainWindow.webContents.openDevTools()
mainWindow.webContents.openDevTools()

// This triggers when user opens a presentation and it has loaded into the window
mainWindow.webContents.on('dom-ready', function(event) {
Expand Down Expand Up @@ -50,13 +50,13 @@ function loadImpressionist () {
// Windows support
impressionistRoot = impressionistRoot.split("\\").join("/");

return `var impressionistRoot = '${impressionistRoot}';
var script = document.createElement("script");
return `var script = document.createElement("script");
script.src = "${impressionistRoot}/js/impressionist.js";
script.type = "text/javascript";
script.onload = function(){
impressionist().gc.pushElement(script)
impressionist().util.triggerEvent(document, "impressionist:init", {})
impressionist().rootDir = '${impressionistRoot}';
impressionist().gc.pushElement(script);
impressionist().util.triggerEvent(document, "impressionist:init", {});
};
document.head.appendChild(script);
`
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/electron/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// Aaannd then we reload impress and put the impressionist bits right back to where they were
impress().init();
var script = impressionist().util.loadJavaScript(
process.resourcesPath + "/../../../../js/impressionist.js", function(){
impressionist().rootDir + "/js/impressionist.js", function(){
impressionist().gc.pushElement(script); // The circle of life :-)
impressionist().util.triggerEvent(document, "impressionist:init", {})
});
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/loadcss/loadcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/
(function ( document, window ) {
'use strict';
// Just load it ASAP. No need to wait for impressionist:init
var link = impressionist().util.loadCss(process.resourcesPath + "/../../../../css/impressionist.css");
impressionist().gc.pushElement(link);
impressionist().gc.addEventListener(document, "impressionist:init", function (event) {
var link = impressionist().util.loadCss(impressionist().rootDir + "/css/impressionist.css");
impressionist().gc.pushElement(link);
});

})(document, window);
2 changes: 1 addition & 1 deletion src/plugins/tinymce/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
var html = '<div id="tinymce-toolbar"></div>';
toolbar = impressionist().util.makeDomElement(html);
gc.appendChild(document.body, toolbar);
script = impressionist().util.loadJavaScript(process.resourcesPath + "/../../../tinymce/tinymce.js", tinymceInit);
script = impressionist().util.loadJavaScript(impressionist().rootDir + "/node_modules/tinymce/tinymce.js", tinymceInit);
impressionist().gc.pushElement(script);
});

Expand Down

0 comments on commit 8616c0d

Please sign in to comment.