-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix errors when not installed in root dir #149
base: master
Are you sure you want to change the base?
Conversation
Use relative paths instead of absolute paths so that if OctoPrint is not in the root of the domain (or is behind a proxy), the files can still be found and this plugin will work. Fixes Kragrathea#148
Funny, same as my submission #147 |
@@ -16,7 +16,7 @@ $(function () { | |||
durJobDate = job.file.date; | |||
if(viewInitialized && gcodeProxy) | |||
{ | |||
gcodeProxy.loadGcode('/downloads/files/local/' + curJobName); | |||
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OctoPrint defines the BASEURL
global variable available to all plugins:
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); | |
gcodeProxy.loadGcode(BASEURL + 'downloads/files/local/' + curJobName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jotadrilo is BASEURL determine dynamically for every browser visiting OctoPrint to ensure that the URL will always be correct for the present visitor, that way if I access it behind a proxy or directly it'll still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory that's what my change should do, no need to add base url for actual relative links.
@@ -569,7 +569,7 @@ $(function () { | |||
this.orbitWhenIdle=false; | |||
this.reloadGcode = function () { | |||
if(gcodeProxy && curJobName!="") | |||
gcodeProxy.loadGcode('/downloads/files/local/' + curJobName); | |||
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); | |
gcodeProxy.loadGcode(BASEURL + 'downloads/files/local/' + curJobName); |
@@ -692,7 +692,7 @@ $(function () { | |||
|
|||
//load Nozzle model. | |||
var objloader = new THREE.OBJLoader(); | |||
objloader.load( '/plugin/prettygcode/static/js/models/ExtruderNozzle.obj', function ( obj ) { | |||
objloader.load( 'plugin/prettygcode/static/js/models/ExtruderNozzle.obj', function ( obj ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objloader.load( 'plugin/prettygcode/static/js/models/ExtruderNozzle.obj', function ( obj ) { | |
objloader.load( BASEURL + 'plugin/prettygcode/static/js/models/ExtruderNozzle.obj', function ( obj ) { |
@@ -721,7 +721,7 @@ $(function () { | |||
scene.add(gcodeObject); | |||
|
|||
if(curJobName!="") | |||
gcodeProxy.loadGcode('/downloads/files/local/' + curJobName); | |||
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcodeProxy.loadGcode('downloads/files/local/' + curJobName); | |
gcodeProxy.loadGcode(BASEURL + 'downloads/files/local/' + curJobName); |
@@ -1533,7 +1533,7 @@ $(function () { | |||
} | |||
|
|||
var fontLoader = new THREE.FontLoader(); | |||
fontLoader.load('/plugin/prettygcode/static/js/helvetiker_bold.typeface.json', function (font) { | |||
fontLoader.load('plugin/prettygcode/static/js/helvetiker_bold.typeface.json', function (font) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fontLoader.load('plugin/prettygcode/static/js/helvetiker_bold.typeface.json', function (font) { | |
fontLoader.load(BASEURL + 'plugin/prettygcode/static/js/helvetiker_bold.typeface.json', function (font) { |
I have added the same comments in both PRs. I'd suggest closing one of them |
Use relative paths instead of absolute paths so that if OctoPrint is not in the root of the domain (or is behind a proxy), the files can still be found and this plugin will work.
Fixes #148