-
Notifications
You must be signed in to change notification settings - Fork 515
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
Add support for include() in remote files; remove need for proxy. #239
Add support for include() in remote files; remove need for proxy. #239
Conversation
Download all files directly (rather than tunneling through a proxy server) to remove dependence on running a special server. This is useful, for example, when providing a remote link to a Github repository for a project that isn't a single file. Remote projects (with includes) are currently limited to someone running a special server; this ensures effectively any remote file host is usable instead. We also store the include file base path separately now since it should be resolved to the host of the primary file rather than the host serving up the OpenJSCAD viewer. This also cleans up the `include` logic a bit: currently regex parsing is used for replacement which isn't safe: i.e., it's possible for the regex to match unnecessarily. It's also the case that multiple includes for the same file can fail since the current logic naively inserts the included source multiple times. Instead I now ensure that the included source is only executed once and rather than inline it override the `include` function to do the work for me. Regex matching of what files to load is still in place; ideally that'd be replaced as well since regex parsing isn't safe.
91ad9f7
to
4a05755
Compare
@jcoleman Thanks for this contribution. This looks like an awesome solution to the ugly implementation of include(). Obviously, we need to test the include of files from various sources. It seems that you've been studying this. :) Can you give us some scripts for testing the new include functionality? Here's what we have now.
|
@z3dev I made this fix to support a project of mine: https://github.com/jcoleman/ada-keyboard In particular, here's a link that exercises the new code (using my fork of the viewer): https://jcoleman.github.io/OpenJSCAD.org/#https://raw.githubusercontent.com/jcoleman/ada-keyboard/master/case/main.jscad Is that what you're looking for? |
@jcoleman Thanks for this PR ! Since I have a lot more fixes in that PR , would you be ok with us merging #241 first, and then I can handle merge conflicts with your PR on top of that ? |
A few more notes also @jcoleman :
|
@kaosat-dev Merging the other works first; is there a timeline on getting that and then this fix in? Defaulting I'm curious why One other thing: I assume when this gets merged probably the proxy server code can be deleted; I didn't do that because I wanted to have others verify the stability of this change first. |
@jcoleman I just finished the work on that PR , so I think it can be merged tomorrow at the latest ? Yeah if it uses the existing I would need to double check when I am not half asleep, but If I recall right there were multiple aspects to the switch of include :
About the proxy: we can double check and remove stuff stepwise, but less code is always better :) |
@jcoleman The other PR is now merged, will try to combine your changes |
@jcoleman I had to open another PR here #244 to merge things because there were a few things to fix/change to your original PR (next time I'll try to merge back to the original PR if possible). By the way , pretty please make sure the examples and command line unit test run before submitting the PR :) |
@kaosat-dev Yep, I did run tests/examples on the first iteration (a few months ago, actually), but I kinda got discouraged with the massive amount of change between master and dev and just wanted to get it working this time. (Excuses!) |
@jcoleman haha I understand, that should really get better soon, once we FINALY merge dev into master, things will be more stable. |
Download all files directly (rather than tunneling through a proxy
server) to remove dependence on running a special server. This is
useful, for example, when providing a remote link to a Github repository
for a project that isn't a single file. Remote projects (with includes)
are currently limited to someone running a special server; this ensures
effectively any remote file host is usable instead.
We also store the include file base path separately now since it should
be resolved to the host of the primary file rather than the host serving
up the OpenJSCAD viewer.
This also cleans up the
include
logic a bit: currently regex parsingis used for replacement which isn't safe: i.e., it's possible for the
regex to match unnecessarily. It's also the case that multiple includes
for the same file can fail since the current logic naively inserts the
included source multiple times. Instead I now ensure that the included
source is only executed once and rather than inline it override the
include
function to do the work for me. Regex matching of what filesto load is still in place; ideally that'd be replaced as well since
regex parsing isn't safe.