Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tyrel
Copy link

@tyrel tyrel commented Mar 3, 2023

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

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
@jneilliii
Copy link
Contributor

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);

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:

Suggested change
gcodeProxy.loadGcode('downloads/files/local/' + curJobName);
gcodeProxy.loadGcode(BASEURL + 'downloads/files/local/' + curJobName);

Copy link
Author

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?

Copy link
Contributor

@jneilliii jneilliii Nov 8, 2024

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

@jotadrilo
Copy link

I have added the same comments in both PRs. I'd suggest closing one of them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PrettyGCode does not work behind proxy
3 participants