toolness / p5.js-widget

A reusable widget for embedding editable p5 sketches in web pages.
https://toolness.github.io/p5.js-widget/
GNU Lesser General Public License v2.1
162 stars 44 forks source link

data path references https://toolness.github.io/p5.js-widget/* if using with loadTable, etc. #39

Closed indefinit closed 8 years ago

indefinit commented 8 years ago

If I'm using loadTable, loadXML, etc. functions with this widget src'ed from your github (for example):

<script src="https://toolness.github.io/p5.js-widget/p5-widget.js"></script>

then the data path will reference toolness.github instead of my local index. This is potentially a problem since it will likely break any user code expecting to load data from my local index, resulting in a 404. Example:

function preload() {
  //my table is comma separated value "csv"
//404 error because https://toolness.github.io/p5.js-widget/data/antarctica_weather_averages.csv
// doesn't exist
table = loadTable("data/antarctica_weather_averages.csv", function(){console.log("found data");});
}

Is there an easy fix to this other than srcing the widget from my local index?

indefinit commented 8 years ago

also, forgive my ignorance, but is there an easy way of compiling the typescript dependencies into one lib js file?

toolness commented 8 years ago

Oh, sorry, I just noticed this issue--for some reason GitHub isn't emailing me when new issues are filed or something.

Good catch! Hmmm, there are multiple ways to tackle this... let me think a bit and get back to you.

also, forgive my ignorance, but is there an easy way of compiling the typescript dependencies into one lib js file?

Hmm, I'm not quite sure what you mean--what are you trying to accomplish? Are you trying to self-host the widget on your own server, or something else?

indefinit commented 8 years ago

Yea, in this specific case, I'm looking to self host all files from a GitHub. Repo and use raw git as a static file server. I use this for most of my tutorials because its quick and simple to organize from my course repo

toolness commented 8 years ago

Ah, gotcha--I've spun that off into #45!

toolness commented 8 years ago

Ok, I think I've fixed this! You can read about the new behavior here:

https://toolness.github.io/p5.js-widget/#base-url

Let me know if this works for you!

indefinit commented 8 years ago

Sorry for the delayed response. Any chace base-url can work with relative paths? For example if I'm developing on localhost but push my code somewhere else, it would be great to have data-base-url="./" to map to the root directory where my index.html lives.

toolness commented 8 years ago

No worries! I Just added this in 81835aed8c28a6486d1f441a84f6c5c6bc4f2fa9.

Note, though, that if you just want the base URL to be the same path as the page you're embedding the widget in, you shouldn't have to provide data-base-url at all.