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

Improper loading of static files on 404 pages #2256

Open
lindapaiste opened this issue Jun 18, 2023 · 1 comment · May be fixed by #2168
Open

Improper loading of static files on 404 pages #2256

lindapaiste opened this issue Jun 18, 2023 · 1 comment · May be fixed by #2168
Labels
Area:Optimization Category for site performance optimization and management Bug Priority:Medium

Comments

@lindapaiste
Copy link
Collaborator

p5.js version

No response

What is your operating system?

None

Web browser and version

No response

Actual Behavior

image

This one is not easily reproducible because the 404 pages choose a sketch at random, so I can't link to a particular URL where it happens. However I noticed it on a 404 page which attempted to render this sketch: https://editor.p5js.org/p5/sketches/Advanced_Data:_Load_Saved_Table

This sketch loads a .csv file:

function preload() {
  table = loadTable("assets/bubbles.csv", "header");
}

The /server/views/404Page.js file re-writes that path:

// Fix links to assets
htmlFile = htmlFile.replace(
/'assets/g,
"'https://rawgit.com/processing/p5.js-website/main/dist/assets/examples/assets/"
);
htmlFile = htmlFile.replace(
/"assets/g,
'"https://rawgit.com/processing/p5.js-website/main/dist/assets/examples/assets/'
);

And we get a URL https://rawgit.com/processing/p5.js-website/main/dist/assets/examples/assets//bubbles.csv which does not exist. The rawgit.com service has actually been deprecated since 2018 and it should not be used. But it does still work if we use the correct URL, which is https://rawgit.com/processing/p5.js-website/main/src/data/examples/assets/bubbles.csv as the file is located at https://github.com/processing/p5.js-website/blob/main/src/data/examples/assets/bubbles.csv. The fatal problem is that we are creating improper paths.

Expected Behavior

When the sketch is run by the previewServer, the output code is:

function preload() {
  table = loadTable("https://cdn.jsdelivr.net/gh/processing/p5.js-website@main/src/data/examples/assets/bubbles.csv", "header");
}

This works, and it matches what is included in the .files property of the sketch object:

{
    "name": "bubbles.csv",
    "content": "",
    "children": [],
    "fileType": "file",
    "_id": "6459341065978bfc7dc6c7b4",
    "url": "https://cdn.jsdelivr.net/gh/processing/p5.js-website@main/src/data/examples/assets/bubbles.csv",
    "createdAt": "2023-05-08T17:40:32.645Z",
    "updatedAt": "2023-05-08T17:40:32.645Z",
    "id": "6459341065978bfc7dc6c7b4"
}

Steps to reproduce

It happens at random on any 404 URL, depending on which sketch is chosen.

@lindapaiste
Copy link
Collaborator Author

We already have code that can render a sketch properly, but it's located on the client rather than the server. The server version is limited and buggy. This issue will be fixed by #2168 once I get it working for all pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Optimization Category for site performance optimization and management Bug Priority:Medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants